2007-03-06 11:59:18 +00:00
|
|
|
/* Unit test suite for Ntdll Port API functions
|
|
|
|
*
|
|
|
|
* Copyright 2006 James Hawkins
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2008-05-12 08:33:26 +00:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include "winternl.h"
|
2007-03-06 11:59:18 +00:00
|
|
|
|
|
|
|
#ifndef __WINE_WINTERNL_H
|
|
|
|
|
|
|
|
typedef struct _CLIENT_ID
|
|
|
|
{
|
|
|
|
HANDLE UniqueProcess;
|
|
|
|
HANDLE UniqueThread;
|
|
|
|
} CLIENT_ID, *PCLIENT_ID;
|
|
|
|
|
|
|
|
typedef struct _LPC_SECTION_WRITE
|
|
|
|
{
|
|
|
|
ULONG Length;
|
|
|
|
HANDLE SectionHandle;
|
|
|
|
ULONG SectionOffset;
|
|
|
|
ULONG ViewSize;
|
|
|
|
PVOID ViewBase;
|
|
|
|
PVOID TargetViewBase;
|
|
|
|
} LPC_SECTION_WRITE, *PLPC_SECTION_WRITE;
|
|
|
|
|
|
|
|
typedef struct _LPC_SECTION_READ
|
|
|
|
{
|
|
|
|
ULONG Length;
|
|
|
|
ULONG ViewSize;
|
|
|
|
PVOID ViewBase;
|
|
|
|
} LPC_SECTION_READ, *PLPC_SECTION_READ;
|
|
|
|
|
|
|
|
typedef struct _LPC_MESSAGE
|
|
|
|
{
|
|
|
|
USHORT DataSize;
|
|
|
|
USHORT MessageSize;
|
|
|
|
USHORT MessageType;
|
|
|
|
USHORT VirtualRangesOffset;
|
|
|
|
CLIENT_ID ClientId;
|
2009-05-17 07:05:22 +00:00
|
|
|
ULONG_PTR MessageId;
|
|
|
|
ULONG_PTR SectionSize;
|
2007-03-06 11:59:18 +00:00
|
|
|
UCHAR Data[ANYSIZE_ARRAY];
|
|
|
|
} LPC_MESSAGE, *PLPC_MESSAGE;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
/* 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;
|
|
|
|
};
|
|
|
|
|
2007-03-06 11:59:18 +00:00
|
|
|
/* Types of LPC messages */
|
|
|
|
#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
|
|
|
|
|
|
|
|
static const WCHAR PORTNAME[] = {'\\','M','y','P','o','r','t',0};
|
|
|
|
|
|
|
|
#define REQUEST1 "Request1"
|
|
|
|
#define REQUEST2 "Request2"
|
|
|
|
#define REPLY "Reply"
|
|
|
|
|
|
|
|
#define MAX_MESSAGE_LEN 30
|
|
|
|
|
2009-05-17 07:05:22 +00:00
|
|
|
static UNICODE_STRING port;
|
2007-03-06 11:59:18 +00:00
|
|
|
|
|
|
|
/* Function pointers for ntdll calls */
|
|
|
|
static HMODULE hntdll = 0;
|
|
|
|
static NTSTATUS (WINAPI *pNtCompleteConnectPort)(HANDLE);
|
|
|
|
static NTSTATUS (WINAPI *pNtAcceptConnectPort)(PHANDLE,ULONG,PLPC_MESSAGE,ULONG,
|
|
|
|
ULONG,PLPC_SECTION_READ);
|
|
|
|
static NTSTATUS (WINAPI *pNtReplyPort)(HANDLE,PLPC_MESSAGE);
|
|
|
|
static NTSTATUS (WINAPI *pNtReplyWaitReceivePort)(PHANDLE,PULONG,PLPC_MESSAGE,
|
|
|
|
PLPC_MESSAGE);
|
|
|
|
static NTSTATUS (WINAPI *pNtCreatePort)(PHANDLE,POBJECT_ATTRIBUTES,ULONG,ULONG,ULONG);
|
|
|
|
static NTSTATUS (WINAPI *pNtRequestWaitReplyPort)(HANDLE,PLPC_MESSAGE,PLPC_MESSAGE);
|
|
|
|
static NTSTATUS (WINAPI *pNtRequestPort)(HANDLE,PLPC_MESSAGE);
|
|
|
|
static NTSTATUS (WINAPI *pNtRegisterThreadTerminatePort)(HANDLE);
|
|
|
|
static NTSTATUS (WINAPI *pNtConnectPort)(PHANDLE,PUNICODE_STRING,
|
|
|
|
PSECURITY_QUALITY_OF_SERVICE,
|
|
|
|
PLPC_SECTION_WRITE,PLPC_SECTION_READ,
|
|
|
|
PVOID,PVOID,PULONG);
|
|
|
|
static NTSTATUS (WINAPI *pRtlInitUnicodeString)(PUNICODE_STRING,LPCWSTR);
|
|
|
|
static NTSTATUS (WINAPI *pNtWaitForSingleObject)(HANDLE,BOOLEAN,PLARGE_INTEGER);
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
|
|
|
|
|
|
|
|
static BOOL is_wow64;
|
2007-03-06 11:59:18 +00:00
|
|
|
|
|
|
|
static BOOL init_function_ptrs(void)
|
|
|
|
{
|
|
|
|
hntdll = LoadLibraryA("ntdll.dll");
|
|
|
|
|
2008-12-12 23:42:40 +00:00
|
|
|
if (!hntdll)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
pNtCompleteConnectPort = (void *)GetProcAddress(hntdll, "NtCompleteConnectPort");
|
|
|
|
pNtAcceptConnectPort = (void *)GetProcAddress(hntdll, "NtAcceptConnectPort");
|
|
|
|
pNtReplyPort = (void *)GetProcAddress(hntdll, "NtReplyPort");
|
|
|
|
pNtReplyWaitReceivePort = (void *)GetProcAddress(hntdll, "NtReplyWaitReceivePort");
|
|
|
|
pNtCreatePort = (void *)GetProcAddress(hntdll, "NtCreatePort");
|
|
|
|
pNtRequestWaitReplyPort = (void *)GetProcAddress(hntdll, "NtRequestWaitReplyPort");
|
|
|
|
pNtRequestPort = (void *)GetProcAddress(hntdll, "NtRequestPort");
|
|
|
|
pNtRegisterThreadTerminatePort = (void *)GetProcAddress(hntdll, "NtRegisterThreadTerminatePort");
|
|
|
|
pNtConnectPort = (void *)GetProcAddress(hntdll, "NtConnectPort");
|
|
|
|
pRtlInitUnicodeString = (void *)GetProcAddress(hntdll, "RtlInitUnicodeString");
|
|
|
|
pNtWaitForSingleObject = (void *)GetProcAddress(hntdll, "NtWaitForSingleObject");
|
2007-03-06 11:59:18 +00:00
|
|
|
|
|
|
|
if (!pNtCompleteConnectPort || !pNtAcceptConnectPort ||
|
|
|
|
!pNtReplyWaitReceivePort || !pNtCreatePort || !pNtRequestWaitReplyPort ||
|
|
|
|
!pNtRequestPort || !pNtRegisterThreadTerminatePort ||
|
|
|
|
!pNtConnectPort || !pRtlInitUnicodeString)
|
|
|
|
{
|
2008-12-12 23:42:40 +00:00
|
|
|
win_skip("Needed port functions are not available\n");
|
|
|
|
FreeLibrary(hntdll);
|
2007-03-06 11:59:18 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
pIsWow64Process = (void *)GetProcAddress(GetModuleHandle("kernel32.dll"), "IsWow64Process");
|
|
|
|
if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
|
2007-03-06 11:59:18 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
static void ProcessConnectionRequest(union lpc_message *LpcMessage, PHANDLE pAcceptPortHandle)
|
2007-03-06 11:59:18 +00:00
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
if (is_wow64)
|
|
|
|
{
|
|
|
|
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");
|
|
|
|
}
|
2007-03-06 11:59:18 +00:00
|
|
|
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
status = pNtAcceptConnectPort(pAcceptPortHandle, 0, &LpcMessage->msg, 1, 0, NULL);
|
2009-05-17 07:05:22 +00:00
|
|
|
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
|
2008-05-12 08:33:26 +00:00
|
|
|
|
2007-03-06 11:59:18 +00:00
|
|
|
status = pNtCompleteConnectPort(*pAcceptPortHandle);
|
2009-05-17 07:05:22 +00:00
|
|
|
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
|
2007-03-06 11:59:18 +00:00
|
|
|
}
|
|
|
|
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
static void ProcessLpcRequest(HANDLE PortHandle, union lpc_message *LpcMessage)
|
2007-03-06 11:59:18 +00:00
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
if (is_wow64)
|
|
|
|
{
|
|
|
|
ok(LpcMessage->msg64.MessageType == LPC_REQUEST,
|
|
|
|
"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);
|
|
|
|
|
|
|
|
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->msg);
|
|
|
|
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
|
|
|
|
ok(LpcMessage->msg.MessageType == LPC_REQUEST,
|
|
|
|
"Expected LPC_REQUEST, got %d\n", LpcMessage->msg.MessageType);
|
|
|
|
ok(!lstrcmp((LPSTR)LpcMessage->msg.Data, REPLY),
|
|
|
|
"Expected %s, got %s\n", REPLY, LpcMessage->msg.Data);
|
|
|
|
}
|
2007-03-06 11:59:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD WINAPI test_ports_client(LPVOID arg)
|
|
|
|
{
|
|
|
|
SECURITY_QUALITY_OF_SERVICE sqos;
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
union lpc_message *LpcMessage, *out;
|
2007-03-06 11:59:18 +00:00
|
|
|
HANDLE PortHandle;
|
|
|
|
ULONG len, size;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
sqos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
|
|
|
|
sqos.ImpersonationLevel = SecurityImpersonation;
|
|
|
|
sqos.ContextTrackingMode = SECURITY_STATIC_TRACKING;
|
|
|
|
sqos.EffectiveOnly = TRUE;
|
|
|
|
|
|
|
|
status = pNtConnectPort(&PortHandle, &port, &sqos, 0, 0, &len, NULL, NULL);
|
2009-05-17 07:05:22 +00:00
|
|
|
todo_wine ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
|
2008-05-12 08:33:26 +00:00
|
|
|
if (status != STATUS_SUCCESS) return 1;
|
2007-03-06 11:59:18 +00:00
|
|
|
|
|
|
|
status = pNtRegisterThreadTerminatePort(PortHandle);
|
2009-05-17 07:05:22 +00:00
|
|
|
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
|
2007-03-06 11:59:18 +00:00
|
|
|
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
if (is_wow64)
|
|
|
|
{
|
|
|
|
size = FIELD_OFFSET(LPC_MESSAGE64, Data[MAX_MESSAGE_LEN]);
|
|
|
|
LpcMessage = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
|
|
|
out = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
|
|
|
|
LpcMessage->msg64.DataSize = lstrlen(REQUEST1) + 1;
|
|
|
|
LpcMessage->msg64.MessageSize = FIELD_OFFSET(LPC_MESSAGE64, Data[LpcMessage->msg64.DataSize]);
|
|
|
|
lstrcpy((LPSTR)LpcMessage->msg64.Data, REQUEST1);
|
|
|
|
|
|
|
|
status = pNtRequestPort(PortHandle, &LpcMessage->msg);
|
|
|
|
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
|
|
|
|
ok(LpcMessage->msg64.MessageType == 0, "Expected 0, got %d\n", LpcMessage->msg64.MessageType);
|
|
|
|
ok(!lstrcmp((LPSTR)LpcMessage->msg64.Data, REQUEST1),
|
|
|
|
"Expected %s, got %s\n", REQUEST1, LpcMessage->msg64.Data);
|
|
|
|
|
|
|
|
/* Fill in the message */
|
|
|
|
memset(LpcMessage, 0, size);
|
|
|
|
LpcMessage->msg64.DataSize = lstrlen(REQUEST2) + 1;
|
|
|
|
LpcMessage->msg64.MessageSize = FIELD_OFFSET(LPC_MESSAGE64, Data[LpcMessage->msg64.DataSize]);
|
|
|
|
lstrcpy((LPSTR)LpcMessage->msg64.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->msg64.Data, REPLY), "Expected %s, got %s\n", REPLY, out->msg64.Data);
|
|
|
|
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);
|
|
|
|
}
|
2007-03-06 11:59:18 +00:00
|
|
|
|
2008-12-12 23:42:40 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, out);
|
|
|
|
HeapFree(GetProcessHeap(), 0, LpcMessage);
|
|
|
|
|
2007-03-06 11:59:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-17 07:05:22 +00:00
|
|
|
static void test_ports_server( HANDLE PortHandle )
|
2007-03-06 11:59:18 +00:00
|
|
|
{
|
|
|
|
HANDLE AcceptPortHandle;
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
union lpc_message *LpcMessage;
|
2007-03-06 11:59:18 +00:00
|
|
|
ULONG size;
|
|
|
|
NTSTATUS status;
|
|
|
|
BOOL done = FALSE;
|
|
|
|
|
|
|
|
size = FIELD_OFFSET(LPC_MESSAGE, Data) + MAX_MESSAGE_LEN;
|
2008-05-12 08:33:26 +00:00
|
|
|
LpcMessage = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
2007-03-06 11:59:18 +00:00
|
|
|
|
|
|
|
while (TRUE)
|
|
|
|
{
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
status = pNtReplyWaitReceivePort(PortHandle, NULL, NULL, &LpcMessage->msg);
|
2007-03-06 11:59:18 +00:00
|
|
|
todo_wine
|
|
|
|
{
|
2008-05-12 08:33:26 +00:00
|
|
|
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d(%x)\n", status, status);
|
2007-03-06 11:59:18 +00:00
|
|
|
}
|
|
|
|
/* STATUS_INVALID_HANDLE: win2k without admin rights will perform an
|
|
|
|
* endless loop here
|
|
|
|
*/
|
|
|
|
if ((status == STATUS_NOT_IMPLEMENTED) ||
|
|
|
|
(status == STATUS_INVALID_HANDLE)) return;
|
|
|
|
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
switch (is_wow64 ? LpcMessage->msg64.MessageType : LpcMessage->msg.MessageType)
|
2007-03-06 11:59:18 +00:00
|
|
|
{
|
|
|
|
case LPC_CONNECTION_REQUEST:
|
|
|
|
ProcessConnectionRequest(LpcMessage, &AcceptPortHandle);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LPC_REQUEST:
|
|
|
|
ProcessLpcRequest(PortHandle, LpcMessage);
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LPC_DATAGRAM:
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
if (is_wow64)
|
|
|
|
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);
|
2007-03-06 11:59:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LPC_CLIENT_DIED:
|
|
|
|
ok(done, "Expected LPC request to be completed!\n");
|
2008-12-12 23:42:40 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, LpcMessage);
|
2007-03-06 11:59:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
Sync advapi32, comctl32, crypt32, cryptui, cryptnet, fusion, gdi32, gdiplus, hlink, imm32, jscript, kernel32, localspl, msacm32, mscms, msi, mstask, msvcrtd, msxml3, ntdll, ole32, pdh, psapi, quartz, rasapi32, riched20 AND rsaenh Winetests.
TBD mshtml, shell32, oleaut32 which still fail to build here
svn path=/trunk/; revision=47931
2010-07-03 12:45:23 +00:00
|
|
|
ok(FALSE, "Unexpected message: %d\n",
|
|
|
|
is_wow64 ? LpcMessage->msg64.MessageType : LpcMessage->msg.MessageType);
|
2007-03-06 11:59:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-12-12 23:42:40 +00:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, LpcMessage);
|
2007-03-06 11:59:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(port)
|
|
|
|
{
|
2009-05-17 07:05:22 +00:00
|
|
|
OBJECT_ATTRIBUTES obj;
|
|
|
|
HANDLE port_handle;
|
|
|
|
NTSTATUS status;
|
2007-03-06 11:59:18 +00:00
|
|
|
|
|
|
|
if (!init_function_ptrs())
|
|
|
|
return;
|
|
|
|
|
2009-05-17 07:05:22 +00:00
|
|
|
pRtlInitUnicodeString(&port, PORTNAME);
|
2007-03-06 11:59:18 +00:00
|
|
|
|
2009-05-17 07:05:22 +00:00
|
|
|
memset(&obj, 0, sizeof(OBJECT_ATTRIBUTES));
|
|
|
|
obj.Length = sizeof(OBJECT_ATTRIBUTES);
|
|
|
|
obj.ObjectName = &port;
|
2007-03-06 11:59:18 +00:00
|
|
|
|
2009-05-17 07:05:22 +00:00
|
|
|
status = pNtCreatePort(&port_handle, &obj, 100, 100, 0);
|
|
|
|
if (status == STATUS_ACCESS_DENIED) skip("Not enough rights\n");
|
|
|
|
else todo_wine ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d\n", status);
|
2008-12-12 23:42:40 +00:00
|
|
|
|
2009-05-17 07:05:22 +00:00
|
|
|
if (status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
DWORD id;
|
|
|
|
HANDLE thread = CreateThread(NULL, 0, test_ports_client, NULL, 0, &id);
|
|
|
|
ok(thread != NULL, "Expected non-NULL thread handle!\n");
|
|
|
|
|
|
|
|
test_ports_server( port_handle );
|
|
|
|
ok( WaitForSingleObject( thread, 10000 ) == 0, "thread didn't exit\n" );
|
|
|
|
CloseHandle(thread);
|
|
|
|
}
|
2008-12-12 23:42:40 +00:00
|
|
|
FreeLibrary(hntdll);
|
2007-03-06 11:59:18 +00:00
|
|
|
}
|