Commit 9608085b authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll/tests: Port functions use the 64-bit structure on Wow64.

parent b7b2a20a
...@@ -69,6 +69,25 @@ typedef struct _LPC_MESSAGE ...@@ -69,6 +69,25 @@ typedef struct _LPC_MESSAGE
#endif #endif
/* on Wow64 we have to use the 64-bit layout */
typedef struct
{
USHORT DataSize;
USHORT MessageSize;
USHORT MessageType;
USHORT VirtualRangesOffset;
ULONGLONG ClientId[2];
ULONGLONG MessageId;
ULONGLONG SectionSize;
UCHAR Data[ANYSIZE_ARRAY];
} LPC_MESSAGE64;
union lpc_message
{
LPC_MESSAGE msg;
LPC_MESSAGE64 msg64;
};
/* Types of LPC messages */ /* Types of LPC messages */
#define UNUSED_MSG_TYPE 0 #define UNUSED_MSG_TYPE 0
#define LPC_REQUEST 1 #define LPC_REQUEST 1
...@@ -110,6 +129,9 @@ static NTSTATUS (WINAPI *pNtConnectPort)(PHANDLE,PUNICODE_STRING, ...@@ -110,6 +129,9 @@ static NTSTATUS (WINAPI *pNtConnectPort)(PHANDLE,PUNICODE_STRING,
PVOID,PVOID,PULONG); PVOID,PVOID,PULONG);
static NTSTATUS (WINAPI *pRtlInitUnicodeString)(PUNICODE_STRING,LPCWSTR); static NTSTATUS (WINAPI *pRtlInitUnicodeString)(PUNICODE_STRING,LPCWSTR);
static NTSTATUS (WINAPI *pNtWaitForSingleObject)(HANDLE,BOOLEAN,PLARGE_INTEGER); static NTSTATUS (WINAPI *pNtWaitForSingleObject)(HANDLE,BOOLEAN,PLARGE_INTEGER);
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
static BOOL is_wow64;
static BOOL init_function_ptrs(void) static BOOL init_function_ptrs(void)
{ {
...@@ -140,47 +162,75 @@ static BOOL init_function_ptrs(void) ...@@ -140,47 +162,75 @@ static BOOL init_function_ptrs(void)
return FALSE; return FALSE;
} }
pIsWow64Process = (void *)GetProcAddress(GetModuleHandle("kernel32.dll"), "IsWow64Process");
if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
return TRUE; return TRUE;
} }
static void ProcessConnectionRequest(PLPC_MESSAGE LpcMessage, PHANDLE pAcceptPortHandle) static void ProcessConnectionRequest(union lpc_message *LpcMessage, PHANDLE pAcceptPortHandle)
{ {
NTSTATUS status; NTSTATUS status;
ok(LpcMessage->MessageType == LPC_CONNECTION_REQUEST, if (is_wow64)
"Expected LPC_CONNECTION_REQUEST, got %d\n", LpcMessage->MessageType); {
ok(!*LpcMessage->Data, "Expected empty string!\n"); ok(LpcMessage->msg64.MessageType == LPC_CONNECTION_REQUEST,
"Expected LPC_CONNECTION_REQUEST, got %d\n", LpcMessage->msg64.MessageType);
ok(!*LpcMessage->msg64.Data, "Expected empty string!\n");
}
else
{
ok(LpcMessage->msg.MessageType == LPC_CONNECTION_REQUEST,
"Expected LPC_CONNECTION_REQUEST, got %d\n", LpcMessage->msg.MessageType);
ok(!*LpcMessage->msg.Data, "Expected empty string!\n");
}
status = pNtAcceptConnectPort(pAcceptPortHandle, 0, LpcMessage, 1, 0, NULL); status = pNtAcceptConnectPort(pAcceptPortHandle, 0, &LpcMessage->msg, 1, 0, NULL);
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status); ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
status = pNtCompleteConnectPort(*pAcceptPortHandle); status = pNtCompleteConnectPort(*pAcceptPortHandle);
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status); ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
} }
static void ProcessLpcRequest(HANDLE PortHandle, PLPC_MESSAGE LpcMessage) static void ProcessLpcRequest(HANDLE PortHandle, union lpc_message *LpcMessage)
{ {
NTSTATUS status; NTSTATUS status;
ok(LpcMessage->MessageType == LPC_REQUEST, if (is_wow64)
"Expected LPC_REQUEST, got %d\n", LpcMessage->MessageType); {
ok(!lstrcmp((LPSTR)LpcMessage->Data, REQUEST2), ok(LpcMessage->msg64.MessageType == LPC_REQUEST,
"Expected %s, got %s\n", REQUEST2, LpcMessage->Data); "Expected LPC_REQUEST, got %d\n", LpcMessage->msg64.MessageType);
ok(!lstrcmp((LPSTR)LpcMessage->msg64.Data, REQUEST2),
"Expected %s, got %s\n", REQUEST2, LpcMessage->msg64.Data);
lstrcpy((LPSTR)LpcMessage->msg64.Data, REPLY);
lstrcpy((LPSTR)LpcMessage->Data, REPLY); status = pNtReplyPort(PortHandle, &LpcMessage->msg);
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
ok(LpcMessage->msg64.MessageType == LPC_REQUEST,
"Expected LPC_REQUEST, got %d\n", LpcMessage->msg64.MessageType);
ok(!lstrcmp((LPSTR)LpcMessage->msg64.Data, REPLY),
"Expected %s, got %s\n", REPLY, LpcMessage->msg64.Data);
}
else
{
ok(LpcMessage->msg.MessageType == LPC_REQUEST,
"Expected LPC_REQUEST, got %d\n", LpcMessage->msg.MessageType);
ok(!lstrcmp((LPSTR)LpcMessage->msg.Data, REQUEST2),
"Expected %s, got %s\n", REQUEST2, LpcMessage->msg.Data);
lstrcpy((LPSTR)LpcMessage->msg.Data, REPLY);
status = pNtReplyPort(PortHandle, LpcMessage); status = pNtReplyPort(PortHandle, &LpcMessage->msg);
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status); ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
ok(LpcMessage->MessageType == LPC_REQUEST, ok(LpcMessage->msg.MessageType == LPC_REQUEST,
"Expected LPC_REQUEST, got %d\n", LpcMessage->MessageType); "Expected LPC_REQUEST, got %d\n", LpcMessage->msg.MessageType);
ok(!lstrcmp((LPSTR)LpcMessage->Data, REPLY), ok(!lstrcmp((LPSTR)LpcMessage->msg.Data, REPLY),
"Expected %s, got %s\n", REPLY, LpcMessage->Data); "Expected %s, got %s\n", REPLY, LpcMessage->msg.Data);
}
} }
static DWORD WINAPI test_ports_client(LPVOID arg) static DWORD WINAPI test_ports_client(LPVOID arg)
{ {
SECURITY_QUALITY_OF_SERVICE sqos; SECURITY_QUALITY_OF_SERVICE sqos;
LPC_MESSAGE *LpcMessage, *out; union lpc_message *LpcMessage, *out;
HANDLE PortHandle; HANDLE PortHandle;
ULONG len, size; ULONG len, size;
NTSTATUS status; NTSTATUS status;
...@@ -197,31 +247,62 @@ static DWORD WINAPI test_ports_client(LPVOID arg) ...@@ -197,31 +247,62 @@ static DWORD WINAPI test_ports_client(LPVOID arg)
status = pNtRegisterThreadTerminatePort(PortHandle); status = pNtRegisterThreadTerminatePort(PortHandle);
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status); ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
size = FIELD_OFFSET(LPC_MESSAGE, Data) + MAX_MESSAGE_LEN; if (is_wow64)
{
size = FIELD_OFFSET(LPC_MESSAGE64, Data[MAX_MESSAGE_LEN]);
LpcMessage = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); LpcMessage = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
out = HeapAlloc(GetProcessHeap(), 0, size); out = HeapAlloc(GetProcessHeap(), 0, size);
LpcMessage->DataSize = lstrlen(REQUEST1) + 1; LpcMessage->msg64.DataSize = lstrlen(REQUEST1) + 1;
LpcMessage->MessageSize = FIELD_OFFSET(LPC_MESSAGE, Data) + LpcMessage->DataSize; LpcMessage->msg64.MessageSize = FIELD_OFFSET(LPC_MESSAGE64, Data[LpcMessage->msg64.DataSize]);
lstrcpy((LPSTR)LpcMessage->Data, REQUEST1); lstrcpy((LPSTR)LpcMessage->msg64.Data, REQUEST1);
status = pNtRequestPort(PortHandle, LpcMessage); status = pNtRequestPort(PortHandle, &LpcMessage->msg);
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status); ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
ok(LpcMessage->MessageType == 0, "Expected 0, got %d\n", LpcMessage->MessageType); ok(LpcMessage->msg64.MessageType == 0, "Expected 0, got %d\n", LpcMessage->msg64.MessageType);
ok(!lstrcmp((LPSTR)LpcMessage->Data, REQUEST1), ok(!lstrcmp((LPSTR)LpcMessage->msg64.Data, REQUEST1),
"Expected %s, got %s\n", REQUEST1, LpcMessage->Data); "Expected %s, got %s\n", REQUEST1, LpcMessage->msg64.Data);
/* Fill in the message */ /* Fill in the message */
memset(LpcMessage, 0, size); memset(LpcMessage, 0, size);
LpcMessage->DataSize = lstrlen(REQUEST2) + 1; LpcMessage->msg64.DataSize = lstrlen(REQUEST2) + 1;
LpcMessage->MessageSize = FIELD_OFFSET(LPC_MESSAGE, Data) + LpcMessage->DataSize; LpcMessage->msg64.MessageSize = FIELD_OFFSET(LPC_MESSAGE64, Data[LpcMessage->msg64.DataSize]);
lstrcpy((LPSTR)LpcMessage->Data, REQUEST2); lstrcpy((LPSTR)LpcMessage->msg64.Data, REQUEST2);
/* Send the message and wait for the reply */ /* Send the message and wait for the reply */
status = pNtRequestWaitReplyPort(PortHandle, LpcMessage, out); status = pNtRequestWaitReplyPort(PortHandle, &LpcMessage->msg, &out->msg);
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status); ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
ok(!lstrcmp((LPSTR)out->Data, REPLY), "Expected %s, got %s\n", REPLY, out->Data); ok(!lstrcmp((LPSTR)out->msg64.Data, REPLY), "Expected %s, got %s\n", REPLY, out->msg64.Data);
ok(out->MessageType == LPC_REPLY, "Expected LPC_REPLY, got %d\n", out->MessageType); ok(out->msg64.MessageType == LPC_REPLY, "Expected LPC_REPLY, got %d\n", out->msg64.MessageType);
}
else
{
size = FIELD_OFFSET(LPC_MESSAGE, Data[MAX_MESSAGE_LEN]);
LpcMessage = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
out = HeapAlloc(GetProcessHeap(), 0, size);
LpcMessage->msg.DataSize = lstrlen(REQUEST1) + 1;
LpcMessage->msg.MessageSize = FIELD_OFFSET(LPC_MESSAGE, Data[LpcMessage->msg.DataSize]);
lstrcpy((LPSTR)LpcMessage->msg.Data, REQUEST1);
status = pNtRequestPort(PortHandle, &LpcMessage->msg);
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
ok(LpcMessage->msg.MessageType == 0, "Expected 0, got %d\n", LpcMessage->msg.MessageType);
ok(!lstrcmp((LPSTR)LpcMessage->msg.Data, REQUEST1),
"Expected %s, got %s\n", REQUEST1, LpcMessage->msg.Data);
/* Fill in the message */
memset(LpcMessage, 0, size);
LpcMessage->msg.DataSize = lstrlen(REQUEST2) + 1;
LpcMessage->msg.MessageSize = FIELD_OFFSET(LPC_MESSAGE, Data[LpcMessage->msg.DataSize]);
lstrcpy((LPSTR)LpcMessage->msg.Data, REQUEST2);
/* Send the message and wait for the reply */
status = pNtRequestWaitReplyPort(PortHandle, &LpcMessage->msg, &out->msg);
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
ok(!lstrcmp((LPSTR)out->msg.Data, REPLY), "Expected %s, got %s\n", REPLY, out->msg.Data);
ok(out->msg.MessageType == LPC_REPLY, "Expected LPC_REPLY, got %d\n", out->msg.MessageType);
}
HeapFree(GetProcessHeap(), 0, out); HeapFree(GetProcessHeap(), 0, out);
HeapFree(GetProcessHeap(), 0, LpcMessage); HeapFree(GetProcessHeap(), 0, LpcMessage);
...@@ -232,7 +313,7 @@ static DWORD WINAPI test_ports_client(LPVOID arg) ...@@ -232,7 +313,7 @@ static DWORD WINAPI test_ports_client(LPVOID arg)
static void test_ports_server( HANDLE PortHandle ) static void test_ports_server( HANDLE PortHandle )
{ {
HANDLE AcceptPortHandle; HANDLE AcceptPortHandle;
PLPC_MESSAGE LpcMessage; union lpc_message *LpcMessage;
ULONG size; ULONG size;
NTSTATUS status; NTSTATUS status;
BOOL done = FALSE; BOOL done = FALSE;
...@@ -242,7 +323,7 @@ static void test_ports_server( HANDLE PortHandle ) ...@@ -242,7 +323,7 @@ static void test_ports_server( HANDLE PortHandle )
while (TRUE) while (TRUE)
{ {
status = pNtReplyWaitReceivePort(PortHandle, NULL, NULL, LpcMessage); status = pNtReplyWaitReceivePort(PortHandle, NULL, NULL, &LpcMessage->msg);
todo_wine todo_wine
{ {
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d(%x)\n", status, status); ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d(%x)\n", status, status);
...@@ -253,7 +334,7 @@ static void test_ports_server( HANDLE PortHandle ) ...@@ -253,7 +334,7 @@ static void test_ports_server( HANDLE PortHandle )
if ((status == STATUS_NOT_IMPLEMENTED) || if ((status == STATUS_NOT_IMPLEMENTED) ||
(status == STATUS_INVALID_HANDLE)) return; (status == STATUS_INVALID_HANDLE)) return;
switch (LpcMessage->MessageType) switch (is_wow64 ? LpcMessage->msg64.MessageType : LpcMessage->msg.MessageType)
{ {
case LPC_CONNECTION_REQUEST: case LPC_CONNECTION_REQUEST:
ProcessConnectionRequest(LpcMessage, &AcceptPortHandle); ProcessConnectionRequest(LpcMessage, &AcceptPortHandle);
...@@ -265,8 +346,12 @@ static void test_ports_server( HANDLE PortHandle ) ...@@ -265,8 +346,12 @@ static void test_ports_server( HANDLE PortHandle )
break; break;
case LPC_DATAGRAM: case LPC_DATAGRAM:
ok(!lstrcmp((LPSTR)LpcMessage->Data, REQUEST1), if (is_wow64)
"Expected %s, got %s\n", REQUEST1, LpcMessage->Data); ok(!lstrcmp((LPSTR)LpcMessage->msg64.Data, REQUEST1),
"Expected %s, got %s\n", REQUEST1, LpcMessage->msg64.Data);
else
ok(!lstrcmp((LPSTR)LpcMessage->msg.Data, REQUEST1),
"Expected %s, got %s\n", REQUEST1, LpcMessage->msg.Data);
break; break;
case LPC_CLIENT_DIED: case LPC_CLIENT_DIED:
...@@ -275,7 +360,8 @@ static void test_ports_server( HANDLE PortHandle ) ...@@ -275,7 +360,8 @@ static void test_ports_server( HANDLE PortHandle )
return; return;
default: default:
ok(FALSE, "Unexpected message: %d\n", LpcMessage->MessageType); ok(FALSE, "Unexpected message: %d\n",
is_wow64 ? LpcMessage->msg64.MessageType : LpcMessage->msg.MessageType);
break; break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment