https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2d9c88e0c5f0c8fc24612…
commit 2d9c88e0c5f0c8fc24612579659a57690e0560bf
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Sun Mar 18 15:53:52 2018 +0100
Commit: GitHub <noreply(a)github.com>
CommitDate: Sun Mar 18 15:53:52 2018 +0100
[WIN32K] Fix 64 bit issues (#420)
- Fix ULONG/SIZE_T issues
- Use LOWORD/HIWORD
- Change a struct member to HANDLE
- Implement lstrlenW helper function
---
win32ss/gdi/ntgdi/dibobj.c | 2 +-
win32ss/gdi/ntgdi/font.c | 4 ++--
win32ss/gdi/ntgdi/font.h | 2 +-
win32ss/gdi/ntgdi/freetype.c | 10 +++++-----
win32ss/gdi/ntgdi/gdidbg.c | 2 +-
win32ss/gdi/ntgdi/gdiobj.c | 2 +-
win32ss/gdi/ntgdi/misc.h | 19 -------------------
win32ss/gdi/ntgdi/palette.c | 4 ++--
win32ss/gdi/ntgdi/text.c | 3 ++-
win32ss/include/callback.h | 2 +-
win32ss/include/ntuser.h | 8 ++++----
win32ss/user/ntuser/class.c | 2 +-
win32ss/user/ntuser/csr.c | 7 +++----
win32ss/user/ntuser/defwnd.c | 2 +-
win32ss/user/ntuser/desktop.c | 4 ++--
win32ss/user/ntuser/event.c | 4 ++--
win32ss/user/ntuser/focus.c | 2 +-
win32ss/user/ntuser/hook.c | 4 ++--
win32ss/user/ntuser/hook.h | 2 +-
win32ss/user/ntuser/input.c | 4 ++--
win32ss/user/ntuser/kbdlayout.c | 10 +++++-----
win32ss/user/ntuser/keyboard.c | 3 ++-
win32ss/user/ntuser/menu.c | 9 +++++++--
win32ss/user/ntuser/message.c | 2 +-
win32ss/user/ntuser/misc/registry.c | 13 +++++++------
win32ss/user/ntuser/nonclient.c | 4 ++--
win32ss/user/ntuser/ntuser.h | 20 ++++++++++++++++++++
win32ss/user/ntuser/object.c | 8 ++++----
win32ss/user/ntuser/painting.c | 4 ++--
win32ss/user/ntuser/simplecall.c | 4 ++--
win32ss/user/ntuser/sysparams.c | 8 ++++----
win32ss/user/ntuser/win32.h | 14 ++++++++++++++
win32ss/user/ntuser/window.c | 4 ++--
win32ss/user/ntuser/winsta.c | 2 +-
win32ss/user/rtl/text.c | 8 --------
35 files changed, 108 insertions(+), 94 deletions(-)
diff --git a/win32ss/gdi/ntgdi/dibobj.c b/win32ss/gdi/ntgdi/dibobj.c
index 9a3d848935..f935bc5d54 100644
--- a/win32ss/gdi/ntgdi/dibobj.c
+++ b/win32ss/gdi/ntgdi/dibobj.c
@@ -1814,7 +1814,7 @@ DIB_CreateDIBSection(
if (mapBits) bm.bmBits = (char *)mapBits + (offset - mapOffset);
}
else if (ovr_pitch && offset)
- bm.bmBits = (LPVOID) offset;
+ bm.bmBits = UlongToPtr(offset);
else
{
offset = 0;
diff --git a/win32ss/gdi/ntgdi/font.c b/win32ss/gdi/ntgdi/font.c
index f106ef28fe..7d1aebbb66 100644
--- a/win32ss/gdi/ntgdi/font.c
+++ b/win32ss/gdi/ntgdi/font.c
@@ -446,10 +446,10 @@ NtGdiAddFontResourceW(
DPRINT("NtGdiAddFontResourceW\n");
/* cwc = Length + trailing zero. */
- if (cwc <= 1 || cwc > UNICODE_STRING_MAX_CHARS)
+ if ((cwc <= 1) || (cwc > UNICODE_STRING_MAX_CHARS))
return 0;
- SafeFileName.MaximumLength = cwc * sizeof(WCHAR);
+ SafeFileName.MaximumLength = (USHORT)(cwc * sizeof(WCHAR));
SafeFileName.Length = SafeFileName.MaximumLength - sizeof(UNICODE_NULL);
SafeFileName.Buffer = ExAllocatePoolWithTag(PagedPool,
SafeFileName.MaximumLength,
diff --git a/win32ss/gdi/ntgdi/font.h b/win32ss/gdi/ntgdi/font.h
index 5cefc9deeb..8d466bd2ec 100644
--- a/win32ss/gdi/ntgdi/font.h
+++ b/win32ss/gdi/ntgdi/font.h
@@ -18,7 +18,7 @@ typedef struct _FONT_ENTRY_MEM
typedef struct _FONT_ENTRY_COLL_MEM
{
LIST_ENTRY ListEntry;
- UINT Handle;
+ HANDLE Handle;
FONT_ENTRY_MEM *Entry;
} FONT_ENTRY_COLL_MEM, *PFONT_ENTRY_COLL_MEM;
diff --git a/win32ss/gdi/ntgdi/freetype.c b/win32ss/gdi/ntgdi/freetype.c
index 92ab8b4461..6417012381 100644
--- a/win32ss/gdi/ntgdi/freetype.c
+++ b/win32ss/gdi/ntgdi/freetype.c
@@ -1081,7 +1081,7 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD
Characteristics)
PVOID Buffer = NULL;
IO_STATUS_BLOCK Iosb;
PVOID SectionObject;
- ULONG ViewSize = 0;
+ SIZE_T ViewSize = 0;
LARGE_INTEGER SectionSize;
OBJECT_ATTRIBUTES ObjectAttributes;
GDI_LOAD_FONT LoadFont;
@@ -1168,7 +1168,7 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD
Characteristics)
Status = ZwOpenKey(&KeyHandle, KEY_WRITE, &ObjectAttributes);
if (NT_SUCCESS(Status))
{
- ULONG DataSize;
+ SIZE_T DataSize;
LPWSTR pFileName = wcsrchr(FileName->Buffer, L'\\');
if (pFileName)
{
@@ -1225,10 +1225,10 @@ IntGdiAddFontMemResource(PVOID Buffer, DWORD dwSize, PDWORD
pNumAdded)
PPROCESSINFO Win32Process = PsGetCurrentProcessWin32Process();
EntryCollection->Entry = LoadFont.PrivateEntry;
IntLockProcessPrivateFonts(Win32Process);
- EntryCollection->Handle = ++Win32Process->PrivateMemFontHandleCount;
+ EntryCollection->Handle =
ULongToHandle(++Win32Process->PrivateMemFontHandleCount);
InsertTailList(&Win32Process->PrivateMemFontListHead,
&EntryCollection->ListEntry);
IntUnLockProcessPrivateFonts(Win32Process);
- Ret = (HANDLE)EntryCollection->Handle;
+ Ret = EntryCollection->Handle;
}
}
*pNumAdded = FaceCount;
@@ -1302,7 +1302,7 @@ IntGdiRemoveFontMemResource(HANDLE hMMFont)
{
CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY_COLL_MEM, ListEntry);
- if (CurrentEntry->Handle == (UINT)hMMFont)
+ if (CurrentEntry->Handle == hMMFont)
{
EntryCollection = CurrentEntry;
UnlinkFontMemCollection(CurrentEntry);
diff --git a/win32ss/gdi/ntgdi/gdidbg.c b/win32ss/gdi/ntgdi/gdidbg.c
index 9c9eb76b64..27297fb0ec 100644
--- a/win32ss/gdi/ntgdi/gdidbg.c
+++ b/win32ss/gdi/ntgdi/gdidbg.c
@@ -365,7 +365,7 @@ DbgGdiHTIntegrityCheck(VOID)
pEntry = &GdiHandleTable->Entries[i];
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)
{
diff --git a/win32ss/gdi/ntgdi/gdiobj.c b/win32ss/gdi/ntgdi/gdiobj.c
index da7488c16c..03d71ebdaf 100644
--- a/win32ss/gdi/ntgdi/gdiobj.c
+++ b/win32ss/gdi/ntgdi/gdiobj.c
@@ -1515,7 +1515,7 @@ GDI_MapHandleTable(PEPROCESS pProcess)
PVOID pvMappedView = NULL;
NTSTATUS Status;
LARGE_INTEGER liOffset;
- ULONG cjViewSize = sizeof(GDI_HANDLE_TABLE);
+ SIZE_T cjViewSize = sizeof(GDI_HANDLE_TABLE);
liOffset.QuadPart = 0;
diff --git a/win32ss/gdi/ntgdi/misc.h b/win32ss/gdi/ntgdi/misc.h
index 547a8a99a0..12c7a73351 100644
--- a/win32ss/gdi/ntgdi/misc.h
+++ b/win32ss/gdi/ntgdi/misc.h
@@ -54,25 +54,6 @@ BOOL
NTAPI
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
SetLastNtError(
NTSTATUS Status);
diff --git a/win32ss/gdi/ntgdi/palette.c b/win32ss/gdi/ntgdi/palette.c
index 7c830afab1..ef4509153e 100644
--- a/win32ss/gdi/ntgdi/palette.c
+++ b/win32ss/gdi/ntgdi/palette.c
@@ -963,7 +963,7 @@ IntSetPaletteEntries(
PPALETTE palGDI;
ULONG numEntries;
- if ((UINT)hpal & GDI_HANDLE_STOCK_MASK)
+ if ((UINT_PTR)hpal & GDI_HANDLE_STOCK_MASK)
{
return 0;
}
@@ -1247,7 +1247,7 @@ NtGdiUnrealizeObject(HGDIOBJ hgdiobj)
PPALETTE palGDI;
if ( !hgdiobj ||
- ((UINT)hgdiobj & GDI_HANDLE_STOCK_MASK) ||
+ ((UINT_PTR)hgdiobj & GDI_HANDLE_STOCK_MASK) ||
!GDI_HANDLE_IS_TYPE(hgdiobj, GDI_OBJECT_TYPE_PALETTE) )
return Ret;
diff --git a/win32ss/gdi/ntgdi/text.c b/win32ss/gdi/ntgdi/text.c
index b4130b6b2f..5c7e3664f2 100644
--- a/win32ss/gdi/ntgdi/text.c
+++ b/win32ss/gdi/ntgdi/text.c
@@ -496,7 +496,8 @@ NtGdiGetTextFaceW(
HFONT hFont;
PTEXTOBJ TextObj;
NTSTATUS Status;
- INT fLen, ret;
+ SIZE_T fLen;
+ INT ret;
/* FIXME: Handle bAliasName */
diff --git a/win32ss/include/callback.h b/win32ss/include/callback.h
index 20ec95afe7..bc8caecb67 100644
--- a/win32ss/include/callback.h
+++ b/win32ss/include/callback.h
@@ -80,7 +80,7 @@ typedef struct _EVENTPROC_CALLBACK_ARGUMENTS
DWORD dwEventThread;
DWORD dwmsEventTime;
WINEVENTPROC Proc;
- INT Mod;
+ INT_PTR Mod;
ULONG_PTR offPfn;
} EVENTPROC_CALLBACK_ARGUMENTS, *PEVENTPROC_CALLBACK_ARGUMENTS;
diff --git a/win32ss/include/ntuser.h b/win32ss/include/ntuser.h
index d3661fb779..724e3e612c 100644
--- a/win32ss/include/ntuser.h
+++ b/win32ss/include/ntuser.h
@@ -219,7 +219,7 @@ typedef struct tagHOOK
int HookId; /* Hook table index */
ULONG_PTR offPfn;
ULONG flags; /* Some internal flags */
- INT ihmod;
+ INT_PTR ihmod;
struct _THREADINFO *ptiHooked;
struct _DESKTOP *rpdesk;
/* ReactOS */
@@ -692,7 +692,7 @@ typedef struct _WND
HMENU SystemMenu;
//PMENU spmenuSys;
/* Window menu handle or window id */
- UINT IDMenu; // Use spmenu
+ UINT_PTR IDMenu; // Use spmenu
//PMENU spmenu;
HRGN hrgnClip;
HRGN hrgnNewFrame;
@@ -1662,14 +1662,14 @@ DWORD
NTAPI
NtUserCallHwndParam(
HWND hWnd,
- DWORD Param,
+ DWORD_PTR Param,
DWORD Routine);
DWORD
NTAPI
NtUserCallHwndParamLock(
HWND hWnd,
- DWORD Param,
+ DWORD_PTR Param,
DWORD Routine);
BOOL
diff --git a/win32ss/user/ntuser/class.c b/win32ss/user/ntuser/class.c
index d5c1324646..5982d6b9e3 100644
--- a/win32ss/user/ntuser/class.c
+++ b/win32ss/user/ntuser/class.c
@@ -2343,7 +2343,7 @@ UserRegisterSystemClasses(VOID)
hBrush = DefaultServerClasses[i].hBrush;
if (hBrush <= (HBRUSH)COLOR_MENUBAR)
{
- hBrush = IntGetSysColorBrush((INT)hBrush);
+ hBrush = IntGetSysColorBrush(HandleToUlong(hBrush));
}
wc.hbrBackground = hBrush;
wc.lpszMenuName = NULL;
diff --git a/win32ss/user/ntuser/csr.c b/win32ss/user/ntuser/csr.c
index e9f7d13974..7893cb53c0 100644
--- a/win32ss/user/ntuser/csr.c
+++ b/win32ss/user/ntuser/csr.c
@@ -87,10 +87,9 @@ CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage,
/* Fill out the Port Message Header */
ApiMessage->Header.u2.ZeroInit = 0;
- ApiMessage->Header.u1.s1.TotalLength = DataLength +
- sizeof(CSR_API_MESSAGE) - sizeof(ApiMessage->Data); //
FIELD_OFFSET(CSR_API_MESSAGE, Data) + DataLength;
- ApiMessage->Header.u1.s1.DataLength = DataLength +
- FIELD_OFFSET(CSR_API_MESSAGE, Data) - sizeof(ApiMessage->Header); //
ApiMessage->Header.u1.s1.TotalLength - sizeof(PORT_MESSAGE);
+ ApiMessage->Header.u1.s1.TotalLength = FIELD_OFFSET(CSR_API_MESSAGE, Data) +
DataLength;
+ ApiMessage->Header.u1.s1.DataLength = ApiMessage->Header.u1.s1.TotalLength -
+ sizeof(ApiMessage->Header);
/* Fill out the CSR Header */
ApiMessage->ApiNumber = ApiNumber;
diff --git a/win32ss/user/ntuser/defwnd.c b/win32ss/user/ntuser/defwnd.c
index f509473011..367c5faac9 100644
--- a/win32ss/user/ntuser/defwnd.c
+++ b/win32ss/user/ntuser/defwnd.c
@@ -967,7 +967,7 @@ IntDefWindowProc(
if (!hBrush) return 0;
if (hBrush <= (HBRUSH)COLOR_MENUBAR)
{
- hBrush = IntGetSysColorBrush((INT)hBrush);
+ hBrush = IntGetSysColorBrush(HandleToUlong(hBrush));
}
if (Wnd->pcls->style & CS_PARENTDC)
{
diff --git a/win32ss/user/ntuser/desktop.c b/win32ss/user/ntuser/desktop.c
index 9f2e3b4d81..7fe1a37096 100644
--- a/win32ss/user/ntuser/desktop.c
+++ b/win32ss/user/ntuser/desktop.c
@@ -1427,7 +1427,7 @@ IntPaintDesktop(HDC hDC)
// We expect at most 4 strings (3 for version, 1 for optional NtSystemRoot)
static POLYTEXTW VerStrs[4] = {{0},{0},{0},{0}};
INT i = 0;
- INT len;
+ SIZE_T len;
HFONT hFont1 = NULL, hFont2 = NULL, hOldFont = NULL;
COLORREF crText, color_old;
@@ -1503,7 +1503,7 @@ IntPaintDesktop(HDC hDC)
PWCHAR pstr = wszzVersion;
for (i = 0; (i < ARRAYSIZE(VerStrs)) && *pstr; ++i)
{
- VerStrs[i].n = wcslen(pstr);
+ VerStrs[i].n = lstrlenW(pstr);
VerStrs[i].lpstr = pstr;
pstr += (VerStrs[i].n + 1);
}
diff --git a/win32ss/user/ntuser/event.c b/win32ss/user/ntuser/event.c
index d4063313aa..a82516cdcf 100644
--- a/win32ss/user/ntuser/event.c
+++ b/win32ss/user/ntuser/event.c
@@ -388,14 +388,14 @@ NtUserSetWinEventHook(
if (hmodWinEventProc != NULL)
{
pEH->offPfn = (ULONG_PTR)((char *)lpfnWinEventProc - (char
*)hmodWinEventProc);
- pEH->ihmod = (INT)hmodWinEventProc;
+ pEH->ihmod = (INT_PTR)hmodWinEventProc;
pEH->Proc = lpfnWinEventProc;
}
else
{
pEH->Proc = lpfnWinEventProc;
pEH->offPfn = 0;
- pEH->ihmod = (INT)hmodWinEventProc;
+ pEH->ihmod = (INT_PTR)hmodWinEventProc;
}
UserDereferenceObject(pEH);
diff --git a/win32ss/user/ntuser/focus.c b/win32ss/user/ntuser/focus.c
index 5e2ea74b7b..cc9ac5f8f5 100644
--- a/win32ss/user/ntuser/focus.c
+++ b/win32ss/user/ntuser/focus.c
@@ -1490,7 +1490,7 @@ IntAllowSetForegroundWindow(DWORD dwProcessId)
ppi = NULL;
if (dwProcessId != ASFW_ANY)
{
- if (!NT_SUCCESS(PsLookupProcessByProcessId((HANDLE)dwProcessId, &Process)))
+ if (!NT_SUCCESS(PsLookupProcessByProcessId(UlongToHandle(dwProcessId),
&Process)))
{
EngSetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
diff --git a/win32ss/user/ntuser/hook.c b/win32ss/user/ntuser/hook.c
index 9cc0f5c748..558f3f975a 100644
--- a/win32ss/user/ntuser/hook.c
+++ b/win32ss/user/ntuser/hook.c
@@ -1470,7 +1470,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
RETURN( NULL);
}
- if ( !(ptiHook = IntTID2PTI( (HANDLE)ThreadId )))
+ if ( !(ptiHook = IntTID2PTI( UlongToHandle(ThreadId) )))
{
ERR("Invalid thread id 0x%x\n", ThreadId);
EngSetLastError(ERROR_INVALID_PARAMETER);
@@ -1556,7 +1556,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
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->rpdesk = ptiHook->rpdesk;
Hook->phkNext = NULL; /* Dont use as a chain! Use link lists for chaining. */
diff --git a/win32ss/user/ntuser/hook.h b/win32ss/user/ntuser/hook.h
index d64af1da01..3eb0ad4660 100644
--- a/win32ss/user/ntuser/hook.h
+++ b/win32ss/user/ntuser/hook.h
@@ -23,7 +23,7 @@ typedef struct tagEVENTHOOK
WINEVENTPROC Proc; /* Event function */
ULONG Flags; /* Some internal flags */
ULONG_PTR offPfn;
- INT ihmod;
+ INT_PTR ihmod;
} EVENTHOOK, *PEVENTHOOK;
typedef struct tagEVENTTABLE
diff --git a/win32ss/user/ntuser/input.c b/win32ss/user/ntuser/input.c
index b004006737..509fcda6e9 100644
--- a/win32ss/user/ntuser/input.c
+++ b/win32ss/user/ntuser/input.c
@@ -677,8 +677,8 @@ NtUserAttachThreadInput(
UserEnterExclusive();
TRACE("Enter NtUserAttachThreadInput %s\n",(fAttach ? "TRUE" :
"FALSE" ));
- pti = IntTID2PTI((HANDLE)idAttach);
- ptiTo = IntTID2PTI((HANDLE)idAttachTo);
+ pti = IntTID2PTI(UlongToHandle(idAttach));
+ ptiTo = IntTID2PTI(UlongToHandle(idAttachTo));
if ( !pti || !ptiTo )
{
diff --git a/win32ss/user/ntuser/kbdlayout.c b/win32ss/user/ntuser/kbdlayout.c
index e123438866..cd57492d99 100644
--- a/win32ss/user/ntuser/kbdlayout.c
+++ b/win32ss/user/ntuser/kbdlayout.c
@@ -156,7 +156,7 @@ UserLoadKbdFile(PUNICODE_STRING pwszKLID)
}
/* Read filename of layout DLL */
- cbSize = sizeof(wszLayoutPath) - wcslen(wszLayoutPath)*sizeof(WCHAR);
+ cbSize = (ULONG)(sizeof(wszLayoutPath) - wcslen(wszLayoutPath)*sizeof(WCHAR));
Status = RegQueryValue(hKey,
L"Layout File",
REG_SZ,
@@ -632,7 +632,7 @@ NtUserLoadKeyboardLayoutEx(
UserEnterExclusive();
/* 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);
if (pKl)
@@ -640,11 +640,11 @@ NtUserLoadKeyboardLayoutEx(
}
/* Let's see if layout was already loaded. */
- pKl = UserHklToKbl((HKL)hkl);
+ pKl = UserHklToKbl(UlongToHandle(hkl));
if (!pKl)
{
/* It wasn't, so load it. */
- pKl = UserLoadKbdLayout(&ustrSafeKLID, (HKL)hkl);
+ pKl = UserLoadKbdLayout(&ustrSafeKLID, UlongToHandle(hkl));
if (!pKl)
goto cleanup;
@@ -682,7 +682,7 @@ NtUserLoadKeyboardLayoutEx(
co_IntShellHookNotify(HSHELL_LANGUAGE, 0, (LPARAM)hkl);
/* Return hkl on success */
- hklRet = (HKL)hkl;
+ hklRet = UlongToHandle(hkl);
/* FIXME: KLF_REPLACELANG
KLF_REORDER */
diff --git a/win32ss/user/ntuser/keyboard.c b/win32ss/user/ntuser/keyboard.c
index d2cba89bc7..6167f9d6ff 100644
--- a/win32ss/user/ntuser/keyboard.c
+++ b/win32ss/user/ntuser/keyboard.c
@@ -1407,7 +1407,8 @@ APIENTRY
NtUserGetKeyNameText(LONG lParam, LPWSTR lpString, int cchSize)
{
PTHREADINFO pti;
- DWORD i, cchKeyName, dwRet = 0;
+ DWORD i, dwRet = 0;
+ SIZE_T cchKeyName;
WORD wScanCode = (lParam >> 16) & 0xFF;
BOOL bExtKey = (HIWORD(lParam) & KF_EXTENDED) ? TRUE : FALSE;
PKBDTABLES pKbdTbl;
diff --git a/win32ss/user/ntuser/menu.c b/win32ss/user/ntuser/menu.c
index ccaed593df..1e29d1d178 100644
--- a/win32ss/user/ntuser/menu.c
+++ b/win32ss/user/ntuser/menu.c
@@ -1170,7 +1170,12 @@ IntSetMenuItemInfo(PMENU MenuObject, PITEM MenuItem,
PROSMENUITEMINFO lpmii, PUN
{
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;
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)
{
NewMenu->hWnd = UserHMGetHandle(Wnd);
diff --git a/win32ss/user/ntuser/message.c b/win32ss/user/ntuser/message.c
index 61835863fd..c8cfededfb 100644
--- a/win32ss/user/ntuser/message.c
+++ b/win32ss/user/ntuser/message.c
@@ -2090,7 +2090,7 @@ NtUserPostThreadMessage(DWORD idThread,
UserEnterExclusive();
- Status = PsLookupThreadByThreadId((HANDLE)idThread,&peThread);
+ Status = PsLookupThreadByThreadId(UlongToHandle(idThread), &peThread);
if ( Status == STATUS_SUCCESS )
{
diff --git a/win32ss/user/ntuser/misc/registry.c b/win32ss/user/ntuser/misc/registry.c
index a1995aba05..0e03e791da 100644
--- a/win32ss/user/ntuser/misc/registry.c
+++ b/win32ss/user/ntuser/misc/registry.c
@@ -263,14 +263,15 @@ RegReadUserSetting(
return NT_SUCCESS(Status);
}
+_Success_(return != FALSE)
BOOL
NTAPI
RegWriteUserSetting(
- IN PCWSTR pwszKeyName,
- IN PCWSTR pwszValueName,
- IN ULONG ulType,
- OUT PVOID pvData,
- IN ULONG cbDataSize)
+ _In_z_ PCWSTR pwszKeyName,
+ _In_z_ PCWSTR pwszValueName,
+ _In_ ULONG ulType,
+ _In_reads_bytes_(cjDataSize) const VOID *pvData,
+ _In_ ULONG cbDataSize)
{
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
@@ -337,7 +338,7 @@ RegWriteUserSetting(
/* Initialize the value name string */
RtlInitUnicodeString(&usValueName, pwszValueName);
- Status = ZwSetValueKey(hkey, &usValueName, 0, ulType, pvData, cbDataSize);
+ Status = ZwSetValueKey(hkey, &usValueName, 0, ulType, (PVOID)pvData,
cbDataSize);
if(!NT_SUCCESS(Status))
{
DPRINT1("Failed to write reg key '%S' value '%S', Status =
%lx\n",
diff --git a/win32ss/user/ntuser/nonclient.c b/win32ss/user/ntuser/nonclient.c
index 8c30fa6900..44476f8cee 100644
--- a/win32ss/user/ntuser/nonclient.c
+++ b/win32ss/user/ntuser/nonclient.c
@@ -808,8 +808,8 @@ NC_DrawFrame( HDC hDC, RECT *CurrentRect, BOOL Active, DWORD Style,
DWORD ExStyl
/* Now the other bit of the frame */
if (Style & (WS_DLGFRAME | WS_BORDER) || ExStyle & WS_EX_DLGMODALFRAME)
{
- DWORD Width = UserGetSystemMetrics(SM_CXBORDER);
- DWORD Height = UserGetSystemMetrics(SM_CYBORDER);
+ LONG Width = UserGetSystemMetrics(SM_CXBORDER);
+ LONG Height = UserGetSystemMetrics(SM_CYBORDER);
NtGdiSelectBrush(hDC, IntGetSysColorBrush(
(ExStyle & (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE)) ? COLOR_3DFACE :
diff --git a/win32ss/user/ntuser/ntuser.h b/win32ss/user/ntuser/ntuser.h
index 79af19d4c0..abd75ce06b 100644
--- a/win32ss/user/ntuser/ntuser.h
+++ b/win32ss/user/ntuser/ntuser.h
@@ -28,4 +28,24 @@ BOOL FASTCALL UserIsEntered(VOID);
BOOL FASTCALL UserIsEnteredExclusive(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 */
diff --git a/win32ss/user/ntuser/object.c b/win32ss/user/ntuser/object.c
index 8fac269c1c..05ed7eebd5 100644
--- a/win32ss/user/ntuser/object.c
+++ b/win32ss/user/ntuser/object.c
@@ -308,12 +308,12 @@ void DbgUserDumpHandleTable(VOID)
PUSER_HANDLE_ENTRY handle_to_entry(PUSER_HANDLE_TABLE ht, HANDLE handle )
{
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)
return NULL;
if (!ht->handles[index].type)
return NULL;
- generation = (unsigned int)handle >> 16;
+ generation = HIWORD(handle);
if (generation == ht->handles[index].generation || !generation || generation ==
0xffff)
return &ht->handles[index];
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 )
{
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)
@@ -479,7 +479,7 @@ HANDLE get_user_full_handle(PUSER_HANDLE_TABLE ht, HANDLE handle )
{
PUSER_HANDLE_ENTRY entry;
- if ((unsigned int)handle >> 16)
+ if ((ULONG_PTR)handle >> 16)
return handle;
if (!(entry = handle_to_entry(ht, handle )))
return handle;
diff --git a/win32ss/user/ntuser/painting.c b/win32ss/user/ntuser/painting.c
index 49528e555b..5b4d04ff20 100644
--- a/win32ss/user/ntuser/painting.c
+++ b/win32ss/user/ntuser/painting.c
@@ -1310,13 +1310,13 @@ BOOL
FASTCALL
IntFlashWindowEx(PWND pWnd, PFLASHWINFO pfwi)
{
- DWORD FlashState;
+ DWORD_PTR FlashState;
UINT uCount = pfwi->uCount;
BOOL Activate = FALSE, Ret = FALSE;
ASSERT(pfwi);
- FlashState = (DWORD)UserGetProp(pWnd, AtomFlashWndState, TRUE);
+ FlashState = (DWORD_PTR)UserGetProp(pWnd, AtomFlashWndState, TRUE);
if (FlashState == FLASHW_FINISHED)
{
diff --git a/win32ss/user/ntuser/simplecall.c b/win32ss/user/ntuser/simplecall.c
index 8296b8d2cd..c7ad21fca0 100644
--- a/win32ss/user/ntuser/simplecall.c
+++ b/win32ss/user/ntuser/simplecall.c
@@ -725,7 +725,7 @@ DWORD
APIENTRY
NtUserCallHwndParam(
HWND hWnd,
- DWORD Param,
+ DWORD_PTR Param,
DWORD Routine)
{
@@ -834,7 +834,7 @@ DWORD
APIENTRY
NtUserCallHwndParamLock(
HWND hWnd,
- DWORD Param,
+ DWORD_PTR Param,
DWORD Routine)
{
DWORD Ret = FALSE;
diff --git a/win32ss/user/ntuser/sysparams.c b/win32ss/user/ntuser/sysparams.c
index 2265219586..c7dca11730 100644
--- a/win32ss/user/ntuser/sysparams.c
+++ b/win32ss/user/ntuser/sysparams.c
@@ -382,7 +382,7 @@ SpiStoreSz(PCWSTR pwszKey, PCWSTR pwszValue, PCWSTR pwsz)
RegWriteUserSetting(pwszKey,
pwszValue,
REG_SZ,
- (PWSTR)pwsz,
+ pwsz,
(wcslen(pwsz) + 1) * sizeof(WCHAR));
}
@@ -561,7 +561,7 @@ UINT_PTR
SpiSetUserPref(DWORD dwMask, PVOID pvValue, FLONG fl)
{
DWORD dwRegMask;
- BOOL bValue = (BOOL)pvValue;
+ BOOL bValue = PtrToUlong(pvValue);
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);
case SPI_SETCURSORSHADOW:
- gspv.bMouseCursorShadow = (BOOL)pvParam;
+ gspv.bMouseCursorShadow = PtrToUlong(pvParam);
return SpiSetUserPref(UPM_CURSORSHADOW, pvParam, fl);
case SPI_GETUIEFFECTS:
@@ -1631,7 +1631,7 @@ SpiGetSet(UINT uiAction, UINT uiParam, PVOID pvParam, FLONG fl)
return SpiGetUserPref(UPM_CLICKLOCK, pvParam, fl);
case SPI_SETMOUSECLICKLOCK:
- gspv.bMouseClickLock = (BOOL)pvParam;
+ gspv.bMouseClickLock = PtrToUlong(pvParam);
return SpiSetUserPref(UPM_CLICKLOCK, pvParam, fl);
case SPI_GETMOUSEVANISH:
diff --git a/win32ss/user/ntuser/win32.h b/win32ss/user/ntuser/win32.h
index cd9d7961ec..4fede2b1f9 100644
--- a/win32ss/user/ntuser/win32.h
+++ b/win32ss/user/ntuser/win32.h
@@ -295,3 +295,17 @@ typedef struct _PROCESSINFO
void NTAPI UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments);
ULONG_PTR NTAPI UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult);
#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
diff --git a/win32ss/user/ntuser/window.c b/win32ss/user/ntuser/window.c
index b52e3dcfe9..06dabf37cb 100644
--- a/win32ss/user/ntuser/window.c
+++ b/win32ss/user/ntuser/window.c
@@ -1385,7 +1385,7 @@ NtUserBuildHwndList(
PWND Window;
HWND *List = NULL;
- Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread);
+ Status = PsLookupThreadByThreadId(UlongToHandle(dwThreadId), &Thread);
if (!NT_SUCCESS(Status))
{
ERR("Thread Id is not valid!\n");
@@ -1840,7 +1840,7 @@ PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs,
}
}
else // Not a child
- pWnd->IDMenu = (UINT) Cs->hMenu;
+ pWnd->IDMenu = (UINT_PTR)Cs->hMenu;
if ( ParentWindow &&
diff --git a/win32ss/user/ntuser/winsta.c b/win32ss/user/ntuser/winsta.c
index 49702059d7..1187e44055 100644
--- a/win32ss/user/ntuser/winsta.c
+++ b/win32ss/user/ntuser/winsta.c
@@ -676,7 +676,7 @@ NtUserGetObjectInformation(
PDESKTOP DesktopObject = NULL;
USEROBJECTFLAGS ObjectFlags;
PVOID pvData = NULL;
- DWORD nDataSize = 0;
+ SIZE_T nDataSize = 0;
_SEH2_TRY
{
diff --git a/win32ss/user/rtl/text.c b/win32ss/user/rtl/text.c
index f278bffec4..f1ed9d714d 100644
--- a/win32ss/user/rtl/text.c
+++ b/win32ss/user/rtl/text.c
@@ -163,11 +163,7 @@ static void TEXT_Ellipsify (HDC hdc, WCHAR *str, unsigned int
max_len,
{
unsigned int len_ellipsis;
unsigned int lo, mid, hi;
-#ifdef _WIN32K_
- len_ellipsis = wcslen (ELLIPSISW);
-#else
len_ellipsis = strlenW (ELLIPSISW);
-#endif
if (len_ellipsis > max_len) len_ellipsis = max_len;
if (*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_under;
WCHAR *lastBkSlash, *lastFwdSlash, *lastSlash;
-#ifdef _WIN32K_
- len_ellipsis = wcslen (ELLIPSISW);
-#else
len_ellipsis = strlenW (ELLIPSISW);
-#endif
if (!max_len) return;
if (len_ellipsis >= max_len) len_ellipsis = max_len - 1;
if (*len_str + len_ellipsis >= max_len)