Skip to content

Commit 2a0acdb

Browse files
authored
[KMTESTS] Kmtest fixes (reactos#8308)
- [KMTEST:IOFILESYSTEM] Add support for NTFS - [KMTEST:IODEVICEOBJECT] Work around a Windows 7 bug, account for struct size changes on x64, accept Vista+ behavior - [KMTEST:EXPOOLS] Accept pool being promoted to NonPaged on Vista+, accept 2GB allocation on x64, guard an undocumented behavior - [KMTEST:CMSECURITY] Add tests for Vista-Win8.1
1 parent b19eba5 commit 2a0acdb

File tree

6 files changed

+506
-117
lines changed

6 files changed

+506
-117
lines changed

modules/rostests/kmtests/ntos_cm/CmSecurity.c

Lines changed: 259 additions & 21 deletions
Large diffs are not rendered by default.

modules/rostests/kmtests/ntos_ex/ExPools.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#define TAG_POOLTEST 'tstP'
1414

15-
#define BASE_POOL_TYPE_MASK 1
15+
#define BASE_POOL_TYPE_MASK 3
1616
#define QUOTA_POOL_MASK 8
1717

1818
static
@@ -141,7 +141,6 @@ VOID
141141
TestPoolQuota(VOID)
142142
{
143143
PEPROCESS Process = PsGetCurrentProcess();
144-
PEPROCESS StoredProcess;
145144
PVOID Memory;
146145
LONG InitialRefCount;
147146
LONG RefCount;
@@ -163,16 +162,23 @@ TestPoolQuota(VOID)
163162
RefCount = GetRefCount(Process);
164163
ok_eq_long(RefCount, InitialRefCount + 1);
165164

166-
/* A pointer to the process is found right before the next pool header */
167-
StoredProcess = ((PVOID *)((ULONG_PTR)Memory + 2 * sizeof(LIST_ENTRY)))[-1];
168-
ok_eq_pointer(StoredProcess, Process);
165+
#ifdef _M_IX86
166+
if (GetNTVersion() <= _WIN32_WINNT_WIN7)
167+
{
168+
/* For x86 NT 6.2 and older: a pointer to the process is found right before the next pool header */
169+
PEPROCESS StoredProcess = ((PVOID *)((ULONG_PTR)Memory + 2 * sizeof(LIST_ENTRY)))[-1];
170+
ok_eq_pointer(StoredProcess, Process);
171+
}
172+
#endif
169173

170174
/* Pool type should have QUOTA_POOL_MASK set */
171175
PoolType = KmtGetPoolType(Memory);
172176
ok(PoolType != 0, "PoolType is 0\n");
173177
PoolType--;
174178
ok(PoolType & QUOTA_POOL_MASK, "PoolType = %x\n", PoolType);
175-
ok((PoolType & BASE_POOL_TYPE_MASK) == PagedPool, "PoolType = %x\n", PoolType);
179+
ok((PoolType & BASE_POOL_TYPE_MASK) == PagedPool || // Win2k3
180+
(PoolType & BASE_POOL_TYPE_MASK) == NonPagedPoolMustSucceed, // Vista+ promotes the memory allocation
181+
"PoolType = %x\n", PoolType);
176182

177183
ExFreePoolWithTag(Memory, 'tQmK');
178184
RefCount = GetRefCount(Process);
@@ -196,6 +202,16 @@ TestPoolQuota(VOID)
196202
ok_eq_long(RefCount, InitialRefCount);
197203
}
198204

205+
#ifdef _WIN64
206+
KmtStartSeh()
207+
Memory = ExAllocatePoolWithQuotaTag(PagedPool,
208+
0x7FFFFFFF,
209+
'tQmK');
210+
ok(Memory != NULL, "Failed to get 2GB block: %p\n", Memory);
211+
if (Memory)
212+
ExFreePoolWithTag(Memory, 'tQmK');
213+
KmtEndSeh(STATUS_SUCCESS);
214+
#else
199215
/* Function raises by default */
200216
KmtStartSeh()
201217
Memory = ExAllocatePoolWithQuotaTag(PagedPool,
@@ -214,6 +230,7 @@ TestPoolQuota(VOID)
214230
if (Memory)
215231
ExFreePoolWithTag(Memory, 'tQmK');
216232
KmtEndSeh(STATUS_SUCCESS);
233+
#endif // _WIN64
217234
}
218235

219236
static

modules/rostests/kmtests/ntos_io/IoDeviceObject_drv.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,10 @@ TestDriverObject(
181181
ok_eq_pointer(DriverObject->DriverExtension->DriverObject, DriverObject);
182182
ok_eq_pointer(DriverObject->DriverExtension->AddDevice, NULL);
183183
ok_eq_ulong(DriverObject->DriverExtension->Count, 0UL);
184+
/* Windows 7 doesn't capitalize "Services" like all other versions before and after it. */
184185
Equal = RtlEqualUnicodeString(RegistryPath,
185186
&RegPath,
186-
FALSE);
187+
(GetNTVersion() == _WIN32_WINNT_WIN7) ? TRUE : FALSE);
187188
ok(Equal, "RegistryPath is '%wZ'\n", RegistryPath);
188189
ok((ULONG_PTR)RegistryPath % PAGE_SIZE == 0, "RegistryPath %p not page-aligned\n", RegistryPath);
189190
ok_eq_pointer(RegistryPath->Buffer, (PWCHAR)(RegistryPath + 1));
@@ -193,7 +194,8 @@ TestDriverObject(
193194
FALSE);
194195
ok(Equal, "ServiceKeyName is '%wZ'\n", &DriverObject->DriverExtension->ServiceKeyName);
195196
ok_eq_tag(KmtGetPoolTag(DriverObject->DriverExtension->ServiceKeyName.Buffer), ' oI');
196-
ok_eq_uint((KmtGetPoolType(DriverObject->DriverExtension->ServiceKeyName.Buffer) - 1) & BASE_POOL_TYPE_MASK, NonPagedPool);
197+
if (GetNTVersion() <= _WIN32_WINNT_WS03) // Not guaranteed on Vista+
198+
ok_eq_uint((KmtGetPoolType(DriverObject->DriverExtension->ServiceKeyName.Buffer) - 1) & BASE_POOL_TYPE_MASK, NonPagedPool);
197199
ok_eq_uint(DriverObject->DriverExtension->ServiceKeyName.MaximumLength, DriverObject->DriverExtension->ServiceKeyName.Length + sizeof(UNICODE_NULL));
198200
ok_eq_uint(DriverObject->DriverExtension->ServiceKeyName.Buffer[DriverObject->DriverExtension->ServiceKeyName.Length / sizeof(WCHAR)], UNICODE_NULL);
199201
Equal = RtlEqualUnicodeString(&DriverObject->DriverName,
@@ -348,7 +350,11 @@ TestDeviceCreated(
348350

349351
/* Check the device object members */
350352
ok(DeviceObject->Type == 3, "Expected Type = 3, got %x\n", DeviceObject->Type);
351-
ok(DeviceObject->Size == 0xb8, "Expected Size = 0xb8, got %x\n", DeviceObject->Size);
353+
#ifdef _M_IX86
354+
ok(DeviceObject->Size == 0xb8, "Expected Size = 0xb8, got 0x%x\n", DeviceObject->Size);
355+
#else
356+
ok(DeviceObject->Size == 0x150, "Expected Size = 0x150, got 0x%x\n", DeviceObject->Size);
357+
#endif
352358
ok(DeviceObject->ReferenceCount == 0, "Expected ReferenceCount = 0, got %lu\n",
353359
DeviceObject->ReferenceCount);
354360
ok(DeviceObject->DriverObject == ThisDriverObject,
@@ -368,17 +374,19 @@ TestDeviceCreated(
368374
"Expected Flags DO_DEVICE_HAS_NAME | DO_DEVICE_INITIALIZING, got %lu\n", DeviceObject->Flags);
369375
}
370376
ok(DeviceObject->DeviceType == FILE_DEVICE_UNKNOWN,
371-
"Expected DeviceType to match creation parameter FILE_DEVICE_UNKNWOWN, got %lu\n",
377+
"Expected DeviceType to match creation parameter FILE_DEVICE_UNKNWOWN, got %lu\n",
372378
DeviceObject->DeviceType);
373379
ok(DeviceObject->ActiveThreadCount == 0, "Expected ActiveThreadCount = 0, got %lu\n", DeviceObject->ActiveThreadCount);
374380

375381
/* Check the extended extension */
376382
extdev = (PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension;
377-
ok(extdev->ExtensionFlags == 0, "Expected Extended ExtensionFlags to be 0, got %lu\n", extdev->ExtensionFlags);
378-
ok (extdev->Type == 13, "Expected Type of 13, got %d\n", extdev->Type);
379-
ok (extdev->Size == 0, "Expected Size of 0, got %d\n", extdev->Size);
380-
ok (extdev->DeviceObject == DeviceObject, "Expected DeviceOject to match newly created device %p, got %p\n",
381-
DeviceObject, extdev->DeviceObject);
383+
ok(extdev->ExtensionFlags == DOE_DEFAULT_SD_PRESENT || // Vista+
384+
extdev->ExtensionFlags == 0, // WS03
385+
"Expected Extended ExtensionFlags to be DOE_DEFAULT_SD_PRESENT or 0, got %lu\n", extdev->ExtensionFlags);
386+
ok(extdev->Type == 13, "Expected Type of 13, got %d\n", extdev->Type);
387+
ok(extdev->Size == 0, "Expected Size of 0, got %d\n", extdev->Size);
388+
ok(extdev->DeviceObject == DeviceObject, "Expected DeviceOject to match newly created device %p, got %p\n",
389+
DeviceObject, extdev->DeviceObject);
382390
ok(extdev->AttachedTo == NULL, "Expected AttachTo to be NULL, got %p\n", extdev->AttachedTo);
383391
ok(extdev->StartIoCount == 0, "Expected StartIoCount = 0, got %lu\n", extdev->StartIoCount);
384392
ok(extdev->StartIoKey == 0, "Expected StartIoKey = 0, got %lu\n", extdev->StartIoKey);
@@ -396,7 +404,11 @@ TestDeviceDeletion(
396404

397405
/* Check the device object members */
398406
ok(DeviceObject->Type == 3, "Expected Type = 3, got %d\n", DeviceObject->Type);
399-
ok(DeviceObject->Size == 0xb8, "Expected Size = 0xb8, got %d\n", DeviceObject->Size);
407+
#ifdef _M_IX86
408+
ok(DeviceObject->Size == 0xb8, "Expected Size = 0xb8, got 0x%x\n", DeviceObject->Size);
409+
#else
410+
ok(DeviceObject->Size == 0x150, "Expected Size = 0x150, got 0x%x\n", DeviceObject->Size);
411+
#endif
400412
ok(DeviceObject->ReferenceCount == 0, "Expected ReferenceCount = 0, got %lu\n",
401413
DeviceObject->ReferenceCount);
402414
if (!Lower)
@@ -426,9 +438,9 @@ TestDeviceDeletion(
426438

427439
/* Check the extended extension */
428440
extdev = (PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension;
429-
/* FIXME: Windows has the MSB set under some conditions, need to find out what this means */
430-
ok((extdev->ExtensionFlags & 0x7fffffff) == DOE_UNLOAD_PENDING,
431-
"Expected Extended ExtensionFlags to be DOE_UNLOAD_PENDING, got 0x%lx\n", extdev->ExtensionFlags);
441+
ok((extdev->ExtensionFlags == (DOE_DEFAULT_SD_PRESENT | DOE_UNLOAD_PENDING) || // Vista+
442+
extdev->ExtensionFlags & 0x7fffffff) == DOE_UNLOAD_PENDING, // WS03 FIXME: Windows has the MSB set under some conditions, need to find out what this means
443+
"Unexpected Extended ExtensionFlags (0x%lx)\n", extdev->ExtensionFlags);
432444
ok (extdev->Type == 13, "Expected Type of 13, got %d\n", extdev->Type);
433445
ok (extdev->Size == 0, "Expected Size of 0, got %d\n", extdev->Size);
434446
ok (extdev->DeviceObject == DeviceObject, "Expected DeviceOject to match newly created device %p, got %p\n",

0 commit comments

Comments
 (0)