[KMTESTS] Fix 64 bit issues
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Mon, 5 Mar 2018 11:07:15 +0000 (12:07 +0100)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sat, 4 Aug 2018 12:39:13 +0000 (14:39 +0200)
modules/rostests/kmtests/ntos_ex/ExDoubleList.c
modules/rostests/kmtests/ntos_ex/ExSingleList.c
modules/rostests/kmtests/ntos_mm/NtCreateSection_user.c
modules/rostests/kmtests/ntos_mm/ZwAllocateVirtualMemory.c
modules/rostests/kmtests/ntos_mm/ZwMapViewOfSection.c
modules/rostests/kmtests/ntos_ob/ObHandle.c
modules/rostests/kmtests/tcpip/connect.c

index c33059c..177e72b 100644 (file)
@@ -27,7 +27,7 @@ LIST_ENTRY Entries[5];
 #define ok_eq_free2(Value, Expected) do              \
 {                                                   \
     if (KmtIsCheckedBuild)                          \
-        ok_eq_pointer(Value, (PVOID)0xBADDD0FF);    \
+        ok_eq_pointer(Value, (PVOID)(ULONG_PTR)0xBADDD0FFBADDD0FFULL);    \
     else                                            \
         ok_eq_pointer(Value, Expected);             \
 } while (0)
index 95671ef..91a1653 100644 (file)
@@ -16,7 +16,7 @@ struct _SINGLE_LIST_ENTRY *__stdcall ExInterlockedPopEntryList(struct _SINGLE_LI
 #define ok_eq_free2(Value, Expected) do              \
 {                                                   \
     if (KmtIsCheckedBuild)                          \
-        ok_eq_pointer(Value, (PVOID)0xBADDD0FF);    \
+        ok_eq_pointer(Value, (PVOID)(ULONG_PTR)0xBADDD0FFBADDD0FFULL);    \
     else                                            \
         ok_eq_pointer(Value, Expected);             \
 } while (0)
index 6c68c45..39cdcd6 100644 (file)
@@ -10,7 +10,7 @@
 START_TEST(NtCreateSection)
 {
     PVOID Buffer;
-    ULONG FileSize;
+    SIZE_T FileSize;
     NTSTATUS Status;
     LARGE_INTEGER MaxFileSize;
     HANDLE Handle, SectionHandle;
index 52e973d..e8188de 100644 (file)
@@ -105,7 +105,7 @@ SimpleErrorChecks(VOID)
     //HANDLE TESTS
     ALLOC_MEMORY_WITH_FREE(NtCurrentProcess(), Base, 0, RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS);
     ALLOC_MEMORY_WITH_FREE(NULL, Base, 0, RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_READWRITE, STATUS_INVALID_HANDLE, STATUS_INVALID_HANDLE);
-    ALLOC_MEMORY_WITH_FREE((HANDLE)0xdeadbeef, Base, 0, RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_READWRITE, STATUS_INVALID_HANDLE, STATUS_INVALID_HANDLE);
+    ALLOC_MEMORY_WITH_FREE((HANDLE)(ULONG_PTR)0xDEADBEEFDEADBEEFull, Base, 0, RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_READWRITE, STATUS_INVALID_HANDLE, STATUS_INVALID_HANDLE);
 
     //BASE ADDRESS TESTS
     Base = (PVOID)0x00567A20;
index ee8b494..b6e6146 100644 (file)
@@ -124,31 +124,31 @@ SimpleErrorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly, HANDLE
 
     //section handle
     TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS);
-    TestMapView((HANDLE)0xDEADBEEF, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_HANDLE, IGNORE);
+    TestMapView((HANDLE)(ULONG_PTR)0xDEADBEEFDEADBEEFull, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_HANDLE, IGNORE);
     TestMapView(INVALID_HANDLE_VALUE, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_OBJECT_TYPE_MISMATCH, IGNORE);
     TestMapView(NULL, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_HANDLE, IGNORE);
 
     //process handle
-    TestMapView(WriteSectionHandle, (HANDLE)0xDEADBEEF, &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_HANDLE, IGNORE);
+    TestMapView(WriteSectionHandle, (HANDLE)(ULONG_PTR)0xDEADBEEFDEADBEEFull, &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_HANDLE, IGNORE);
     TestMapView(WriteSectionHandle, (HANDLE)NULL, &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_HANDLE, IGNORE);
 
     //base address
-    BaseAddress = (PVOID)0x00567A20;
+    BaseAddress = (PVOID)(ULONG_PTR)0x00567A20;
     TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_MAPPED_ALIGNMENT, IGNORE);
 
-    BaseAddress = (PVOID) 0x60000000;
+    BaseAddress = (PVOID)(ULONG_PTR)0x60000000;
     TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS);
 
     BaseAddress = (PVOID)((char *)MmSystemRangeStart + 200);
     TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_PARAMETER_3, IGNORE);
 
     //invalid section handle AND unaligned base address
-    BaseAddress = (PVOID)0x00567A20;
-    TestMapView((HANDLE)0xDEADBEEF, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_HANDLE, IGNORE);
+    BaseAddress = (PVOID)(ULONG_PTR)0x00567A20;
+    TestMapView((HANDLE)(ULONG_PTR)0xDEADBEEFDEADBEEFull, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_HANDLE, IGNORE);
 
     //invalid process handle AND unaligned base address
-    BaseAddress = (PVOID)0x00567A20;
-    TestMapView(WriteSectionHandle, (HANDLE)0xDEADBEEF, &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_HANDLE, IGNORE);
+    BaseAddress = (PVOID)(ULONG_PTR)0x00567A20;
+    TestMapView(WriteSectionHandle, (HANDLE)(ULONG_PTR)0xDEADBEEFDEADBEEFull, &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_HANDLE, IGNORE);
 
     //try mapping section to an already mapped address
     Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &AllocBase, 0, &AllocSize, MEM_COMMIT, PAGE_READWRITE);
index 2b659df..bd1dd51 100644 (file)
@@ -184,19 +184,19 @@ START_TEST(ObHandle)
         Status = NtClose(NULL);
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         DPRINT("Closing null kernel handle (NtClose)\n");
-        Status = NtClose((HANDLE)0x80000000);
+        Status = NtClose(LongToHandle(0x80000000));
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         DPRINT("Closing -1 handle (NtClose)\n");
-        Status = NtClose((HANDLE)0x7FFFFFFF);
+        Status = NtClose(LongToHandle(0x7FFFFFFF));
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         DPRINT("Closing -1 kernel handle (NtClose)\n");
-        Status = NtClose((HANDLE)0xFFFFFFFF);
+        Status = NtClose(LongToHandle(0xFFFFFFFF));
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         DPRINT("Closing 123 handle (NtClose)\n");
-        Status = NtClose((HANDLE)123);
+        Status = NtClose(LongToHandle(123));
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         DPRINT("Closing 123 kernel handle (NtClose)\n");
-        Status = NtClose((HANDLE)(123 | 0x80000000));
+        Status = NtClose(LongToHandle(123 | 0x80000000));
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
 
         /* ObCloseHandle with UserMode accepts everything */
@@ -204,19 +204,19 @@ START_TEST(ObHandle)
         Status = ObCloseHandle(NULL, UserMode);
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         DPRINT("Closing null kernel handle (ObCloseHandle, UserMode)\n");
-        Status = ObCloseHandle((HANDLE)0x80000000, UserMode);
+        Status = ObCloseHandle(LongToHandle(0x80000000), UserMode);
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         DPRINT("Closing -1 handle (ObCloseHandle, UserMode)\n");
-        Status = ObCloseHandle((HANDLE)0x7FFFFFFF, UserMode);
+        Status = ObCloseHandle(LongToHandle(0x7FFFFFFF), UserMode);
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         DPRINT("Closing -1 kernel handle (ObCloseHandle, UserMode)\n");
-        Status = ObCloseHandle((HANDLE)0xFFFFFFFF, UserMode);
+        Status = ObCloseHandle(LongToHandle(0xFFFFFFFF), UserMode);
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         DPRINT("Closing 123 handle (ObCloseHandle, UserMode)\n");
-        Status = ObCloseHandle((HANDLE)123, UserMode);
+        Status = ObCloseHandle(LongToHandle(123), UserMode);
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         DPRINT("Closing 123 kernel handle (ObCloseHandle, UserMode)\n");
-        Status = ObCloseHandle((HANDLE)(123 | 0x80000000), UserMode);
+        Status = ObCloseHandle(LongToHandle(123 | 0x80000000), UserMode);
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
 
         /* ZwClose only accepts 0 and -1 */
@@ -224,32 +224,32 @@ START_TEST(ObHandle)
         Status = ZwClose(NULL);
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         DPRINT("Closing null kernel handle (ZwClose)\n");
-        Status = ZwClose((HANDLE)0x80000000);
+        Status = ZwClose(LongToHandle(0x80000000));
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         /* INVALID_KERNEL_HANDLE, 0x7FFFFFFF
         Status = ZwClose((HANDLE)0x7FFFFFFF);*/
         DPRINT("Closing -1 kernel handle (ZwClose)\n");
-        Status = ZwClose((HANDLE)0xFFFFFFFF);
+        Status = ZwClose(LongToHandle(0xFFFFFFFF));
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         /* INVALID_KERNEL_HANDLE, 0x7B, 1, 0, 0
-        Status = ZwClose((HANDLE)123);
-        Status = ZwClose((HANDLE)(123 | 0x80000000));*/
+        Status = ZwClose(LongToHandle(123));
+        Status = ZwClose(LongToHandle(123 | 0x80000000));*/
 
         /* ObCloseHandle with KernelMode accepts only 0 and -1 */
         DPRINT("Closing null handle (ObCloseHandle, KernelMode)\n");
         Status = ObCloseHandle(NULL, KernelMode);
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         DPRINT("Closing null kernel handle (ObCloseHandle, KernelMode)\n");
-        Status = ObCloseHandle((HANDLE)0x80000000, KernelMode);
+        Status = ObCloseHandle(LongToHandle(0x80000000), KernelMode);
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         /* INVALID_KERNEL_HANDLE, 0x7FFFFFFF, 1, 0, 0
         Status = ObCloseHandle((HANDLE)0x7FFFFFFF, KernelMode);*/
         DPRINT("Closing -1 kernel handle (ObCloseHandle, KernelMode)\n");
-        Status = ObCloseHandle((HANDLE)0xFFFFFFFF, KernelMode);
+        Status = ObCloseHandle(LongToHandle(0xFFFFFFFF), KernelMode);
         ok_eq_hex(Status, STATUS_INVALID_HANDLE);
         /* INVALID_KERNEL_HANDLE, 0x7B, 1, 0, 0
-        Status = ObCloseHandle((HANDLE)123, KernelMode);
-        Status = ObCloseHandle((HANDLE)(123 | 0x80000000), KernelMode);*/
+        Status = ObCloseHandle(LongToHandle(123), KernelMode);
+        Status = ObCloseHandle(LongToHandle(123 | 0x80000000), KernelMode);*/
     KmtEndSeh(STATUS_SUCCESS);
 
     if (SystemProcessHandle)
index d548a63..89fc758 100644 (file)
@@ -59,7 +59,7 @@ TestTcpConnect(void)
     ULONG FileInfoSize;
     IN_ADDR InAddr;
     LPCWSTR AddressTerminator;
-    CONNECTION_CONTEXT ConnectionContext = (CONNECTION_CONTEXT)0xC0CAC01A;
+    CONNECTION_CONTEXT ConnectionContext = (CONNECTION_CONTEXT)(ULONG_PTR)0xC0CAC01AC0CAC01AULL;
     KEVENT Event;
     TDI_CONNECTION_INFORMATION RequestInfo, ReturnInfo;