[REACTOS] Fix 64 bit issues

This commit is contained in:
Timo Kreuzer 2018-07-07 16:09:03 +02:00
parent 0f8439aa71
commit cf77354dce
11 changed files with 36 additions and 26 deletions

View file

@ -14,7 +14,7 @@
static BOOL static BOOL
SendTime(SOCKET sock, CHAR *time) SendTime(SOCKET sock, CHAR *time)
{ {
DWORD stringSize = strlen(time) + 1; SIZE_T stringSize = strlen(time) + 1;
if (send(sock, time, stringSize, 0) == SOCKET_ERROR) if (send(sock, time, stringSize, 0) == SOCKET_ERROR)
{ {
LogEvent(L"DayTime: Error sending data", WSAGetLastError(), 0, LOG_ERROR); LogEvent(L"DayTime: Error sending data", WSAGetLastError(), 0, LOG_ERROR);

View file

@ -70,20 +70,20 @@ LogToFile(LPCWSTR lpMsg,
UINT flags) UINT flags)
{ {
LPWSTR lpFullMsg = NULL; LPWSTR lpFullMsg = NULL;
DWORD msgLen; SIZE_T msgLen;
msgLen = wcslen(lpMsg) + 1; msgLen = wcslen(lpMsg) + 1;
if (flags & LOG_ERROR) if (flags & LOG_ERROR)
{ {
LPVOID lpSysMsg; LPWSTR lpSysMsg;
DWORD eMsgLen; DWORD eMsgLen;
eMsgLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, eMsgLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, NULL,
errNum, errNum,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&lpSysMsg, (LPWSTR)&lpSysMsg,
0, 0,
NULL); 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) if (lpFullMsg)
{ {
DWORD bytesWritten; DWORD bytesWritten;
@ -130,7 +137,7 @@ LogToFile(LPCWSTR lpMsg,
bRet = WriteFile(hLogFile, bRet = WriteFile(hLogFile,
lpFullMsg, lpFullMsg,
wcslen(lpFullMsg) * sizeof(WCHAR), (DWORD)msgLen * sizeof(WCHAR),
&bytesWritten, &bytesWritten,
&olWrite); &olWrite);
if (!bRet) if (!bRet)

View file

@ -182,7 +182,7 @@ public:
virtual HRESULT STDMETHODCALLTYPE virtual HRESULT STDMETHODCALLTYPE
InvokeCommand(LPCMINVOKECOMMANDINFO lpici) InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
{ {
UINT uiCmdId = (UINT)lpici->lpVerb; UINT uiCmdId = PtrToUlong(lpici->lpVerb);
if (uiCmdId != 0) if (uiCmdId != 0)
{ {
if ((uiCmdId >= ID_SHELL_CMD_FIRST) && (uiCmdId <= ID_SHELL_CMD_LAST)) if ((uiCmdId >= ID_SHELL_CMD_FIRST) && (uiCmdId <= ID_SHELL_CMD_LAST))

View file

@ -3322,7 +3322,7 @@ public:
virtual HRESULT STDMETHODCALLTYPE virtual HRESULT STDMETHODCALLTYPE
InvokeCommand(LPCMINVOKECOMMANDINFO lpici) InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
{ {
UINT uiCmdId = (UINT) lpici->lpVerb; UINT uiCmdId = PtrToUlong(lpici->lpVerb);
if (uiCmdId != 0) if (uiCmdId != 0)
{ {
if (uiCmdId >= m_idCmdCmFirst) if (uiCmdId >= m_idCmdCmFirst)

View file

@ -1536,9 +1536,9 @@ SmpInitializeKnownDllsInternal(IN PUNICODE_STRING Directory,
/* Checksum failed, so don't even try going further -- kill SMSS */ /* Checksum failed, so don't even try going further -- kill SMSS */
RtlInitUnicodeString(&ErrorResponse, RtlInitUnicodeString(&ErrorResponse,
L"Verification of a KnownDLL failed."); 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)); SmpTerminate(ErrorParameters, 5, RTL_NUMBER_OF(ErrorParameters));
} }
else if (!(ImageCharacteristics & IMAGE_FILE_DLL)) else if (!(ImageCharacteristics & IMAGE_FILE_DLL))
@ -1546,9 +1546,9 @@ SmpInitializeKnownDllsInternal(IN PUNICODE_STRING Directory,
/* An invalid known DLL entry will also kill SMSS */ /* An invalid known DLL entry will also kill SMSS */
RtlInitUnicodeString(&ErrorResponse, RtlInitUnicodeString(&ErrorResponse,
L"Non-DLL file included in KnownDLL list."); 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));
} }

View file

@ -152,8 +152,8 @@ HalpInitDma(VOID)
* Check if Extended DMA is available. We're just going to do a random * Check if Extended DMA is available. We're just going to do a random
* read and write. * read and write.
*/ */
WRITE_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((PUCHAR)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); DPRINT1("Machine supports EISA DMA. Bus type: %lu\n", HalpBusType);
HalpEisaDma = TRUE; 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); ExtendedMode.Byte);
} }
else else
{ {
WRITE_PORT_UCHAR((PUCHAR)FIELD_OFFSET(EISA_CONTROL, DmaExtendedMode2), WRITE_PORT_UCHAR(UlongToPtr(FIELD_OFFSET(EISA_CONTROL, DmaExtendedMode2)),
ExtendedMode.Byte); ExtendedMode.Byte);
} }
} }

View file

@ -231,12 +231,12 @@ HvpInitializeMemoryHive(
SIZE_T ChunkSize; SIZE_T ChunkSize;
ChunkSize = ChunkBase->Length; ChunkSize = ChunkBase->Length;
DPRINT("ChunkSize: %lx\n", ChunkSize); DPRINT("ChunkSize: %zx\n", ChunkSize);
if (ChunkSize < sizeof(HBASE_BLOCK) || if (ChunkSize < sizeof(HBASE_BLOCK) ||
!HvpVerifyHiveHeader(ChunkBase)) !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)); "or HvpVerifyHiveHeader() failed\n", ChunkSize, sizeof(HBASE_BLOCK));
return STATUS_REGISTRY_CORRUPT; return STATUS_REGISTRY_CORRUPT;
} }

View file

@ -166,9 +166,12 @@ KeBugCheckEx(
IN ULONG_PTR BugCheckParameter4) IN ULONG_PTR BugCheckParameter4)
{ {
char Buffer[70]; char Buffer[70];
printf("*** STOP: 0x%08X (0x%08lX, 0x%08lX, 0x%08lX, 0x%08lX)", printf("*** STOP: 0x%08X (0x%p,0x%p,0x%p,0x%p)",
BugCheckCode, BugCheckParameter1, BugCheckParameter2, BugCheckCode,
BugCheckParameter3, BugCheckParameter4); (PVOID)BugCheckParameter1,
(PVOID)BugCheckParameter2,
(PVOID)BugCheckParameter3,
(PVOID)BugCheckParameter4);
ASSERT(FALSE); ASSERT(FALSE);
} }

View file

@ -338,7 +338,7 @@ CsrSrvCreateSharedSection(IN PCHAR ParameterValue)
ULONG Size; ULONG Size;
NTSTATUS Status; NTSTATUS Status;
LARGE_INTEGER SectionSize; LARGE_INTEGER SectionSize;
ULONG ViewSize = 0; SIZE_T ViewSize = 0;
PPEB Peb = NtCurrentPeb(); PPEB Peb = NtCurrentPeb();
/* If there's no parameter, fail */ /* If there's no parameter, fail */
@ -457,7 +457,7 @@ CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
OUT PCSR_API_CONNECTINFO ConnectInfo) OUT PCSR_API_CONNECTINFO ConnectInfo)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG ViewSize = 0; SIZE_T ViewSize = 0;
/* Check if we have a process */ /* Check if we have a process */
if (CsrProcess) if (CsrProcess)

View 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); DRIVER_EXTRA_SIZE);
cbOutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE); cbOutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);

View 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); DeviceExtension->VramSize.LowPart);
/* Initialize the video modes */ /* Initialize the video modes */