ReactOS 0.4.16-dev-91-g764881a
NtUnloadDriver.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API Tests
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Test for NtUnloadDriver
5 * COPYRIGHT: Copyright 2019 Thomas Faber (thomas.faber@reactos.org)
6 */
7
8#include "precomp.h"
9
11{
13 BOOLEAN OldPrivilege, OldPrivilege2;
16
18 if (!NT_SUCCESS(Status))
19 {
20 skip("Failed to drop driver load privilege\n");
21 return;
22 }
23
26
28 if (!NT_SUCCESS(Status))
29 {
30 skip("Failed to acquire driver load privilege\n");
31 goto Exit;
32 }
33
36
37 RtlInitEmptyUnicodeString(&ServiceName, NULL, 0);
40
41 Buffer = AllocateGuarded(0x10000);
42 if (!Buffer)
43 {
44 skip("Failed to allocate memory\n");
45 goto Exit;
46 }
47
48 RtlFillMemoryUlong(Buffer, 0x10000, 'A' << 16 | 'A');
49
50 ServiceName.Buffer = Buffer;
51 ServiceName.Length = 0xFFFF;
52 ServiceName.MaximumLength = MAXUSHORT;
55
56 ServiceName.Buffer = Buffer;
57 ServiceName.Length = 0xFFFE;
58 ServiceName.MaximumLength = MAXUSHORT;
61
62 ServiceName.Buffer = Buffer;
63 ServiceName.Length = 0xFFFD;
64 ServiceName.MaximumLength = MAXUSHORT;
67
68 ServiceName.Buffer = Buffer;
69 ServiceName.Length = 0xFFFC;
70 ServiceName.MaximumLength = MAXUSHORT;
73
74 ServiceName.Buffer = Buffer;
75 ServiceName.Length = 0x1000;
76 ServiceName.MaximumLength = MAXUSHORT;
79
80 ServiceName.Buffer = Buffer;
81 ServiceName.Length = 1;
82 ServiceName.MaximumLength = MAXUSHORT;
85
86 Buffer[0xFFFC / sizeof(WCHAR)] = L'\\';
87 ServiceName.Buffer = Buffer;
88 ServiceName.Length = 0xFFFC;
89 ServiceName.MaximumLength = MAXUSHORT;
92
93 Buffer[0xFFFC / sizeof(WCHAR) - 1] = L'\\';
94 ServiceName.Buffer = Buffer;
95 ServiceName.Length = 0xFFFC;
96 ServiceName.MaximumLength = MAXUSHORT;
99
100Exit:
101 if (Buffer != NULL)
102 {
104 }
105
106 Status = RtlAdjustPrivilege(SE_LOAD_DRIVER_PRIVILEGE, OldPrivilege, FALSE, &OldPrivilege2);
108}
NTSTATUS NtUnloadDriver(IN PUNICODE_STRING DriverServiceName)
Definition: driver.c:2208
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
unsigned char BOOLEAN
static VOID FreeGuarded(_In_ PVOID Pointer)
Definition: apitest_guard.h:45
static PVOID AllocateGuarded(_In_ SIZE_T SizeRequested)
Definition: apitest_guard.h:10
#define ok_hex(expression, result)
Definition: atltest.h:94
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
static WCHAR ServiceName[]
Definition: browser.c:19
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
#define RtlFillMemoryUlong(dst, len, val)
Definition: mkhive.h:55
#define SE_LOAD_DRIVER_PRIVILEGE
Definition: security.c:664
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
#define STATUS_OBJECT_PATH_SYNTAX_BAD
Definition: ntstatus.h:295
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
static void Exit(void)
Definition: sock.c:1330
#define MAXUSHORT
Definition: typedefs.h:83
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
__wchar_t WCHAR
Definition: xmlstorage.h:180