Author: tfaber
Date: Mon Feb 20 17:31:50 2017
New Revision: 73862
URL:
http://svn.reactos.org/svn/reactos?rev=73862&view=rev
Log:
[USER32][UXTHEME]
- Make API hooks type-safe. Fixes stack pointer corruption when calling
ThemeGetScrollInfo. Powered by /RTC1
Modified:
trunk/reactos/dll/win32/uxtheme/themehooks.c
trunk/reactos/sdk/include/reactos/undocuser.h
trunk/reactos/win32ss/user/user32/misc/usrapihk.c
Modified: trunk/reactos/dll/win32/uxtheme/themehooks.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/themehoo…
==============================================================================
--- trunk/reactos/dll/win32/uxtheme/themehooks.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/uxtheme/themehooks.c [iso-8859-1] Mon Feb 20 17:31:50 2017
@@ -269,7 +269,7 @@
return user32ApiHook.SetWindowRgn(hWnd, hRgn, bRedraw);
}
-BOOL ThemeGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi)
+BOOL WINAPI ThemeGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi)
{
PWND_CONTEXT pwndContext;
DWORD style;
@@ -341,7 +341,7 @@
puah->DlgProcArray.Size = UAHOWP_MAX_SIZE;
puah->SetWindowRgn = ThemeSetWindowRgn;
- puah->GetScrollInfo = (FARPROC)ThemeGetScrollInfo;
+ puah->GetScrollInfo = ThemeGetScrollInfo;
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCPAINT);
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCACTIVATE);
Modified: trunk/reactos/sdk/include/reactos/undocuser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/reactos/undocu…
==============================================================================
--- trunk/reactos/sdk/include/reactos/undocuser.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/include/reactos/undocuser.h [iso-8859-1] Mon Feb 20 17:31:50 2017
@@ -204,6 +204,18 @@
typedef LRESULT(CALLBACK *WNDPROC_OWP)(HWND,UINT,WPARAM,LPARAM,ULONG_PTR,PDWORD);
typedef int (WINAPI *SETWINDOWRGN)(HWND hWnd, HRGN hRgn, BOOL bRedraw);
+typedef BOOL (WINAPI *GETSCROLLINFO)(HWND,INT,LPSCROLLINFO);
+typedef INT (WINAPI *SETSCROLLINFO)(HWND,int,LPCSCROLLINFO,BOOL);
+typedef BOOL (WINAPI *ENABLESCROLLBAR)(HWND,UINT,UINT);
+typedef BOOL (WINAPI *ADJUSTWINDOWRECTEX)(LPRECT,DWORD,BOOL,DWORD);
+typedef int (WINAPI *GETSYSTEMMETRICS)(int);
+typedef BOOL (WINAPI *SYSTEMPARAMETERSINFOA)(UINT,UINT,PVOID,UINT);
+typedef BOOL (WINAPI *SYSTEMPARAMETERSINFOW)(UINT,UINT,PVOID,UINT);
+typedef BOOL (__fastcall *FORCERESETUSERAPIHOOK)(HINSTANCE);
+typedef BOOL (WINAPI *DRAWFRAMECONTROL)(HDC,LPRECT,UINT,UINT);
+typedef BOOL (WINAPI *DRAWCAPTION)(HWND,HDC,LPCRECT,UINT);
+typedef BOOL (WINAPI *MDIREDRAWFRAME)(HWND,DWORD);
+typedef DWORD (WINAPI *GETREALWINDOWOWNER)(HWND);
typedef struct _UAHOWP
{
@@ -221,10 +233,10 @@
WNDPROC DefWindowProcA;
WNDPROC DefWindowProcW;
UAHOWP DefWndProcArray;
- FARPROC GetScrollInfo;
- FARPROC SetScrollInfo;
- FARPROC EnableScrollBar;
- FARPROC AdjustWindowRectEx;
+ GETSCROLLINFO GetScrollInfo;
+ SETSCROLLINFO SetScrollInfo;
+ ENABLESCROLLBAR EnableScrollBar;
+ ADJUSTWINDOWRECTEX AdjustWindowRectEx;
SETWINDOWRGN SetWindowRgn;
WNDPROC_OWP PreWndProc;
WNDPROC_OWP PostWndProc;
@@ -232,14 +244,14 @@
WNDPROC_OWP PreDefDlgProc;
WNDPROC_OWP PostDefDlgProc;
UAHOWP DlgProcArray;
- FARPROC GetSystemMetrics;
- FARPROC SystemParametersInfoA;
- FARPROC SystemParametersInfoW;
- FARPROC ForceResetUserApiHook;
- FARPROC DrawFrameControl;
- FARPROC DrawCaption;
- FARPROC MDIRedrawFrame;
- FARPROC GetRealWindowOwner;
+ GETSYSTEMMETRICS GetSystemMetrics;
+ SYSTEMPARAMETERSINFOA SystemParametersInfoA;
+ SYSTEMPARAMETERSINFOW SystemParametersInfoW;
+ FORCERESETUSERAPIHOOK ForceResetUserApiHook;
+ DRAWFRAMECONTROL DrawFrameControl;
+ DRAWCAPTION DrawCaption;
+ MDIREDRAWFRAME MDIRedrawFrame;
+ GETREALWINDOWOWNER GetRealWindowOwner;
} USERAPIHOOK, *PUSERAPIHOOK;
typedef enum _UAPIHK
Modified: trunk/reactos/win32ss/user/user32/misc/usrapihk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/misc/u…
==============================================================================
--- trunk/reactos/win32ss/user/user32/misc/usrapihk.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/misc/usrapihk.c [iso-8859-1] Mon Feb 20 17:31:50
2017
@@ -28,7 +28,7 @@
BOOL WINAPI RealSystemParametersInfoA(UINT,UINT,PVOID,UINT);
BOOL WINAPI RealSystemParametersInfoW(UINT,UINT,PVOID,UINT);
DWORD WINAPI GetRealWindowOwner(HWND);
-LRESULT WINAPI RealUserDrawCaption(HWND hWnd, HDC hDC, LPCRECT lpRc, UINT uFlags);
+BOOL WINAPI RealUserDrawCaption(HWND hWnd, HDC hDC, LPCRECT lpRc, UINT uFlags);
/* GLOBALS *******************************************************************/
@@ -137,10 +137,10 @@
puah->DefWindowProcW = RealDefWindowProcW;
puah->DefWndProcArray.MsgBitArray = NULL;
puah->DefWndProcArray.Size = 0;
- puah->GetScrollInfo = (FARPROC)RealGetScrollInfo;
- puah->SetScrollInfo = (FARPROC)RealSetScrollInfo;
- puah->EnableScrollBar = (FARPROC)NtUserEnableScrollBar;
- puah->AdjustWindowRectEx = (FARPROC)RealAdjustWindowRectEx;
+ puah->GetScrollInfo = RealGetScrollInfo;
+ puah->SetScrollInfo = RealSetScrollInfo;
+ puah->EnableScrollBar = NtUserEnableScrollBar;
+ puah->AdjustWindowRectEx = RealAdjustWindowRectEx;
puah->SetWindowRgn = NtUserSetWindowRgn;
puah->PreWndProc = DefaultOWP;
puah->PostWndProc = DefaultOWP;
@@ -150,14 +150,14 @@
puah->PostDefDlgProc = DefaultOWP;
puah->DlgProcArray.MsgBitArray = NULL;
puah->DlgProcArray.Size = 0;
- puah->GetSystemMetrics = (FARPROC)RealGetSystemMetrics;
- puah->SystemParametersInfoA = (FARPROC)RealSystemParametersInfoA;
- puah->SystemParametersInfoW = (FARPROC)RealSystemParametersInfoW;
- puah->ForceResetUserApiHook = (FARPROC)ForceResetUserApiHook;
- puah->DrawFrameControl = (FARPROC)RealDrawFrameControl;
- puah->DrawCaption = (FARPROC)RealUserDrawCaption;
- puah->MDIRedrawFrame = (FARPROC)RealMDIRedrawFrame;
- puah->GetRealWindowOwner = (FARPROC)GetRealWindowOwner;
+ puah->GetSystemMetrics = RealGetSystemMetrics;
+ puah->SystemParametersInfoA = RealSystemParametersInfoA;
+ puah->SystemParametersInfoW = RealSystemParametersInfoW;
+ puah->ForceResetUserApiHook = ForceResetUserApiHook;
+ puah->DrawFrameControl = RealDrawFrameControl;
+ puah->DrawCaption = RealUserDrawCaption;
+ puah->MDIRedrawFrame = RealMDIRedrawFrame;
+ puah->GetRealWindowOwner = GetRealWindowOwner;
}
BOOL
@@ -262,7 +262,7 @@
RtlEnterCriticalSection(&gcsUserApiHook);
if (!pfn(uahLoadInit,&uah) || // Swap data, User32 to and Uxtheme from!
- uah.ForceResetUserApiHook != (FARPROC)ForceResetUserApiHook ||
+ uah.ForceResetUserApiHook != ForceResetUserApiHook ||
uah.size <= 0 )
{
RtlLeaveCriticalSection(&gcsUserApiHook);
@@ -347,10 +347,10 @@
RealDefWindowProcA,
RealDefWindowProcW,
{NULL, 0},
- (FARPROC)RealGetScrollInfo,
- (FARPROC)RealSetScrollInfo,
- (FARPROC)NtUserEnableScrollBar,
- (FARPROC)RealAdjustWindowRectEx,
+ RealGetScrollInfo,
+ RealSetScrollInfo,
+ NtUserEnableScrollBar,
+ RealAdjustWindowRectEx,
NtUserSetWindowRgn,
DefaultOWP,
DefaultOWP,
@@ -358,14 +358,14 @@
DefaultOWP,
DefaultOWP,
{NULL, 0},
- (FARPROC)RealGetSystemMetrics,
- (FARPROC)RealSystemParametersInfoA,
- (FARPROC)RealSystemParametersInfoW,
- (FARPROC)ForceResetUserApiHook,
- (FARPROC)RealDrawFrameControl,
- (FARPROC)NtUserDrawCaption,
- (FARPROC)RealMDIRedrawFrame,
- (FARPROC)GetRealWindowOwner,
+ RealGetSystemMetrics,
+ RealSystemParametersInfoA,
+ RealSystemParametersInfoW,
+ ForceResetUserApiHook,
+ RealDrawFrameControl,
+ NtUserDrawCaption,
+ RealMDIRedrawFrame,
+ GetRealWindowOwner,
};
/* FUNCTIONS *****************************************************************/