[WIN32K] Fix 64 bit issues (#420)

- Fix ULONG/SIZE_T issues
- Use LOWORD/HIWORD
- Change a struct member to HANDLE
- Implement lstrlenW helper function
This commit is contained in:
Timo Kreuzer 2018-03-18 15:53:52 +01:00 committed by GitHub
parent 5b2ff8a3f9
commit 2d9c88e0c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 108 additions and 94 deletions

View file

@ -1814,7 +1814,7 @@ DIB_CreateDIBSection(
if (mapBits) bm.bmBits = (char *)mapBits + (offset - mapOffset); if (mapBits) bm.bmBits = (char *)mapBits + (offset - mapOffset);
} }
else if (ovr_pitch && offset) else if (ovr_pitch && offset)
bm.bmBits = (LPVOID) offset; bm.bmBits = UlongToPtr(offset);
else else
{ {
offset = 0; offset = 0;

View file

@ -446,10 +446,10 @@ NtGdiAddFontResourceW(
DPRINT("NtGdiAddFontResourceW\n"); DPRINT("NtGdiAddFontResourceW\n");
/* cwc = Length + trailing zero. */ /* cwc = Length + trailing zero. */
if (cwc <= 1 || cwc > UNICODE_STRING_MAX_CHARS) if ((cwc <= 1) || (cwc > UNICODE_STRING_MAX_CHARS))
return 0; return 0;
SafeFileName.MaximumLength = cwc * sizeof(WCHAR); SafeFileName.MaximumLength = (USHORT)(cwc * sizeof(WCHAR));
SafeFileName.Length = SafeFileName.MaximumLength - sizeof(UNICODE_NULL); SafeFileName.Length = SafeFileName.MaximumLength - sizeof(UNICODE_NULL);
SafeFileName.Buffer = ExAllocatePoolWithTag(PagedPool, SafeFileName.Buffer = ExAllocatePoolWithTag(PagedPool,
SafeFileName.MaximumLength, SafeFileName.MaximumLength,

View file

@ -18,7 +18,7 @@ typedef struct _FONT_ENTRY_MEM
typedef struct _FONT_ENTRY_COLL_MEM typedef struct _FONT_ENTRY_COLL_MEM
{ {
LIST_ENTRY ListEntry; LIST_ENTRY ListEntry;
UINT Handle; HANDLE Handle;
FONT_ENTRY_MEM *Entry; FONT_ENTRY_MEM *Entry;
} FONT_ENTRY_COLL_MEM, *PFONT_ENTRY_COLL_MEM; } FONT_ENTRY_COLL_MEM, *PFONT_ENTRY_COLL_MEM;

View file

@ -1081,7 +1081,7 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
PVOID Buffer = NULL; PVOID Buffer = NULL;
IO_STATUS_BLOCK Iosb; IO_STATUS_BLOCK Iosb;
PVOID SectionObject; PVOID SectionObject;
ULONG ViewSize = 0; SIZE_T ViewSize = 0;
LARGE_INTEGER SectionSize; LARGE_INTEGER SectionSize;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
GDI_LOAD_FONT LoadFont; GDI_LOAD_FONT LoadFont;
@ -1168,7 +1168,7 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
Status = ZwOpenKey(&KeyHandle, KEY_WRITE, &ObjectAttributes); Status = ZwOpenKey(&KeyHandle, KEY_WRITE, &ObjectAttributes);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
ULONG DataSize; SIZE_T DataSize;
LPWSTR pFileName = wcsrchr(FileName->Buffer, L'\\'); LPWSTR pFileName = wcsrchr(FileName->Buffer, L'\\');
if (pFileName) if (pFileName)
{ {
@ -1225,10 +1225,10 @@ IntGdiAddFontMemResource(PVOID Buffer, DWORD dwSize, PDWORD pNumAdded)
PPROCESSINFO Win32Process = PsGetCurrentProcessWin32Process(); PPROCESSINFO Win32Process = PsGetCurrentProcessWin32Process();
EntryCollection->Entry = LoadFont.PrivateEntry; EntryCollection->Entry = LoadFont.PrivateEntry;
IntLockProcessPrivateFonts(Win32Process); IntLockProcessPrivateFonts(Win32Process);
EntryCollection->Handle = ++Win32Process->PrivateMemFontHandleCount; EntryCollection->Handle = ULongToHandle(++Win32Process->PrivateMemFontHandleCount);
InsertTailList(&Win32Process->PrivateMemFontListHead, &EntryCollection->ListEntry); InsertTailList(&Win32Process->PrivateMemFontListHead, &EntryCollection->ListEntry);
IntUnLockProcessPrivateFonts(Win32Process); IntUnLockProcessPrivateFonts(Win32Process);
Ret = (HANDLE)EntryCollection->Handle; Ret = EntryCollection->Handle;
} }
} }
*pNumAdded = FaceCount; *pNumAdded = FaceCount;
@ -1302,7 +1302,7 @@ IntGdiRemoveFontMemResource(HANDLE hMMFont)
{ {
CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY_COLL_MEM, ListEntry); CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY_COLL_MEM, ListEntry);
if (CurrentEntry->Handle == (UINT)hMMFont) if (CurrentEntry->Handle == hMMFont)
{ {
EntryCollection = CurrentEntry; EntryCollection = CurrentEntry;
UnlinkFontMemCollection(CurrentEntry); UnlinkFontMemCollection(CurrentEntry);

View file

@ -365,7 +365,7 @@ DbgGdiHTIntegrityCheck(VOID)
pEntry = &GdiHandleTable->Entries[i]; pEntry = &GdiHandleTable->Entries[i];
Type = pEntry->Type; Type = pEntry->Type;
Handle = (HGDIOBJ)((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)
{ {

View file

@ -1515,7 +1515,7 @@ GDI_MapHandleTable(PEPROCESS pProcess)
PVOID pvMappedView = NULL; PVOID pvMappedView = NULL;
NTSTATUS Status; NTSTATUS Status;
LARGE_INTEGER liOffset; LARGE_INTEGER liOffset;
ULONG cjViewSize = sizeof(GDI_HANDLE_TABLE); SIZE_T cjViewSize = sizeof(GDI_HANDLE_TABLE);
liOffset.QuadPart = 0; liOffset.QuadPart = 0;

View file

@ -54,25 +54,6 @@ BOOL
NTAPI NTAPI
RegReadDWORD(HKEY hkey, PWSTR pwszValue, PDWORD pdwData); RegReadDWORD(HKEY hkey, PWSTR pwszValue, PDWORD pdwData);
_Success_(return!=FALSE)
BOOL
NTAPI
RegReadUserSetting(
_In_z_ PCWSTR pwszKeyName,
_In_z_ PCWSTR pwszValueName,
_In_ ULONG ulType,
_Out_writes_(cbDataSize) _When_(ulType == REG_SZ, _Post_z_) PVOID pvData,
_In_ ULONG cbDataSize);
BOOL
NTAPI
RegWriteUserSetting(
IN PCWSTR pwszKeyName,
IN PCWSTR pwszValueName,
IN ULONG ulType,
OUT PVOID pvData,
IN ULONG cbDataSize);
VOID FASTCALL VOID FASTCALL
SetLastNtError( SetLastNtError(
NTSTATUS Status); NTSTATUS Status);

View file

@ -963,7 +963,7 @@ IntSetPaletteEntries(
PPALETTE palGDI; PPALETTE palGDI;
ULONG numEntries; ULONG numEntries;
if ((UINT)hpal & GDI_HANDLE_STOCK_MASK) if ((UINT_PTR)hpal & GDI_HANDLE_STOCK_MASK)
{ {
return 0; return 0;
} }
@ -1247,7 +1247,7 @@ NtGdiUnrealizeObject(HGDIOBJ hgdiobj)
PPALETTE palGDI; PPALETTE palGDI;
if ( !hgdiobj || if ( !hgdiobj ||
((UINT)hgdiobj & GDI_HANDLE_STOCK_MASK) || ((UINT_PTR)hgdiobj & GDI_HANDLE_STOCK_MASK) ||
!GDI_HANDLE_IS_TYPE(hgdiobj, GDI_OBJECT_TYPE_PALETTE) ) !GDI_HANDLE_IS_TYPE(hgdiobj, GDI_OBJECT_TYPE_PALETTE) )
return Ret; return Ret;

View file

@ -496,7 +496,8 @@ NtGdiGetTextFaceW(
HFONT hFont; HFONT hFont;
PTEXTOBJ TextObj; PTEXTOBJ TextObj;
NTSTATUS Status; NTSTATUS Status;
INT fLen, ret; SIZE_T fLen;
INT ret;
/* FIXME: Handle bAliasName */ /* FIXME: Handle bAliasName */

View file

@ -80,7 +80,7 @@ typedef struct _EVENTPROC_CALLBACK_ARGUMENTS
DWORD dwEventThread; DWORD dwEventThread;
DWORD dwmsEventTime; DWORD dwmsEventTime;
WINEVENTPROC Proc; WINEVENTPROC Proc;
INT Mod; INT_PTR Mod;
ULONG_PTR offPfn; ULONG_PTR offPfn;
} EVENTPROC_CALLBACK_ARGUMENTS, *PEVENTPROC_CALLBACK_ARGUMENTS; } EVENTPROC_CALLBACK_ARGUMENTS, *PEVENTPROC_CALLBACK_ARGUMENTS;

View file

@ -219,7 +219,7 @@ typedef struct tagHOOK
int HookId; /* Hook table index */ int HookId; /* Hook table index */
ULONG_PTR offPfn; ULONG_PTR offPfn;
ULONG flags; /* Some internal flags */ ULONG flags; /* Some internal flags */
INT ihmod; INT_PTR ihmod;
struct _THREADINFO *ptiHooked; struct _THREADINFO *ptiHooked;
struct _DESKTOP *rpdesk; struct _DESKTOP *rpdesk;
/* ReactOS */ /* ReactOS */
@ -692,7 +692,7 @@ typedef struct _WND
HMENU SystemMenu; HMENU SystemMenu;
//PMENU spmenuSys; //PMENU spmenuSys;
/* Window menu handle or window id */ /* Window menu handle or window id */
UINT IDMenu; // Use spmenu UINT_PTR IDMenu; // Use spmenu
//PMENU spmenu; //PMENU spmenu;
HRGN hrgnClip; HRGN hrgnClip;
HRGN hrgnNewFrame; HRGN hrgnNewFrame;
@ -1662,14 +1662,14 @@ DWORD
NTAPI NTAPI
NtUserCallHwndParam( NtUserCallHwndParam(
HWND hWnd, HWND hWnd,
DWORD Param, DWORD_PTR Param,
DWORD Routine); DWORD Routine);
DWORD DWORD
NTAPI NTAPI
NtUserCallHwndParamLock( NtUserCallHwndParamLock(
HWND hWnd, HWND hWnd,
DWORD Param, DWORD_PTR Param,
DWORD Routine); DWORD Routine);
BOOL BOOL

View file

@ -2343,7 +2343,7 @@ UserRegisterSystemClasses(VOID)
hBrush = DefaultServerClasses[i].hBrush; hBrush = DefaultServerClasses[i].hBrush;
if (hBrush <= (HBRUSH)COLOR_MENUBAR) if (hBrush <= (HBRUSH)COLOR_MENUBAR)
{ {
hBrush = IntGetSysColorBrush((INT)hBrush); hBrush = IntGetSysColorBrush(HandleToUlong(hBrush));
} }
wc.hbrBackground = hBrush; wc.hbrBackground = hBrush;
wc.lpszMenuName = NULL; wc.lpszMenuName = NULL;

View file

@ -87,10 +87,9 @@ CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage,
/* Fill out the Port Message Header */ /* Fill out the Port Message Header */
ApiMessage->Header.u2.ZeroInit = 0; ApiMessage->Header.u2.ZeroInit = 0;
ApiMessage->Header.u1.s1.TotalLength = DataLength + ApiMessage->Header.u1.s1.TotalLength = FIELD_OFFSET(CSR_API_MESSAGE, Data) + DataLength;
sizeof(CSR_API_MESSAGE) - sizeof(ApiMessage->Data); // FIELD_OFFSET(CSR_API_MESSAGE, Data) + DataLength; ApiMessage->Header.u1.s1.DataLength = ApiMessage->Header.u1.s1.TotalLength -
ApiMessage->Header.u1.s1.DataLength = DataLength + sizeof(ApiMessage->Header);
FIELD_OFFSET(CSR_API_MESSAGE, Data) - sizeof(ApiMessage->Header); // ApiMessage->Header.u1.s1.TotalLength - sizeof(PORT_MESSAGE);
/* Fill out the CSR Header */ /* Fill out the CSR Header */
ApiMessage->ApiNumber = ApiNumber; ApiMessage->ApiNumber = ApiNumber;

View file

@ -967,7 +967,7 @@ IntDefWindowProc(
if (!hBrush) return 0; if (!hBrush) return 0;
if (hBrush <= (HBRUSH)COLOR_MENUBAR) if (hBrush <= (HBRUSH)COLOR_MENUBAR)
{ {
hBrush = IntGetSysColorBrush((INT)hBrush); hBrush = IntGetSysColorBrush(HandleToUlong(hBrush));
} }
if (Wnd->pcls->style & CS_PARENTDC) if (Wnd->pcls->style & CS_PARENTDC)
{ {

View file

@ -1427,7 +1427,7 @@ IntPaintDesktop(HDC hDC)
// We expect at most 4 strings (3 for version, 1 for optional NtSystemRoot) // We expect at most 4 strings (3 for version, 1 for optional NtSystemRoot)
static POLYTEXTW VerStrs[4] = {{0},{0},{0},{0}}; static POLYTEXTW VerStrs[4] = {{0},{0},{0},{0}};
INT i = 0; INT i = 0;
INT len; SIZE_T len;
HFONT hFont1 = NULL, hFont2 = NULL, hOldFont = NULL; HFONT hFont1 = NULL, hFont2 = NULL, hOldFont = NULL;
COLORREF crText, color_old; COLORREF crText, color_old;
@ -1503,7 +1503,7 @@ IntPaintDesktop(HDC hDC)
PWCHAR pstr = wszzVersion; PWCHAR pstr = wszzVersion;
for (i = 0; (i < ARRAYSIZE(VerStrs)) && *pstr; ++i) for (i = 0; (i < ARRAYSIZE(VerStrs)) && *pstr; ++i)
{ {
VerStrs[i].n = wcslen(pstr); VerStrs[i].n = lstrlenW(pstr);
VerStrs[i].lpstr = pstr; VerStrs[i].lpstr = pstr;
pstr += (VerStrs[i].n + 1); pstr += (VerStrs[i].n + 1);
} }

View file

@ -388,14 +388,14 @@ NtUserSetWinEventHook(
if (hmodWinEventProc != NULL) if (hmodWinEventProc != NULL)
{ {
pEH->offPfn = (ULONG_PTR)((char *)lpfnWinEventProc - (char *)hmodWinEventProc); pEH->offPfn = (ULONG_PTR)((char *)lpfnWinEventProc - (char *)hmodWinEventProc);
pEH->ihmod = (INT)hmodWinEventProc; pEH->ihmod = (INT_PTR)hmodWinEventProc;
pEH->Proc = lpfnWinEventProc; pEH->Proc = lpfnWinEventProc;
} }
else else
{ {
pEH->Proc = lpfnWinEventProc; pEH->Proc = lpfnWinEventProc;
pEH->offPfn = 0; pEH->offPfn = 0;
pEH->ihmod = (INT)hmodWinEventProc; pEH->ihmod = (INT_PTR)hmodWinEventProc;
} }
UserDereferenceObject(pEH); UserDereferenceObject(pEH);

View file

@ -1490,7 +1490,7 @@ IntAllowSetForegroundWindow(DWORD dwProcessId)
ppi = NULL; ppi = NULL;
if (dwProcessId != ASFW_ANY) if (dwProcessId != ASFW_ANY)
{ {
if (!NT_SUCCESS(PsLookupProcessByProcessId((HANDLE)dwProcessId, &Process))) if (!NT_SUCCESS(PsLookupProcessByProcessId(UlongToHandle(dwProcessId), &Process)))
{ {
EngSetLastError(ERROR_INVALID_PARAMETER); EngSetLastError(ERROR_INVALID_PARAMETER);
return FALSE; return FALSE;

View file

@ -1470,7 +1470,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
RETURN( NULL); RETURN( NULL);
} }
if ( !(ptiHook = IntTID2PTI( (HANDLE)ThreadId ))) if ( !(ptiHook = IntTID2PTI( UlongToHandle(ThreadId) )))
{ {
ERR("Invalid thread id 0x%x\n", ThreadId); ERR("Invalid thread id 0x%x\n", ThreadId);
EngSetLastError(ERROR_INVALID_PARAMETER); EngSetLastError(ERROR_INVALID_PARAMETER);
@ -1556,7 +1556,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
RETURN( NULL); RETURN( NULL);
} }
Hook->ihmod = (INT)Mod; // Module Index from atom table, Do this for now. Hook->ihmod = (INT_PTR)Mod; // Module Index from atom table, Do this for now.
Hook->HookId = HookId; Hook->HookId = HookId;
Hook->rpdesk = ptiHook->rpdesk; Hook->rpdesk = ptiHook->rpdesk;
Hook->phkNext = NULL; /* Dont use as a chain! Use link lists for chaining. */ Hook->phkNext = NULL; /* Dont use as a chain! Use link lists for chaining. */

View file

@ -23,7 +23,7 @@ typedef struct tagEVENTHOOK
WINEVENTPROC Proc; /* Event function */ WINEVENTPROC Proc; /* Event function */
ULONG Flags; /* Some internal flags */ ULONG Flags; /* Some internal flags */
ULONG_PTR offPfn; ULONG_PTR offPfn;
INT ihmod; INT_PTR ihmod;
} EVENTHOOK, *PEVENTHOOK; } EVENTHOOK, *PEVENTHOOK;
typedef struct tagEVENTTABLE typedef struct tagEVENTTABLE

View file

@ -677,8 +677,8 @@ NtUserAttachThreadInput(
UserEnterExclusive(); UserEnterExclusive();
TRACE("Enter NtUserAttachThreadInput %s\n",(fAttach ? "TRUE" : "FALSE" )); TRACE("Enter NtUserAttachThreadInput %s\n",(fAttach ? "TRUE" : "FALSE" ));
pti = IntTID2PTI((HANDLE)idAttach); pti = IntTID2PTI(UlongToHandle(idAttach));
ptiTo = IntTID2PTI((HANDLE)idAttachTo); ptiTo = IntTID2PTI(UlongToHandle(idAttachTo));
if ( !pti || !ptiTo ) if ( !pti || !ptiTo )
{ {

View file

@ -156,7 +156,7 @@ UserLoadKbdFile(PUNICODE_STRING pwszKLID)
} }
/* Read filename of layout DLL */ /* Read filename of layout DLL */
cbSize = sizeof(wszLayoutPath) - wcslen(wszLayoutPath)*sizeof(WCHAR); cbSize = (ULONG)(sizeof(wszLayoutPath) - wcslen(wszLayoutPath)*sizeof(WCHAR));
Status = RegQueryValue(hKey, Status = RegQueryValue(hKey,
L"Layout File", L"Layout File",
REG_SZ, REG_SZ,
@ -632,7 +632,7 @@ NtUserLoadKeyboardLayoutEx(
UserEnterExclusive(); UserEnterExclusive();
/* If hklUnload is specified, unload it and load new layput as default */ /* If hklUnload is specified, unload it and load new layput as default */
if (hklUnload && hklUnload != (HKL)hkl) if (hklUnload && (hklUnload != UlongToHandle(hkl)))
{ {
pKl = UserHklToKbl(hklUnload); pKl = UserHklToKbl(hklUnload);
if (pKl) if (pKl)
@ -640,11 +640,11 @@ NtUserLoadKeyboardLayoutEx(
} }
/* Let's see if layout was already loaded. */ /* Let's see if layout was already loaded. */
pKl = UserHklToKbl((HKL)hkl); pKl = UserHklToKbl(UlongToHandle(hkl));
if (!pKl) if (!pKl)
{ {
/* It wasn't, so load it. */ /* It wasn't, so load it. */
pKl = UserLoadKbdLayout(&ustrSafeKLID, (HKL)hkl); pKl = UserLoadKbdLayout(&ustrSafeKLID, UlongToHandle(hkl));
if (!pKl) if (!pKl)
goto cleanup; goto cleanup;
@ -682,7 +682,7 @@ NtUserLoadKeyboardLayoutEx(
co_IntShellHookNotify(HSHELL_LANGUAGE, 0, (LPARAM)hkl); co_IntShellHookNotify(HSHELL_LANGUAGE, 0, (LPARAM)hkl);
/* Return hkl on success */ /* Return hkl on success */
hklRet = (HKL)hkl; hklRet = UlongToHandle(hkl);
/* FIXME: KLF_REPLACELANG /* FIXME: KLF_REPLACELANG
KLF_REORDER */ KLF_REORDER */

View file

@ -1407,7 +1407,8 @@ APIENTRY
NtUserGetKeyNameText(LONG lParam, LPWSTR lpString, int cchSize) NtUserGetKeyNameText(LONG lParam, LPWSTR lpString, int cchSize)
{ {
PTHREADINFO pti; PTHREADINFO pti;
DWORD i, cchKeyName, dwRet = 0; DWORD i, dwRet = 0;
SIZE_T cchKeyName;
WORD wScanCode = (lParam >> 16) & 0xFF; WORD wScanCode = (lParam >> 16) & 0xFF;
BOOL bExtKey = (HIWORD(lParam) & KF_EXTENDED) ? TRUE : FALSE; BOOL bExtKey = (HIWORD(lParam) & KF_EXTENDED) ? TRUE : FALSE;
PKBDTABLES pKbdTbl; PKBDTABLES pKbdTbl;

View file

@ -1170,7 +1170,12 @@ IntSetMenuItemInfo(PMENU MenuObject, PITEM MenuItem, PROSMENUITEMINFO lpmii, PUN
{ {
UNICODE_STRING Source; UNICODE_STRING Source;
Source.Length = Source.MaximumLength = lpmii->cch * sizeof(WCHAR); if (!NT_VERIFY(lpmii->cch <= UNICODE_STRING_MAX_CHARS))
{
return FALSE;
}
Source.Length = Source.MaximumLength = (USHORT)(lpmii->cch * sizeof(WCHAR));
Source.Buffer = lpmii->dwTypeData; Source.Buffer = lpmii->dwTypeData;
MenuItem->lpstr.Buffer = DesktopHeapAlloc( MenuObject->head.rpdesk, Source.Length + sizeof(WCHAR)); MenuItem->lpstr.Buffer = DesktopHeapAlloc( MenuObject->head.rpdesk, Source.Length + sizeof(WCHAR));
@ -5288,7 +5293,7 @@ IntSetMenu(
} }
Wnd->IDMenu = (UINT) Menu; Wnd->IDMenu = (UINT_PTR) Menu;
if (NULL != NewMenu) if (NULL != NewMenu)
{ {
NewMenu->hWnd = UserHMGetHandle(Wnd); NewMenu->hWnd = UserHMGetHandle(Wnd);

View file

@ -2090,7 +2090,7 @@ NtUserPostThreadMessage(DWORD idThread,
UserEnterExclusive(); UserEnterExclusive();
Status = PsLookupThreadByThreadId((HANDLE)idThread,&peThread); Status = PsLookupThreadByThreadId(UlongToHandle(idThread), &peThread);
if ( Status == STATUS_SUCCESS ) if ( Status == STATUS_SUCCESS )
{ {

View file

@ -263,14 +263,15 @@ RegReadUserSetting(
return NT_SUCCESS(Status); return NT_SUCCESS(Status);
} }
_Success_(return != FALSE)
BOOL BOOL
NTAPI NTAPI
RegWriteUserSetting( RegWriteUserSetting(
IN PCWSTR pwszKeyName, _In_z_ PCWSTR pwszKeyName,
IN PCWSTR pwszValueName, _In_z_ PCWSTR pwszValueName,
IN ULONG ulType, _In_ ULONG ulType,
OUT PVOID pvData, _In_reads_bytes_(cjDataSize) const VOID *pvData,
IN ULONG cbDataSize) _In_ ULONG cbDataSize)
{ {
NTSTATUS Status; NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
@ -337,7 +338,7 @@ RegWriteUserSetting(
/* Initialize the value name string */ /* Initialize the value name string */
RtlInitUnicodeString(&usValueName, pwszValueName); RtlInitUnicodeString(&usValueName, pwszValueName);
Status = ZwSetValueKey(hkey, &usValueName, 0, ulType, pvData, cbDataSize); Status = ZwSetValueKey(hkey, &usValueName, 0, ulType, (PVOID)pvData, cbDataSize);
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
DPRINT1("Failed to write reg key '%S' value '%S', Status = %lx\n", DPRINT1("Failed to write reg key '%S' value '%S', Status = %lx\n",

View file

@ -808,8 +808,8 @@ NC_DrawFrame( HDC hDC, RECT *CurrentRect, BOOL Active, DWORD Style, DWORD ExStyl
/* Now the other bit of the frame */ /* Now the other bit of the frame */
if (Style & (WS_DLGFRAME | WS_BORDER) || ExStyle & WS_EX_DLGMODALFRAME) if (Style & (WS_DLGFRAME | WS_BORDER) || ExStyle & WS_EX_DLGMODALFRAME)
{ {
DWORD Width = UserGetSystemMetrics(SM_CXBORDER); LONG Width = UserGetSystemMetrics(SM_CXBORDER);
DWORD Height = UserGetSystemMetrics(SM_CYBORDER); LONG Height = UserGetSystemMetrics(SM_CYBORDER);
NtGdiSelectBrush(hDC, IntGetSysColorBrush( NtGdiSelectBrush(hDC, IntGetSysColorBrush(
(ExStyle & (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE)) ? COLOR_3DFACE : (ExStyle & (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE)) ? COLOR_3DFACE :

View file

@ -28,4 +28,24 @@ BOOL FASTCALL UserIsEntered(VOID);
BOOL FASTCALL UserIsEnteredExclusive(VOID); BOOL FASTCALL UserIsEnteredExclusive(VOID);
DWORD FASTCALL UserGetLanguageToggle(VOID); DWORD FASTCALL UserGetLanguageToggle(VOID);
_Success_(return != FALSE)
BOOL
NTAPI
RegReadUserSetting(
_In_z_ PCWSTR pwszKeyName,
_In_z_ PCWSTR pwszValueName,
_In_ ULONG ulType,
_Out_writes_bytes_(cjDataSize) _When_(ulType == REG_SZ, _Post_z_) PVOID pvData,
_In_ ULONG cjDataSize);
_Success_(return != FALSE)
BOOL
NTAPI
RegWriteUserSetting(
_In_z_ PCWSTR pwszKeyName,
_In_z_ PCWSTR pwszValueName,
_In_ ULONG ulType,
_In_reads_bytes_(cjDataSize) const VOID *pvData,
_In_ ULONG cjDataSize);
/* EOF */ /* EOF */

View file

@ -308,12 +308,12 @@ void DbgUserDumpHandleTable(VOID)
PUSER_HANDLE_ENTRY handle_to_entry(PUSER_HANDLE_TABLE ht, HANDLE handle ) PUSER_HANDLE_ENTRY handle_to_entry(PUSER_HANDLE_TABLE ht, HANDLE handle )
{ {
unsigned short generation; unsigned short generation;
int index = (((unsigned int)handle & 0xffff) - FIRST_USER_HANDLE) >> 1; int index = (LOWORD(handle) - FIRST_USER_HANDLE) >> 1;
if (index < 0 || index >= ht->nb_handles) if (index < 0 || index >= ht->nb_handles)
return NULL; return NULL;
if (!ht->handles[index].type) if (!ht->handles[index].type)
return NULL; return NULL;
generation = (unsigned int)handle >> 16; generation = HIWORD(handle);
if (generation == ht->handles[index].generation || !generation || generation == 0xffff) if (generation == ht->handles[index].generation || !generation || generation == 0xffff)
return &ht->handles[index]; return &ht->handles[index];
return NULL; return NULL;
@ -322,7 +322,7 @@ PUSER_HANDLE_ENTRY handle_to_entry(PUSER_HANDLE_TABLE ht, HANDLE handle )
__inline static HANDLE entry_to_handle(PUSER_HANDLE_TABLE ht, PUSER_HANDLE_ENTRY ptr ) __inline static HANDLE entry_to_handle(PUSER_HANDLE_TABLE ht, PUSER_HANDLE_ENTRY ptr )
{ {
int index = ptr - ht->handles; int index = ptr - ht->handles;
return (HANDLE)(((index << 1) + FIRST_USER_HANDLE) + (ptr->generation << 16)); return (HANDLE)((((INT_PTR)index << 1) + FIRST_USER_HANDLE) + (ptr->generation << 16));
} }
__inline static PUSER_HANDLE_ENTRY alloc_user_entry(PUSER_HANDLE_TABLE ht) __inline static PUSER_HANDLE_ENTRY alloc_user_entry(PUSER_HANDLE_TABLE ht)
@ -479,7 +479,7 @@ HANDLE get_user_full_handle(PUSER_HANDLE_TABLE ht, HANDLE handle )
{ {
PUSER_HANDLE_ENTRY entry; PUSER_HANDLE_ENTRY entry;
if ((unsigned int)handle >> 16) if ((ULONG_PTR)handle >> 16)
return handle; return handle;
if (!(entry = handle_to_entry(ht, handle ))) if (!(entry = handle_to_entry(ht, handle )))
return handle; return handle;

View file

@ -1310,13 +1310,13 @@ BOOL
FASTCALL FASTCALL
IntFlashWindowEx(PWND pWnd, PFLASHWINFO pfwi) IntFlashWindowEx(PWND pWnd, PFLASHWINFO pfwi)
{ {
DWORD FlashState; DWORD_PTR FlashState;
UINT uCount = pfwi->uCount; UINT uCount = pfwi->uCount;
BOOL Activate = FALSE, Ret = FALSE; BOOL Activate = FALSE, Ret = FALSE;
ASSERT(pfwi); ASSERT(pfwi);
FlashState = (DWORD)UserGetProp(pWnd, AtomFlashWndState, TRUE); FlashState = (DWORD_PTR)UserGetProp(pWnd, AtomFlashWndState, TRUE);
if (FlashState == FLASHW_FINISHED) if (FlashState == FLASHW_FINISHED)
{ {

View file

@ -725,7 +725,7 @@ DWORD
APIENTRY APIENTRY
NtUserCallHwndParam( NtUserCallHwndParam(
HWND hWnd, HWND hWnd,
DWORD Param, DWORD_PTR Param,
DWORD Routine) DWORD Routine)
{ {
@ -834,7 +834,7 @@ DWORD
APIENTRY APIENTRY
NtUserCallHwndParamLock( NtUserCallHwndParamLock(
HWND hWnd, HWND hWnd,
DWORD Param, DWORD_PTR Param,
DWORD Routine) DWORD Routine)
{ {
DWORD Ret = FALSE; DWORD Ret = FALSE;

View file

@ -382,7 +382,7 @@ SpiStoreSz(PCWSTR pwszKey, PCWSTR pwszValue, PCWSTR pwsz)
RegWriteUserSetting(pwszKey, RegWriteUserSetting(pwszKey,
pwszValue, pwszValue,
REG_SZ, REG_SZ,
(PWSTR)pwsz, pwsz,
(wcslen(pwsz) + 1) * sizeof(WCHAR)); (wcslen(pwsz) + 1) * sizeof(WCHAR));
} }
@ -561,7 +561,7 @@ UINT_PTR
SpiSetUserPref(DWORD dwMask, PVOID pvValue, FLONG fl) SpiSetUserPref(DWORD dwMask, PVOID pvValue, FLONG fl)
{ {
DWORD dwRegMask; DWORD dwRegMask;
BOOL bValue = (BOOL)pvValue; BOOL bValue = PtrToUlong(pvValue);
REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION); REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION);
@ -1612,7 +1612,7 @@ SpiGetSet(UINT uiAction, UINT uiParam, PVOID pvParam, FLONG fl)
return SpiGetUserPref(UPM_CURSORSHADOW, pvParam, fl); return SpiGetUserPref(UPM_CURSORSHADOW, pvParam, fl);
case SPI_SETCURSORSHADOW: case SPI_SETCURSORSHADOW:
gspv.bMouseCursorShadow = (BOOL)pvParam; gspv.bMouseCursorShadow = PtrToUlong(pvParam);
return SpiSetUserPref(UPM_CURSORSHADOW, pvParam, fl); return SpiSetUserPref(UPM_CURSORSHADOW, pvParam, fl);
case SPI_GETUIEFFECTS: case SPI_GETUIEFFECTS:
@ -1631,7 +1631,7 @@ SpiGetSet(UINT uiAction, UINT uiParam, PVOID pvParam, FLONG fl)
return SpiGetUserPref(UPM_CLICKLOCK, pvParam, fl); return SpiGetUserPref(UPM_CLICKLOCK, pvParam, fl);
case SPI_SETMOUSECLICKLOCK: case SPI_SETMOUSECLICKLOCK:
gspv.bMouseClickLock = (BOOL)pvParam; gspv.bMouseClickLock = PtrToUlong(pvParam);
return SpiSetUserPref(UPM_CLICKLOCK, pvParam, fl); return SpiSetUserPref(UPM_CLICKLOCK, pvParam, fl);
case SPI_GETMOUSEVANISH: case SPI_GETMOUSEVANISH:

View file

@ -295,3 +295,17 @@ typedef struct _PROCESSINFO
void NTAPI UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments); void NTAPI UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments);
ULONG_PTR NTAPI UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult); ULONG_PTR NTAPI UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult);
#endif #endif
/* Helper function used by some wine code */
__forceinline
int
lstrlenW(
_In_ LPCWSTR lpString)
{
size_t size = wcslen(lpString);
if (size > ULONG_MAX) __fastfail(FAST_FAIL_RANGE_CHECK_FAILURE);
return (int)size;
}
#define strlenW lstrlenW

View file

@ -1385,7 +1385,7 @@ NtUserBuildHwndList(
PWND Window; PWND Window;
HWND *List = NULL; HWND *List = NULL;
Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread); Status = PsLookupThreadByThreadId(UlongToHandle(dwThreadId), &Thread);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ERR("Thread Id is not valid!\n"); ERR("Thread Id is not valid!\n");
@ -1840,7 +1840,7 @@ PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs,
} }
} }
else // Not a child else // Not a child
pWnd->IDMenu = (UINT) Cs->hMenu; pWnd->IDMenu = (UINT_PTR)Cs->hMenu;
if ( ParentWindow && if ( ParentWindow &&

View file

@ -676,7 +676,7 @@ NtUserGetObjectInformation(
PDESKTOP DesktopObject = NULL; PDESKTOP DesktopObject = NULL;
USEROBJECTFLAGS ObjectFlags; USEROBJECTFLAGS ObjectFlags;
PVOID pvData = NULL; PVOID pvData = NULL;
DWORD nDataSize = 0; SIZE_T nDataSize = 0;
_SEH2_TRY _SEH2_TRY
{ {

View file

@ -163,11 +163,7 @@ static void TEXT_Ellipsify (HDC hdc, WCHAR *str, unsigned int max_len,
{ {
unsigned int len_ellipsis; unsigned int len_ellipsis;
unsigned int lo, mid, hi; unsigned int lo, mid, hi;
#ifdef _WIN32K_
len_ellipsis = wcslen (ELLIPSISW);
#else
len_ellipsis = strlenW (ELLIPSISW); len_ellipsis = strlenW (ELLIPSISW);
#endif
if (len_ellipsis > max_len) len_ellipsis = max_len; if (len_ellipsis > max_len) len_ellipsis = max_len;
if (*len_str > max_len - len_ellipsis) if (*len_str > max_len - len_ellipsis)
*len_str = max_len - len_ellipsis; *len_str = max_len - len_ellipsis;
@ -274,11 +270,7 @@ static void TEXT_PathEllipsify (HDC hdc, WCHAR *str, unsigned int max_len,
int len_trailing; int len_trailing;
int len_under; int len_under;
WCHAR *lastBkSlash, *lastFwdSlash, *lastSlash; WCHAR *lastBkSlash, *lastFwdSlash, *lastSlash;
#ifdef _WIN32K_
len_ellipsis = wcslen (ELLIPSISW);
#else
len_ellipsis = strlenW (ELLIPSISW); len_ellipsis = strlenW (ELLIPSISW);
#endif
if (!max_len) return; if (!max_len) return;
if (len_ellipsis >= max_len) len_ellipsis = max_len - 1; if (len_ellipsis >= max_len) len_ellipsis = max_len - 1;
if (*len_str + len_ellipsis >= max_len) if (*len_str + len_ellipsis >= max_len)