1 /* 2 * PROJECT: ReactOS kernel-mode tests 3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+) 4 * PURPOSE: Kernel-Mode Test Suite Example user-mode test part 5 * COPYRIGHT: Copyright 2011-2018 Thomas Faber <thomas.faber@reactos.org> 6 */ 7 8 #include <kmt_test.h> 9 10 #include "Example.h" 11 12 START_TEST(Example) 13 { 14 /* do some user-mode stuff */ 15 SYSTEM_INFO SystemInfo; 16 MY_STRUCT MyStruct[2] = { { 123, ":D" }, { 0 } }; 17 DWORD Length = sizeof MyStruct; 18 DWORD Error; 19 20 trace("Message from user-mode\n"); 21 22 GetSystemInfo(&SystemInfo); 23 ok(SystemInfo.dwActiveProcessorMask != 0, "No active processors?!\n"); 24 25 /* now run the kernel-mode part (see Example.c). 26 * If no user-mode part exists, this is what's done automatically */ 27 KmtRunKernelTest("Example"); 28 29 /* now start the special-purpose driver */ 30 Error = KmtLoadAndOpenDriver(L"Example", FALSE); 31 ok_eq_int(Error, ERROR_SUCCESS); 32 if (Error) 33 return; 34 trace("After Create\n"); 35 36 ok(KmtSendToDriver(IOCTL_NOTIFY) == ERROR_SUCCESS, "\n"); 37 ok(KmtSendStringToDriver(IOCTL_SEND_STRING, "yay") == ERROR_SUCCESS, "\n"); 38 ok(KmtSendBufferToDriver(IOCTL_SEND_MYSTRUCT, MyStruct, sizeof MyStruct[0], &Length) == ERROR_SUCCESS, "\n"); 39 ok_eq_int(MyStruct[1].a, 456); 40 ok_eq_str(MyStruct[1].b, "!!!"); 41 42 KmtCloseDriver(); 43 trace("After Close\n"); 44 KmtUnloadDriver(); 45 trace("After Unload\n"); 46 } 47