82e4b1af225fe9fbfdfb43fe35c2c2278875cc0a
[reactos.git] / rostests / kmtests / ntos_ob / ObWait.c
1 /*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite *WaitForMultipleObjects
5 * PROGRAMMER: Pierre Schweitzer <thomas.faber@reactos.org>
6 */
7
8 #include <kmt_test.h>
9
10 #define NDEBUG
11 #include <debug.h>
12
13 static
14 VOID
15 NTAPI
16 KernelModeTest(IN PVOID Context)
17 {
18 NTSTATUS Status;
19
20 Status = ZwWaitForMultipleObjects(2, (void **)0x42424242, WaitAll, FALSE, NULL);
21 ok_eq_hex(Status, STATUS_ACCESS_VIOLATION);
22 }
23
24 START_TEST(ZwWaitForMultipleObjects)
25 {
26 NTSTATUS Status;
27 OBJECT_ATTRIBUTES ObjectAttributes;
28 HANDLE ThreadHandle;
29 PVOID ThreadObject = NULL;
30
31 /* We've to be in kernel mode, so spawn a thread */
32 InitializeObjectAttributes(&ObjectAttributes,
33 NULL,
34 OBJ_KERNEL_HANDLE,
35 NULL,
36 NULL);
37 Status = PsCreateSystemThread(&ThreadHandle,
38 SYNCHRONIZE,
39 &ObjectAttributes,
40 NULL,
41 NULL,
42 KernelModeTest,
43 NULL);
44 ok_eq_hex(Status, STATUS_SUCCESS);
45 if (Status == STATUS_SUCCESS)
46 {
47 /* Then, just wait on our thread to finish */
48 Status = ObReferenceObjectByHandle(ThreadHandle,
49 SYNCHRONIZE,
50 *PsThreadType,
51 KernelMode,
52 &ThreadObject,
53 NULL);
54 ObCloseHandle(ThreadHandle, KernelMode);
55
56 Status = KeWaitForSingleObject(ThreadObject,
57 Executive,
58 KernelMode,
59 FALSE,
60 NULL);
61 ok_eq_hex(Status, STATUS_SUCCESS);
62 ObDereferenceObject(ThreadObject);
63 }
64 }