ReactOS  0.4.13-dev-563-g0561610
port.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winreg.h"
#include "winnls.h"
#include "wine/test.h"
#include "winternl.h"
Include dependency graph for port.c:

Go to the source code of this file.

Classes

struct  _CLIENT_ID
 
struct  _LPC_SECTION_WRITE
 
struct  _LPC_SECTION_READ
 
struct  _LPC_MESSAGE
 
struct  LPC_MESSAGE64
 
union  lpc_message
 

Macros

#define WIN32_NO_STATUS
 
#define UNUSED_MSG_TYPE   0
 
#define LPC_REQUEST   1
 
#define LPC_REPLY   2
 
#define LPC_DATAGRAM   3
 
#define LPC_LOST_REPLY   4
 
#define LPC_PORT_CLOSED   5
 
#define LPC_CLIENT_DIED   6
 
#define LPC_EXCEPTION   7
 
#define LPC_DEBUG_EVENT   8
 
#define LPC_ERROR_EVENT   9
 
#define LPC_CONNECTION_REQUEST   10
 
#define REQUEST1   "Request1"
 
#define REQUEST2   "Request2"
 
#define REPLY   "Reply"
 
#define MAX_MESSAGE_LEN   30
 

Typedefs

typedef struct _CLIENT_ID CLIENT_ID
 
typedef struct _CLIENT_IDPCLIENT_ID
 
typedef struct _LPC_SECTION_WRITE LPC_SECTION_WRITE
 
typedef struct _LPC_SECTION_WRITEPLPC_SECTION_WRITE
 
typedef struct _LPC_SECTION_READ LPC_SECTION_READ
 
typedef struct _LPC_SECTION_READPLPC_SECTION_READ
 
typedef struct _LPC_MESSAGE LPC_MESSAGE
 
typedef struct _LPC_MESSAGEPLPC_MESSAGE
 

Functions

static NTSTATUS (WINAPI *pNtCompleteConnectPort)(HANDLE)
 
static BOOL (WINAPI *pIsWow64Process)(HANDLE
 
static BOOL init_function_ptrs (void)
 
static void ProcessConnectionRequest (union lpc_message *LpcMessage, PHANDLE pAcceptPortHandle)
 
static void ProcessLpcRequest (HANDLE PortHandle, union lpc_message *LpcMessage)
 
static DWORD WINAPI test_ports_client (LPVOID arg)
 
static void test_ports_server (HANDLE PortHandle)
 
 START_TEST (port)
 

Variables

static const WCHAR PORTNAME [] = {'\\','M','y','P','o','r','t',0}
 
static UNICODE_STRING port
 
static HMODULE hntdll = 0
 
static ULONG
 
static PULONG
 
static POBJECT_ATTRIBUTES
 
static PUNICODE_STRING
 
static PSECURITY_QUALITY_OF_SERVICE
 
static PVOID
 
static LPCWSTR
 
static PBOOL
 
static BOOL is_wow64
 

Macro Definition Documentation

◆ LPC_CLIENT_DIED

#define LPC_CLIENT_DIED   6

Definition at line 98 of file port.c.

◆ LPC_CONNECTION_REQUEST

#define LPC_CONNECTION_REQUEST   10

Definition at line 102 of file port.c.

◆ LPC_DATAGRAM

#define LPC_DATAGRAM   3

Definition at line 95 of file port.c.

◆ LPC_DEBUG_EVENT

#define LPC_DEBUG_EVENT   8

Definition at line 100 of file port.c.

◆ LPC_ERROR_EVENT

#define LPC_ERROR_EVENT   9

Definition at line 101 of file port.c.

◆ LPC_EXCEPTION

#define LPC_EXCEPTION   7

Definition at line 99 of file port.c.

◆ LPC_LOST_REPLY

#define LPC_LOST_REPLY   4

Definition at line 96 of file port.c.

◆ LPC_PORT_CLOSED

#define LPC_PORT_CLOSED   5

Definition at line 97 of file port.c.

◆ LPC_REPLY

#define LPC_REPLY   2

Definition at line 94 of file port.c.

◆ LPC_REQUEST

#define LPC_REQUEST   1

Definition at line 93 of file port.c.

◆ MAX_MESSAGE_LEN

#define MAX_MESSAGE_LEN   30

Definition at line 110 of file port.c.

◆ REPLY

#define REPLY   "Reply"

Definition at line 108 of file port.c.

◆ REQUEST1

#define REQUEST1   "Request1"

Definition at line 106 of file port.c.

◆ REQUEST2

#define REQUEST2   "Request2"

Definition at line 107 of file port.c.

◆ UNUSED_MSG_TYPE

#define UNUSED_MSG_TYPE   0

Definition at line 92 of file port.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 24 of file port.c.

Typedef Documentation

◆ CLIENT_ID

◆ LPC_MESSAGE

◆ LPC_SECTION_READ

◆ LPC_SECTION_WRITE

◆ PCLIENT_ID

◆ PLPC_MESSAGE

static PLPC_MESSAGE

Definition at line 117 of file port.c.

◆ PLPC_SECTION_READ

Definition at line 117 of file port.c.

◆ PLPC_SECTION_WRITE

Definition at line 117 of file port.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pIsWow64Process)
static

◆ init_function_ptrs()

static BOOL init_function_ptrs ( void  )
static

Definition at line 135 of file port.c.

136 {
137  hntdll = LoadLibraryA("ntdll.dll");
138 
139  if (!hntdll)
140  return FALSE;
141 
142  pNtCompleteConnectPort = (void *)GetProcAddress(hntdll, "NtCompleteConnectPort");
143  pNtAcceptConnectPort = (void *)GetProcAddress(hntdll, "NtAcceptConnectPort");
144  pNtReplyPort = (void *)GetProcAddress(hntdll, "NtReplyPort");
145  pNtReplyWaitReceivePort = (void *)GetProcAddress(hntdll, "NtReplyWaitReceivePort");
146  pNtCreatePort = (void *)GetProcAddress(hntdll, "NtCreatePort");
147  pNtRequestWaitReplyPort = (void *)GetProcAddress(hntdll, "NtRequestWaitReplyPort");
148  pNtRequestPort = (void *)GetProcAddress(hntdll, "NtRequestPort");
149  pNtRegisterThreadTerminatePort = (void *)GetProcAddress(hntdll, "NtRegisterThreadTerminatePort");
150  pNtConnectPort = (void *)GetProcAddress(hntdll, "NtConnectPort");
151  pRtlInitUnicodeString = (void *)GetProcAddress(hntdll, "RtlInitUnicodeString");
152 
153  if (!pNtCompleteConnectPort || !pNtAcceptConnectPort ||
154  !pNtReplyWaitReceivePort || !pNtCreatePort || !pNtRequestWaitReplyPort ||
155  !pNtRequestPort || !pNtRegisterThreadTerminatePort ||
156  !pNtConnectPort || !pRtlInitUnicodeString)
157  {
158  win_skip("Needed port functions are not available\n");
160  return FALSE;
161  }
162 
163  pIsWow64Process = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsWow64Process");
164  if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
165  return TRUE;
166 }
#define TRUE
Definition: types.h:120
static HMODULE hntdll
Definition: port.c:115
static BOOL is_wow64
Definition: port.c:133
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define FreeLibrary(x)
Definition: compat.h:405
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
#define GetProcAddress(x, y)
Definition: compat.h:410
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ NTSTATUS()

static NTSTATUS ( WINAPI pNtCompleteConnectPort)
static

◆ ProcessConnectionRequest()

static void ProcessConnectionRequest ( union lpc_message LpcMessage,
PHANDLE  pAcceptPortHandle 
)
static

Definition at line 168 of file port.c.

169 {
171 
172  if (is_wow64)
173  {
175  "Expected LPC_CONNECTION_REQUEST, got %d\n", LpcMessage->msg64.MessageType);
176  ok(!*LpcMessage->msg64.Data, "Expected empty string!\n");
177  }
178  else
179  {
180  ok(LpcMessage->msg.MessageType == LPC_CONNECTION_REQUEST,
181  "Expected LPC_CONNECTION_REQUEST, got %d\n", LpcMessage->msg.MessageType);
182  ok(!*LpcMessage->msg.Data, "Expected empty string!\n");
183  }
184 
185  status = pNtAcceptConnectPort(pAcceptPortHandle, 0, &LpcMessage->msg, 1, NULL, NULL);
186  ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
187 
188  status = pNtCompleteConnectPort(*pAcceptPortHandle);
189  ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
190 }
LPC_MESSAGE64 msg64
Definition: port.c:88
UCHAR Data[ANYSIZE_ARRAY]
Definition: port.c:67
#define LPC_CONNECTION_REQUEST
Definition: port.c:102
LONG NTSTATUS
Definition: precomp.h:26
static BOOL is_wow64
Definition: port.c:133
USHORT MessageType
Definition: port.c:62
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
USHORT MessageType
Definition: port.c:77
UCHAR Data[ANYSIZE_ARRAY]
Definition: port.c:82
return STATUS_SUCCESS
Definition: btrfs.c:2777
static SERVICE_STATUS status
Definition: service.c:31
LPC_MESSAGE msg
Definition: port.c:87
Definition: ps.c:97

Referenced by test_ports_server().

◆ ProcessLpcRequest()

static void ProcessLpcRequest ( HANDLE  PortHandle,
union lpc_message LpcMessage 
)
static

Definition at line 192 of file port.c.

193 {
195 
196  if (is_wow64)
197  {
198  ok(LpcMessage->msg64.MessageType == LPC_REQUEST,
199  "Expected LPC_REQUEST, got %d\n", LpcMessage->msg64.MessageType);
200  ok(!strcmp((LPSTR)LpcMessage->msg64.Data, REQUEST2),
201  "Expected %s, got %s\n", REQUEST2, LpcMessage->msg64.Data);
202  strcpy((LPSTR)LpcMessage->msg64.Data, REPLY);
203 
204  status = pNtReplyPort(PortHandle, &LpcMessage->msg);
205  ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
206  ok(LpcMessage->msg64.MessageType == LPC_REQUEST,
207  "Expected LPC_REQUEST, got %d\n", LpcMessage->msg64.MessageType);
208  ok(!strcmp((LPSTR)LpcMessage->msg64.Data, REPLY),
209  "Expected %s, got %s\n", REPLY, LpcMessage->msg64.Data);
210  }
211  else
212  {
213  ok(LpcMessage->msg.MessageType == LPC_REQUEST,
214  "Expected LPC_REQUEST, got %d\n", LpcMessage->msg.MessageType);
215  ok(!strcmp((LPSTR)LpcMessage->msg.Data, REQUEST2),
216  "Expected %s, got %s\n", REQUEST2, LpcMessage->msg.Data);
217  strcpy((LPSTR)LpcMessage->msg.Data, REPLY);
218 
219  status = pNtReplyPort(PortHandle, &LpcMessage->msg);
220  ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
221  ok(LpcMessage->msg.MessageType == LPC_REQUEST,
222  "Expected LPC_REQUEST, got %d\n", LpcMessage->msg.MessageType);
223  ok(!strcmp((LPSTR)LpcMessage->msg.Data, REPLY),
224  "Expected %s, got %s\n", REPLY, LpcMessage->msg.Data);
225  }
226 }
LPC_MESSAGE64 msg64
Definition: port.c:88
UCHAR Data[ANYSIZE_ARRAY]
Definition: port.c:67
#define REPLY
Definition: port.c:108
#define LPC_REQUEST
Definition: port.c:93
LONG NTSTATUS
Definition: precomp.h:26
static BOOL is_wow64
Definition: port.c:133
char * LPSTR
Definition: xmlstorage.h:182
USHORT MessageType
Definition: port.c:62
#define ok(value,...)
USHORT MessageType
Definition: port.c:77
UCHAR Data[ANYSIZE_ARRAY]
Definition: port.c:82
#define REQUEST2
Definition: port.c:107
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
return STATUS_SUCCESS
Definition: btrfs.c:2777
static SERVICE_STATUS status
Definition: service.c:31
LPC_MESSAGE msg
Definition: port.c:87
Definition: ps.c:97

Referenced by test_ports_server().

◆ START_TEST()

START_TEST ( port  )

Definition at line 370 of file port.c.

371 {
373  HANDLE port_handle;
375 
376  if (!init_function_ptrs())
377  return;
378 
379  pRtlInitUnicodeString(&port, PORTNAME);
380 
381  memset(&obj, 0, sizeof(OBJECT_ATTRIBUTES));
382  obj.Length = sizeof(OBJECT_ATTRIBUTES);
383  obj.ObjectName = &port;
384 
385  status = pNtCreatePort(&port_handle, &obj, 100, 100, 0);
386  if (status == STATUS_ACCESS_DENIED) skip("Not enough rights\n");
387  else todo_wine ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d\n", status);
388 
389  if (status == STATUS_SUCCESS)
390  {
391  DWORD id;
393  ok(thread != NULL, "Expected non-NULL thread handle!\n");
394 
395  test_ports_server( port_handle );
396  ok( WaitForSingleObject( thread, 10000 ) == 0, "thread didn't exit\n" );
398  }
400 }
#define CloseHandle
Definition: compat.h:398
LONG NTSTATUS
Definition: precomp.h:26
static HMODULE hntdll
Definition: port.c:115
static void test_ports_server(HANDLE PortHandle)
Definition: port.c:311
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ok(value,...)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:111
smooth NULL
Definition: ftsmooth.c:416
struct _OBJECT_ATTRIBUTES OBJECT_ATTRIBUTES
static DWORD WINAPI test_ports_client(LPVOID arg)
Definition: port.c:228
#define FreeLibrary(x)
Definition: compat.h:405
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
static HANDLE thread
Definition: service.c:33
#define todo_wine
Definition: test.h:154
static BOOL init_function_ptrs(void)
Definition: port.c:135
#define skip(...)
GLenum GLuint id
Definition: glext.h:5579
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define memset(x, y, z)
Definition: compat.h:39
static SERVICE_STATUS status
Definition: service.c:31
static const WCHAR PORTNAME[]
Definition: port.c:104
static UNICODE_STRING port
Definition: port.c:112
Definition: ps.c:97

◆ test_ports_client()

static DWORD WINAPI test_ports_client ( LPVOID  arg)
static

Definition at line 228 of file port.c.

229 {
231  union lpc_message *LpcMessage, *out;
232  HANDLE PortHandle;
233  ULONG len, size;
235 
236  sqos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
239  sqos.EffectiveOnly = TRUE;
240 
241  status = pNtConnectPort(&PortHandle, &port, &sqos, 0, 0, &len, NULL, NULL);
242  todo_wine ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
243  if (status != STATUS_SUCCESS) return 1;
244 
245  status = pNtRegisterThreadTerminatePort(PortHandle);
246  ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
247 
248  if (is_wow64)
249  {
251  LpcMessage = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
252  out = HeapAlloc(GetProcessHeap(), 0, size);
253 
254  LpcMessage->msg64.DataSize = strlen(REQUEST1) + 1;
255  LpcMessage->msg64.MessageSize = FIELD_OFFSET(LPC_MESSAGE64, Data[LpcMessage->msg64.DataSize]);
256  strcpy((LPSTR)LpcMessage->msg64.Data, REQUEST1);
257 
258  status = pNtRequestPort(PortHandle, &LpcMessage->msg);
259  ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
260  ok(LpcMessage->msg64.MessageType == 0, "Expected 0, got %d\n", LpcMessage->msg64.MessageType);
261  ok(!strcmp((LPSTR)LpcMessage->msg64.Data, REQUEST1),
262  "Expected %s, got %s\n", REQUEST1, LpcMessage->msg64.Data);
263 
264  /* Fill in the message */
265  memset(LpcMessage, 0, size);
266  LpcMessage->msg64.DataSize = strlen(REQUEST2) + 1;
267  LpcMessage->msg64.MessageSize = FIELD_OFFSET(LPC_MESSAGE64, Data[LpcMessage->msg64.DataSize]);
268  strcpy((LPSTR)LpcMessage->msg64.Data, REQUEST2);
269 
270  /* Send the message and wait for the reply */
271  status = pNtRequestWaitReplyPort(PortHandle, &LpcMessage->msg, &out->msg);
272  ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
273  ok(!strcmp((LPSTR)out->msg64.Data, REPLY), "Expected %s, got %s\n", REPLY, out->msg64.Data);
274  ok(out->msg64.MessageType == LPC_REPLY, "Expected LPC_REPLY, got %d\n", out->msg64.MessageType);
275  }
276  else
277  {
279  LpcMessage = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
280  out = HeapAlloc(GetProcessHeap(), 0, size);
281 
282  LpcMessage->msg.DataSize = strlen(REQUEST1) + 1;
283  LpcMessage->msg.MessageSize = FIELD_OFFSET(LPC_MESSAGE, Data[LpcMessage->msg.DataSize]);
284  strcpy((LPSTR)LpcMessage->msg.Data, REQUEST1);
285 
286  status = pNtRequestPort(PortHandle, &LpcMessage->msg);
287  ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
288  ok(LpcMessage->msg.MessageType == 0, "Expected 0, got %d\n", LpcMessage->msg.MessageType);
289  ok(!strcmp((LPSTR)LpcMessage->msg.Data, REQUEST1),
290  "Expected %s, got %s\n", REQUEST1, LpcMessage->msg.Data);
291 
292  /* Fill in the message */
293  memset(LpcMessage, 0, size);
294  LpcMessage->msg.DataSize = strlen(REQUEST2) + 1;
295  LpcMessage->msg.MessageSize = FIELD_OFFSET(LPC_MESSAGE, Data[LpcMessage->msg.DataSize]);
296  strcpy((LPSTR)LpcMessage->msg.Data, REQUEST2);
297 
298  /* Send the message and wait for the reply */
299  status = pNtRequestWaitReplyPort(PortHandle, &LpcMessage->msg, &out->msg);
300  ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
301  ok(!strcmp((LPSTR)out->msg.Data, REPLY), "Expected %s, got %s\n", REPLY, out->msg.Data);
302  ok(out->msg.MessageType == LPC_REPLY, "Expected LPC_REPLY, got %d\n", out->msg.MessageType);
303  }
304 
305  HeapFree(GetProcessHeap(), 0, out);
306  HeapFree(GetProcessHeap(), 0, LpcMessage);
307 
308  return 0;
309 }
LPC_MESSAGE64 msg64
Definition: port.c:88
UCHAR Data[ANYSIZE_ARRAY]
Definition: port.c:67
#define TRUE
Definition: types.h:120
#define REPLY
Definition: port.c:108
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LONG NTSTATUS
Definition: precomp.h:26
static BOOL is_wow64
Definition: port.c:133
char * LPSTR
Definition: xmlstorage.h:182
#define LPC_REPLY
Definition: port.c:94
SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
Definition: lsa.idl:66
#define REQUEST1
Definition: port.c:106
USHORT MessageType
Definition: port.c:62
#define MAX_MESSAGE_LEN
Definition: port.c:110
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
USHORT MessageSize
Definition: port.c:76
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
USHORT DataSize
Definition: port.c:60
static FILE * out
Definition: regtests2xml.c:44
#define todo_wine
Definition: test.h:154
GLenum GLsizei len
Definition: glext.h:6722
USHORT MessageType
Definition: port.c:77
UCHAR Data[ANYSIZE_ARRAY]
Definition: port.c:82
#define REQUEST2
Definition: port.c:107
USHORT MessageSize
Definition: port.c:61
#define SECURITY_STATIC_TRACKING
Definition: setypes.h:104
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
struct _SECURITY_QUALITY_OF_SERVICE SECURITY_QUALITY_OF_SERVICE
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: lsa.idl:65
USHORT DataSize
Definition: port.c:75
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define memset(x, y, z)
Definition: compat.h:39
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:394
LPC_MESSAGE msg
Definition: port.c:87
static UNICODE_STRING port
Definition: port.c:112
Definition: ps.c:97

Referenced by START_TEST().

◆ test_ports_server()

static void test_ports_server ( HANDLE  PortHandle)
static

Definition at line 311 of file port.c.

312 {
313  HANDLE AcceptPortHandle;
314  union lpc_message *LpcMessage;
315  ULONG size;
317  BOOL done = FALSE;
318 
320  LpcMessage = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
321 
322  while (TRUE)
323  {
324  status = pNtReplyWaitReceivePort(PortHandle, NULL, NULL, &LpcMessage->msg);
325  todo_wine
326  {
327  ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d(%x)\n", status, status);
328  }
329  /* STATUS_INVALID_HANDLE: win2k without admin rights will perform an
330  * endless loop here
331  */
332  if ((status == STATUS_NOT_IMPLEMENTED) ||
333  (status == STATUS_INVALID_HANDLE)) return;
334 
335  switch (is_wow64 ? LpcMessage->msg64.MessageType : LpcMessage->msg.MessageType)
336  {
338  ProcessConnectionRequest(LpcMessage, &AcceptPortHandle);
339  break;
340 
341  case LPC_REQUEST:
342  ProcessLpcRequest(PortHandle, LpcMessage);
343  done = TRUE;
344  break;
345 
346  case LPC_DATAGRAM:
347  if (is_wow64)
348  ok(!strcmp((LPSTR)LpcMessage->msg64.Data, REQUEST1),
349  "Expected %s, got %s\n", REQUEST1, LpcMessage->msg64.Data);
350  else
351  ok(!strcmp((LPSTR)LpcMessage->msg.Data, REQUEST1),
352  "Expected %s, got %s\n", REQUEST1, LpcMessage->msg.Data);
353  break;
354 
355  case LPC_CLIENT_DIED:
356  ok(done, "Expected LPC request to be completed!\n");
357  HeapFree(GetProcessHeap(), 0, LpcMessage);
358  return;
359 
360  default:
361  ok(FALSE, "Unexpected message: %d\n",
362  is_wow64 ? LpcMessage->msg64.MessageType : LpcMessage->msg.MessageType);
363  break;
364  }
365  }
366 
367  HeapFree(GetProcessHeap(), 0, LpcMessage);
368 }
LPC_MESSAGE64 msg64
Definition: port.c:88
UCHAR Data[ANYSIZE_ARRAY]
Definition: port.c:67
#define TRUE
Definition: types.h:120
static void ProcessLpcRequest(HANDLE PortHandle, union lpc_message *LpcMessage)
Definition: port.c:192
#define LPC_CONNECTION_REQUEST
Definition: port.c:102
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define LPC_REQUEST
Definition: port.c:93
LONG NTSTATUS
Definition: precomp.h:26
static BOOL is_wow64
Definition: port.c:133
char * LPSTR
Definition: xmlstorage.h:182
#define LPC_DATAGRAM
Definition: port.c:95
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
#define REQUEST1
Definition: port.c:106
unsigned int BOOL
Definition: ntddk_ex.h:94
USHORT MessageType
Definition: port.c:62
#define MAX_MESSAGE_LEN
Definition: port.c:110
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static void ProcessConnectionRequest(union lpc_message *LpcMessage, PHANDLE pAcceptPortHandle)
Definition: port.c:168
#define todo_wine
Definition: test.h:154
USHORT MessageType
Definition: port.c:77
UCHAR Data[ANYSIZE_ARRAY]
Definition: port.c:82
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
return STATUS_SUCCESS
Definition: btrfs.c:2777
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:394
#define LPC_CLIENT_DIED
Definition: port.c:98
LPC_MESSAGE msg
Definition: port.c:87
Definition: ps.c:97

Referenced by START_TEST().

Variable Documentation

◆ hntdll

HMODULE hntdll = 0
static

Definition at line 115 of file port.c.

Referenced by init_function_ptrs(), and START_TEST().

◆ is_wow64

◆ LPCWSTR

Definition at line 130 of file port.c.

◆ PBOOL

Definition at line 131 of file port.c.

◆ POBJECT_ATTRIBUTES

Definition at line 122 of file port.c.

◆ port

UNICODE_STRING port
static

Definition at line 112 of file port.c.

Referenced by START_TEST(), and test_ports_client().

◆ PORTNAME

const WCHAR PORTNAME[] = {'\\','M','y','P','o','r','t',0}
static

Definition at line 104 of file port.c.

Referenced by START_TEST().

◆ PSECURITY_QUALITY_OF_SERVICE

Definition at line 126 of file port.c.

◆ PULONG

Definition at line 120 of file port.c.

◆ PUNICODE_STRING

Definition at line 126 of file port.c.

◆ PVOID

Definition at line 126 of file port.c.

◆ ULONG

Definition at line 117 of file port.c.