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