[REACTOS] Fix misc 64 bit issues (#783)

* [WIN32K] Fix handle calculation in DbgGdiHTIntegrityCheck
* [NOTEPAD] Fix MSVC warnings
* [PSDK] Simplify *PROC definitions in windef.h
* [VIDEOPRT] Don't try to use NtVdmControl on x64
* [FREELDR] Fix some macros
* [CRT] Make qsort 64 bit compatible
* [NTOS] Use #ifndef _WIN64 instead of #ifdef _M_IX86 around C_ASSERTs
* [FAST486] Fix 64 bit warnings and change DWORD to ULONG, so it can be used in kernel mode
* [APPHELP_APITEST] Fix 64 bit issue
This commit is contained in:
Timo Kreuzer 2019-01-05 10:50:11 +01:00 committed by GitHub
parent d67156fa98
commit cfd1647914
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 54 additions and 42 deletions

View file

@ -445,7 +445,7 @@ ata_str_to_mode(
) )
{ {
int mode; int mode;
int len; size_t len;
if(!_stricmp(str, "SATA600")) if(!_stricmp(str, "SATA600"))
return ATA_SA600; return ATA_SA600;
@ -1688,7 +1688,8 @@ main (
) )
{ {
//ULONG Flags = 0; //ULONG Flags = 0;
int i, j; int i;
uintptr_t j;
char a; char a;
int bus_id = -1; int bus_id = -1;
int dev_id = -1; int dev_id = -1;

View file

@ -1095,7 +1095,7 @@ DIALOG_GoTo_DialogProc(HWND hwndDialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
switch(uMsg) { switch(uMsg) {
case WM_INITDIALOG: case WM_INITDIALOG:
hTextBox = GetDlgItem(hwndDialog, ID_LINENUMBER); hTextBox = GetDlgItem(hwndDialog, ID_LINENUMBER);
_sntprintf(szText, ARRAY_SIZE(szText), _T("%ld"), lParam); _sntprintf(szText, ARRAY_SIZE(szText), _T("%Id"), lParam);
SetWindowText(hTextBox, szText); SetWindowText(hTextBox, szText);
break; break;
case WM_COMMAND: case WM_COMMAND:

View file

@ -42,10 +42,6 @@ typedef enum
ENCODING_UTF16BE = 2, ENCODING_UTF16BE = 2,
ENCODING_UTF8 = 3 ENCODING_UTF8 = 3
} ENCODING; } ENCODING;
// #define ENCODING_ANSI 0
#define ENCODING_UNICODE 1
#define ENCODING_UNICODE_BE 2
// #define ENCODING_UTF8 3
// #define MIN_ENCODING 0 // #define MIN_ENCODING 0
// #define MAX_ENCODING 3 // #define MAX_ENCODING 3

View file

@ -85,12 +85,12 @@ ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, ENCODING *pencFile,
/* Look for Byte Order Marks */ /* Look for Byte Order Marks */
if ((dwSize >= 2) && (pBytes[0] == 0xFF) && (pBytes[1] == 0xFE)) if ((dwSize >= 2) && (pBytes[0] == 0xFF) && (pBytes[1] == 0xFE))
{ {
encFile = ENCODING_UNICODE; encFile = ENCODING_UTF16LE;
dwPos += 2; dwPos += 2;
} }
else if ((dwSize >= 2) && (pBytes[0] == 0xFE) && (pBytes[1] == 0xFF)) else if ((dwSize >= 2) && (pBytes[0] == 0xFE) && (pBytes[1] == 0xFF))
{ {
encFile = ENCODING_UNICODE_BE; encFile = ENCODING_UTF16BE;
dwPos += 2; dwPos += 2;
} }
else if ((dwSize >= 3) && (pBytes[0] == 0xEF) && (pBytes[1] == 0xBB) && (pBytes[2] == 0xBF)) else if ((dwSize >= 3) && (pBytes[0] == 0xEF) && (pBytes[1] == 0xBB) && (pBytes[2] == 0xBF))
@ -101,7 +101,7 @@ ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, ENCODING *pencFile,
switch(encFile) switch(encFile)
{ {
case ENCODING_UNICODE_BE: case ENCODING_UTF16BE:
for (i = dwPos; i < dwSize-1; i += 2) for (i = dwPos; i < dwSize-1; i += 2)
{ {
b = pBytes[i+0]; b = pBytes[i+0];
@ -110,7 +110,7 @@ ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, ENCODING *pencFile,
} }
/* fall through */ /* fall through */
case ENCODING_UNICODE: case ENCODING_UTF16LE:
pszText = (LPWSTR) &pBytes[dwPos]; pszText = (LPWSTR) &pBytes[dwPos];
dwCharCount = (dwSize - dwPos) / sizeof(WCHAR); dwCharCount = (dwSize - dwPos) / sizeof(WCHAR);
break; break;
@ -239,13 +239,13 @@ static BOOL WriteEncodedText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENC
{ {
switch(encFile) switch(encFile)
{ {
case ENCODING_UNICODE: case ENCODING_UTF16LE:
pBytes = (LPBYTE) &pszText[dwPos]; pBytes = (LPBYTE) &pszText[dwPos];
dwByteCount = (dwTextLen - dwPos) * sizeof(WCHAR); dwByteCount = (dwTextLen - dwPos) * sizeof(WCHAR);
dwPos = dwTextLen; dwPos = dwTextLen;
break; break;
case ENCODING_UNICODE_BE: case ENCODING_UTF16BE:
dwByteCount = (dwTextLen - dwPos) * sizeof(WCHAR); dwByteCount = (dwTextLen - dwPos) * sizeof(WCHAR);
if (dwByteCount > sizeof(buffer)) if (dwByteCount > sizeof(buffer))
dwByteCount = sizeof(buffer); dwByteCount = sizeof(buffer);

View file

@ -31,10 +31,10 @@
#define PtrToPfn(p) \ #define PtrToPfn(p) \
((((ULONGLONG)p) >> PAGE_SHIFT) & 0xfffffffULL) ((((ULONGLONG)p) >> PAGE_SHIFT) & 0xfffffffULL)
#define VAtoPXI(va) ((((ULONG64)va) >> PXI_SHIFT) & 0x1FF) #define VAtoPXI(va) ((((ULONG64)(va)) >> PXI_SHIFT) & 0x1FF)
#define VAtoPPI(va) ((((ULONG64)va) >> PPI_SHIFT) & 0x1FF) #define VAtoPPI(va) ((((ULONG64)(va)) >> PPI_SHIFT) & 0x1FF)
#define VAtoPDI(va) ((((ULONG64)va) >> PDI_SHIFT) & 0x1FF) #define VAtoPDI(va) ((((ULONG64)(va)) >> PDI_SHIFT) & 0x1FF)
#define VAtoPTI(va) ((((ULONG64)va) >> PTI_SHIFT) & 0x1FF) #define VAtoPTI(va) ((((ULONG64)(va)) >> PTI_SHIFT) & 0x1FF)
#ifndef ASM #ifndef ASM

View file

@ -32,7 +32,7 @@ static HRESULT __stdcall Volume_FindMixerControl(CSysTray * pSysTray)
TRACE("Volume_FindDefaultMixerID\n"); TRACE("Volume_FindDefaultMixerID\n");
result = waveOutMessage((HWAVEOUT)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&waveOutId, (DWORD_PTR)&param2); result = waveOutMessage((HWAVEOUT)UlongToHandle(WAVE_MAPPER), DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&waveOutId, (DWORD_PTR)&param2);
if (result) if (result)
return E_FAIL; return E_FAIL;
@ -46,7 +46,7 @@ static HRESULT __stdcall Volume_FindMixerControl(CSysTray * pSysTray)
{ {
TRACE("waveOut default device is %d\n", waveOutId); TRACE("waveOut default device is %d\n", waveOutId);
result = mixerGetID((HMIXEROBJ)waveOutId, &mixerId, MIXER_OBJECTF_WAVEOUT); result = mixerGetID((HMIXEROBJ)UlongToHandle(waveOutId), &mixerId, MIXER_OBJECTF_WAVEOUT);
if (result) if (result)
return E_FAIL; return E_FAIL;
@ -77,7 +77,7 @@ static HRESULT __stdcall Volume_FindMixerControl(CSysTray * pSysTray)
{ {
mixerLine.cbStruct = sizeof(mixerLine); mixerLine.cbStruct = sizeof(mixerLine);
mixerLine.dwDestination = idx; mixerLine.dwDestination = idx;
if (!mixerGetLineInfoW((HMIXEROBJ)g_mixerId, &mixerLine, 0)) if (!mixerGetLineInfoW((HMIXEROBJ)UlongToHandle(g_mixerId), &mixerLine, 0))
{ {
if (mixerLine.dwComponentType >= MIXERLINE_COMPONENTTYPE_DST_SPEAKERS && if (mixerLine.dwComponentType >= MIXERLINE_COMPONENTTYPE_DST_SPEAKERS &&
mixerLine.dwComponentType <= MIXERLINE_COMPONENTTYPE_DST_HEADPHONES) mixerLine.dwComponentType <= MIXERLINE_COMPONENTTYPE_DST_HEADPHONES)
@ -100,7 +100,7 @@ static HRESULT __stdcall Volume_FindMixerControl(CSysTray * pSysTray)
mixerLineControls.pamxctrl = &mixerControl; mixerLineControls.pamxctrl = &mixerControl;
mixerLineControls.cbmxctrl = sizeof(mixerControl); mixerLineControls.cbmxctrl = sizeof(mixerControl);
if (mixerGetLineControlsW((HMIXEROBJ)g_mixerId, &mixerLineControls, MIXER_GETLINECONTROLSF_ONEBYTYPE)) if (mixerGetLineControlsW((HMIXEROBJ)UlongToHandle(g_mixerId), &mixerLineControls, MIXER_GETLINECONTROLSF_ONEBYTYPE))
return E_FAIL; return E_FAIL;
TRACE("Found control id %d for mute: %d\n", mixerControl.dwControlID); TRACE("Found control id %d for mute: %d\n", mixerControl.dwControlID);

View file

@ -24,7 +24,7 @@ BOOL WINAPI
WriteFile(IN HANDLE hFile, WriteFile(IN HANDLE hFile,
IN LPCVOID lpBuffer, IN LPCVOID lpBuffer,
IN DWORD nNumberOfBytesToWrite OPTIONAL, IN DWORD nNumberOfBytesToWrite OPTIONAL,
OUT LPDWORD lpNumberOfBytesWritten OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten,
IN LPOVERLAPPED lpOverlapped OPTIONAL) IN LPOVERLAPPED lpOverlapped OPTIONAL)
{ {
NTSTATUS Status; NTSTATUS Status;

View file

@ -342,10 +342,10 @@ ViewTree_LoadTree(HKEY hKey, LPCWSTR pszKeyName, DWORD dwParentID)
else else
{ {
// HKeyRoot // HKeyRoot
Value = DWORD(HKEY_CURRENT_USER); HKEY HKeyRoot = HKEY_CURRENT_USER;
Size = sizeof(Value); Size = sizeof(HKeyRoot);
RegQueryValueExW(hKey, L"HKeyRoot", NULL, NULL, LPBYTE(&Value), &Size); RegQueryValueExW(hKey, L"HKeyRoot", NULL, NULL, LPBYTE(&HKeyRoot), &Size);
pEntry->hkeyRoot = HKEY(Value); pEntry->hkeyRoot = HKeyRoot;
// RegPath // RegPath
pEntry->szRegPath[0] = 0; pEntry->szRegPath[0] = 0;
@ -782,7 +782,7 @@ ViewDlg_RestoreDefaults(HWND hwndDlg)
continue; continue;
} }
RegSetValueExW(hKey, pEntry->szValueName, 0, REG_DWORD, RegSetValueExW(hKey, pEntry->szValueName, 0, REG_DWORD,
LPBYTE(pEntry->dwDefaultValue), sizeof(DWORD)); LPBYTE(&pEntry->dwDefaultValue), sizeof(DWORD));
RegCloseKey(hKey); RegCloseKey(hKey);
// update check status // update check status

View file

@ -248,7 +248,7 @@ WSALookupServiceBeginA(IN LPWSAQUERYSETA lpqsRestrictions,
{ {
INT ErrorCode; INT ErrorCode;
LPWSAQUERYSETW UnicodeQuerySet = NULL; LPWSAQUERYSETW UnicodeQuerySet = NULL;
DWORD UnicodeQuerySetSize = 0; SIZE_T UnicodeQuerySetSize = 0;
DPRINT("WSALookupServiceBeginA: %p\n", lpqsRestrictions); DPRINT("WSALookupServiceBeginA: %p\n", lpqsRestrictions);
@ -523,12 +523,25 @@ WSALookupServiceNextA(IN HANDLE hLookup,
if (ErrorCode == ERROR_SUCCESS) if (ErrorCode == ERROR_SUCCESS)
{ {
SIZE_T SetSize = *lpdwBufferLength;
/* Now convert back to ANSI */ /* Now convert back to ANSI */
ErrorCode = MapUnicodeQuerySetToAnsi(UnicodeQuerySet, ErrorCode = MapUnicodeQuerySetToAnsi(UnicodeQuerySet,
lpdwBufferLength, &SetSize,
lpqsResults); lpqsResults);
if (ErrorCode != ERROR_SUCCESS) if (ErrorCode != ERROR_SUCCESS)
{
SetLastError(ErrorCode); SetLastError(ErrorCode);
}
else if (SetSize > MAXDWORD)
{
ErrorCode = ERROR_ARITHMETIC_OVERFLOW;
SetLastError(ErrorCode);
}
else
{
*lpdwBufferLength = SetSize;
}
} }
else else
{ {

View file

@ -136,7 +136,7 @@ typedef struct _INFORMATION_CLASS_INFO
#endif #endif
#ifdef _M_IX86 #ifndef _WIN64
C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, SystemCall) == 0x300); C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, SystemCall) == 0x300);
C_ASSERT(FIELD_OFFSET(KTHREAD, InitialStack) == KTHREAD_INITIAL_STACK); C_ASSERT(FIELD_OFFSET(KTHREAD, InitialStack) == KTHREAD_INITIAL_STACK);

View file

@ -244,15 +244,10 @@ typedef HANDLE HGLOBAL;
typedef HANDLE HLOCAL; typedef HANDLE HLOCAL;
typedef HANDLE GLOBALHANDLE; typedef HANDLE GLOBALHANDLE;
typedef HANDLE LOCALHANDLE; typedef HANDLE LOCALHANDLE;
#ifdef _WIN64
typedef INT_PTR (WINAPI *FARPROC)(); typedef INT_PTR (WINAPI *FARPROC)();
typedef INT_PTR (WINAPI *NEARPROC)(); typedef INT_PTR (WINAPI *NEARPROC)();
typedef INT_PTR (WINAPI *PROC)(); typedef INT_PTR (WINAPI *PROC)();
#else
typedef int (WINAPI *FARPROC)();
typedef int (WINAPI *NEARPROC)();
typedef int (WINAPI *PROC)();
#endif
typedef void *HGDIOBJ; typedef void *HGDIOBJ;

View file

@ -113,7 +113,7 @@
* (by reading outside of the prefetch buffer). The prefetch cache must * (by reading outside of the prefetch buffer). The prefetch cache must
* also not cross a page boundary. * also not cross a page boundary.
*/ */
C_ASSERT((FAST486_CACHE_SIZE >= sizeof(DWORD)) C_ASSERT((FAST486_CACHE_SIZE >= sizeof(ULONG))
&& (FAST486_CACHE_SIZE <= FAST486_PAGE_SIZE)); && (FAST486_CACHE_SIZE <= FAST486_PAGE_SIZE));
struct _FAST486_STATE; struct _FAST486_STATE;

View file

@ -30,6 +30,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <search.h> #include <search.h>
#define long intptr_t
#define min(a, b) (a) < (b) ? (a) : (b) #define min(a, b) (a) < (b) ? (a) : (b)
/* /*
@ -50,7 +52,7 @@
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
static __inline void static __inline void
swapfunc(char *a, char *b, int n, int swaptype) swapfunc(char *a, char *b, intptr_t n, int swaptype)
{ {
if(swaptype <= 1) if(swaptype <= 1)
swapcode(long, a, b, n) swapcode(long, a, b, n)
@ -91,7 +93,8 @@ __cdecl
qsort(void *a, size_t n, size_t es, int (__cdecl *cmp)(const void*, const void*)) qsort(void *a, size_t n, size_t es, int (__cdecl *cmp)(const void*, const void*))
{ {
char *pa, *pb, *pc, *pd, *pl, *pm, *pn; char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
int d, r, swaptype, swap_cnt; int swaptype, swap_cnt;
intptr_t d, r;
loop: SWAPINIT(a, es); loop: SWAPINIT(a, es);
swap_cnt = 0; swap_cnt = 0;

View file

@ -38,7 +38,7 @@ FASTCALL
Fast486MemReadCallback(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size) Fast486MemReadCallback(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
{ {
UNREFERENCED_PARAMETER(State); UNREFERENCED_PARAMETER(State);
RtlMoveMemory(Buffer, (PVOID)Address, Size); RtlMoveMemory(Buffer, UlongToPtr(Address), Size);
} }
static VOID static VOID
@ -46,7 +46,7 @@ FASTCALL
Fast486MemWriteCallback(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size) Fast486MemWriteCallback(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
{ {
UNREFERENCED_PARAMETER(State); UNREFERENCED_PARAMETER(State);
RtlMoveMemory((PVOID)Address, Buffer, Size); RtlMoveMemory(UlongToPtr(Address), Buffer, Size);
} }
static VOID static VOID

View file

@ -40,7 +40,9 @@ IntInitializeVideoAddressSpace(VOID)
PVOID BaseAddress; PVOID BaseAddress;
LARGE_INTEGER Offset; LARGE_INTEGER Offset;
SIZE_T ViewSize; SIZE_T ViewSize;
#ifdef _M_IX86
CHAR IVTAndBda[1024+256]; CHAR IVTAndBda[1024+256];
#endif // _M_IX86
/* Free the 1MB pre-reserved region. In reality, ReactOS should simply support us mapping the view into the reserved area, but it doesn't. */ /* Free the 1MB pre-reserved region. In reality, ReactOS should simply support us mapping the view into the reserved area, but it doesn't. */
BaseAddress = 0; BaseAddress = 0;
@ -124,6 +126,7 @@ IntInitializeVideoAddressSpace(VOID)
return 0; return 0;
} }
#ifdef _M_IX86
/* Get the real mode IVT and BDA from the kernel */ /* Get the real mode IVT and BDA from the kernel */
Status = NtVdmControl(VdmInitialize, IVTAndBda); Status = NtVdmControl(VdmInitialize, IVTAndBda);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -131,6 +134,7 @@ IntInitializeVideoAddressSpace(VOID)
DPRINT1("NtVdmControl failed (status %x)\n", Status); DPRINT1("NtVdmControl failed (status %x)\n", Status);
return Status; return Status;
} }
#endif // _M_IX86
/* Return success */ /* Return success */
return STATUS_SUCCESS; return STATUS_SUCCESS;

View file

@ -365,7 +365,7 @@ DbgGdiHTIntegrityCheck(VOID)
pEntry = &GdiHandleTable->Entries[i]; pEntry = &GdiHandleTable->Entries[i];
Type = pEntry->Type; Type = pEntry->Type;
Handle = (HGDIOBJ)(((ULONG_PTR)Type << GDI_ENTRY_UPPER_SHIFT) + i); Handle = (HGDIOBJ)(ULONG_PTR)((Type << GDI_ENTRY_UPPER_SHIFT) + i);
if (Type & GDI_ENTRY_BASETYPE_MASK) if (Type & GDI_ENTRY_BASETYPE_MASK)
{ {