ReactOS  0.4.15-dev-3173-g40ee59d
NtUnloadDriver.c File Reference
#include "precomp.h"
Include dependency graph for NtUnloadDriver.c:

Go to the source code of this file.

Functions

 START_TEST (NtUnloadDriver)
 

Function Documentation

◆ START_TEST()

START_TEST ( NtUnloadDriver  )

Definition at line 10 of file NtUnloadDriver.c.

11 {
13  BOOLEAN OldPrivilege, OldPrivilege2;
15  PWCHAR Buffer = NULL;
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 
100 Exit:
101  if (Buffer != NULL)
102  {
104  }
105 
106  Status = RtlAdjustPrivilege(SE_LOAD_DRIVER_PRIVILEGE, OldPrivilege, FALSE, &OldPrivilege2);
108 }
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#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)
static VOID FreeGuarded(_In_ PVOID Pointer)
Definition: apitest_guard.h:45
uint16_t * PWCHAR
Definition: typedefs.h:56
#define ok_hex(expression, result)
Definition: atltest.h:94
static PVOID AllocateGuarded(_In_ SIZE_T SizeRequested)
Definition: apitest_guard.h:10
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
Definition: bufpool.h:45
#define RtlFillMemoryUlong(dst, len, val)
Definition: mkhive.h:55
Status
Definition: gdiplustypes.h:24
LPTSTR ServiceName
Definition: ServiceMain.c:15
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static void Exit(void)
Definition: sock.c:1331
static const WCHAR L[]
Definition: oid.c:1250
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
NTSTATUS NtUnloadDriver(IN PUNICODE_STRING DriverServiceName)
Definition: driver.c:2181
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
#define NULL
Definition: types.h:112
#define MAXUSHORT
Definition: typedefs.h:83
#define skip(...)
Definition: atltest.h:64
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_OBJECT_PATH_SYNTAX_BAD
Definition: ntstatus.h:295