kernel32: Don't run the CreateRemoteThread tests if the child process isn't mapped at the same address as the parent process.

This commit is contained in:
Rob Shearman 2007-02-19 15:45:54 +00:00 committed by Alexandre Julliard
parent 3047ea9e78
commit ea8ccb2590
1 changed files with 26 additions and 0 deletions

View File

@ -203,15 +203,37 @@ static DWORD WINAPI threadFunc_CloseHandle(LPVOID p)
return 0;
}
static void create_function_addr_events(HANDLE events[2])
{
char buffer[256];
sprintf(buffer, "threadFunc_SetEvent %p", threadFunc_SetEvent);
events[0] = CreateEvent(NULL, FALSE, FALSE, buffer);
sprintf(buffer, "threadFunc_CloseHandle %p", threadFunc_CloseHandle);
events[1] = CreateEvent(NULL, FALSE, FALSE, buffer);
}
/* check CreateRemoteThread */
static VOID test_CreateRemoteThread(void)
{
HANDLE hProcess, hThread, hEvent, hRemoteEvent;
DWORD tid, ret, exitcode;
HANDLE hAddrEvents[2];
hProcess = create_target_process("sleep");
ok(hProcess != NULL, "Can't start process\n");
/* ensure threadFunc_SetEvent & threadFunc_CloseHandle are the same
* address as in the child process */
create_function_addr_events(hAddrEvents);
ret = WaitForMultipleObjects(2, hAddrEvents, TRUE, 5000);
if (ret == WAIT_TIMEOUT)
{
skip("child process wasn't mapped at same address, so can't do CreateRemoteThread tests.\n");
return;
}
hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
ok(hEvent != NULL, "Can't create event, err=%u\n", GetLastError());
ret = DuplicateHandle(GetCurrentProcess(), hEvent, hProcess, &hRemoteEvent,
@ -843,6 +865,10 @@ START_TEST(thread)
{
if (!strcmp(argv[2], "sleep"))
{
HANDLE hAddrEvents[2];
create_function_addr_events(hAddrEvents);
SetEvent(hAddrEvents[0]);
SetEvent(hAddrEvents[1]);
Sleep(5000); /* spawned process runs for at most 5 seconds */
return;
}