https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cf77354dceaa68dbcdf07…
commit cf77354dceaa68dbcdf0713a3a0db8a170a1f881
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Sat Jul 7 16:09:03 2018 +0200
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Sat Aug 4 19:19:34 2018 +0200
[REACTOS] Fix 64 bit issues
---
base/services/tcpsvcs/daytime.c | 2 +-
base/services/tcpsvcs/log.c | 15 +++++++++++----
base/shell/explorer/startctxmnu.cpp | 2 +-
base/shell/explorer/traywnd.cpp | 2 +-
base/system/smss/sminit.c | 8 ++++----
hal/halx86/generic/dma.c | 12 ++++++------
sdk/lib/cmlib/hiveinit.c | 4 ++--
sdk/tools/mkhive/rtl.c | 9 ++++++---
subsystems/win32/csrsrv/server.c | 4 ++--
win32ss/drivers/displays/framebuf_new/enable.c | 2 +-
win32ss/drivers/miniport/vmx_svga/vmx_svga.c | 2 +-
11 files changed, 36 insertions(+), 26 deletions(-)
diff --git a/base/services/tcpsvcs/daytime.c b/base/services/tcpsvcs/daytime.c
index b6e4a46b56..75ca525fc3 100644
--- a/base/services/tcpsvcs/daytime.c
+++ b/base/services/tcpsvcs/daytime.c
@@ -14,7 +14,7 @@
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);
diff --git a/base/services/tcpsvcs/log.c b/base/services/tcpsvcs/log.c
index 2cb0543c32..3b2d467d71 100644
--- a/base/services/tcpsvcs/log.c
+++ b/base/services/tcpsvcs/log.c
@@ -70,20 +70,20 @@ LogToFile(LPCWSTR lpMsg,
UINT flags)
{
LPWSTR lpFullMsg = NULL;
- DWORD msgLen;
+ SIZE_T msgLen;
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),
- (LPTSTR)&lpSysMsg,
+ (LPWSTR)&lpSysMsg,
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;
@@ -130,7 +137,7 @@ LogToFile(LPCWSTR lpMsg,
bRet = WriteFile(hLogFile,
lpFullMsg,
- wcslen(lpFullMsg) * sizeof(WCHAR),
+ (DWORD)msgLen * sizeof(WCHAR),
&bytesWritten,
&olWrite);
if (!bRet)
diff --git a/base/shell/explorer/startctxmnu.cpp b/base/shell/explorer/startctxmnu.cpp
index 590ada5062..ba5b766266 100644
--- a/base/shell/explorer/startctxmnu.cpp
+++ b/base/shell/explorer/startctxmnu.cpp
@@ -182,7 +182,7 @@ public:
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))
diff --git a/base/shell/explorer/traywnd.cpp b/base/shell/explorer/traywnd.cpp
index 8fd6c55f19..63ece92395 100644
--- a/base/shell/explorer/traywnd.cpp
+++ b/base/shell/explorer/traywnd.cpp
@@ -3322,7 +3322,7 @@ public:
virtual HRESULT STDMETHODCALLTYPE
InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
{
- UINT uiCmdId = (UINT) lpici->lpVerb;
+ UINT uiCmdId = PtrToUlong(lpici->lpVerb);
if (uiCmdId != 0)
{
if (uiCmdId >= m_idCmdCmFirst)
diff --git a/base/system/smss/sminit.c b/base/system/smss/sminit.c
index 8fc6ab317d..49141ff2d0 100644
--- a/base/system/smss/sminit.c
+++ b/base/system/smss/sminit.c
@@ -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.");
- ErrorParameters[0] = (ULONG)&ErrorResponse;
+ ErrorParameters[0] = (ULONG_PTR)&ErrorResponse;
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))
@@ -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.");
- ErrorParameters[0] = (ULONG)&ErrorResponse;
+ ErrorParameters[0] = (ULONG_PTR)&ErrorResponse;
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));
}
diff --git a/hal/halx86/generic/dma.c b/hal/halx86/generic/dma.c
index af3d82351f..48748c7d5a 100644
--- a/hal/halx86/generic/dma.c
+++ b/hal/halx86/generic/dma.c
@@ -152,8 +152,8 @@ HalpInitDma(VOID)
* 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;
@@ -479,11 +479,11 @@ HalpDmaInitializeEisaAdapter(IN PADAPTER_OBJECT AdapterObject,
if (Controller == 1)
{
- AdapterBaseVa = (PVOID)FIELD_OFFSET(EISA_CONTROL, DmaController1);
+ AdapterBaseVa = UlongToPtr(FIELD_OFFSET(EISA_CONTROL, DmaController1));
}
else
{
- AdapterBaseVa = (PVOID)FIELD_OFFSET(EISA_CONTROL, DmaController2);
+ AdapterBaseVa = UlongToPtr(FIELD_OFFSET(EISA_CONTROL, DmaController2));
}
AdapterObject->AdapterNumber = Controller;
@@ -517,12 +517,12 @@ HalpDmaInitializeEisaAdapter(IN PADAPTER_OBJECT AdapterObject,
if (Controller == 1)
{
- WRITE_PORT_UCHAR((PUCHAR)FIELD_OFFSET(EISA_CONTROL, DmaExtendedMode1),
+ WRITE_PORT_UCHAR(UlongToPtr(FIELD_OFFSET(EISA_CONTROL, DmaExtendedMode1)),
ExtendedMode.Byte);
}
else
{
- WRITE_PORT_UCHAR((PUCHAR)FIELD_OFFSET(EISA_CONTROL, DmaExtendedMode2),
+ WRITE_PORT_UCHAR(UlongToPtr(FIELD_OFFSET(EISA_CONTROL, DmaExtendedMode2)),
ExtendedMode.Byte);
}
}
diff --git a/sdk/lib/cmlib/hiveinit.c b/sdk/lib/cmlib/hiveinit.c
index 7aab1797de..ba4e784fbc 100644
--- a/sdk/lib/cmlib/hiveinit.c
+++ b/sdk/lib/cmlib/hiveinit.c
@@ -231,12 +231,12 @@ HvpInitializeMemoryHive(
SIZE_T ChunkSize;
ChunkSize = ChunkBase->Length;
- DPRINT("ChunkSize: %lx\n", ChunkSize);
+ DPRINT("ChunkSize: %zx\n", ChunkSize);
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;
}
diff --git a/sdk/tools/mkhive/rtl.c b/sdk/tools/mkhive/rtl.c
index f2c84c7fde..3bef91da9a 100644
--- a/sdk/tools/mkhive/rtl.c
+++ b/sdk/tools/mkhive/rtl.c
@@ -166,9 +166,12 @@ KeBugCheckEx(
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);
}
diff --git a/subsystems/win32/csrsrv/server.c b/subsystems/win32/csrsrv/server.c
index 2ac9ba8cd7..c161bb4166 100644
--- a/subsystems/win32/csrsrv/server.c
+++ b/subsystems/win32/csrsrv/server.c
@@ -338,7 +338,7 @@ CsrSrvCreateSharedSection(IN PCHAR ParameterValue)
ULONG Size;
NTSTATUS Status;
LARGE_INTEGER SectionSize;
- ULONG ViewSize = 0;
+ SIZE_T ViewSize = 0;
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;
- ULONG ViewSize = 0;
+ SIZE_T ViewSize = 0;
/* Check if we have a process */
if (CsrProcess)
diff --git a/win32ss/drivers/displays/framebuf_new/enable.c
b/win32ss/drivers/displays/framebuf_new/enable.c
index 76c06df5ea..f22ef24f76 100644
--- a/win32ss/drivers/displays/framebuf_new/enable.c
+++ b/win32ss/drivers/displays/framebuf_new/enable.c
@@ -456,7 +456,7 @@ DEVMODEW *pdm)
cOutputModes--;
- pdm = (LPDEVMODEW) ( ((ULONG)pdm) + sizeof(DEVMODEW) +
+ pdm = (LPDEVMODEW) ( ((ULONG_PTR)pdm) + sizeof(DEVMODEW) +
DRIVER_EXTRA_SIZE);
cbOutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
diff --git a/win32ss/drivers/miniport/vmx_svga/vmx_svga.c
b/win32ss/drivers/miniport/vmx_svga/vmx_svga.c
index 605c5e5056..0afd883fec 100644
--- a/win32ss/drivers/miniport/vmx_svga/vmx_svga.c
+++ b/win32ss/drivers/miniport/vmx_svga/vmx_svga.c
@@ -125,7 +125,7 @@ VmxFindAdapter(IN PVOID HwDeviceExtension,
}
/* Zero the frame buffer */
- VideoPortZeroMemory((PVOID)DeviceExtension->FrameBuffer.LowPart,
+ VideoPortZeroMemory((PVOID)(ULONG_PTR)DeviceExtension->FrameBuffer.QuadPart,
DeviceExtension->VramSize.LowPart);
/* Initialize the video modes */