diff --git a/modules/rostests/kmtests/include/kmt_test.h b/modules/rostests/kmtests/include/kmt_test.h index 8c38b73d9c9..0d146aceeb7 100644 --- a/modules/rostests/kmtests/include/kmt_test.h +++ b/modules/rostests/kmtests/include/kmt_test.h @@ -282,16 +282,22 @@ VOID KmtFreeGuarded(PVOID Pointer); _SEH2_TRY \ { -#define KmtEndSeh(ExpectedStatus) \ +#define KmtEndSeh_(Line, ExpectedStatus) \ } \ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) \ { \ ExceptionStatus = _SEH2_GetExceptionCode(); \ } \ _SEH2_END; \ - ok_eq_hex(ExceptionStatus, (ExpectedStatus)); \ + KmtOk((ExceptionStatus) == (ExpectedStatus), \ + __FILE__ ":" #Line ":", \ + "ExceptionStatus = 0x%08lx, expected " \ + #ExpectedStatus " (0x%08lx)\n", \ + ExceptionStatus, ExpectedStatus); \ } +#define KmtEndSeh(ExpectedStatus) KmtEndSeh_(__LINE__, ExpectedStatus) + #define KmtGetSystemOrEmbeddedRoutineAddress(RoutineName) \ p##RoutineName = KmtGetSystemRoutineAddress(L ## #RoutineName); \ if (!p##RoutineName) \ diff --git a/modules/rostests/kmtests/ntos_mm/ZwAllocateVirtualMemory.c b/modules/rostests/kmtests/ntos_mm/ZwAllocateVirtualMemory.c index e8188dedfef..de4434c4239 100644 --- a/modules/rostests/kmtests/ntos_mm/ZwAllocateVirtualMemory.c +++ b/modules/rostests/kmtests/ntos_mm/ZwAllocateVirtualMemory.c @@ -39,8 +39,8 @@ typedef struct _TEST_CONTEXT else if (!NT_SUCCESS(Status)) \ ok_eq_pointer(BaseAddress, NULL); \ RegionSize = 0; \ - Status = ZwFreeVirtualMemory(ProcessHandle, &BaseAddress, &RegionSize, MEM_RELEASE); \ - if (FreeStatus != IGNORE) ok_eq_hex(Status, FreeStatus); \ + Status2 = ZwFreeVirtualMemory(ProcessHandle, &BaseAddress, &RegionSize, MEM_RELEASE); \ + if (FreeStatus != IGNORE) ok_eq_hex(Status2, FreeStatus); \ BaseAddress = NULL; \ RegionSize = DEFAULT_ALLOC_SIZE; \ } while (0) \ @@ -67,38 +67,44 @@ CheckBuffer(PVOID Buffer, SIZE_T Size, UCHAR Value) static SIZE_T -CheckBufferRead(CONST VOID *Source, CONST VOID *Destination, SIZE_T Length, NTSTATUS ExpectedStatus) +CheckBufferRead_(ULONG Line, CONST VOID *Source, CONST VOID *Destination, SIZE_T Length, NTSTATUS ExpectedStatus) { SIZE_T Match = 0; KmtStartSeh() Match = RtlCompareMemory(Source, Destination, Length); - KmtEndSeh(ExpectedStatus); + KmtEndSeh_(Line, ExpectedStatus); return Match; } +#define CheckBufferRead(Source, Destination, Length, ExpectedStatus) \ + CheckBufferRead_(__LINE__, Source, Destination, Length, ExpectedStatus) + static VOID -CheckBufferReadWrite(PVOID Destination, CONST VOID *Source, SIZE_T Length, NTSTATUS ExpectedStatus) +CheckBufferReadWrite_(ULONG Line, PVOID Destination, CONST VOID *Source, SIZE_T Length, NTSTATUS ExpectedStatus) { //do a little bit of writing/reading to memory SIZE_T Match = 0; KmtStartSeh() RtlCopyMemory(Destination, Source, Length); - KmtEndSeh(ExpectedStatus); + KmtEndSeh_(Line, ExpectedStatus); Match = CheckBufferRead(Source, Destination, Length, ExpectedStatus); if (ExpectedStatus == STATUS_SUCCESS) ok_eq_int(Match, Length); + if (ExpectedStatus == STATUS_SUCCESS && Match != Length) ok_eq_int(Line, 0); } +#define CheckBufferReadWrite(Destination, Source, Length, ExpectedStatus) \ + CheckBufferReadWrite_(__LINE__, Destination, Source, Length, ExpectedStatus) static VOID SimpleErrorChecks(VOID) { - NTSTATUS Status; + NTSTATUS Status, Status2; PVOID Base = NULL; SIZE_T RegionSize = DEFAULT_ALLOC_SIZE;