2 * Author: Skywing (skywing@valhallalegends.com)
4 * Purpose: Test Thread-EventPair functionality.
15 HANDLE MakeEventPair()
19 OBJECT_ATTRIBUTES Attributes;
21 InitializeObjectAttributes(&Attributes, NULL, 0, NULL, NULL);
22 Status = NtCreateEventPair(&EventPair, STANDARD_RIGHTS_ALL, &Attributes);
23 printf("Status %08x creating eventpair\n", Status);
27 DWORD __stdcall threadfunc(void* eventpair)
29 printf("Thread: Set eventpair status %08x\n", NtSetInformationThread(NtCurrentThread(), ThreadEventPair, &eventpair, sizeof(HANDLE)));
32 printf("Thread: Setting low and waiting high...\n");
33 printf("Thread: status = %08x\n", NtSetLowWaitHighThread());
34 printf("Thread: status = %08x\n", NtSetHighWaitLowThread());
35 printf("Thread: Terminating...\n");
39 int main(int ac, char **av)
42 HANDLE EventPair, Thread;
44 printf("Main: NtSetLowWaitHighThread is at %08x\n", NtSetLowWaitHighThread);
46 EventPair = MakeEventPair();
49 printf("Main: Could not create event pair.\n");
53 printf("Main: EventPair = %08x\n", EventPair);
54 Thread = CreateThread(0, 0, threadfunc, EventPair, 0, &id);
55 printf("Main: ThreadId for new thread is %08x\n", id);
56 printf("Main: Setting high and waiting low\n");
57 printf("Main: status = %08x\n", NtSetHighWaitLowEventPair(EventPair));
59 printf("Main: status = %08x\n", NtSetLowWaitHighEventPair(EventPair));
61 /* WaitForSingleObject(Thread, INFINITE); FIXME: Waiting on thread handle causes double spinlock acquisition (and subsequent crash) in PsUnblockThread - ntoskrnl/ps/thread.c */
63 printf("Main: Terminating...\n");