update for HEAD-2003091401
[reactos.git] / include / napi / lpc.h
1 #ifndef __INCLUDE_NAPI_LPC_H
2 #define __INCLUDE_NAPI_LPC_H
3
4 #ifdef __USE_W32API
5 #include <ddk/ntapi.h>
6 #include <napi/types.h>
7 #endif /* !__USE_W32API */
8
9 #include <ntos/security.h>
10
11 #define MAX_MESSAGE_DATA   (0x130)
12
13 #ifndef __USE_W32API
14
15 typedef enum 
16 {
17     UNUSED_MSG_TYPE        = 0x0, /* ReactOS */
18     LPC_NEW_MESSAGE        = 0x0, /* NT */
19     LPC_REQUEST            = 0x1,
20     LPC_REPLY              = 0x2,
21     LPC_DATAGRAM           = 0x3,
22     LPC_LOST_REPLY         = 0x4,
23     LPC_PORT_CLOSED        = 0x5,
24     LPC_CLIENT_DIED        = 0x6,
25     LPC_EXCEPTION          = 0x7,
26     LPC_DEBUG_EVENT        = 0x8,
27     LPC_ERROR_EVENT        = 0x9,
28     LPC_CONNECTION_REQUEST = 0xa,
29     LPC_CONNECTION_REFUSED = 0xb
30
31 } LPC_TYPE, *PLPC_TYPE;
32
33 typedef struct _LPC_SECTION_WRITE
34 {
35    ULONG Length;
36    HANDLE SectionHandle;
37    ULONG SectionOffset;
38    ULONG ViewSize;
39    PVOID ViewBase;
40    PVOID TargetViewBase;
41 } LPC_SECTION_WRITE, *PLPC_SECTION_WRITE;
42
43 typedef struct _LPC_SECTION_READ
44 {
45    ULONG Length;
46    ULONG ViewSize;
47    PVOID ViewBase;
48 } LPC_SECTION_READ, *PLPC_SECTION_READ;
49
50 typedef struct _LPC_MESSAGE
51 {
52    USHORT DataSize;
53    USHORT MessageSize;
54    USHORT MessageType;
55    USHORT VirtualRangesOffset;
56    CLIENT_ID ClientId;
57    ULONG MessageId;
58    ULONG SectionSize; /* CallbackID */
59 } LPC_MESSAGE, *PLPC_MESSAGE;
60
61 #endif /* !__USE_W32API */
62
63
64 typedef struct _LPC_TERMINATION_MESSAGE
65 {
66    LPC_MESSAGE Header;
67    TIME CreationTime;
68 } LPC_TERMINATION_MESSAGE, *PLPC_TERMINATION_MESSAGE;
69
70 typedef struct _LPC_DEBUG_MESSAGE
71 {
72    LPC_MESSAGE Header;
73    ULONG EventCode;
74    ULONG Status;
75    union {
76       struct {
77          EXCEPTION_RECORD ExceptionRecord;
78          ULONG FirstChance;
79       } Exception;
80       struct {
81          ULONG Reserved;
82          PVOID StartAddress;
83       } CreateThread;
84       struct {
85          ULONG Reserved;
86          HANDLE FileHandle;
87          PVOID Base;
88          ULONG PointerToSymbolTable;
89          ULONG NumberOfSymbols;
90          ULONG Reserved2;
91          PVOID EntryPoint;
92       } CreateProcess;
93       struct {
94          ULONG ExitCode;
95       } ExitThread;
96       struct {
97          ULONG ExitCode;
98       } ExitProcess;
99       struct {
100          HANDLE FileHandle;
101          PVOID Base;
102          ULONG PointerToSymbolTable;
103          ULONG NumberOfSymbols;
104       } LoadDll;
105       struct {
106          PVOID Base;
107       } UnloadDll;
108 #ifdef ANONYMOUSUNIONS
109    };
110 #else
111    } u;
112 #endif
113 } LPC_DEBUG_MESSAGE, * PLPC_DEBUG_MESSAGE;
114
115 typedef struct _LPC_MAX_MESSAGE
116 {
117    LPC_MESSAGE Header;
118    BYTE Data[MAX_MESSAGE_DATA];
119 } LPC_MAX_MESSAGE, *PLPC_MAX_MESSAGE;
120
121 #define PORT_MESSAGE_TYPE(m) (LPC_TYPE)((m).Header.MessageType)
122
123 #ifndef __USE_NT_LPC__
124 NTSTATUS STDCALL NtAcceptConnectPort (PHANDLE   PortHandle,
125                                       HANDLE NamedPortHandle,
126                                       PLPC_MESSAGE ServerReply,
127                                       BOOLEAN AcceptIt,
128                                       PLPC_SECTION_WRITE WriteMap,
129                                       PLPC_SECTION_READ ReadMap);
130 #else
131 NTSTATUS STDCALL NtAcceptConnectPort (PHANDLE   PortHandle,
132                                       ULONG PortIdentifier,
133                                       PLPC_MESSAGE ServerReply,
134                                       BOOLEAN AcceptIt,
135                                       PLPC_SECTION_WRITE WriteMap,
136                                       PLPC_SECTION_READ ReadMap);
137 #endif /* ndef __USE_NT_LPC__ */
138
139 NTSTATUS STDCALL NtCompleteConnectPort (HANDLE PortHandle);
140
141 NTSTATUS STDCALL NtConnectPort(PHANDLE PortHandle,
142                                PUNICODE_STRING PortName,
143                                PSECURITY_QUALITY_OF_SERVICE SecurityQos,
144                                PLPC_SECTION_WRITE SectionInfo,
145                                PLPC_SECTION_READ MapInfo,
146                                PULONG MaxMessageSize,
147                                PVOID ConnectInfo,
148                                PULONG ConnectInfoLength);
149
150 NTSTATUS STDCALL NtReplyWaitReplyPort (HANDLE PortHandle,
151                                        PLPC_MESSAGE ReplyMessage);
152  
153 NTSTATUS STDCALL NtCreatePort(PHANDLE PortHandle,
154                               POBJECT_ATTRIBUTES ObjectAttributes,
155                               ULONG MaxConnectInfoLength,
156                               ULONG MaxDataLength,
157                               ULONG NPMessageQueueSize OPTIONAL);
158
159 NTSTATUS STDCALL NtCreateWaitablePort(PHANDLE PortHandle,
160                                       POBJECT_ATTRIBUTES ObjectAttributes,
161                                       ULONG MaxConnectInfoLength,
162                                       ULONG MaxDataLength,
163                                       ULONG NPMessageQueueSize OPTIONAL);
164
165 NTSTATUS STDCALL NtImpersonateClientOfPort (HANDLE PortHandle,
166                                             PLPC_MESSAGE ClientMessage);
167
168 NTSTATUS STDCALL NtListenPort (HANDLE PortHandle,
169                                PLPC_MESSAGE LpcMessage);
170
171 NTSTATUS STDCALL NtQueryInformationPort (HANDLE PortHandle,
172                                          CINT PortInformationClass,     
173                                          PVOID PortInformation, 
174                                          ULONG PortInformationLength,   
175                                          PULONG ReturnLength);
176 NTSTATUS STDCALL NtReplyPort (HANDLE PortHandle,
177                               PLPC_MESSAGE LpcReply);
178 NTSTATUS STDCALL NtReplyWaitReceivePort (HANDLE PortHandle,
179                                          PULONG PortId,
180                                          PLPC_MESSAGE MessageReply,
181                                          PLPC_MESSAGE MessageRequest);
182 NTSTATUS STDCALL NtRequestPort (HANDLE PortHandle,
183                                 PLPC_MESSAGE LpcMessage);
184
185 NTSTATUS STDCALL NtRequestWaitReplyPort (HANDLE PortHandle,
186                                          PLPC_MESSAGE LpcReply,      
187                                          PLPC_MESSAGE LpcRequest);
188
189 NTSTATUS STDCALL NtReadRequestData (HANDLE PortHandle,
190                                     PLPC_MESSAGE Message,
191                                     ULONG Index,
192                                     PVOID Buffer,
193                                     ULONG BufferLength,
194                                     PULONG ReturnLength);
195
196 NTSTATUS STDCALL NtWriteRequestData (HANDLE PortHandle,
197                                      PLPC_MESSAGE Message,
198                                      ULONG Index,
199                                      PVOID Buffer,
200                                      ULONG BufferLength,
201                                      PULONG ReturnLength);
202
203
204 #endif /* __INCLUDE_NAPI_LPC_H */