ReactOS  0.4.14-dev-315-gbb6fece
Example_user.c
Go to the documentation of this file.
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 
19  trace("Message from user-mode\n");
20 
21  GetSystemInfo(&SystemInfo);
22  ok(SystemInfo.dwActiveProcessorMask != 0, "No active processors?!\n");
23 
24  /* now run the kernel-mode part (see Example.c).
25  * If no user-mode part exists, this is what's done automatically */
26  KmtRunKernelTest("Example");
27 
28  /* now start the special-purpose driver */
29  KmtLoadDriver(L"Example", FALSE);
30  trace("After Entry\n");
31  KmtOpenDriver();
32  trace("After Create\n");
33 
36  ok(KmtSendBufferToDriver(IOCTL_SEND_MYSTRUCT, MyStruct, sizeof MyStruct[0], &Length) == ERROR_SUCCESS, "\n");
37  ok_eq_int(MyStruct[1].a, 456);
38  ok_eq_str(MyStruct[1].b, "!!!");
39 
41  trace("After Close\n");
43  trace("After Unload\n");
44 }
#define IOCTL_SEND_STRING
Definition: Example.h:18
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ok_eq_int(value, expected)
Definition: kmt_test.h:238
START_TEST(Example)
Definition: Example_user.c:12
#define IOCTL_SEND_MYSTRUCT
Definition: Example.h:19
#define IOCTL_NOTIFY
Definition: Example.h:17
DWORD KmtSendStringToDriver(IN DWORD ControlCode, IN PCSTR String)
Definition: support.c:248
DWORD_PTR dwActiveProcessorMask
Definition: winbase.h:1136
DWORD KmtSendBufferToDriver(IN DWORD ControlCode, IN OUT PVOID Buffer OPTIONAL, IN DWORD InLength, IN OUT PDWORD OutLength)
Definition: support.c:325
VOID KmtCloseDriver(VOID)
Definition: support.c:200
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
DWORD KmtRunKernelTest(IN PCSTR TestName)
Definition: support.c:94
#define trace
Definition: atltest.h:70
#define ok_eq_str(value, expected)
Definition: kmt_test.h:261
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static const WCHAR L[]
Definition: oid.c:1250
DWORD KmtSendToDriver(IN DWORD ControlCode)
Definition: support.c:224
VOID KmtUnloadDriver(VOID)
Definition: support.c:155
#define ok(value,...)
Definition: atltest.h:57
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:142
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
VOID KmtLoadDriver(IN PCWSTR ServiceName, IN BOOLEAN RestartIfRunning)
Definition: support.c:127
VOID KmtOpenDriver(VOID)
Definition: support.c:174