[REACTOS] Fix 64 bit issues
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sat, 7 Jul 2018 14:09:03 +0000 (16:09 +0200)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sat, 4 Aug 2018 17:19:34 +0000 (19:19 +0200)
base/services/tcpsvcs/daytime.c
base/services/tcpsvcs/log.c
base/shell/explorer/startctxmnu.cpp
base/shell/explorer/traywnd.cpp
base/system/smss/sminit.c
hal/halx86/generic/dma.c
sdk/lib/cmlib/hiveinit.c
sdk/tools/mkhive/rtl.c
subsystems/win32/csrsrv/server.c
win32ss/drivers/displays/framebuf_new/enable.c
win32ss/drivers/miniport/vmx_svga/vmx_svga.c

index b6e4a46..75ca525 100644 (file)
@@ -14,7 +14,7 @@
 static BOOL
 SendTime(SOCKET sock, CHAR *time)
 {
 static BOOL
 SendTime(SOCKET sock, CHAR *time)
 {
-    DWORD stringSize = strlen(time) + 1;
+    SIZE_T stringSize = strlen(time) + 1;
     if (send(sock, time, stringSize, 0) == SOCKET_ERROR)
     {
         LogEvent(L"DayTime: Error sending data", WSAGetLastError(), 0, LOG_ERROR);
     if (send(sock, time, stringSize, 0) == SOCKET_ERROR)
     {
         LogEvent(L"DayTime: Error sending data", WSAGetLastError(), 0, LOG_ERROR);
index 2cb0543..3b2d467 100644 (file)
@@ -70,20 +70,20 @@ LogToFile(LPCWSTR lpMsg,
           UINT flags)
 {
     LPWSTR lpFullMsg = NULL;
           UINT flags)
 {
     LPWSTR lpFullMsg = NULL;
-    DWORD msgLen;
+    SIZE_T msgLen;
 
     msgLen = wcslen(lpMsg) + 1;
 
     if (flags & LOG_ERROR)
     {
 
     msgLen = wcslen(lpMsg) + 1;
 
     if (flags & LOG_ERROR)
     {
-        LPVOID lpSysMsg;
+        LPWSTR lpSysMsg;
         DWORD eMsgLen;
 
         eMsgLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
                                  NULL,
                                  errNum,
                                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
         DWORD eMsgLen;
 
         eMsgLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
                                  NULL,
                                  errNum,
                                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                                 (LPTSTR)&lpSysMsg,
+                                 (LPWSTR)&lpSysMsg,
                                  0,
                                  NULL);
 
                                  0,
                                  NULL);
 
@@ -122,6 +122,13 @@ LogToFile(LPCWSTR lpMsg,
         }
     }
 
         }
     }
 
+    /* Make sure the length in bytes doesn't overflow a DWORD */
+    msgLen = wcslen(lpFullMsg);
+    if (msgLen > (MAXDWORD / sizeof(WCHAR)))
+    {
+        RaiseException(EXCEPTION_INT_OVERFLOW, 0, 0, NULL);
+    }
+
     if (lpFullMsg)
     {
         DWORD bytesWritten;
     if (lpFullMsg)
     {
         DWORD bytesWritten;
@@ -130,7 +137,7 @@ LogToFile(LPCWSTR lpMsg,
 
         bRet = WriteFile(hLogFile,
                          lpFullMsg,
 
         bRet = WriteFile(hLogFile,
                          lpFullMsg,
-                         wcslen(lpFullMsg) * sizeof(WCHAR),
+                         (DWORD)msgLen * sizeof(WCHAR),
                          &bytesWritten,
                          &olWrite);
         if (!bRet)
                          &bytesWritten,
                          &olWrite);
         if (!bRet)
index 590ada5..ba5b766 100644 (file)
@@ -182,7 +182,7 @@ public:
     virtual HRESULT STDMETHODCALLTYPE
         InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
     {
     virtual HRESULT STDMETHODCALLTYPE
         InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
     {
-        UINT uiCmdId = (UINT)lpici->lpVerb;
+        UINT uiCmdId = PtrToUlong(lpici->lpVerb);
         if (uiCmdId != 0)
         {
             if ((uiCmdId >= ID_SHELL_CMD_FIRST) && (uiCmdId <= ID_SHELL_CMD_LAST))
         if (uiCmdId != 0)
         {
             if ((uiCmdId >= ID_SHELL_CMD_FIRST) && (uiCmdId <= ID_SHELL_CMD_LAST))
index 8fd6c55..63ece92 100644 (file)
@@ -3322,7 +3322,7 @@ public:
     virtual HRESULT STDMETHODCALLTYPE
         InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
     {
     virtual HRESULT STDMETHODCALLTYPE
         InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
     {
-        UINT uiCmdId = (UINT) lpici->lpVerb;
+        UINT uiCmdId = PtrToUlong(lpici->lpVerb);
         if (uiCmdId != 0)
         {
             if (uiCmdId >= m_idCmdCmFirst)
         if (uiCmdId != 0)
         {
             if (uiCmdId >= m_idCmdCmFirst)
index 8fc6ab3..49141ff 100644 (file)
@@ -1536,9 +1536,9 @@ SmpInitializeKnownDllsInternal(IN PUNICODE_STRING Directory,
             /* Checksum failed, so don't even try going further -- kill SMSS */
             RtlInitUnicodeString(&ErrorResponse,
                                  L"Verification of a KnownDLL failed.");
             /* Checksum failed, so don't even try going further -- kill SMSS */
             RtlInitUnicodeString(&ErrorResponse,
                                  L"Verification of a KnownDLL failed.");
-            ErrorParameters[0] = (ULONG)&ErrorResponse;
+            ErrorParameters[0] = (ULONG_PTR)&ErrorResponse;
             ErrorParameters[1] = Status;
             ErrorParameters[1] = Status;
-            ErrorParameters[2] = (ULONG)&RegEntry->Value;
+            ErrorParameters[2] = (ULONG_PTR)&RegEntry->Value;
             SmpTerminate(ErrorParameters, 5, RTL_NUMBER_OF(ErrorParameters));
         }
         else if (!(ImageCharacteristics & IMAGE_FILE_DLL))
             SmpTerminate(ErrorParameters, 5, RTL_NUMBER_OF(ErrorParameters));
         }
         else if (!(ImageCharacteristics & IMAGE_FILE_DLL))
@@ -1546,9 +1546,9 @@ SmpInitializeKnownDllsInternal(IN PUNICODE_STRING Directory,
             /* An invalid known DLL entry will also kill SMSS */
             RtlInitUnicodeString(&ErrorResponse,
                                  L"Non-DLL file included in KnownDLL list.");
             /* An invalid known DLL entry will also kill SMSS */
             RtlInitUnicodeString(&ErrorResponse,
                                  L"Non-DLL file included in KnownDLL list.");
-            ErrorParameters[0] = (ULONG)&ErrorResponse;
+            ErrorParameters[0] = (ULONG_PTR)&ErrorResponse;
             ErrorParameters[1] = STATUS_INVALID_IMPORT_OF_NON_DLL;
             ErrorParameters[1] = STATUS_INVALID_IMPORT_OF_NON_DLL;
-            ErrorParameters[2] = (ULONG)&RegEntry->Value;
+            ErrorParameters[2] = (ULONG_PTR)&RegEntry->Value;
             SmpTerminate(ErrorParameters, 5, RTL_NUMBER_OF(ErrorParameters));
         }
 
             SmpTerminate(ErrorParameters, 5, RTL_NUMBER_OF(ErrorParameters));
         }
 
index af3d823..48748c7 100644 (file)
@@ -152,8 +152,8 @@ HalpInitDma(VOID)
         * Check if Extended DMA is available. We're just going to do a random
         * read and write.
         */
         * Check if Extended DMA is available. We're just going to do a random
         * read and write.
         */
-        WRITE_PORT_UCHAR((PUCHAR)FIELD_OFFSET(EISA_CONTROL, DmaController2Pages.Channel2), 0x2A);
-        if (READ_PORT_UCHAR((PUCHAR)FIELD_OFFSET(EISA_CONTROL, DmaController2Pages.Channel2)) == 0x2A)
+        WRITE_PORT_UCHAR(UlongToPtr(FIELD_OFFSET(EISA_CONTROL, DmaController2Pages.Channel2)), 0x2A);
+        if (READ_PORT_UCHAR(UlongToPtr(FIELD_OFFSET(EISA_CONTROL, DmaController2Pages.Channel2))) == 0x2A)
         {
             DPRINT1("Machine supports EISA DMA. Bus type: %lu\n", HalpBusType);
             HalpEisaDma = TRUE;
         {
             DPRINT1("Machine supports EISA DMA. Bus type: %lu\n", HalpBusType);
             HalpEisaDma = TRUE;
@@ -479,11 +479,11 @@ HalpDmaInitializeEisaAdapter(IN PADAPTER_OBJECT AdapterObject,
 
     if (Controller == 1)
     {
 
     if (Controller == 1)
     {
-        AdapterBaseVa = (PVOID)FIELD_OFFSET(EISA_CONTROL, DmaController1);
+        AdapterBaseVa = UlongToPtr(FIELD_OFFSET(EISA_CONTROL, DmaController1));
     }
     else
     {
     }
     else
     {
-        AdapterBaseVa = (PVOID)FIELD_OFFSET(EISA_CONTROL, DmaController2);
+        AdapterBaseVa = UlongToPtr(FIELD_OFFSET(EISA_CONTROL, DmaController2));
     }
 
     AdapterObject->AdapterNumber = Controller;
     }
 
     AdapterObject->AdapterNumber = Controller;
@@ -517,12 +517,12 @@ HalpDmaInitializeEisaAdapter(IN PADAPTER_OBJECT AdapterObject,
 
         if (Controller == 1)
         {
 
         if (Controller == 1)
         {
-            WRITE_PORT_UCHAR((PUCHAR)FIELD_OFFSET(EISA_CONTROL, DmaExtendedMode1),
+            WRITE_PORT_UCHAR(UlongToPtr(FIELD_OFFSET(EISA_CONTROL, DmaExtendedMode1)),
                             ExtendedMode.Byte);
         }
         else
         {
                             ExtendedMode.Byte);
         }
         else
         {
-            WRITE_PORT_UCHAR((PUCHAR)FIELD_OFFSET(EISA_CONTROL, DmaExtendedMode2),
+            WRITE_PORT_UCHAR(UlongToPtr(FIELD_OFFSET(EISA_CONTROL, DmaExtendedMode2)),
                             ExtendedMode.Byte);
         }
     }
                             ExtendedMode.Byte);
         }
     }
index 7aab179..ba4e784 100644 (file)
@@ -231,12 +231,12 @@ HvpInitializeMemoryHive(
     SIZE_T ChunkSize;
 
     ChunkSize = ChunkBase->Length;
     SIZE_T ChunkSize;
 
     ChunkSize = ChunkBase->Length;
-    DPRINT("ChunkSize: %lx\n", ChunkSize);
+    DPRINT("ChunkSize: %zx\n", ChunkSize);
 
     if (ChunkSize < sizeof(HBASE_BLOCK) ||
         !HvpVerifyHiveHeader(ChunkBase))
     {
 
     if (ChunkSize < sizeof(HBASE_BLOCK) ||
         !HvpVerifyHiveHeader(ChunkBase))
     {
-        DPRINT1("Registry is corrupt: ChunkSize %lu < sizeof(HBASE_BLOCK) %lu, "
+        DPRINT1("Registry is corrupt: ChunkSize 0x%zx < sizeof(HBASE_BLOCK) 0x%zx, "
                 "or HvpVerifyHiveHeader() failed\n", ChunkSize, sizeof(HBASE_BLOCK));
         return STATUS_REGISTRY_CORRUPT;
     }
                 "or HvpVerifyHiveHeader() failed\n", ChunkSize, sizeof(HBASE_BLOCK));
         return STATUS_REGISTRY_CORRUPT;
     }
index f2c84c7..3bef91d 100644 (file)
@@ -166,9 +166,12 @@ KeBugCheckEx(
     IN ULONG_PTR BugCheckParameter4)
 {
     char Buffer[70];
     IN ULONG_PTR BugCheckParameter4)
 {
     char Buffer[70];
-    printf("*** STOP: 0x%08X (0x%08lX, 0x%08lX, 0x%08lX, 0x%08lX)",
-           BugCheckCode, BugCheckParameter1, BugCheckParameter2,
-           BugCheckParameter3, BugCheckParameter4);
+    printf("*** STOP: 0x%08X (0x%p,0x%p,0x%p,0x%p)",
+           BugCheckCode,
+           (PVOID)BugCheckParameter1,
+           (PVOID)BugCheckParameter2,
+           (PVOID)BugCheckParameter3,
+           (PVOID)BugCheckParameter4);
     ASSERT(FALSE);
 }
 
     ASSERT(FALSE);
 }
 
index 2ac9ba8..c161bb4 100644 (file)
@@ -338,7 +338,7 @@ CsrSrvCreateSharedSection(IN PCHAR ParameterValue)
     ULONG Size;
     NTSTATUS Status;
     LARGE_INTEGER SectionSize;
     ULONG Size;
     NTSTATUS Status;
     LARGE_INTEGER SectionSize;
-    ULONG ViewSize = 0;
+    SIZE_T ViewSize = 0;
     PPEB Peb = NtCurrentPeb();
 
     /* If there's no parameter, fail */
     PPEB Peb = NtCurrentPeb();
 
     /* If there's no parameter, fail */
@@ -457,7 +457,7 @@ CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
                           OUT PCSR_API_CONNECTINFO ConnectInfo)
 {
     NTSTATUS Status;
                           OUT PCSR_API_CONNECTINFO ConnectInfo)
 {
     NTSTATUS Status;
-    ULONG ViewSize = 0;
+    SIZE_T ViewSize = 0;
 
     /* Check if we have a process */
     if (CsrProcess)
 
     /* Check if we have a process */
     if (CsrProcess)
index 76c06df..f22ef24 100644 (file)
@@ -456,7 +456,7 @@ DEVMODEW *pdm)
 
                 cOutputModes--;
 
 
                 cOutputModes--;
 
-                pdm = (LPDEVMODEW) ( ((ULONG)pdm) + sizeof(DEVMODEW) +
+                pdm = (LPDEVMODEW) ( ((ULONG_PTR)pdm) + sizeof(DEVMODEW) +
                                                    DRIVER_EXTRA_SIZE);
 
                 cbOutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
                                                    DRIVER_EXTRA_SIZE);
 
                 cbOutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
index 605c5e5..0afd883 100644 (file)
@@ -125,7 +125,7 @@ VmxFindAdapter(IN PVOID HwDeviceExtension,
     }
 
     /* Zero the frame buffer */
     }
 
     /* Zero the frame buffer */
-    VideoPortZeroMemory((PVOID)DeviceExtension->FrameBuffer.LowPart,
+    VideoPortZeroMemory((PVOID)(ULONG_PTR)DeviceExtension->FrameBuffer.QuadPart,
                         DeviceExtension->VramSize.LowPart);
 
     /* Initialize the video modes */
                         DeviceExtension->VramSize.LowPart);
 
     /* Initialize the video modes */