Reactos

[KMTESTS] Fixes for 2003, Vista, 7, 8, 10 x86 and x64 (#8175)

Fix several kmtests in preparation for testbots with newer versions of Windows. There's still more kmtests to fix, but this fixes all the kmtests that bugchecked during my testing.

authored by

Carl J. Bialorucki and committed by
GitHub
19e8fbb2 83faff87

+614 -178
+2
modules/rostests/kmtests/include/kmt_test.h
··· 18 18 19 19 #include <kmt_platform.h> 20 20 21 + #define GetNTVersion() ((SharedUserData->NtMajorVersion << 8) | SharedUserData->NtMinorVersion) 22 + 21 23 typedef VOID KMT_TESTFUNC(VOID); 22 24 typedef KMT_TESTFUNC *PKMT_TESTFUNC; 23 25
+10 -3
modules/rostests/kmtests/kmtest_drv/kmtest_drv.c
··· 58 58 PDRIVER_OBJECT KmtDriverObject = NULL; 59 59 static KMT_USER_WORK_LIST WorkList; 60 60 static ULONG RequestId = 0; 61 + static const LONGLONG TimeoutDuration = -10LL * (1000 * 1000 * 10); // 10 seconds 61 62 62 63 /* Entry */ 63 64 /** ··· 440 441 { 441 442 PLIST_ENTRY Entry; 442 443 PKMT_USER_WORK_ENTRY WorkItem; 444 + LARGE_INTEGER Timeout; 443 445 444 446 DPRINT("DriverIoControl. IOCTL_KMTEST_USERMODE_AWAIT_REQ, len=%lu\n", 445 447 IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength); 446 448 447 449 /* TODO: prevent multiple concurrent invocations */ 448 - Status = KeWaitForSingleObject(&WorkList.NewWorkEvent, UserRequest, UserMode, FALSE, NULL); 449 - if (Status == STATUS_USER_APC || Status == STATUS_KERNEL_APC) 450 + Timeout.QuadPart = TimeoutDuration; 451 + Status = KeWaitForSingleObject(&WorkList.NewWorkEvent, UserRequest, UserMode, FALSE, &Timeout); 452 + 453 + if (Status == STATUS_TIMEOUT) 454 + DPRINT1("KeWaitForSingleObject timed out!\n"); 455 + 456 + if (Status == STATUS_USER_APC || Status == STATUS_KERNEL_APC || Status == STATUS_TIMEOUT) 450 457 break; 451 458 452 459 if (IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KMT_CALLBACK_REQUEST_PACKET)) ··· 580 587 581 588 KeSetEvent(&WorkList.NewWorkEvent, IO_NO_INCREMENT, FALSE); 582 589 583 - Timeout.QuadPart = -10 * 1000 * 1000 * 10; //wait for 10 seconds 590 + Timeout.QuadPart = TimeoutDuration; 584 591 Status = KeWaitForSingleObject(&WorkEntry->WorkDoneEvent, Executive, UserMode, FALSE, &Timeout); 585 592 586 593 if (Status == STATUS_USER_APC || Status == STATUS_KERNEL_APC || Status == STATUS_TIMEOUT)
+66 -55
modules/rostests/kmtests/ntos_ke/KeDpc.c
··· 54 54 ok_eq_pointer(Dpc->SystemArgument2, SystemArgument2); 55 55 ok_eq_pointer(Dpc->DpcData, NULL); 56 56 57 - ok_eq_uint(Prcb->DpcRoutineActive, 1); 58 - /* this DPC is not in the list anymore, but it was at the head! */ 59 - ok_eq_pointer(Prcb->DpcData[DPC_NORMAL].DpcListHead.Flink, Dpc->DpcListEntry.Flink); 60 - ok_eq_pointer(Prcb->DpcData[DPC_NORMAL].DpcListHead.Blink, Dpc->DpcListEntry.Blink); 57 + if (GetNTVersion() == _WIN32_WINNT_WS03) 58 + { 59 + ok_eq_uint(Prcb->DpcRoutineActive, 1); 60 + /* this DPC is not in the list anymore, but it was at the head! */ 61 + ok_eq_pointer(Prcb->DpcData[DPC_NORMAL].DpcListHead.Flink, Dpc->DpcListEntry.Flink); 62 + ok_eq_pointer(Prcb->DpcData[DPC_NORMAL].DpcListHead.Blink, Dpc->DpcListEntry.Blink); 63 + } 61 64 } 62 65 63 66 START_TEST(KeDpc) ··· 81 84 ok_eq_uint(Dpc.Importance, DpcImportance); 82 85 ok_eq_uint(Dpc.Number, 0); 83 86 ok_eq_pointer(Dpc.DpcListEntry.Flink, (LIST_ENTRY *)0x5555555555555555LL); 84 - ok_eq_pointer(Dpc.DpcListEntry.Blink, (LIST_ENTRY *)0x5555555555555555LL); 87 + if (Dpc.DpcListEntry.Blink) 88 + ok_eq_pointer(Dpc.DpcListEntry.Blink, (LIST_ENTRY *)0x5555555555555555LL); 85 89 ok_eq_pointer(Dpc.DeferredRoutine, DpcHandler); 86 90 ok_eq_pointer(Dpc.DeferredContext, &Dpc); 87 91 ok_eq_pointer(Dpc.SystemArgument1, (PVOID)0x5555555555555555LL); 88 92 ok_eq_pointer(Dpc.SystemArgument2, (PVOID)0x5555555555555555LL); 89 93 ok_eq_pointer(Dpc.DpcData, NULL); 90 94 91 - /* simply run the Dpc a few times */ 92 - for (i = 0; i < 5; ++i) 95 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 93 96 { 94 - ok_dpccount(); 95 - Ret = KeInsertQueueDpc(&Dpc, (PVOID)0xabc123, (PVOID)0x5678); 96 - ok_bool_true(Ret, "KeInsertQueueDpc returned"); 97 - ++ExpectedDpcCount; 98 - ok_dpccount(); 99 - } 97 + // Windows 8+ is stricter about misusing DPC, these tests bugcheck there. 98 + 99 + /* simply run the Dpc a few times */ 100 + for (i = 0; i < 5; ++i) 101 + { 102 + ok_dpccount(); 103 + Ret = KeInsertQueueDpc(&Dpc, (PVOID)0xabc123, (PVOID)0x5678); 104 + ok_bool_true(Ret, "KeInsertQueueDpc returned"); 105 + ++ExpectedDpcCount; 106 + ok_dpccount(); 107 + } 100 108 101 - /* insert into queue at high irql 102 - * -> should only run when lowered to APC_LEVEL, 103 - * inserting a second time should fail 104 - */ 105 - KeRaiseIrql(APC_LEVEL, &Irql); 106 - for (i = 0; i < 5; ++i) 107 - { 108 - KeRaiseIrql(DISPATCH_LEVEL, &Irql2); 109 - ok_dpccount(); 110 - Ret = KeInsertQueueDpc(&Dpc, (PVOID)0xabc123, (PVOID)0x5678); 111 - ok_bool_true(Ret, "KeInsertQueueDpc returned"); 112 - Ret = KeInsertQueueDpc(&Dpc, (PVOID)0xdef, (PVOID)0x123); 113 - ok_bool_false(Ret, "KeInsertQueueDpc returned"); 114 - ok_dpccount(); 115 - KeRaiseIrql(HIGH_LEVEL, &Irql3); 109 + /* insert into queue at high irql 110 + * -> should only run when lowered to APC_LEVEL, 111 + * inserting a second time should fail 112 + */ 113 + KeRaiseIrql(APC_LEVEL, &Irql); 114 + for (i = 0; i < 5; ++i) 115 + { 116 + KeRaiseIrql(DISPATCH_LEVEL, &Irql2); 117 + ok_dpccount(); 118 + Ret = KeInsertQueueDpc(&Dpc, (PVOID)0xabc123, (PVOID)0x5678); 119 + ok_bool_true(Ret, "KeInsertQueueDpc returned"); 120 + Ret = KeInsertQueueDpc(&Dpc, (PVOID)0xdef, (PVOID)0x123); 121 + ok_bool_false(Ret, "KeInsertQueueDpc returned"); 122 + ok_dpccount(); 123 + KeRaiseIrql(HIGH_LEVEL, &Irql3); 124 + ok_dpccount(); 125 + KeLowerIrql(Irql3); 126 + ok_dpccount(); 127 + KeLowerIrql(Irql2); 128 + ++ExpectedDpcCount; 116 129 ok_dpccount(); 117 - KeLowerIrql(Irql3); 118 - ok_dpccount(); 119 - KeLowerIrql(Irql2); 120 - ++ExpectedDpcCount; 121 - ok_dpccount(); 122 - } 123 - KeLowerIrql(Irql); 130 + } 131 + KeLowerIrql(Irql); 124 132 125 - /* now test removing from the queue */ 126 - KeRaiseIrql(APC_LEVEL, &Irql); 127 - for (i = 0; i < 5; ++i) 128 - { 129 - KeRaiseIrql(DISPATCH_LEVEL, &Irql2); 130 - ok_dpccount(); 131 - Ret = KeRemoveQueueDpc(&Dpc); 132 - ok_bool_false(Ret, "KeRemoveQueueDpc returned"); 133 - Ret = KeInsertQueueDpc(&Dpc, (PVOID)0xabc123, (PVOID)0x5678); 134 - ok_bool_true(Ret, "KeInsertQueueDpc returned"); 135 - ok_dpccount(); 136 - KeRaiseIrql(HIGH_LEVEL, &Irql3); 133 + /* now test removing from the queue */ 134 + KeRaiseIrql(APC_LEVEL, &Irql); 135 + for (i = 0; i < 5; ++i) 136 + { 137 + KeRaiseIrql(DISPATCH_LEVEL, &Irql2); 137 138 ok_dpccount(); 138 - KeLowerIrql(Irql3); 139 - ok_dpccount(); 140 - Ret = KeRemoveQueueDpc(&Dpc); 141 - ok_bool_true(Ret, "KeRemoveQueueDpc returned"); 142 - KeLowerIrql(Irql2); 143 - ok_dpccount(); 139 + Ret = KeRemoveQueueDpc(&Dpc); 140 + ok_bool_false(Ret, "KeRemoveQueueDpc returned"); 141 + Ret = KeInsertQueueDpc(&Dpc, (PVOID)0xabc123, (PVOID)0x5678); 142 + ok_bool_true(Ret, "KeInsertQueueDpc returned"); 143 + ok_dpccount(); 144 + KeRaiseIrql(HIGH_LEVEL, &Irql3); 145 + ok_dpccount(); 146 + KeLowerIrql(Irql3); 147 + ok_dpccount(); 148 + Ret = KeRemoveQueueDpc(&Dpc); 149 + ok_bool_true(Ret, "KeRemoveQueueDpc returned"); 150 + KeLowerIrql(Irql2); 151 + ok_dpccount(); 152 + } 153 + KeLowerIrql(Irql); 144 154 } 145 - KeLowerIrql(Irql); 146 155 147 156 /* parameter checks */ 148 157 Status = STATUS_SUCCESS; ··· 153 162 } _SEH2_END; 154 163 ok_eq_hex(Status, STATUS_SUCCESS); 155 164 156 - if (!skip(Status == STATUS_SUCCESS, "KeInitializeDpc failed\n")) 165 + if (!skip(Status == STATUS_SUCCESS, "KeInitializeDpc failed\n") && 166 + GetNTVersion() < _WIN32_WINNT_WIN8) 157 167 { 168 + // Inserting NULL in a DPC gives a TIMER_OR_DPC_INVALID bugcheck on Windows 8+. 158 169 KeRaiseIrql(HIGH_LEVEL, &Irql); 159 170 Ret = KeInsertQueueDpc(&Dpc, NULL, NULL); 160 171 ok_bool_true(Ret, "KeInsertQueueDpc returned");
+65 -10
modules/rostests/kmtests/ntos_ke/KeSpinLock.c
··· 238 238 \ 239 239 if ((CheckData)->IsAcquired) \ 240 240 ExpectedIrql = (CheckData)->IrqlWhenAcquired; \ 241 - ok_irql(ExpectedIrql); \ 242 - ok_bool_false(KeAreApcsDisabled(), "KeAreApcsDisabled returned"); \ 241 + if (GetNTVersion() < _WIN32_WINNT_WIN8) \ 242 + ok_irql(ExpectedIrql); \ 243 + if (GetNTVersion() == _WIN32_WINNT_WS03) \ 244 + ok_bool_false(KeAreApcsDisabled(), "KeAreApcsDisabled returned"); \ 243 245 ok_bool_true(KmtAreInterruptsEnabled(), "Interrupts enabled:"); \ 244 246 } while (0) 245 247 ··· 257 259 if (SpinLock) 258 260 ok_eq_ulongptr(*SpinLock, 0); 259 261 CheckData->Acquire(SpinLock, CheckData); 260 - CheckSpinLock(SpinLock, CheckData, 1); 262 + #ifdef _M_IX86 263 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 264 + CheckSpinLock(SpinLock, CheckData, 1); 265 + #endif 261 266 CheckData->Release(SpinLock, CheckData); 262 - CheckSpinLock(SpinLock, CheckData, 0); 267 + #ifdef _M_IX86 268 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 269 + CheckSpinLock(SpinLock, CheckData, 0); 270 + #endif 263 271 264 272 if (CheckData->TryAcquire) 265 273 { ··· 295 303 { 296 304 /* acquire/release without irql change */ 297 305 CheckData->AcquireNoRaise(SpinLock, CheckData); 298 - CheckSpinLock(SpinLock, CheckData, 1); 306 + #ifdef _M_IX86 307 + // Fails on x64 and Windows 8+ 308 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 309 + CheckSpinLock(SpinLock, CheckData, 1); 310 + #endif 299 311 CheckData->ReleaseNoLower(SpinLock, CheckData); 300 312 CheckSpinLock(SpinLock, CheckData, 0); 301 313 302 314 /* acquire without raise, but normal release */ 303 315 CheckData->AcquireNoRaise(SpinLock, CheckData); 304 - CheckSpinLock(SpinLock, CheckData, 1); 316 + #ifdef _M_IX86 317 + // Fails on x64 and Windows 8+ 318 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 319 + CheckSpinLock(SpinLock, CheckData, 1); 320 + #endif 305 321 CheckData->Release(SpinLock, CheckData); 306 322 CheckSpinLock(SpinLock, CheckData, 0); 307 323 308 324 /* acquire normally but release without lower */ 309 325 CheckData->Acquire(SpinLock, CheckData); 310 - CheckSpinLock(SpinLock, CheckData, 1); 326 + #ifdef _M_IX86 327 + // Fails on x64 and Windows 8+ 328 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 329 + CheckSpinLock(SpinLock, CheckData, 1); 330 + #endif 311 331 CheckData->ReleaseNoLower(SpinLock, CheckData); 312 332 CheckSpinLock(SpinLock, CheckData, 0); 313 333 CheckData->IsAcquired = FALSE; ··· 349 369 PKSPIN_LOCK pSpinLock = &SpinLock; 350 370 KIRQL Irql, SynchIrql = KmtIsMultiProcessorBuild ? IPI_LEVEL - 2 : DISPATCH_LEVEL; 351 371 KIRQL OriginalIrqls[] = { PASSIVE_LEVEL, APC_LEVEL, DISPATCH_LEVEL, HIGH_LEVEL }; 352 - CHECK_DATA TestData[] = 372 + CHECK_DATA TestDataWS03[] = 353 373 { 354 374 { CheckLock, DISPATCH_LEVEL, AcquireNormal, ReleaseNormal, NULL, AcquireNoRaise, ReleaseNoLower, TryNoRaise }, 355 375 { CheckLock, DISPATCH_LEVEL, AcquireExp, ReleaseExp, NULL, AcquireExpNoRaise, ReleaseExpNoLower, NULL }, ··· 363 383 { CheckQueue, DISPATCH_LEVEL, AcquireQueued, ReleaseQueued, TryQueued, NULL, NULL, NULL, LockQueuePfnLock }, 364 384 { CheckQueue, SynchIrql, AcquireQueuedSynch, ReleaseQueued, TryQueuedSynch, NULL, NULL, NULL, LockQueuePfnLock }, 365 385 }; 386 + CHECK_DATA TestDataWin7[] = 387 + { 388 + { CheckLock, DISPATCH_LEVEL, AcquireNormal, ReleaseNormal, NULL, AcquireNoRaise, ReleaseNoLower, TryNoRaise }, 389 + { CheckLock, DISPATCH_LEVEL, AcquireExp, ReleaseExp, NULL, AcquireExpNoRaise, ReleaseExpNoLower, NULL }, 390 + { CheckLock, DISPATCH_LEVEL, AcquireNormal, ReleaseNormal, NULL, AcquireInt, ReleaseInt, NULL }, 391 + { CheckLock, SynchIrql, AcquireSynch, ReleaseNormal, NULL, NULL, NULL, NULL }, 392 + { CheckQueueHandle, DISPATCH_LEVEL, AcquireInStackQueued, ReleaseInStackQueued, NULL, AcquireInStackNoRaise, ReleaseInStackNoRaise, NULL }, 393 + { CheckQueueHandle, SynchIrql, AcquireInStackSynch, ReleaseInStackQueued, NULL, NULL, NULL, NULL }, 394 + { CheckQueueHandle, DISPATCH_LEVEL, AcquireInStackQueued, ReleaseInStackQueued, NULL, AcquireInStackForDpc, ReleaseInStackForDpc, NULL }, 395 + }; 396 + CHECK_DATA *TestData; 397 + ULONG TestElements; 366 398 int i, iIrql; 367 399 PKPRCB Prcb; 368 400 ··· 398 430 if (!KmtIsMultiProcessorBuild && !KmtIsCheckedBuild) 399 431 pSpinLock = NULL; 400 432 401 - for (i = 0; i < sizeof TestData / sizeof TestData[0]; ++i) 433 + switch (GetNTVersion()) 434 + { 435 + case _WIN32_WINNT_VISTA: 436 + #ifdef _M_X64 437 + skip(FALSE, "This test is broken on Vista x64.\n"); 438 + goto done; 439 + #endif 440 + case _WIN32_WINNT_WS03: 441 + TestData = TestDataWS03; 442 + TestElements = RTL_NUMBER_OF(TestDataWS03); 443 + break; 444 + case _WIN32_WINNT_WIN7: 445 + case _WIN32_WINNT_WIN8: 446 + case _WIN32_WINNT_WINBLUE: 447 + case _WIN32_WINNT_WIN10: 448 + TestData = TestDataWin7; 449 + TestElements = RTL_NUMBER_OF(TestDataWin7); 450 + break; 451 + default: 452 + skip(FALSE, "Unknown NT version (0x%X).\n", GetNTVersion()); 453 + goto done; 454 + } 455 + 456 + for (i = 0; i < TestElements; ++i) 402 457 { 403 458 memset(&SpinLock, 0x55, sizeof SpinLock); 404 459 KeInitializeSpinLock(&SpinLock); ··· 423 478 KeLowerIrql(Irql); 424 479 } 425 480 } 426 - 481 + done: 427 482 KmtSetIrql(PASSIVE_LEVEL); 428 483 }
+9 -3
modules/rostests/kmtests/ntos_mm/MmMdl.c
··· 133 133 NULL, 134 134 FALSE, 135 135 NormalPagePriority); 136 + #ifdef _M_IX86 136 137 ok(SystemVa == NULL, "MmMapLockedPagesSpecifyCache succeeded for 2 GB\n"); 138 + #endif 137 139 if (SystemVa != NULL) 138 140 MmUnmapLockedPages(SystemVa, Mdl); 139 141 ok(MmGetMdlByteCount(Mdl) <= 2UL * 1024 * 1024 * 1024, "Byte count: %lu\n", MmGetMdlByteCount(Mdl)); ··· 209 211 ok((Mdl->MdlFlags & MDL_PAGES_LOCKED) == 0, "MDL locked\n"); 210 212 ok((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) == 0, "MDL from non paged\n"); 211 213 212 - MmBuildMdlForNonPagedPool(Mdl); 213 - ok((Mdl->MdlFlags & MDL_PAGES_LOCKED) == 0, "MDL locked\n"); 214 - ok((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) != 0, "MDL from paged\n"); 214 + // This fails an assertion on Windows 8+ checked and can bugcheck Windows 10+ free. 215 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 216 + { 217 + MmBuildMdlForNonPagedPool(Mdl); 218 + ok((Mdl->MdlFlags & MDL_PAGES_LOCKED) == 0, "MDL locked\n"); 219 + ok((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) != 0, "MDL from paged\n"); 220 + } 215 221 216 222 IoFreeMdl(Mdl); 217 223 ExFreePoolWithTag(Page, 'Test');
+49 -15
modules/rostests/kmtests/ntos_mm/MmReservedMapping.c
··· 9 9 #include <kmt_test.h> 10 10 11 11 static BOOLEAN g_IsPae; 12 - static ULONG g_OsVersion; 13 12 static BOOLEAN g_IsReactOS; 14 13 15 14 #ifdef _M_IX86 ··· 81 80 ULONGLONG PteValue, ExpectedValue; 82 81 ULONG i; 83 82 83 + #ifdef _M_AMD64 84 + if (skip(GetNTVersion() < _WIN32_WINNT_WIN10, 85 + "Win10 1607+ breaks these next tests.\n")) 86 + return Valid; 87 + #endif 88 + 84 89 for (i = 0; i < ValidPtes; i++) 85 90 { 86 91 CurrentAddress = (PUCHAR)BaseAddress + i * PAGE_SIZE; ··· 106 111 } 107 112 CurrentAddress = (PUCHAR)BaseAddress - 1 * PAGE_SIZE; 108 113 PteValue = GET_PTE_VALUE(CurrentAddress); 114 + 115 + if (skip(GetNTVersion() < _WIN32_WINNT_WIN10, 116 + "DVRT (Win10 1607+) breaks these next tests.\n")) 117 + return Valid; 118 + 119 + #ifdef _M_AMD64 120 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 121 + ExpectedValue = ((PoolTag & ~1ULL) + 1) << 28; 122 + else if (GetNTVersion() >= _WIN32_WINNT_VISTA) 123 + #else 124 + if (GetNTVersion() >= _WIN32_WINNT_VISTA) 125 + #endif 126 + ExpectedValue = ((PoolTag & ~1ULL) + 1) << 32; 127 + else 128 + ExpectedValue = PoolTag & ~1ULL; 129 + 109 130 Valid = Valid && 110 - ok(PteValue == (PoolTag & ~1ULL), 111 - "PTE for %p contains 0x%I64x, expected %x\n", 112 - CurrentAddress, PteValue, PoolTag & ~1); 131 + ok(PteValue == ExpectedValue, 132 + "PTE for %p contains 0x%I64x, expected 0x%I64x\n", 133 + CurrentAddress, PteValue, ExpectedValue); 113 134 CurrentAddress = (PUCHAR)BaseAddress - 2 * PAGE_SIZE; 114 135 PteValue = GET_PTE_VALUE(CurrentAddress); 115 136 116 - if (g_IsReactOS || g_OsVersion >= 0x0600) 137 + #ifdef _M_AMD64 138 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 139 + { 140 + ExpectedValue = (TotalPtes + 2) << 28; 141 + } 142 + else if (g_IsReactOS || GetNTVersion() >= _WIN32_WINNT_VISTA) 143 + #else 144 + if (g_IsReactOS || GetNTVersion() >= _WIN32_WINNT_VISTA) 145 + #endif 117 146 { 118 147 /* On ReactOS and on Vista+ the size is stored in 119 148 * the NextEntry field of a MMPTE_LIST structure */ 120 - #ifdef _M_IX86 121 - ExpectedValue = (TotalPtes + 2) << 12; 122 - #elif defined(_M_AMD64) 123 149 ExpectedValue = ((ULONG64)TotalPtes + 2) << 32; 124 - #endif 125 150 } 126 151 else 127 152 { ··· 130 155 } 131 156 Valid = Valid && 132 157 ok(PteValue == ExpectedValue, 133 - "PTE for %p contains 0x%I64x, expected %x\n", 158 + "PTE for %p contains 0x%I64x, expected 0x%I64x\n", 134 159 CurrentAddress, PteValue, ExpectedValue); 135 160 #endif 136 161 ··· 187 212 188 213 KmtStartSeh() 189 214 *(volatile ULONG *)BaseAddress = 0x01234567; 215 + ok_eq_ulong(*(volatile ULONG *)BaseAddress, 0x01234567); 190 216 KmtEndSeh(STATUS_SUCCESS); 191 217 192 218 MmUnmapReservedMapping(BaseAddress, ··· 205 231 ok(BaseAddress != NULL, "MmMapLockedPagesWithReservedMapping failed\n"); 206 232 if (!skip(BaseAddress != NULL, "Failed to map MDL\n")) 207 233 { 208 - ok_eq_pointer(BaseAddress, (PUCHAR)Mapping + sizeof(ULONG)); 234 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 235 + ok_eq_pointer(BaseAddress, (PVOID)ALIGN_DOWN_BY((PUCHAR)Mapping + sizeof(ULONG), 16)); 236 + else 237 + ok_eq_pointer(BaseAddress, (PUCHAR)Mapping + sizeof(ULONG)); 209 238 210 239 ok_bool_true(ValidateMapping(BaseAddress, TotalPtes, PoolTag, 1, MdlPages), 211 240 "ValidateMapping returned"); 212 241 213 242 KmtStartSeh() 214 243 *(volatile ULONG *)BaseAddress = 0x01234567; 244 + ok_eq_ulong(*(volatile ULONG *)BaseAddress, 0x01234567); 215 245 KmtEndSeh(STATUS_SUCCESS); 216 246 217 247 MmUnmapReservedMapping(BaseAddress, ··· 223 253 } 224 254 225 255 MmFreePagesFromMdl(Mdl); 256 + ExFreePool(Mdl); 226 257 227 258 /* Map all pages */ 228 259 Mdl = pMmAllocatePagesForMdlEx(ZeroPhysical, ··· 253 284 for (i = 0; i < TotalPtes; i++) 254 285 { 255 286 KmtStartSeh() 256 - *((volatile ULONG *)BaseAddress + i * PAGE_SIZE / sizeof(ULONG)) = 0x01234567; 287 + *((volatile ULONG *)((PUCHAR)BaseAddress + i * PAGE_SIZE)) = 0x01234567 + i; 288 + ok_eq_ulong(*((volatile ULONG *)((PUCHAR)BaseAddress + i * PAGE_SIZE)), 0x01234567 + i); 257 289 KmtEndSeh(STATUS_SUCCESS); 258 290 } 259 291 ··· 266 298 } 267 299 268 300 MmFreePagesFromMdl(Mdl); 301 + ExFreePool(Mdl); 269 302 270 303 /* Try to map more pages than we reserved */ 271 304 Mdl = pMmAllocatePagesForMdlEx(ZeroPhysical, ··· 292 325 } 293 326 294 327 MmFreePagesFromMdl(Mdl); 328 + ExFreePool(Mdl); 295 329 } 296 330 297 331 START_TEST(MmReservedMapping) ··· 299 333 PVOID Mapping; 300 334 301 335 g_IsPae = ExIsProcessorFeaturePresent(PF_PAE_ENABLED); 302 - g_OsVersion = SharedUserData->NtMajorVersion << 8 | SharedUserData->NtMinorVersion; 303 336 g_IsReactOS = *(PULONG)(KI_USER_SHARED_DATA + PAGE_SIZE - sizeof(ULONG)) == 0x8eac705; 304 - ok(g_IsReactOS == 1, "Not reactos\n"); 337 + if (!g_IsReactOS) 338 + trace("Not ReactOS\n"); 305 339 306 340 pMmAllocatePagesForMdlEx = KmtGetSystemRoutineAddress(L"MmAllocatePagesForMdlEx"); 307 341 ··· 317 351 } 318 352 319 353 /* 10 pages */ 320 - Mapping = MmAllocateMappingAddress(10 * PAGE_SIZE, 'MRmK' & ~1); 354 + Mapping = MmAllocateMappingAddress(10 * PAGE_SIZE, 'MRmK'); 321 355 ok(Mapping != NULL, "MmAllocateMappingAddress failed\n"); 322 356 if (!skip(Mapping != NULL, "No mapping\n")) 323 357 {
+202 -57
modules/rostests/kmtests/ntos_mm/MmSection.c
··· 96 96 IN HANDLE FileHandle2, 97 97 IN PFILE_OBJECT FileObject2) 98 98 { 99 - NTSTATUS Status = STATUS_SUCCESS; 99 + NTSTATUS Status = STATUS_SUCCESS, ExceptionStatus = STATUS_SUCCESS; 100 100 PVOID SectionObject; 101 101 LARGE_INTEGER MaximumSize; 102 102 ULONG PointerCount1, PointerCount2; 103 103 104 - KmtStartSeh() 104 + _SEH2_TRY 105 + { 105 106 Status = MmCreateSection(NULL, 0, NULL, NULL, 0, SEC_RESERVE, NULL, NULL); 106 - KmtEndSeh(STATUS_SUCCESS); 107 - ok_eq_hex(Status, STATUS_INVALID_PAGE_PROTECTION); 107 + } 108 + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 109 + { 110 + ExceptionStatus = _SEH2_GetExceptionCode(); 111 + } 112 + _SEH2_END; 113 + 114 + if (GetNTVersion() < _WIN32_WINNT_WIN10) 115 + { 116 + ok_eq_hex(ExceptionStatus, STATUS_SUCCESS); 117 + ok_eq_hex(Status, STATUS_INVALID_PAGE_PROTECTION); 118 + } 119 + else 120 + { 121 + ok_eq_hex(ExceptionStatus, STATUS_ACCESS_VIOLATION); 122 + ok_eq_hex(Status, STATUS_SUCCESS); 123 + } 108 124 109 125 if (!KmtIsCheckedBuild) 110 126 { ··· 119 135 } 120 136 121 137 SectionObject = KmtInvalidPointer; 122 - KmtStartSeh() 138 + _SEH2_TRY 139 + { 123 140 Status = MmCreateSection(&SectionObject, 0, NULL, NULL, 0, SEC_RESERVE, NULL, NULL); 124 - KmtEndSeh(STATUS_SUCCESS); 125 - ok_eq_hex(Status, STATUS_INVALID_PAGE_PROTECTION); 141 + } 142 + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 143 + { 144 + ExceptionStatus = _SEH2_GetExceptionCode(); 145 + } 146 + _SEH2_END; 147 + 148 + if (GetNTVersion() < _WIN32_WINNT_WIN10) 149 + { 150 + ok_eq_hex(ExceptionStatus, STATUS_SUCCESS); 151 + ok_eq_hex(Status, STATUS_INVALID_PAGE_PROTECTION); 152 + } 153 + else 154 + { 155 + ok_eq_hex(ExceptionStatus, STATUS_ACCESS_VIOLATION); 156 + ok_eq_hex(Status, STATUS_SUCCESS); 157 + } 126 158 ok_eq_pointer(SectionObject, KmtInvalidPointer); 127 159 128 160 if (SectionObject && SectionObject != KmtInvalidPointer) ··· 211 243 if (!skip(FileHandle1 != NULL && FileObject1 != NULL && 212 244 FileHandle2 != NULL && FileObject2 != NULL, "No file handle or object\n")) 213 245 { 214 - PointerCount1 = 3; 215 - PointerCount2 = 3; 246 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 247 + { 248 + PointerCount1 = 3; 249 + PointerCount2 = 3; 250 + } 251 + else 252 + { 253 + #ifdef _M_IX86 254 + PointerCount1 = 31; 255 + PointerCount2 = 33; 256 + #else 257 + PointerCount1 = 32767; 258 + PointerCount2 = 32769; 259 + #endif 260 + } 216 261 /* image section */ 217 262 CheckObject(FileHandle2, PointerCount2, 1L); 218 263 SectionObject = KmtInvalidPointer; ··· 224 269 ok_eq_longlong(MaximumSize.QuadPart, 1LL); 225 270 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 226 271 ok(SectionObject != NULL, "Section object pointer NULL\n"); 272 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 273 + PointerCount2 -= 2; 227 274 CheckObject(FileHandle2, PointerCount2, 1L); 228 - CheckSection(SectionObject, SEC_IMAGE); 275 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 276 + CheckSection(SectionObject, SEC_IMAGE); 229 277 TestMapView(SectionObject, FALSE, TRUE); 230 278 231 279 if (SectionObject && SectionObject != KmtInvalidPointer) 232 280 ObDereferenceObject(SectionObject); 233 281 282 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 283 + PointerCount2--; 234 284 CheckObject(FileHandle2, PointerCount2, 1L); 235 285 SectionObject = KmtInvalidPointer; 236 286 MaximumSize.QuadPart = 1; 237 287 KmtStartSeh() 238 288 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, NULL, FileObject2); 239 289 KmtEndSeh(STATUS_SUCCESS); 240 - ok_eq_hex(Status, STATUS_SUCCESS); 290 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 291 + ok_eq_hex(Status, STATUS_SUCCESS); 292 + else 293 + ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6); 241 294 ok_eq_longlong(MaximumSize.QuadPart, 1LL); 242 - ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 295 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 296 + ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 243 297 ok(SectionObject != NULL, "Section object pointer NULL\n"); 244 - //++PointerCount2; 298 + if (GetNTVersion() == _WIN32_WINNT_WS03) 299 + ++PointerCount2; 300 + else if (GetNTVersion() >= _WIN32_WINNT_WIN8) 301 + --PointerCount2; 245 302 CheckObject(FileHandle2, PointerCount2, 1L); 246 - CheckSection(SectionObject, SEC_IMAGE); 247 - TestMapView(SectionObject, FALSE, TRUE); 303 + CheckSection(SectionObject, 0); 304 + TestMapView(SectionObject, TRUE, TRUE); 248 305 249 306 if (SectionObject && SectionObject != KmtInvalidPointer) 250 307 ObDereferenceObject(SectionObject); 251 - //--PointerCount2; // ???? 252 308 309 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 310 + PointerCount2--; 253 311 CheckObject(FileHandle2, PointerCount2, 1L); 254 312 SectionObject = KmtInvalidPointer; 255 313 MaximumSize.QuadPart = 1; 256 314 KmtStartSeh() 257 315 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle2, FileObject2); 258 316 KmtEndSeh(STATUS_SUCCESS); 259 - ok_eq_hex(Status, STATUS_SUCCESS); 317 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 318 + ok_eq_hex(Status, STATUS_SUCCESS); 319 + else 320 + ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6); 260 321 ok_eq_longlong(MaximumSize.QuadPart, 1LL); 261 - ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 322 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 323 + ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 262 324 ok(SectionObject != NULL, "Section object pointer NULL\n"); 325 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 326 + PointerCount2--; 263 327 CheckObject(FileHandle2, PointerCount2, 1L); 264 - CheckSection(SectionObject, SEC_IMAGE); 265 - TestMapView(SectionObject, FALSE, TRUE); 328 + CheckSection(SectionObject, 0); 329 + TestMapView(SectionObject, TRUE, TRUE); 266 330 267 331 if (SectionObject && SectionObject != KmtInvalidPointer) 268 332 ObDereferenceObject(SectionObject); ··· 277 341 ok_eq_hex(Status, STATUS_INVALID_IMAGE_NOT_MZ); 278 342 ok_eq_longlong(MaximumSize.QuadPart, 1LL); 279 343 ok_eq_pointer(SectionObject, KmtInvalidPointer); 344 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 345 + PointerCount1 -= 2; 280 346 CheckObject(FileHandle1, PointerCount1, 1L); 281 347 282 348 if (SectionObject && SectionObject != KmtInvalidPointer) 283 349 ObDereferenceObject(SectionObject); 284 350 351 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 352 + PointerCount1--; 285 353 CheckObject(FileHandle1, PointerCount1, 1L); 286 354 SectionObject = KmtInvalidPointer; 287 355 MaximumSize.QuadPart = 1; 288 356 KmtStartSeh() 289 357 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, NULL, FileObject1); 290 358 KmtEndSeh(STATUS_SUCCESS); 291 - ok_eq_hex(Status, STATUS_SUCCESS); 359 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 360 + ok_eq_hex(Status, STATUS_SUCCESS); 361 + else 362 + ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6); 292 363 ok_eq_longlong(MaximumSize.QuadPart, 1LL); 293 - ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 364 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 365 + ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 294 366 ok(SectionObject != NULL, "Section object pointer NULL\n"); 295 - ++PointerCount1; 367 + if (GetNTVersion() == _WIN32_WINNT_WS03) 368 + ++PointerCount1; 369 + else if (GetNTVersion() >= _WIN32_WINNT_WIN8) 370 + --PointerCount1; 296 371 CheckObject(FileHandle1, PointerCount1, 1L); 297 372 CheckSection(SectionObject, 0); 298 373 TestMapView(SectionObject, TRUE, FALSE); 299 374 300 375 if (SectionObject && SectionObject != KmtInvalidPointer) 301 376 ObDereferenceObject(SectionObject); 302 - //--PointerCount1; // ???? 303 377 378 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 379 + --PointerCount1; 304 380 CheckObject(FileHandle1, PointerCount1, 1L); 305 381 SectionObject = KmtInvalidPointer; 306 382 MaximumSize.QuadPart = 1; 307 383 KmtStartSeh() 308 384 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle1, FileObject1); 309 385 KmtEndSeh(STATUS_SUCCESS); 310 - ok_eq_hex(Status, STATUS_SUCCESS); 386 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 387 + ok_eq_hex(Status, STATUS_SUCCESS); 388 + else 389 + ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6); 311 390 ok_eq_longlong(MaximumSize.QuadPart, 1LL); 312 - ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 391 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 392 + ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 313 393 ok(SectionObject != NULL, "Section object pointer NULL\n"); 394 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 395 + --PointerCount1; 314 396 CheckObject(FileHandle1, PointerCount1, 1L); 315 397 CheckSection(SectionObject, 0); 316 398 TestMapView(SectionObject, TRUE, FALSE); ··· 319 401 ObDereferenceObject(SectionObject); 320 402 321 403 /* image section with two different files */ 404 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 405 + --PointerCount1; 322 406 CheckObject(FileHandle1, PointerCount1, 1L); 323 407 SectionObject = KmtInvalidPointer; 324 408 MaximumSize.QuadPart = 1; 325 409 KmtStartSeh() 326 410 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle1, FileObject2); 327 411 KmtEndSeh(STATUS_SUCCESS); 328 - ok_eq_hex(Status, STATUS_SUCCESS); 412 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 413 + ok_eq_hex(Status, STATUS_SUCCESS); 414 + else 415 + ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6); 329 416 ok_eq_longlong(MaximumSize.QuadPart, 1LL); 330 - ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 417 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 418 + ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 331 419 ok(SectionObject != NULL, "Section object pointer NULL\n"); 420 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 421 + { 422 + --PointerCount1; 423 + --PointerCount2; 424 + } 332 425 CheckObject(FileHandle1, PointerCount1, 1L); 333 426 CheckObject(FileHandle2, PointerCount2, 1L); 334 - CheckSection(SectionObject, SEC_IMAGE); 335 - TestMapView(SectionObject, FALSE, TRUE); 427 + CheckSection(SectionObject, 0); 428 + TestMapView(SectionObject, TRUE, TRUE); 336 429 337 430 if (SectionObject && SectionObject != KmtInvalidPointer) 338 431 ObDereferenceObject(SectionObject); 339 432 433 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 434 + --PointerCount1; 340 435 CheckObject(FileHandle1, PointerCount1, 1L); 341 436 SectionObject = KmtInvalidPointer; 342 437 MaximumSize.QuadPart = 1; 343 438 KmtStartSeh() 344 439 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle2, FileObject1); 345 440 KmtEndSeh(STATUS_SUCCESS); 346 - ok_eq_hex(Status, STATUS_SUCCESS); 441 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 442 + ok_eq_hex(Status, STATUS_SUCCESS); 443 + else 444 + ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6); 347 445 ok_eq_longlong(MaximumSize.QuadPart, 1LL); 348 - ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 446 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 447 + ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 349 448 ok(SectionObject != NULL, "Section object pointer NULL\n"); 449 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 450 + { 451 + --PointerCount1; 452 + --PointerCount2; 453 + } 350 454 CheckObject(FileHandle1, PointerCount1, 1L); 351 455 CheckObject(FileHandle2, PointerCount2, 1L); 352 456 CheckSection(SectionObject, 0); ··· 356 460 ObDereferenceObject(SectionObject); 357 461 358 462 /* data file section */ 463 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 464 + --PointerCount1; 359 465 CheckObject(FileHandle1, PointerCount1, 1L); 360 466 SectionObject = KmtInvalidPointer; 361 467 MaximumSize.QuadPart = 1; ··· 366 472 ok_eq_longlong(MaximumSize.QuadPart, 1LL); 367 473 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 368 474 ok(SectionObject != NULL, "Section object pointer NULL\n"); 475 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 476 + PointerCount1 -= 2; 369 477 CheckObject(FileHandle1, PointerCount1, 1L); 370 - CheckSection(SectionObject, 0); 478 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 479 + CheckSection(SectionObject, 0); 371 480 TestMapView(SectionObject, TRUE, FALSE); 372 481 373 482 if (SectionObject && SectionObject != KmtInvalidPointer) 374 483 ObDereferenceObject(SectionObject); 375 484 485 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 486 + --PointerCount1; 376 487 CheckObject(FileHandle1, PointerCount1, 1L); 377 488 SectionObject = KmtInvalidPointer; 378 489 MaximumSize.QuadPart = 1; 379 490 KmtStartSeh() 380 491 Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, NULL, FileObject1); 381 492 KmtEndSeh(STATUS_SUCCESS); 382 - ok_eq_hex(Status, STATUS_SUCCESS); 383 493 ok_eq_longlong(MaximumSize.QuadPart, 1LL); 384 494 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 385 495 ok(SectionObject != NULL, "Section object pointer NULL\n"); 496 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 497 + --PointerCount1; 386 498 CheckObject(FileHandle1, PointerCount1, 1L); 387 - CheckSection(SectionObject, 0); 499 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 500 + CheckSection(SectionObject, 0); 388 501 TestMapView(SectionObject, TRUE, FALSE); 389 502 390 503 if (SectionObject && SectionObject != KmtInvalidPointer) 391 504 ObDereferenceObject(SectionObject); 392 505 506 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 507 + --PointerCount1; 393 508 CheckObject(FileHandle1, PointerCount1, 1L); 394 509 SectionObject = KmtInvalidPointer; 395 510 MaximumSize.QuadPart = 1; ··· 400 515 ok_eq_longlong(MaximumSize.QuadPart, 1LL); 401 516 ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n"); 402 517 ok(SectionObject != NULL, "Section object pointer NULL\n"); 518 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 519 + --PointerCount1; 403 520 CheckObject(FileHandle1, PointerCount1, 1L); 404 - CheckSection(SectionObject, 0); 521 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 522 + CheckSection(SectionObject, 0); 405 523 TestMapView(SectionObject, TRUE, FALSE); 406 524 407 525 if (SectionObject && SectionObject != KmtInvalidPointer) 408 526 ObDereferenceObject(SectionObject); 409 527 528 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 529 + --PointerCount1; 410 530 CheckObject(FileHandle1, PointerCount1, 1L); 411 531 } 412 532 } ··· 700 820 ViewUnmap, 701 821 0, 702 822 PAGE_READWRITE); 703 - ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6); 823 + if (GetNTVersion() < _WIN32_WINNT_WIN10) 824 + ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6); 825 + else 826 + ok_eq_hex(Status, STATUS_SUCCESS); 704 827 if (NT_SUCCESS(Status)) 705 828 { 706 829 KmtStartSeh() ··· 746 869 ViewUnmap, 747 870 0, 748 871 PAGE_READWRITE); 749 - ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6); 872 + if (GetNTVersion() < _WIN32_WINNT_WIN10) 873 + ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6); 874 + else 875 + ok_eq_hex(Status, STATUS_SUCCESS); 750 876 if (NT_SUCCESS(Status)) 751 877 { 752 878 KmtStartSeh() ··· 788 914 ZwClose(SectionHandle); 789 915 790 916 /* Assertion failure: AllocationAttributes & SEC_IMAGE | SEC_RESERVE | SEC_COMMIT */ 791 - if (!KmtIsCheckedBuild) 917 + if (!KmtIsCheckedBuild && !(GetNTVersion() >= _WIN32_WINNT_WIN10)) 792 918 { 793 919 InitializeObjectAttributes(&ObjectAttributes, 794 920 NULL, ··· 808 934 ObDereferenceObject(SectionObject); 809 935 } 810 936 811 - InitializeObjectAttributes(&ObjectAttributes, 812 - NULL, 813 - OBJ_KERNEL_HANDLE, 814 - NULL, 815 - NULL); 816 - Status = MmCreateSection(&SectionObject, 817 - SECTION_ALL_ACCESS, 818 - &ObjectAttributes, 819 - NULL, 820 - PAGE_READWRITE, 821 - SEC_RESERVE | 0x80000000, 822 - NULL, 823 - NULL); 824 - ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6); 825 - if (NT_SUCCESS(Status)) 826 - ObDereferenceObject(SectionObject); 937 + if (GetNTVersion() < _WIN32_WINNT_WIN10) 938 + { 939 + InitializeObjectAttributes(&ObjectAttributes, 940 + NULL, 941 + OBJ_KERNEL_HANDLE, 942 + NULL, 943 + NULL); 944 + Status = MmCreateSection(&SectionObject, 945 + SECTION_ALL_ACCESS, 946 + &ObjectAttributes, 947 + NULL, 948 + PAGE_READWRITE, 949 + SEC_RESERVE | 0x80000000, 950 + NULL, 951 + NULL); 952 + ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6); 953 + if (NT_SUCCESS(Status)) 954 + ObDereferenceObject(SectionObject); 955 + } 827 956 828 957 ExFreePoolWithTag(ZeroPageContents, 'ZPmK'); 829 958 ExFreePoolWithTag(MyPage, 'MPmK'); ··· 866 995 ok_eq_hex(Status, STATUS_SUCCESS); 867 996 ok_eq_ulongptr(IoStatusBlock.Information, FILE_OPENED); 868 997 ok(FileHandle1 != NULL, "FileHandle1 is NULL\n"); 869 - CheckObject(FileHandle1, 2L, 1L); 998 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 999 + CheckObject(FileHandle1, 2L, 1L); 1000 + #ifdef _M_IX86 1001 + else 1002 + CheckObject(FileHandle1, 33L, 1L); 1003 + #else 1004 + else 1005 + CheckObject(FileHandle1, 32769L, 1L); 1006 + #endif 870 1007 871 1008 InitializeObjectAttributes(&ObjectAttributes, &FileName2, OBJ_CASE_INSENSITIVE, NULL, NULL); 872 1009 Status = ZwCreateFile(&FileHandle2, GENERIC_READ, &ObjectAttributes, &IoStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, FILE_OPEN, FILE_NON_DIRECTORY_FILE, NULL, 0); ··· 879 1016 Status = ObReferenceObjectByHandle(FileHandle1, FILE_READ_DATA | FILE_WRITE_DATA, *IoFileObjectType, KernelMode, (PVOID *)&FileObject1, NULL); 880 1017 ok_eq_hex(Status, STATUS_SUCCESS); 881 1018 ok(FileObject1 != NULL, "FileObject1 is NULL\n"); 882 - CheckObject(FileHandle1, 3L, 1L); 1019 + if (GetNTVersion() < _WIN32_WINNT_WIN8) 1020 + CheckObject(FileHandle1, 3L, 1L); 1021 + #ifdef _M_IX86 1022 + else 1023 + CheckObject(FileHandle1, 32L, 1L); 1024 + #else 1025 + else 1026 + CheckObject(FileHandle1, 32768L, 1L); 1027 + #endif 883 1028 } 884 1029 885 1030 if (!skip(Status == STATUS_SUCCESS && FileHandle2 != NULL, "Failed to open file 2\n"))
+8 -1
modules/rostests/kmtests/ntos_mm/ZwCreateSection.c
··· 473 473 474 474 Length.QuadPart = TestStringSize; 475 475 CREATE_SECTION(Section, (SECTION_ALL_ACCESS), NULL, Length, PAGE_READONLY, SEC_COMMIT, FileHandle, STATUS_SUCCESS, NO_HANDLE_CLOSE); 476 - CheckObject(Section, 2, 1); 476 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 477 + #ifdef _M_IX86 478 + CheckObject(Section, 33, 1); 479 + #else 480 + CheckObject(Section, 32769, 1); 481 + #endif 482 + else 483 + CheckObject(Section, 2, 1); 477 484 CheckSection(Section, SEC_FILE, Length.QuadPart, STATUS_SUCCESS); 478 485 ZwClose(Section); //manually close it due to NO_HANDLE_CLOSE in CREATE_SECTION 479 486
+84 -11
modules/rostests/kmtests/ntos_mm/ZwMapViewOfSection.c
··· 10 10 #define IGNORE -99 11 11 #define NEW_CONTENT "NewContent" 12 12 #define NEW_CONTENT_LEN sizeof(NEW_CONTENT) 13 + #define IsInvalidParamStatus(Status) \ 14 + (Status == STATUS_INVALID_PARAMETER || Status == STATUS_INVALID_PARAMETER_MIX || \ 15 + (Status >= STATUS_INVALID_PARAMETER_1 && Status <= STATUS_INVALID_PARAMETER_12)) 16 + #define ok_invalid_parameter(Status) ok(IsInvalidParamStatus(Status), "Invalid status code (0x%X)\n", Status) 13 17 14 18 static UNICODE_STRING FileReadOnlyPath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntdll.dll"); 15 19 static UNICODE_STRING NtosImgPath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntoskrnl.exe"); ··· 24 28 #define TestMapView(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect, MapStatus, UnmapStatus) do \ 25 29 { \ 26 30 Status = ZwMapViewOfSection(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect); \ 27 - ok_eq_hex(Status, MapStatus); \ 31 + if (GetNTVersion() >= _WIN32_WINNT_WIN10 && IsInvalidParamStatus(MapStatus)) \ 32 + ok_invalid_parameter(MapStatus); \ 33 + else \ 34 + ok_eq_hex(Status, MapStatus); \ 28 35 if (NT_SUCCESS(Status)) \ 29 36 { \ 30 37 Status = ZwUnmapViewOfSection(ProcessHandle, BaseAddress); \ ··· 161 168 } 162 169 163 170 //zero bits 171 + #ifdef _M_IX86 164 172 TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 1, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS); 165 173 TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 5, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS); 166 174 TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, -1, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_PARAMETER_4, IGNORE); 175 + #else 176 + TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 1, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, GetNTVersion() >= _WIN32_WINNT_WIN8 ? STATUS_INVALID_PARAMETER_4 : STATUS_SUCCESS, STATUS_SUCCESS); 177 + TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 5, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, GetNTVersion() >= _WIN32_WINNT_WIN8 ? STATUS_INVALID_PARAMETER_4 : STATUS_SUCCESS, STATUS_SUCCESS); 178 + TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, -1, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_SUCCESS, IGNORE); 179 + #endif 167 180 TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 20, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_NO_MEMORY, IGNORE); 168 181 TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 21, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_NO_MEMORY, IGNORE); 169 182 TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 22, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_PARAMETER_4, IGNORE); ··· 207 220 TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, MEM_RESERVE, PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS); 208 221 TestMapView(PageFileSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, MEM_RESERVE, PAGE_READWRITE, STATUS_INVALID_PARAMETER_9, STATUS_SUCCESS); 209 222 TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, (MEM_RESERVE | MEM_COMMIT), PAGE_READWRITE, STATUS_INVALID_PARAMETER_9, IGNORE); 210 - TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, (MEM_LARGE_PAGES | MEM_RESERVE), PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS); 223 + TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, (MEM_LARGE_PAGES | MEM_RESERVE), PAGE_READWRITE, (NTSTATUS)(GetNTVersion() >= _WIN32_WINNT_WIN10 ? STATUS_INVALID_PARAMETER : STATUS_SUCCESS), STATUS_SUCCESS); 211 224 212 225 //win32protect 213 226 TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READONLY, STATUS_SUCCESS, STATUS_SUCCESS); ··· 258 271 259 272 //test first conditional branch 260 273 ViewSize = -1; 261 - MmTestMapView(SectionObject, PsGetCurrentProcess(), &BaseAddress, 0, TestStringSize, &SectionOffset, &ViewSize, ViewUnmap, MEM_RESERVE, PAGE_READWRITE, STATUS_INVALID_VIEW_SIZE, IGNORE); 274 + #ifdef _M_IX86 275 + NTSTATUS MapStatus; 276 + 277 + switch (GetNTVersion()) 278 + { 279 + case _WIN32_WINNT_WIN8: 280 + case _WIN32_WINNT_WINBLUE: 281 + MapStatus = STATUS_INVALID_VIEW_SIZE; 282 + break; 283 + case _WIN32_WINNT_WIN10: 284 + MapStatus = STATUS_CONFLICTING_ADDRESSES; 285 + break; 286 + default: 287 + MapStatus = STATUS_SUCCESS; 288 + break; 289 + } 290 + 291 + MmTestMapView(SectionObject, PsGetCurrentProcess(), &BaseAddress, 0, TestStringSize, 292 + &SectionOffset, &ViewSize, ViewUnmap, MEM_RESERVE, PAGE_READWRITE, MapStatus, IGNORE); 293 + #else 294 + MmTestMapView(SectionObject, PsGetCurrentProcess(), &BaseAddress, 0, TestStringSize, 295 + &SectionOffset, &ViewSize, ViewUnmap, MEM_RESERVE, PAGE_READWRITE, STATUS_INVALID_VIEW_SIZE, IGNORE); 296 + #endif 262 297 263 298 //test second conditional branch 264 299 ViewSize = 1; ··· 286 321 if (!skip((FileContent != NULL), "Error allocating memory for FileContent\n")) 287 322 { 288 323 Status = ZwReadFile(FileHandle, NULL, NULL, NULL, &IoStatusBlock, FileContent, BufferLength, &ByteOffset, NULL); 289 - ok_eq_hex(Status, STATUS_SUCCESS); 324 + ok(Status == STATUS_SUCCESS || Status == STATUS_PENDING, "Unexpected status (0x%X).\n", Status); 290 325 ok_eq_ulongptr(IoStatusBlock.Information, BufferLength); 291 326 292 327 Match = 0; ··· 310 345 SIZE_T Match; 311 346 LARGE_INTEGER SectionOffset; 312 347 OBJECT_ATTRIBUTES ObjectAttributes; 348 + ULONG PtrCnt; 313 349 314 350 UNREFERENCED_PARAMETER(StartContext); 315 351 352 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 353 + #ifdef _M_IX86 354 + PtrCnt = 64; 355 + #else 356 + PtrCnt = 65536; 357 + #endif 358 + else 359 + PtrCnt = 4; 360 + 316 361 BaseAddress = NULL; 317 362 ViewSize = TestStringSize; 318 363 SectionOffset.QuadPart = 0; ··· 321 366 Status = ZwOpenSection(&SectionHandle, SECTION_ALL_ACCESS, &ObjectAttributes); 322 367 if (!skip(NT_SUCCESS(Status), "Error acquiring handle to section. Error = %p\n", Status)) 323 368 { 324 - CheckObject(SectionHandle, 4, 2); 369 + CheckObject(SectionHandle, PtrCnt, 2); 325 370 Status = ZwMapViewOfSection(SectionHandle, NtCurrentProcess(), &BaseAddress, 0, TestStringSize, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_READWRITE); 371 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 372 + PtrCnt -= 2; 326 373 327 374 //make sure ZwMapViewofSection doesn't touch the section ref counts. 328 - CheckObject(SectionHandle, 4, 2); 375 + CheckObject(SectionHandle, PtrCnt, 2); 376 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 377 + PtrCnt--; 329 378 330 379 if (!skip(NT_SUCCESS(Status), "Error mapping page file view in system process. Error = %p\n", Status)) 331 380 { ··· 336 385 ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress); 337 386 338 387 //make sure ZwMapViewofSection doesn't touch the section ref counts. 339 - CheckObject(SectionHandle, 4, 2); 388 + CheckObject(SectionHandle, PtrCnt, 2); 340 389 } 341 390 342 391 ZwClose(SectionHandle); ··· 360 409 LARGE_INTEGER MaximumSize; 361 410 SIZE_T Match; 362 411 SIZE_T ViewSize = 0; 412 + ULONG PtrCnt; 413 + 414 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 415 + #ifdef _M_IX86 416 + PtrCnt = 34; 417 + #else 418 + PtrCnt = 32770; 419 + #endif 420 + else 421 + PtrCnt = 3; 363 422 364 423 InitializeObjectAttributes(&ObjectAttributes, &SharedSectionName, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); 365 424 MaximumSize.QuadPart = TestStringSize; 366 425 SectionOffset.QuadPart = 0; 367 426 368 427 Status = ZwCreateSection(&WriteSectionHandle, SECTION_ALL_ACCESS, &ObjectAttributes, &MaximumSize, PAGE_READWRITE, SEC_COMMIT, FileHandleWriteOnly); 369 - CheckObject(WriteSectionHandle, 3, 1); 428 + CheckObject(WriteSectionHandle, PtrCnt, 1); 429 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 430 + PtrCnt -= 2; 370 431 ok(NT_SUCCESS(Status), "Error creating write section from file. Error = %p\n", Status); 371 432 372 433 //check for section reading/writing by comparing section content to a well-known value. 373 434 Status = ZwMapViewOfSection(WriteSectionHandle, NtCurrentProcess() ,&BaseAddress, 0, 0, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_READWRITE); 374 - CheckObject(WriteSectionHandle, 3, 1); 435 + CheckObject(WriteSectionHandle, PtrCnt, 1); 375 436 if (!skip(NT_SUCCESS(Status), "Error mapping view with READ/WRITE priv. Error = %p\n", Status)) 376 437 { 377 438 Match = RtlCompareMemory(BaseAddress, TestString, TestStringSize); ··· 505 566 SIZE_T Match; 506 567 PVOID ThreadObject; 507 568 OBJECT_ATTRIBUTES ObjectAttributes; 569 + ULONG PtrCnt; 570 + 571 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 572 + #ifdef _M_IX86 573 + PtrCnt = 34; 574 + #else 575 + PtrCnt = 32770; 576 + #endif 577 + else 578 + PtrCnt = 3; 508 579 509 580 MaxSectionSize.QuadPart = TestStringSize; 510 581 SectionOffset.QuadPart = 0; ··· 517 588 Status = ZwCreateSection(&PageFileSectionHandle, SECTION_ALL_ACCESS, &ObjectAttributes, &MaxSectionSize, PAGE_READWRITE, SEC_COMMIT, NULL); 518 589 if (!skip(NT_SUCCESS(Status), "Error creating page file section. Error = %p\n", Status)) 519 590 { 520 - CheckObject(PageFileSectionHandle, 3, 1); 591 + CheckObject(PageFileSectionHandle, PtrCnt, 1); 521 592 Status = ZwMapViewOfSection(PageFileSectionHandle, NtCurrentProcess(), &BaseAddress, 0, TestStringSize, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_READWRITE); 593 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 594 + PtrCnt -= 2; 522 595 if (!skip(NT_SUCCESS(Status), "Error mapping page file view. Error = %p\n", Status)) 523 596 { 524 597 HANDLE SysThreadHandle; 525 598 526 - CheckObject(PageFileSectionHandle, 3, 1); 599 + CheckObject(PageFileSectionHandle, PtrCnt, 1); 527 600 528 601 //check also the SEC_COMMIT flag 529 602 Test_NtQueryVirtualMemory(BaseAddress, PAGE_SIZE, MEM_COMMIT, PAGE_READWRITE);
+91 -18
modules/rostests/kmtests/ntos_ob/ObHandle.c
··· 34 34 { 35 35 NTSTATUS Status; 36 36 HANDLE NewHandle; 37 + ULONG i, PtrCnt1, PtrCnt2; 37 38 struct 38 39 { 39 40 ACCESS_MASK DesiredAccess; ··· 59 60 { DIRECTORY_QUERY, OBJ_INHERIT, DUPLICATE_SAME_ACCESS | DUPLICATE_SAME_ATTRIBUTES, 60 61 DIRECTORY_ALL_ACCESS, 0 }, 61 62 }; 62 - ULONG i; 63 + 64 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 65 + { 66 + #ifdef _M_IX86 67 + PtrCnt1 = 65UL; 68 + PtrCnt2 = 31UL; 69 + #else 70 + PtrCnt1 = 65537UL; 71 + PtrCnt2 = 32767UL; 72 + #endif 73 + } 74 + 75 + else 76 + { 77 + PtrCnt1 = 3UL; 78 + PtrCnt2 = 2UL; 79 + } 63 80 64 81 for (i = 0; i < RTL_NUMBER_OF(Tests); i++) 65 82 { 83 + if (GetNTVersion() >= _WIN32_WINNT_WIN7 && 84 + Tests[i].RequestedAttributes == OBJ_KERNEL_HANDLE) 85 + { 86 + skip(FALSE, "Invalid on NT 6.1+\n"); 87 + continue; 88 + } 89 + 66 90 trace("Test %lu\n", i); 67 91 Status = ZwDuplicateObject(ZwCurrentProcess(), 68 92 Handle, ··· 75 99 if (!skip(NT_SUCCESS(Status), "DuplicateHandle failed\n")) 76 100 { 77 101 ok(IsUserHandle(NewHandle), "New handle = %p\n", NewHandle); 78 - CheckObject(NewHandle, 3UL, 2UL, Tests[i].ExpectedAttributes, Tests[i].GrantedAccess); 79 - CheckObject(Handle, 3UL, 2UL, 0UL, DIRECTORY_ALL_ACCESS); 102 + CheckObject(NewHandle, PtrCnt1, 2UL, Tests[i].ExpectedAttributes, Tests[i].GrantedAccess); 103 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 104 + PtrCnt1--; 105 + CheckObject(Handle, PtrCnt1, 2UL, 0UL, DIRECTORY_ALL_ACCESS); 106 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 107 + PtrCnt1--; 80 108 81 109 Status = ObCloseHandle(NewHandle, UserMode); 82 110 ok_eq_hex(Status, STATUS_SUCCESS); 83 - CheckObject(Handle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 111 + CheckObject(Handle, PtrCnt2, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 112 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 113 + PtrCnt2 -= 2; 84 114 } 85 115 } 86 116 ··· 96 126 if (!skip(NT_SUCCESS(Status), "DuplicateHandle failed\n")) 97 127 { 98 128 ok(IsKernelHandle(NewHandle), "New handle = %p\n", NewHandle); 99 - CheckObject(NewHandle, 3UL, 2UL, 0, DIRECTORY_ALL_ACCESS); 100 - CheckObject(Handle, 3UL, 2UL, 0UL, DIRECTORY_ALL_ACCESS); 101 - 129 + CheckObject(NewHandle, PtrCnt1, 2UL, 0, DIRECTORY_ALL_ACCESS); 130 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 131 + PtrCnt1--; 132 + CheckObject(Handle, PtrCnt1, 2UL, 0UL, DIRECTORY_ALL_ACCESS); 133 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 134 + PtrCnt1--; 102 135 Status = ObCloseHandle(NewHandle, UserMode); 103 136 ok_eq_hex(Status, STATUS_INVALID_HANDLE); 104 - CheckObject(NewHandle, 3UL, 2UL, 0, DIRECTORY_ALL_ACCESS); 105 - CheckObject(Handle, 3UL, 2UL, 0UL, DIRECTORY_ALL_ACCESS); 137 + CheckObject(NewHandle, PtrCnt1, 2UL, 0, DIRECTORY_ALL_ACCESS); 138 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 139 + PtrCnt1--; 140 + CheckObject(Handle, PtrCnt1, 2UL, 0UL, DIRECTORY_ALL_ACCESS); 106 141 107 142 if (IsKernelHandle(NewHandle)) 108 143 { 109 144 Status = ObCloseHandle(NewHandle, KernelMode); 110 145 ok_eq_hex(Status, STATUS_SUCCESS); 111 - CheckObject(Handle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 146 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 147 + PtrCnt2--; 148 + CheckObject(Handle, PtrCnt2, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 112 149 } 113 150 } 114 151 } ··· 145 182 if (!skip(NT_SUCCESS(Status), "No directory handle\n")) 146 183 { 147 184 ok(IsUserHandle(UserDirectoryHandle), "User handle = %p\n", UserDirectoryHandle); 148 - CheckObject(UserDirectoryHandle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 185 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 186 + #ifdef _M_IX86 187 + CheckObject(UserDirectoryHandle, 33UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 188 + #else 189 + CheckObject(UserDirectoryHandle, 32769UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 190 + #endif 191 + else 192 + CheckObject(UserDirectoryHandle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 149 193 150 194 TestDuplicate(UserDirectoryHandle); 151 195 ··· 165 209 if (!skip(NT_SUCCESS(Status), "No directory handle\n")) 166 210 { 167 211 ok(IsKernelHandle(KernelDirectoryHandle), "Kernel handle = %p\n", KernelDirectoryHandle); 168 - CheckObject(KernelDirectoryHandle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 212 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 213 + #ifdef _M_IX86 214 + CheckObject(KernelDirectoryHandle, 33UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 215 + #else 216 + CheckObject(KernelDirectoryHandle, 32769UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 217 + #endif 218 + else 219 + CheckObject(KernelDirectoryHandle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 169 220 170 221 TestDuplicate(KernelDirectoryHandle); 171 222 172 223 Status = ObCloseHandle(KernelDirectoryHandle, UserMode); 173 224 ok_eq_hex(Status, STATUS_INVALID_HANDLE); 174 - CheckObject(KernelDirectoryHandle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 225 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 226 + #ifdef _M_IX86 227 + CheckObject(KernelDirectoryHandle, 17UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 228 + #else 229 + CheckObject(KernelDirectoryHandle, 32753UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 230 + #endif 231 + else 232 + CheckObject(KernelDirectoryHandle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS); 175 233 176 234 Status = ObCloseHandle(KernelDirectoryHandle, KernelMode); 177 235 ok_eq_hex(Status, STATUS_SUCCESS); ··· 191 249 ok_eq_hex(Status, STATUS_INVALID_HANDLE); 192 250 DPRINT("Closing -1 kernel handle (NtClose)\n"); 193 251 Status = NtClose(LongToHandle(0xFFFFFFFF)); 194 - ok_eq_hex(Status, STATUS_INVALID_HANDLE); 252 + if (GetNTVersion() >= _WIN32_WINNT_WIN10) 253 + ok_eq_hex(Status, STATUS_SUCCESS); 254 + else 255 + ok_eq_hex(Status, STATUS_INVALID_HANDLE); 195 256 DPRINT("Closing 123 handle (NtClose)\n"); 196 257 Status = NtClose(LongToHandle(123)); 197 - ok_eq_hex(Status, STATUS_INVALID_HANDLE); 258 + if (GetNTVersion() >= _WIN32_WINNT_WIN8) 259 + ok_eq_hex(Status, STATUS_SUCCESS); 260 + else if (GetNTVersion() != _WIN32_WINNT_WS03) 261 + ok_eq_hex(Status, STATUS_INVALID_HANDLE); 198 262 DPRINT("Closing 123 kernel handle (NtClose)\n"); 199 263 Status = NtClose(LongToHandle(123 | 0x80000000)); 200 264 ok_eq_hex(Status, STATUS_INVALID_HANDLE); ··· 211 275 ok_eq_hex(Status, STATUS_INVALID_HANDLE); 212 276 DPRINT("Closing -1 kernel handle (ObCloseHandle, UserMode)\n"); 213 277 Status = ObCloseHandle(LongToHandle(0xFFFFFFFF), UserMode); 214 - ok_eq_hex(Status, STATUS_INVALID_HANDLE); 278 + if (GetNTVersion() >= _WIN32_WINNT_WIN10) 279 + ok_eq_hex(Status, STATUS_SUCCESS); 280 + else 281 + ok_eq_hex(Status, STATUS_INVALID_HANDLE); 215 282 DPRINT("Closing 123 handle (ObCloseHandle, UserMode)\n"); 216 283 Status = ObCloseHandle(LongToHandle(123), UserMode); 217 284 ok_eq_hex(Status, STATUS_INVALID_HANDLE); ··· 230 297 Status = ZwClose((HANDLE)0x7FFFFFFF);*/ 231 298 DPRINT("Closing -1 kernel handle (ZwClose)\n"); 232 299 Status = ZwClose(LongToHandle(0xFFFFFFFF)); 233 - ok_eq_hex(Status, STATUS_INVALID_HANDLE); 300 + if (GetNTVersion() >= _WIN32_WINNT_WIN10) 301 + ok_eq_hex(Status, STATUS_SUCCESS); 302 + else 303 + ok_eq_hex(Status, STATUS_INVALID_HANDLE); 234 304 /* INVALID_KERNEL_HANDLE, 0x7B, 1, 0, 0 235 305 Status = ZwClose(LongToHandle(123)); 236 306 Status = ZwClose(LongToHandle(123 | 0x80000000));*/ ··· 246 316 Status = ObCloseHandle((HANDLE)0x7FFFFFFF, KernelMode);*/ 247 317 DPRINT("Closing -1 kernel handle (ObCloseHandle, KernelMode)\n"); 248 318 Status = ObCloseHandle(LongToHandle(0xFFFFFFFF), KernelMode); 249 - ok_eq_hex(Status, STATUS_INVALID_HANDLE); 319 + if (GetNTVersion() >= _WIN32_WINNT_WIN10) 320 + ok_eq_hex(Status, STATUS_SUCCESS); 321 + else 322 + ok_eq_hex(Status, STATUS_INVALID_HANDLE); 250 323 /* INVALID_KERNEL_HANDLE, 0x7B, 1, 0, 0 251 324 Status = ObCloseHandle(LongToHandle(123), KernelMode); 252 325 Status = ObCloseHandle(LongToHandle(123 | 0x80000000), KernelMode);*/
+10 -2
modules/rostests/kmtests/ntos_ob/ObTypes.c
··· 151 151 152 152 static 153 153 VOID 154 - TestObjectTypes(VOID) 154 + TestWin2003ObjectTypes(VOID) 155 155 { 156 156 ULONG Index; 157 157 ··· 258 258 259 259 START_TEST(ObTypes) 260 260 { 261 - TestObjectTypes(); 261 + switch (GetNTVersion()) 262 + { 263 + case _WIN32_WINNT_WS03: 264 + TestWin2003ObjectTypes(); 265 + break; 266 + default: 267 + skip(FALSE, "FIXME: kmtest:ObTypes is invalid for this NT version (0x%X).\n", GetNTVersion()); 268 + break; 269 + } 262 270 }
+4
modules/rostests/kmtests/rtl/RtlMemory.c
··· 253 253 RtlCopyMemoryNonTemporal(Buffer + 13, Buffer + 62, 95); 254 254 ok_bool_true(CheckPattern(Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0), "CheckPattern"); 255 255 256 + #ifdef _M_IX86 256 257 MakePattern(Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0); 257 258 RtlCopyMemoryNonTemporal(Buffer + 78, Buffer + 43, 107); 258 259 ok_bool_true(CheckPattern(Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0), "CheckPattern"); 260 + #else 261 + skip(FALSE, "FIXME: This part of the test is broken on x64.\n"); 262 + #endif 259 263 260 264 KeLowerIrql(Irql); 261 265 Status = STATUS_SUCCESS;
+14 -3
modules/rostests/kmtests/rtl/RtlStack.c
··· 25 25 ULONG ExpectedHash; 26 26 ULONG i; 27 27 const ULONG FunctionSizeGuess = 0x1000; 28 + NTSTATUS ExceptionStatus = STATUS_SUCCESS; 28 29 29 30 ReturnAddresses[3] = _ReturnAddress(); 30 31 ··· 56 57 ok_eq_pointer(Frames[3], ReturnAddresses[1]); 57 58 ok_eq_pointer(Frames[4], (PVOID)(ULONG_PTR)0x5555555555555555); 58 59 59 - KmtStartSeh() 60 + _SEH2_TRY 61 + { 60 62 RtlCaptureStackBackTrace(0, 5, NULL, NULL); 61 - KmtEndSeh(STATUS_ACCESS_VIOLATION); 63 + } 64 + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 65 + { 66 + ExceptionStatus = _SEH2_GetExceptionCode(); 67 + } 68 + _SEH2_END; 69 + if (GetNTVersion() == _WIN32_WINNT_WS03) 70 + ok_eq_hex(ExceptionStatus, STATUS_ACCESS_VIOLATION); 71 + else 72 + ok_eq_hex(ExceptionStatus, STATUS_SUCCESS); 62 73 63 74 RtlFillMemory(Frames, sizeof(Frames), 0x55); 64 75 Hash = 0x55555555; ··· 157 168 #ifdef NTOS_MODE_USER 158 169 Teb = NtCurrentTeb(); 159 170 #else 160 - Teb = KeGetCurrentThread()->Teb; 171 + Teb = PsGetCurrentThreadTeb(); 161 172 #endif 162 173 ok(Teb != NULL, "Teb is NULL!\n"); 163 174 if (Teb == NULL)