Author: jimtabor
Date: Tue Sep 15 17:24:09 2009
New Revision: 43053
URL:
http://svn.reactos.org/svn/reactos?rev=43053&view=rev
Log:
[User32] Theme Support Interface
- This is part 1, Tested with Wine user32 tests, Seamonkey, FireFox and AbiWord.
[References:]
-
http://www.reactos.org/wiki/RegisterUserApiHook
-
http://www.codeproject.com/KB/miscctrl/uxtheme.aspx
-
http://opcode0x90.wordpress.com/2007/05/11/user32__clientloadlibraryx/
- US Patent 6992681 and 6762767 - Theme aware management using fusion
Added:
trunk/reactos/dll/win32/user32/misc/usrapihk.c (with props)
Modified:
trunk/reactos/dll/win32/user32/controls/scrollbar.c
trunk/reactos/dll/win32/user32/include/user32.h
trunk/reactos/dll/win32/user32/include/window.h
trunk/reactos/dll/win32/user32/misc/desktop.c
trunk/reactos/dll/win32/user32/misc/dllmain.c
trunk/reactos/dll/win32/user32/misc/stubs.c
trunk/reactos/dll/win32/user32/user32.pspec
trunk/reactos/dll/win32/user32/user32.rbuild
trunk/reactos/dll/win32/user32/windows/defwnd.c
trunk/reactos/dll/win32/user32/windows/draw.c
trunk/reactos/dll/win32/user32/windows/message.c
trunk/reactos/dll/win32/user32/windows/nonclient.c
trunk/reactos/dll/win32/user32/windows/paint.c
trunk/reactos/dll/win32/user32/windows/window.c
trunk/reactos/include/reactos/win32k/ntuser.h
trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c
trunk/reactos/subsystems/win32/win32k/w32ksvc.db
Modified: trunk/reactos/dll/win32/user32/controls/scrollbar.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/…
==============================================================================
--- trunk/reactos/dll/win32/user32/controls/scrollbar.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/controls/scrollbar.c [iso-8859-1] Tue Sep 15 17:24:09
2009
@@ -1475,17 +1475,71 @@
/*
* @implemented
*/
+BOOL WINAPI EnableScrollBar( HWND hwnd, UINT nBar, UINT flags )
+{
+ BOOL Hook, Ret = FALSE;
+
+ LOADUSERAPIHOOK
+
+ Hook = BeginIfHookedUserApiHook();
+
+ /* Bypass SEH and go direct. */
+ if (!Hook) return NtUserEnableScrollBar(hwnd, nBar, flags);
+
+ _SEH2_TRY
+ {
+ Ret = guah.EnableScrollBar(hwnd, nBar, flags);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+
+ EndUserApiHook();
+
+ return Ret;
+}
+
+BOOL WINAPI
+RealGetScrollInfo(HWND Wnd, INT SBType, LPSCROLLINFO Info)
+{
+ if (SB_CTL == SBType)
+ {
+ return SendMessageW(Wnd, SBM_GETSCROLLINFO, 0, (LPARAM) Info);
+ }
+ else
+ {
+ return NtUserGetScrollInfo(Wnd, SBType, Info);
+ }
+}
+
+/*
+ * @implemented
+ */
BOOL WINAPI
GetScrollInfo(HWND Wnd, INT SBType, LPSCROLLINFO Info)
{
- if (SB_CTL == SBType)
- {
- return SendMessageW(Wnd, SBM_GETSCROLLINFO, 0, (LPARAM) Info);
- }
- else
- {
- return NtUserGetScrollInfo(Wnd, SBType, Info);
- }
+ BOOL Hook, Ret = FALSE;
+
+ LOADUSERAPIHOOK
+
+ Hook = BeginIfHookedUserApiHook();
+
+ /* Bypass SEH and go direct. */
+ if (!Hook) return RealGetScrollInfo(Wnd, SBType, Info);
+
+ _SEH2_TRY
+ {
+ Ret = guah.GetScrollInfo(Wnd, SBType, Info);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+
+ EndUserApiHook();
+
+ return Ret;
}
/*
@@ -1526,20 +1580,48 @@
}
}
+INT WINAPI
+RealSetScrollInfo(HWND Wnd, int SBType, LPCSCROLLINFO Info, BOOL bRedraw)
+{
+ if (SB_CTL == SBType)
+ {
+ return SendMessageW(Wnd, SBM_SETSCROLLINFO, (WPARAM) bRedraw, (LPARAM) Info);
+ }
+ else
+ {
+ return NtUserSetScrollInfo(Wnd, SBType, Info, bRedraw);
+ }
+}
+
/*
* @implemented
*/
INT WINAPI
SetScrollInfo(HWND Wnd, int SBType, LPCSCROLLINFO Info, BOOL bRedraw)
{
- if (SB_CTL == SBType)
- {
- return SendMessageW(Wnd, SBM_SETSCROLLINFO, (WPARAM) bRedraw, (LPARAM) Info);
- }
- else
- {
- return NtUserSetScrollInfo(Wnd, SBType, Info, bRedraw);
- }
+ BOOL Hook;
+ INT Ret = 0;
+
+ LOADUSERAPIHOOK
+
+ Hook = BeginIfHookedUserApiHook();
+
+ /* Bypass SEH and go direct. */
+ if (!Hook) return RealSetScrollInfo(Wnd, SBType, Info, bRedraw);
+
+ _SEH2_TRY
+ {
+ Ret = guah.SetScrollInfo(Wnd, SBType, Info, bRedraw);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+
+ EndUserApiHook();
+
+ return Ret;
+
}
/*
Modified: trunk/reactos/dll/win32/user32/include/user32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/u…
==============================================================================
--- trunk/reactos/dll/win32/user32/include/user32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/include/user32.h [iso-8859-1] Tue Sep 15 17:24:09 2009
@@ -42,6 +42,76 @@
/* SEH Support with PSEH */
#include <pseh/pseh2.h>
+/* Temporarily in here for now. */
+typedef struct _USERAPIHOOKINFO
+{
+ DWORD m_size;
+ LPCWSTR m_dllname1;
+ LPCWSTR m_funname1;
+ LPCWSTR m_dllname2;
+ LPCWSTR m_funname2;
+} USERAPIHOOKINFO,*PUSERAPIHOOKINFO;
+
+typedef LRESULT(CALLBACK *WNDPROC_OWP)(HWND,UINT,WPARAM,LPARAM,ULONG_PTR,PDWORD);
+
+typedef struct _UAHOWP
+{
+ BYTE* MsgBitArray;
+ DWORD Size;
+} UAHOWP, *PUAHOWP;
+
+typedef struct tagUSERAPIHOOK
+{
+ DWORD size;
+ WNDPROC DefWindowProcA;
+ WNDPROC DefWindowProcW;
+ UAHOWP DefWndProcArray;
+ FARPROC GetScrollInfo;
+ FARPROC SetScrollInfo;
+ FARPROC EnableScrollBar;
+ FARPROC AdjustWindowRectEx;
+ FARPROC SetWindowRgn;
+ WNDPROC_OWP PreWndProc;
+ WNDPROC_OWP PostWndProc;
+ UAHOWP WndProcArray;
+ WNDPROC_OWP PreDefDlgProc;
+ WNDPROC_OWP PostDefDlgProc;
+ UAHOWP DlgProcArray;
+ FARPROC GetSystemMetrics;
+ FARPROC SystemParametersInfoA;
+ FARPROC SystemParametersInfoW;
+ FARPROC ForceResetUserApiHook;
+ FARPROC DrawFrameControl;
+ FARPROC DrawCaption;
+ FARPROC MDIRedrawFrame;
+ FARPROC GetRealWindowOwner;
+} USERAPIHOOK, *PUSERAPIHOOK;
+
+typedef enum _UAPIHK
+{
+ uahLoadInit,
+ uahStop,
+ uahShutdown
+} UAPIHK, *PUAPIHK;
+
+extern RTL_CRITICAL_SECTION gcsUserApiHook;
+extern USERAPIHOOK guah;
+typedef DWORD (CALLBACK * USERAPIHOOKPROC)(UAPIHK State, ULONG_PTR Info);
+BOOL FASTCALL BeginIfHookedUserApiHook(VOID);
+BOOL FASTCALL EndUserApiHook(VOID);
+BOOL FASTCALL IsInsideUserApiHook(VOID);
+VOID FASTCALL ResetUserApiHook(PUSERAPIHOOK);
+BOOL FASTCALL IsMsgOverride(UINT,PUAHOWP);
+
+#define LOADUSERAPIHOOK \
+ if (!gfServerProcess && \
+ !IsInsideUserApiHook() && \
+ (gpsi->dwSRVIFlags & SRVINFO_APIHOOK) && \
+ !RtlIsThreadWithinLoaderCallout()) \
+ { \
+ NtUserCallNoParam(NOPARAM_ROUTINE_LOADUSERAPIHOOK); \
+ } \
+
/* FIXME: Use ntgdi.h then cleanup... */
LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *);
BOOL FASTCALL IsMetaFile(HDC);
@@ -49,6 +119,7 @@
extern PPROCESSINFO g_ppi;
extern ULONG_PTR g_ulSharedDelta;
extern PSERVERINFO gpsi;
+extern BOOL gfServerProcess;
static __inline PVOID
SharedPtrToUser(PVOID Ptr)
Modified: trunk/reactos/dll/win32/user32/include/window.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/w…
==============================================================================
--- trunk/reactos/dll/win32/user32/include/window.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/include/window.h [iso-8859-1] Tue Sep 15 17:24:09 2009
@@ -45,7 +45,7 @@
DWORD
SCROLL_HitTest( HWND hwnd, INT nBar, POINT pt, BOOL bDragging );
-LRESULT FASTCALL IntCallWindowProcW(BOOL IsAnsiProc, WNDPROC WndProc,
+LRESULT FASTCALL IntCallWindowProcW(BOOL IsAnsiProc, WNDPROC WndProc, PWND pWnd,
HWND hWnd, UINT Msg, WPARAM wParam,
LPARAM lParam);
@@ -66,3 +66,4 @@
HWND* WIN_ListChildren (HWND hWndparent);
ULONG_PTR FASTCALL IntGetWndProc(PWND, BOOL);
+DWORD WINAPI GetRealWindowOwner(HWND);
Modified: trunk/reactos/dll/win32/user32/misc/desktop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/desk…
==============================================================================
--- trunk/reactos/dll/win32/user32/misc/desktop.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/misc/desktop.c [iso-8859-1] Tue Sep 15 17:24:09 2009
@@ -90,18 +90,49 @@
#undef COPYS
}
+int WINAPI
+RealGetSystemMetrics(int nIndex)
+{
+ GetConnected();
+// FIXME("Global Server Data -> %x\n",gpsi);
+ if (nIndex < 0 || nIndex >= SM_CMETRICS) return 0;
+ return gpsi->aiSysMet[nIndex];
+}
+
/*
* @implemented
*/
int WINAPI
GetSystemMetrics(int nIndex)
{
- GetConnected();
-// FIXME("Global Sever Data -> %x\n",gpsi);
- if (nIndex < 0 || nIndex >= SM_CMETRICS) return 0;
- return gpsi->aiSysMet[nIndex];
-}
-
+ BOOL Hook;
+ int Ret = 0;
+
+ if (!gpsi) // Fixme! Hax! Need Timos delay load support?
+ {
+ return RealGetSystemMetrics(nIndex);
+ }
+
+ LOADUSERAPIHOOK
+
+ Hook = BeginIfHookedUserApiHook();
+
+ /* Bypass SEH and go direct. */
+ if (!Hook) return RealGetSystemMetrics(nIndex);
+
+ _SEH2_TRY
+ {
+ Ret = guah.GetSystemMetrics(nIndex);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+
+ EndUserApiHook();
+
+ return Ret;
+}
/*
* @unimplemented
@@ -110,11 +141,9 @@
{
return SystemParametersInfoA(SPI_SETDESKWALLPAPER,0,(PVOID)filename,TRUE);
}
-/*
- * @implemented
- */
+
BOOL WINAPI
-SystemParametersInfoA(UINT uiAction,
+RealSystemParametersInfoA(UINT uiAction,
UINT uiParam,
PVOID pvParam,
UINT fWinIni)
@@ -275,6 +304,58 @@
return NtUserSystemParametersInfo(uiAction, uiParam, pvParam, fWinIni);
}
+BOOL WINAPI
+RealSystemParametersInfoW(UINT uiAction,
+ UINT uiParam,
+ PVOID pvParam,
+ UINT fWinIni)
+{
+ switch(uiAction)
+ {
+
+ case SPI_SETDESKWALLPAPER:
+ {
+ UNICODE_STRING ustrWallpaper;
+
+ RtlInitUnicodeString(&ustrWallpaper, pvParam);
+ return NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, uiParam,
&ustrWallpaper, fWinIni);
+ }
+ }
+ return NtUserSystemParametersInfo(uiAction, uiParam, pvParam, fWinIni);
+}
+
+
+/*
+ * @implemented
+ */
+BOOL WINAPI
+SystemParametersInfoA(UINT uiAction,
+ UINT uiParam,
+ PVOID pvParam,
+ UINT fWinIni)
+{
+ BOOL Hook, Ret = FALSE;
+
+ LOADUSERAPIHOOK
+
+ Hook = BeginIfHookedUserApiHook();
+
+ /* Bypass SEH and go direct. */
+ if (!Hook) return RealSystemParametersInfoA(uiAction, uiParam, pvParam, fWinIni);
+
+ _SEH2_TRY
+ {
+ Ret = guah.SystemParametersInfoA(uiAction, uiParam, pvParam, fWinIni);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+
+ EndUserApiHook();
+
+ return Ret;
+}
/*
* @implemented
@@ -285,20 +366,28 @@
PVOID pvParam,
UINT fWinIni)
{
- switch(uiAction)
- {
-
- case SPI_SETDESKWALLPAPER:
- {
- UNICODE_STRING ustrWallpaper;
-
- RtlInitUnicodeString(&ustrWallpaper, pvParam);
- return NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, uiParam,
&ustrWallpaper, fWinIni);
- }
- }
- return NtUserSystemParametersInfo(uiAction, uiParam, pvParam, fWinIni);
-}
-
+ BOOL Hook, Ret = FALSE;
+
+ LOADUSERAPIHOOK
+
+ Hook = BeginIfHookedUserApiHook();
+
+ /* Bypass SEH and go direct. */
+ if (!Hook) return RealSystemParametersInfoW(uiAction, uiParam, pvParam, fWinIni);
+
+ _SEH2_TRY
+ {
+ Ret = guah.SystemParametersInfoW(uiAction, uiParam, pvParam, fWinIni);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+
+ EndUserApiHook();
+
+ return Ret;
+}
/*
* @implemented
Modified: trunk/reactos/dll/win32/user32/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/dllm…
==============================================================================
--- trunk/reactos/dll/win32/user32/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/misc/dllmain.c [iso-8859-1] Tue Sep 15 17:24:09 2009
@@ -13,6 +13,7 @@
PUSER_HANDLE_ENTRY gHandleEntries = NULL;
PSERVERINFO gpsi = NULL;
ULONG_PTR g_ulSharedDelta;
+BOOL gfServerProcess = FALSE;
WCHAR szAppInit[KEY_LENGTH];
@@ -244,6 +245,10 @@
gpsi = SharedPtrToUser(UserCon.siClient.psi);
gHandleTable = SharedPtrToUser(UserCon.siClient.aheList);
gHandleEntries = SharedPtrToUser(gHandleTable->handles);
+
+ RtlInitializeCriticalSection(&gcsUserApiHook);
+ gfServerProcess = TRUE; // FIXME HAX! Used in
CsrClientConnectToServer(,,,,&gfServerProcess);
+
//ERR("1 SI 0x%x : HT 0x%x : D 0x%x\n", UserCon.siClient.psi,
UserCon.siClient.aheList, g_ulSharedDelta);
/* Allocate an index for user32 thread local data. */
Modified: trunk/reactos/dll/win32/user32/misc/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/stub…
==============================================================================
--- trunk/reactos/dll/win32/user32/misc/stubs.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/misc/stubs.c [iso-8859-1] Tue Sep 15 17:24:09 2009
@@ -485,25 +485,6 @@
return FALSE;
}
-typedef BOOL (CALLBACK *THEME_HOOK_FUNC) (DWORD state,PVOID arg2); //return type and 2nd
parameter unknown
-/*
- * @unimplemented
- */
-BOOL WINAPI RegisterUserApiHook(HINSTANCE instance,THEME_HOOK_FUNC proc)
-{
- UNIMPLEMENTED;
- return FALSE;
-}
-
-/*
- * @unimplemented
- */
-BOOL WINAPI UnregisterUserApiHook(VOID)
-{
- UNIMPLEMENTED;
- return FALSE;
-}
-
/*
* @unimplemented
*/
Added: trunk/reactos/dll/win32/user32/misc/usrapihk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/usra…
==============================================================================
--- trunk/reactos/dll/win32/user32/misc/usrapihk.c (added)
+++ trunk/reactos/dll/win32/user32/misc/usrapihk.c [iso-8859-1] Tue Sep 15 17:24:09 2009
@@ -1,0 +1,397 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS user32.dll
+ * FILE: dll/win32/user32/misc/usrapihk.c
+ * PURPOSE: User32.dll User32 Api Hook interface and support functions
+ * PROGRAMMER:
+ *
+ *
+ *
+ * Information:
+ *
http://www.reactos.org/wiki/RegisterUserApiHook
+ *
+ */
+#include <user32.h>
+
+#include <wine/debug.h>
+
+WINE_DEFAULT_DEBUG_CHANNEL(user32);
+
+BOOL WINAPI RealAdjustWindowRectEx(LPRECT,DWORD,BOOL,DWORD);
+LRESULT WINAPI RealDefWindowProcA(HWND,UINT,WPARAM,LPARAM);
+LRESULT WINAPI RealDefWindowProcW(HWND,UINT,WPARAM,LPARAM);
+BOOL WINAPI RealDrawFrameControl(HDC,LPRECT,UINT,UINT);
+BOOL WINAPI RealGetScrollInfo(HWND,INT,LPSCROLLINFO);
+int WINAPI RealGetSystemMetrics(int);
+BOOL WINAPI RealMDIRedrawFrame(HWND,DWORD);
+INT WINAPI RealSetScrollInfo(HWND,int,LPCSCROLLINFO,BOOL);
+BOOL WINAPI RealSystemParametersInfoA(UINT,UINT,PVOID,UINT);
+BOOL WINAPI RealSystemParametersInfoW(UINT,UINT,PVOID,UINT);
+
+/* GLOBALS *******************************************************************/
+
+DWORD gcLoadUserApiHook = 0;
+LONG gcCallUserApiHook = 0;
+DWORD gfUserApiHook;
+HINSTANCE ghmodUserApiHook = NULL;
+USERAPIHOOKPROC gpfnInitUserApi;
+RTL_CRITICAL_SECTION gcsUserApiHook;
+// API Hooked Message group bitmaps
+BYTE grgbDwpLiteHookMsg[128];
+BYTE grgbWndLiteHookMsg[128];
+BYTE grgbDlgLiteHookMsg[128];
+
+/* INTERNAL ******************************************************************/
+
+/*
+ Pre and Post Message handler stub.
+ */
+LRESULT
+WINAPI
+DefaultOWP(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR lResult, PDWORD
pData)
+{
+ return 0;
+}
+
+/*
+ Check for API Hooked Message Overrides. Using message bitmapping.. One bit
+ corresponds to one message number.
+ */
+BOOL
+FASTCALL
+IsMsgOverride( UINT Msg, PUAHOWP puaowpOverride)
+{
+ UINT nMsg = Msg / 8; // Group Indexed, (Msg 1024) / 8 = (0 -> 127) bytes Max
+
+ if ( puaowpOverride && nMsg < puaowpOverride->Size )
+ {
+ return (puaowpOverride->MsgBitArray[nMsg] & (1 << (Msg &
WM_SETFOCUS)));
+ }
+ return FALSE;
+}
+
+VOID
+FASTCALL
+CopyMsgMask(PUAHOWP Dest, PUAHOWP Src, PVOID hkmsg, DWORD Size)
+{
+ DWORD nSize;
+
+ if ( Src && Src->Size > 0 )
+ {
+ Dest->MsgBitArray = hkmsg;
+ nSize = Src->Size;
+ if ( Size < nSize) nSize = Size;
+ Dest->Size = nSize;
+ RtlCopyMemory(Dest->MsgBitArray, Src->MsgBitArray, nSize);
+ return;
+ }
+
+ Dest->MsgBitArray = NULL;
+ Dest->Size = 0;
+ return;
+}
+
+
+BOOL
+FASTCALL
+IsInsideUserApiHook(VOID)
+{
+ if ( ghmodUserApiHook && gfUserApiHook ) return TRUE;
+ return FALSE;
+}
+
+BOOL
+FASTCALL
+BeginIfHookedUserApiHook(VOID)
+{
+ InterlockedIncrement(&gcCallUserApiHook);
+ if (IsInsideUserApiHook()) return TRUE;
+
+ InterlockedDecrement(&gcCallUserApiHook);
+ return FALSE;
+}
+
+BOOL
+FASTCALL
+ForceResetUserApiHook(HINSTANCE hInstance)
+{
+ if ( ghmodUserApiHook == hInstance &&
+ RtlIsThreadWithinLoaderCallout() )
+ {
+ ResetUserApiHook(&guah);
+ gpfnInitUserApi = NULL;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+VOID
+FASTCALL
+ResetUserApiHook(PUSERAPIHOOK puah)
+{
+ // Setup Structure.....
+ puah->size = sizeof(USERAPIHOOK);
+ puah->DefWindowProcA = (WNDPROC)RealDefWindowProcA;
+ puah->DefWindowProcW = (WNDPROC)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->SetWindowRgn = (FARPROC)NtUserSetWindowRgn;
+ puah->PreWndProc = (WNDPROC_OWP)DefaultOWP;
+ puah->PostWndProc = (WNDPROC_OWP)DefaultOWP;
+ puah->WndProcArray.MsgBitArray = NULL;
+ puah->WndProcArray.Size = 0;
+ puah->PreDefDlgProc = (WNDPROC_OWP)DefaultOWP;
+ puah->PostDefDlgProc = (WNDPROC_OWP)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)NtUserDrawCaption;
+ puah->MDIRedrawFrame = (FARPROC)RealMDIRedrawFrame;
+ puah->GetRealWindowOwner = (FARPROC)GetRealWindowOwner;
+}
+
+BOOL
+FASTCALL
+EndUserApiHook(VOID)
+{
+ HMODULE hModule;
+ USERAPIHOOKPROC pfn;
+ BOOL Ret = FALSE;
+
+ if ( !InterlockedDecrement(&gcCallUserApiHook) )
+ {
+ if ( !gcLoadUserApiHook )
+ {
+ RtlEnterCriticalSection(&gcsUserApiHook);
+
+ pfn = gpfnInitUserApi;
+ hModule = ghmodUserApiHook;
+ ghmodUserApiHook = NULL;
+ gpfnInitUserApi = NULL;
+
+ RtlLeaveCriticalSection(&gcsUserApiHook);
+
+ if ( pfn ) Ret = pfn(uahStop, 0);
+
+ if ( hModule ) Ret = FreeLibrary(hModule);
+ }
+ }
+ return Ret;
+}
+
+BOOL
+WINAPI
+ClearUserApiHook(HINSTANCE hInstance)
+{
+ HMODULE hModule;
+ USERAPIHOOKPROC pfn = NULL, pfn1 = NULL;
+
+ RtlEnterCriticalSection(&gcsUserApiHook);
+ hModule = ghmodUserApiHook;
+ if ( ghmodUserApiHook == hInstance )
+ {
+ pfn1 = gpfnInitUserApi;
+ if ( --gcLoadUserApiHook == 1 )
+ {
+ gfUserApiHook = 0;
+ ResetUserApiHook(&guah);
+ if ( gcCallUserApiHook )
+ {
+ hInstance = NULL;
+ pfn1 = NULL;
+ pfn = gpfnInitUserApi;
+ gcLoadUserApiHook = 1;
+ }
+ else
+ {
+ hInstance = hModule;
+ ghmodUserApiHook = NULL;
+ gpfnInitUserApi = NULL;
+ }
+ }
+ }
+ RtlLeaveCriticalSection(&gcsUserApiHook);
+
+ if ( pfn )
+ {
+ pfn(uahShutdown, 0); // Shutdown.
+
+ RtlEnterCriticalSection(&gcsUserApiHook);
+ pfn1 = gpfnInitUserApi;
+
+ if ( --gcLoadUserApiHook == 1 )
+ {
+ if ( gcCallUserApiHook )
+ {
+ hInstance = NULL;
+ pfn1 = NULL;
+ }
+ else
+ {
+ hInstance = ghmodUserApiHook;
+ ghmodUserApiHook = NULL;
+ gpfnInitUserApi = NULL;
+ }
+ }
+ RtlLeaveCriticalSection(&gcsUserApiHook);
+ }
+
+ if ( pfn1 ) pfn1(uahStop, 0);
+
+ return hInstance != 0;
+}
+
+BOOL
+WINAPI
+InitUserApiHook(HINSTANCE hInstance, USERAPIHOOKPROC pfn)
+{
+ USERAPIHOOK uah;
+
+ ResetUserApiHook(&uah);
+
+ RtlEnterCriticalSection(&gcsUserApiHook);
+
+ if (!pfn(uahLoadInit,(ULONG_PTR)&uah) || // Swap data, User32 to and Uxtheme
from!
+ uah.ForceResetUserApiHook != (FARPROC)ForceResetUserApiHook ||
+ uah.size <= 0 )
+ {
+ RtlLeaveCriticalSection(&gcsUserApiHook);
+ return FALSE;
+ }
+
+ if ( ghmodUserApiHook )
+ {
+ if ( ghmodUserApiHook != hInstance )
+ {
+ RtlLeaveCriticalSection(&gcsUserApiHook);
+ pfn(uahStop, 0);
+ return FALSE;
+ }
+ gcLoadUserApiHook++;
+ }
+ else
+ {
+ ghmodUserApiHook = hInstance;
+ // Do not over write GetRealWindowOwner.
+ RtlCopyMemory(&guah, &uah, sizeof(USERAPIHOOK) - sizeof(LONG));
+ gpfnInitUserApi = pfn;
+ gcLoadUserApiHook = 1;
+ gfUserApiHook = 1;
+ // Copy Message Masks
+ CopyMsgMask(&guah.DefWndProcArray,
+ &uah.DefWndProcArray,
+ &grgbDwpLiteHookMsg,
+ sizeof(grgbDwpLiteHookMsg));
+
+ CopyMsgMask(&guah.WndProcArray,
+ &uah.WndProcArray,
+ &grgbWndLiteHookMsg,
+ sizeof(grgbWndLiteHookMsg));
+
+ CopyMsgMask(&guah.DlgProcArray,
+ &uah.DlgProcArray,
+ &grgbDlgLiteHookMsg,
+ sizeof(grgbDlgLiteHookMsg));
+ }
+ RtlLeaveCriticalSection(&gcsUserApiHook);
+ return TRUE;
+}
+
+BOOL
+WINAPI
+RealMDIRedrawFrame(HWND hWnd, DWORD flags)
+{
+ return (BOOL)NtUserCallHwndLock(hWnd, HWNDLOCK_ROUTINE_REDRAWFRAME);
+}
+
+BOOL
+WINAPI
+MDIRedrawFrame(HWND hWnd, DWORD flags)
+{
+ BOOL Hook, Ret = FALSE;
+
+ LOADUSERAPIHOOK
+
+ Hook = BeginIfHookedUserApiHook();
+
+ /* Bypass SEH and go direct. */
+ if (!Hook) return RealMDIRedrawFrame(hWnd, flags);
+
+ _SEH2_TRY
+ {
+ Ret = guah.MDIRedrawFrame(hWnd, flags);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+
+ EndUserApiHook();
+
+ return Ret;
+}
+
+USERAPIHOOK guah =
+{
+ sizeof(USERAPIHOOK),
+ (WNDPROC)RealDefWindowProcA,
+ (WNDPROC)RealDefWindowProcW,
+ {NULL, 0},
+ (FARPROC)RealGetScrollInfo,
+ (FARPROC)RealSetScrollInfo,
+ (FARPROC)NtUserEnableScrollBar,
+ (FARPROC)RealAdjustWindowRectEx,
+ (FARPROC)NtUserSetWindowRgn,
+ (WNDPROC_OWP)DefaultOWP,
+ (WNDPROC_OWP)DefaultOWP,
+ {NULL, 0},
+ (WNDPROC_OWP)DefaultOWP,
+ (WNDPROC_OWP)DefaultOWP,
+ {NULL, 0},
+ (FARPROC)RealGetSystemMetrics,
+ (FARPROC)RealSystemParametersInfoA,
+ (FARPROC)RealSystemParametersInfoW,
+ (FARPROC)ForceResetUserApiHook,
+ (FARPROC)RealDrawFrameControl,
+ (FARPROC)NtUserDrawCaption,
+ (FARPROC)RealMDIRedrawFrame,
+ (FARPROC)GetRealWindowOwner,
+};
+
+/* FUNCTIONS *****************************************************************/
+
+/*
+ * @implemented
+ */
+BOOL WINAPI RegisterUserApiHook(PUSERAPIHOOKINFO puah)
+{
+ UNICODE_STRING m_dllname1;
+ UNICODE_STRING m_funname1;
+
+ if (puah->m_size == sizeof(USERAPIHOOKINFO))
+ {
+ WARN("RegisterUserApiHook: %S and %S",puah->m_dllname1,
puah->m_funname1);
+ RtlInitUnicodeString(&m_dllname1, puah->m_dllname1);
+ RtlInitUnicodeString(&m_funname1, puah->m_funname1);
+ return NtUserRegisterUserApiHook( &m_dllname1, &m_funname1, 0, 0);
+ }
+ return FALSE;
+}
+
+/*
+ * @implemented
+ */
+BOOL WINAPI UnregisterUserApiHook(VOID)
+{
+ // Direct call to Win32k! Here only as a prototype.....
+ UNIMPLEMENTED;
+ return FALSE;
+}
Propchange: trunk/reactos/dll/win32/user32/misc/usrapihk.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/dll/win32/user32/misc/usrapihk.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: trunk/reactos/dll/win32/user32/user32.pspec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/user32.ps…
==============================================================================
--- trunk/reactos/dll/win32/user32/user32.pspec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/user32.pspec [iso-8859-1] Tue Sep 15 17:24:09 2009
@@ -194,7 +194,7 @@
@ stdcall EditWndProc(long long long long) EditWndProcA
@ stdcall EmptyClipboard() NtUserEmptyClipboard
@ stdcall EnableMenuItem(long long long)
-@ stdcall EnableScrollBar(long long long) NtUserEnableScrollBar
+@ stdcall EnableScrollBar(long long long)
@ stdcall EnableWindow(long long)
@ stdcall EndDeferWindowPos(long)
@ stdcall EndDialog(long long)
@@ -557,7 +557,7 @@
@ stdcall RegisterShellHookWindow(long)
@ stdcall RegisterSystemThread(long long)
@ stdcall RegisterTasklist(long) NtUserRegisterTasklist
-@ stub RegisterUserApiHook
+@ stdcall RegisterUserApiHook(ptr)
@ stdcall RegisterWindowMessageA(str)
@ stdcall RegisterWindowMessageW(wstr)
@ stdcall ReleaseCapture()
@@ -711,7 +711,7 @@
@ stdcall UnregisterDeviceNotification(long)
@ stdcall UnregisterHotKey(long long) NtUserUnregisterHotKey
@ stub UnregisterMessagePumpHook
-@ stub UnregisterUserApiHook
+@ stdcall UnregisterUserApiHook() NtUserUnregisterUserApiHook
@ stdcall UpdateLayeredWindow(long long ptr ptr long ptr long ptr long)
@ stdcall UpdateLayeredWindowIndirect(long ptr)
@ stdcall UpdatePerUserSystemParameters(long long)
Modified: trunk/reactos/dll/win32/user32/user32.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/user32.rb…
==============================================================================
--- trunk/reactos/dll/win32/user32/user32.rbuild [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/user32.rbuild [iso-8859-1] Tue Sep 15 17:24:09 2009
@@ -43,6 +43,7 @@
<file>rtlstr.c</file>
<file>stubs.c</file>
<file>timer.c</file>
+ <file>usrapihk.c</file>
<file>winhelp.c</file>
<file>winsta.c</file>
<file>wsprintf.c</file>
Modified: trunk/reactos/dll/win32/user32/windows/defwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/d…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1] Tue Sep 15 17:24:09 2009
@@ -1879,10 +1879,10 @@
LRESULT WINAPI
-DefWindowProcA(HWND hWnd,
- UINT Msg,
- WPARAM wParam,
- LPARAM lParam)
+RealDefWindowProcA(HWND hWnd,
+ UINT Msg,
+ WPARAM wParam,
+ LPARAM lParam)
{
LRESULT Result = 0;
PWND Wnd;
@@ -2032,10 +2032,10 @@
LRESULT WINAPI
-DefWindowProcW(HWND hWnd,
- UINT Msg,
- WPARAM wParam,
- LPARAM lParam)
+RealDefWindowProcW(HWND hWnd,
+ UINT Msg,
+ WPARAM wParam,
+ LPARAM lParam)
{
LRESULT Result = 0;
PWND Wnd;
@@ -2175,3 +2175,68 @@
return Result;
}
+LRESULT WINAPI
+DefWindowProcA(HWND hWnd,
+ UINT Msg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ BOOL Hook, msgOverride;
+ LRESULT Result = 0;
+
+ LOADUSERAPIHOOK
+
+ Hook = BeginIfHookedUserApiHook();
+ if (Hook)
+ msgOverride = IsMsgOverride(Msg, &guah.DefWndProcArray);
+
+ /* Bypass SEH and go direct. */
+ if (!Hook || !msgOverride)
+ return RealDefWindowProcA(hWnd, Msg, wParam, lParam);
+
+ _SEH2_TRY
+ {
+ Result = guah.DefWindowProcA(hWnd, Msg, wParam, lParam);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+
+ EndUserApiHook();
+
+ return Result;
+}
+
+LRESULT WINAPI
+DefWindowProcW(HWND hWnd,
+ UINT Msg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ BOOL Hook, msgOverride;
+ LRESULT Result = 0;
+
+ LOADUSERAPIHOOK
+
+ Hook = BeginIfHookedUserApiHook();
+ if (Hook)
+ msgOverride = IsMsgOverride(Msg, &guah.DefWndProcArray);
+
+ /* Bypass SEH and go direct. */
+ if (!Hook || !msgOverride)
+ return RealDefWindowProcW(hWnd, Msg, wParam, lParam);
+
+ _SEH2_TRY
+ {
+ Result = guah.DefWindowProcW(hWnd, Msg, wParam, lParam);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+
+ EndUserApiHook();
+
+ return Result;
+}
Modified: trunk/reactos/dll/win32/user32/windows/draw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/d…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/draw.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/draw.c [iso-8859-1] Tue Sep 15 17:24:09 2009
@@ -1437,7 +1437,7 @@
* @implemented
*/
BOOL WINAPI
-DrawFrameControl(HDC hDC, LPRECT rc, UINT uType, UINT uState)
+RealDrawFrameControl(HDC hDC, LPRECT rc, UINT uType, UINT uState)
{
if (GetMapMode(hDC) != MM_TEXT)
return FALSE;
@@ -1461,6 +1461,32 @@
return FALSE;
}
+BOOL WINAPI
+DrawFrameControl(HDC hDC, LPRECT rc, UINT uType, UINT uState)
+{
+ BOOL Hook, Ret = FALSE;
+
+ LOADUSERAPIHOOK
+
+ Hook = BeginIfHookedUserApiHook();
+
+ /* Bypass SEH and go direct. */
+ if (!Hook) return RealDrawFrameControl(hDC, rc, uType, uState);
+
+ _SEH2_TRY
+ {
+ Ret = guah.DrawFrameControl(hDC, rc, uType, uState);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+
+ EndUserApiHook();
+
+ return Ret;
+}
+
/*
* @implemented
*/
Modified: trunk/reactos/dll/win32/user32/windows/message.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/m…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] Tue Sep 15 17:24:09
2009
@@ -1138,6 +1138,7 @@
LRESULT FASTCALL
IntCallWindowProcW(BOOL IsAnsiProc,
WNDPROC WndProc,
+ PWND pWnd,
HWND hWnd,
UINT Msg,
WPARAM wParam,
@@ -1145,7 +1146,9 @@
{
MSG AnsiMsg;
MSG UnicodeMsg;
- LRESULT Result;
+ BOOL Hook = FALSE, MsgOverride = FALSE, Dialog;
+ LRESULT Result = 0, PreResult = 0;
+ DWORD Data = 0;
if (WndProc == NULL)
{
@@ -1153,33 +1156,116 @@
return FALSE;
}
+ if (pWnd)
+ Dialog = (pWnd->fnid == FNID_DIALOG);
+ else
+ Dialog = FALSE;
+
+ Hook = BeginIfHookedUserApiHook();
+ if (Hook)
+ {
+ if (!Dialog)
+ MsgOverride = IsMsgOverride( Msg, &guah.WndProcArray);
+ else
+ MsgOverride = IsMsgOverride( Msg, &guah.DlgProcArray);
+ }
+
if (IsAnsiProc)
- {
+ {
UnicodeMsg.hwnd = hWnd;
UnicodeMsg.message = Msg;
UnicodeMsg.wParam = wParam;
UnicodeMsg.lParam = lParam;
if (! MsgiUnicodeToAnsiMessage(&AnsiMsg, &UnicodeMsg))
- {
- return FALSE;
- }
+ {
+ goto Exit;
+ }
+
+ if (Hook && MsgOverride)
+ {
+ _SEH2_TRY
+ {
+ if (!Dialog)
+ PreResult = guah.PreWndProc(AnsiMsg.hwnd, AnsiMsg.message, AnsiMsg.wParam,
AnsiMsg.lParam, (ULONG_PTR)&Result, &Data );
+ else
+ PreResult = guah.PreDefDlgProc(AnsiMsg.hwnd, AnsiMsg.message,
AnsiMsg.wParam, AnsiMsg.lParam, (ULONG_PTR)&Result, &Data );
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+ }
+
+ if (PreResult) goto Exit;
+
Result = WndProc(AnsiMsg.hwnd, AnsiMsg.message, AnsiMsg.wParam, AnsiMsg.lParam);
+ if (Hook && MsgOverride)
+ {
+ _SEH2_TRY
+ {
+ if (!Dialog)
+ guah.PostWndProc(AnsiMsg.hwnd, AnsiMsg.message, AnsiMsg.wParam,
AnsiMsg.lParam, (ULONG_PTR)&Result, &Data );
+ else
+ guah.PostDefDlgProc(AnsiMsg.hwnd, AnsiMsg.message, AnsiMsg.wParam,
AnsiMsg.lParam, (ULONG_PTR)&Result, &Data );
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+ }
+
if (! MsgiUnicodeToAnsiReply(&AnsiMsg, &UnicodeMsg, &Result))
- {
- return FALSE;
- }
- return Result;
- }
+ {
+ goto Exit;
+ }
+ }
else
- {
- return WndProc(hWnd, Msg, wParam, lParam);
- }
+ {
+ if (Hook && MsgOverride)
+ {
+ _SEH2_TRY
+ {
+ if (!Dialog)
+ PreResult = guah.PreWndProc(hWnd, Msg, wParam, lParam,
(ULONG_PTR)&Result, &Data );
+ else
+ PreResult = guah.PreDefDlgProc(hWnd, Msg, wParam, lParam,
(ULONG_PTR)&Result, &Data );
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+ }
+
+ if (PreResult) goto Exit;
+
+ Result = WndProc(hWnd, Msg, wParam, lParam);
+
+ if (Hook && MsgOverride)
+ {
+ _SEH2_TRY
+ {
+ if (!Dialog)
+ guah.PostWndProc(hWnd, Msg, wParam, lParam, (ULONG_PTR)&Result,
&Data );
+ else
+ guah.PostDefDlgProc(hWnd, Msg, wParam, lParam, (ULONG_PTR)&Result,
&Data );
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+ }
+ }
+
+Exit:
+ if (Hook) EndUserApiHook();
+ return Result;
}
static LRESULT FASTCALL
IntCallWindowProcA(BOOL IsAnsiProc,
WNDPROC WndProc,
+ PWND pWnd,
HWND hWnd,
UINT Msg,
WPARAM wParam,
@@ -1187,7 +1273,9 @@
{
MSG AnsiMsg;
MSG UnicodeMsg;
- LRESULT Result;
+ BOOL Hook = FALSE, MsgOverride = FALSE, Dialog;
+ LRESULT Result = 0, PreResult = 0;
+ DWORD Data = 0;
if (WndProc == NULL)
{
@@ -1195,29 +1283,111 @@
return FALSE;
}
+ if (pWnd)
+ Dialog = (pWnd->fnid == FNID_DIALOG);
+ else
+ Dialog = FALSE;
+
+ Hook = BeginIfHookedUserApiHook();
+ if (Hook)
+ {
+ if (!Dialog)
+ MsgOverride = IsMsgOverride( Msg, &guah.WndProcArray);
+ else
+ MsgOverride = IsMsgOverride( Msg, &guah.DlgProcArray);
+ }
+
if (IsAnsiProc)
- {
- return WndProc(hWnd, Msg, wParam, lParam);
- }
+ {
+ if (Hook && MsgOverride)
+ {
+ _SEH2_TRY
+ {
+ if (!Dialog)
+ PreResult = guah.PreWndProc(hWnd, Msg, wParam, lParam,
(ULONG_PTR)&Result, &Data );
+ else
+ PreResult = guah.PreDefDlgProc(hWnd, Msg, wParam, lParam,
(ULONG_PTR)&Result, &Data );
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+ }
+
+ if (PreResult) goto Exit;
+
+ Result = WndProc(hWnd, Msg, wParam, lParam);
+
+ if (Hook && MsgOverride)
+ {
+ _SEH2_TRY
+ {
+ if (!Dialog)
+ guah.PostWndProc(hWnd, Msg, wParam, lParam, (ULONG_PTR)&Result,
&Data );
+ else
+ guah.PostDefDlgProc(hWnd, Msg, wParam, lParam, (ULONG_PTR)&Result,
&Data );
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+ }
+ }
else
- {
+ {
AnsiMsg.hwnd = hWnd;
AnsiMsg.message = Msg;
AnsiMsg.wParam = wParam;
AnsiMsg.lParam = lParam;
if (! MsgiAnsiToUnicodeMessage(&UnicodeMsg, &AnsiMsg))
- {
- return FALSE;
- }
+ {
+ goto Exit;
+ }
+
+ if (Hook && MsgOverride)
+ {
+ _SEH2_TRY
+ {
+ if (!Dialog)
+ PreResult = guah.PreWndProc(UnicodeMsg.hwnd, UnicodeMsg.message,
UnicodeMsg.wParam, UnicodeMsg.lParam, (ULONG_PTR)&Result, &Data );
+ else
+ PreResult = guah.PreDefDlgProc(UnicodeMsg.hwnd, UnicodeMsg.message,
UnicodeMsg.wParam, UnicodeMsg.lParam, (ULONG_PTR)&Result, &Data );
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+ }
+
+ if (PreResult) goto Exit;
+
Result = WndProc(UnicodeMsg.hwnd, UnicodeMsg.message,
UnicodeMsg.wParam, UnicodeMsg.lParam);
+ if (Hook && MsgOverride)
+ {
+ _SEH2_TRY
+ {
+ if (!Dialog)
+ guah.PostWndProc(UnicodeMsg.hwnd, UnicodeMsg.message, UnicodeMsg.wParam,
UnicodeMsg.lParam, (ULONG_PTR)&Result, &Data );
+ else
+ guah.PostDefDlgProc(UnicodeMsg.hwnd, UnicodeMsg.message,
UnicodeMsg.wParam, UnicodeMsg.lParam, (ULONG_PTR)&Result, &Data );
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+ }
+
if (! MsgiAnsiToUnicodeReply(&UnicodeMsg, &AnsiMsg, &Result))
- {
- return FALSE;
- }
- return Result;
- }
+ {
+ goto Exit;
+ }
+ }
+
+Exit:
+ if (Hook) EndUserApiHook();
+ return Result;
}
@@ -1267,9 +1437,9 @@
the same.
*/
if (!Ansi)
- return IntCallWindowProcW(IsAnsi, WndProc, hWnd, Msg, wParam, lParam);
+ return IntCallWindowProcW(IsAnsi, WndProc, Wnd, hWnd, Msg, wParam, lParam);
else
- return IntCallWindowProcA(IsAnsi, WndProc, hWnd, Msg, wParam, lParam);
+ return IntCallWindowProcA(IsAnsi, WndProc, Wnd, hWnd, Msg, wParam, lParam);
}
@@ -1283,6 +1453,7 @@
WPARAM wParam,
LPARAM lParam)
{
+ PWND pWnd;
PCALLPROCDATA CallProc;
if (lpPrevWndFunc == NULL)
@@ -1291,8 +1462,10 @@
return 0;
}
+ pWnd = ValidateHwnd(hWnd);
+
if (!IsCallProcHandle(lpPrevWndFunc))
- return IntCallWindowProcA(TRUE, lpPrevWndFunc, hWnd, Msg, wParam, lParam);
+ return IntCallWindowProcA(TRUE, lpPrevWndFunc, pWnd, hWnd, Msg, wParam, lParam);
else
{
CallProc = ValidateCallProc((HANDLE)lpPrevWndFunc);
@@ -1300,6 +1473,7 @@
{
return IntCallWindowProcA(!(CallProc->wType & UserGetCPDA2U),
CallProc->pfnClientPrevious,
+ pWnd,
hWnd,
Msg,
wParam,
@@ -1324,6 +1498,7 @@
WPARAM wParam,
LPARAM lParam)
{
+ PWND pWnd;
PCALLPROCDATA CallProc;
/* FIXME - can the first parameter be NULL? */
@@ -1333,8 +1508,10 @@
return 0;
}
+ pWnd = ValidateHwnd(hWnd);
+
if (!IsCallProcHandle(lpPrevWndFunc))
- return IntCallWindowProcW(FALSE, lpPrevWndFunc, hWnd, Msg, wParam, lParam);
+ return IntCallWindowProcW(FALSE, lpPrevWndFunc, pWnd, hWnd, Msg, wParam,
lParam);
else
{
CallProc = ValidateCallProc((HANDLE)lpPrevWndFunc);
@@ -1342,6 +1519,7 @@
{
return IntCallWindowProcW(!(CallProc->wType & UserGetCPDA2U),
CallProc->pfnClientPrevious,
+ pWnd,
hWnd,
Msg,
wParam,
@@ -1821,13 +1999,14 @@
MSG UMMsg, KMMsg;
NTUSERSENDMESSAGEINFO Info;
LRESULT Result;
+ PWND Window;
+ PTHREADINFO ti = GetW32ThreadInfo();
+
+ Window = ValidateHwnd(Wnd);
+ if (!Window) return FALSE;
if (Wnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST))
{
- PWND Window;
- PTHREADINFO ti = GetW32ThreadInfo();
-
- Window = ValidateHwnd(Wnd);
if (Window != NULL && Window->head.pti == ti &&
!IsThreadHooked(GetWin32ClientInfo()))
{
/* NOTE: We can directly send messages to the window procedure
@@ -1861,6 +2040,7 @@
/* We need to send the message ourselves */
Result = IntCallWindowProcW( Info.Ansi,
Info.Proc,
+ Window,
UMMsg.hwnd,
UMMsg.message,
UMMsg.wParam,
@@ -1885,13 +2065,14 @@
MSG KMMsg;
LRESULT Result;
NTUSERSENDMESSAGEINFO Info;
+ PWND Window;
+ PTHREADINFO ti = GetW32ThreadInfo();
+
+ Window = ValidateHwnd(Wnd);
+ if (!Window) return FALSE;
if (Wnd != HWND_BROADCAST && (Msg < WM_DDE_FIRST || Msg > WM_DDE_LAST))
{
- PWND Window;
- PTHREADINFO ti = GetW32ThreadInfo();
-
- Window = ValidateHwnd(Wnd);
if (Window != NULL && Window->head.pti == ti &&
!IsThreadHooked(GetWin32ClientInfo()))
{
/* NOTE: We can directly send messages to the window procedure
@@ -1934,7 +2115,7 @@
the Unicode message though */
MsgiUMToKMCleanup(&UcMsg, &KMMsg);
MsgiAnsiToUnicodeCleanup(&UcMsg, &AnsiMsg);
- Result = IntCallWindowProcA(Info.Ansi, Info.Proc, Wnd, Msg, wParam, lParam);
+ Result = IntCallWindowProcA(Info.Ansi, Info.Proc, Window, Wnd, Msg, wParam,
lParam);
}
else
{
@@ -1943,6 +2124,7 @@
message to avoid another conversion */
Result = IntCallWindowProcW( Info.Ansi,
Info.Proc,
+ Window,
UcMsg.hwnd,
UcMsg.message,
UcMsg.wParam,
@@ -2048,21 +2230,28 @@
}
if (! Info.HandledByKernel)
{
+ PWND pWnd;
+ pWnd = ValidateHwnd(hWnd);
/* We need to send the message ourselves */
if (Info.Ansi)
{
/* Ansi message and Ansi window proc, that's easy. Clean up
the Unicode message though */
MsgiAnsiToUnicodeCleanup(&UcMsg, &AnsiMsg);
- Result = IntCallWindowProcA(Info.Ansi, Info.Proc, hWnd, Msg, wParam, lParam);
+ Result = IntCallWindowProcA(Info.Ansi, Info.Proc, pWnd, hWnd, Msg, wParam,
lParam);
}
else
{
/* Unicode winproc. Although we started out with an Ansi message we
already converted it to Unicode for the kernel call. Reuse that
message to avoid another conversion */
- Result = IntCallWindowProcW(Info.Ansi, Info.Proc, UcMsg.hwnd,
- UcMsg.message, UcMsg.wParam, UcMsg.lParam);
+ Result = IntCallWindowProcW( Info.Ansi,
+ Info.Proc,
+ pWnd,
+ UcMsg.hwnd,
+ UcMsg.message,
+ UcMsg.wParam,
+ UcMsg.lParam);
if (! MsgiAnsiToUnicodeReply(&UcMsg, &AnsiMsg, &Result))
{
SPY_ExitMessage(SPY_RESULT_OK, hWnd, Msg, Result, wParam, lParam);
@@ -2112,8 +2301,10 @@
lpdwResult, &Info);
if (! Info.HandledByKernel)
{
+ PWND pWnd;
+ pWnd = ValidateHwnd(hWnd);
/* We need to send the message ourselves */
- Result = IntCallWindowProcW(Info.Ansi, Info.Proc, hWnd, Msg, wParam, lParam);
+ Result = IntCallWindowProcW(Info.Ansi, Info.Proc, pWnd, hWnd, Msg, wParam,
lParam);
if(lpdwResult)
*lpdwResult = Result;
@@ -2322,6 +2513,8 @@
{
PWINDOWPROC_CALLBACK_ARGUMENTS CallbackArgs;
MSG KMMsg, UMMsg;
+ PWND pWnd = NULL;
+ PCLIENTINFO pci = GetWin32ClientInfo();
/* Make sure we don't try to access mem beyond what we were given */
if (ArgumentLength < sizeof(WINDOWPROC_CALLBACK_ARGUMENTS))
@@ -2362,8 +2555,12 @@
{
}
+ if (pci->CallbackWnd.hWnd == UMMsg.hwnd)
+ pWnd = pci->CallbackWnd.pvWnd;
+
CallbackArgs->Result = IntCallWindowProcW( CallbackArgs->IsAnsiProc,
CallbackArgs->Proc,
+ pWnd,
UMMsg.hwnd,
UMMsg.message,
UMMsg.wParam,
Modified: trunk/reactos/dll/win32/user32/windows/nonclient.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/n…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/nonclient.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/nonclient.c [iso-8859-1] Tue Sep 15 17:24:09
2009
@@ -1058,6 +1058,34 @@
/* PUBLIC FUNCTIONS ***********************************************************/
+BOOL WINAPI
+RealAdjustWindowRectEx(LPRECT lpRect,
+ DWORD dwStyle,
+ BOOL bMenu,
+ DWORD dwExStyle)
+{
+ SIZE BorderSize;
+
+ if (bMenu)
+ {
+ lpRect->top -= GetSystemMetrics(SM_CYMENU);
+ }
+ if ((dwStyle & WS_CAPTION) == WS_CAPTION)
+ {
+ if (dwExStyle & WS_EX_TOOLWINDOW)
+ lpRect->top -= GetSystemMetrics(SM_CYSMCAPTION);
+ else
+ lpRect->top -= GetSystemMetrics(SM_CYCAPTION);
+ }
+ UserGetWindowBorders(dwStyle, dwExStyle, &BorderSize, TRUE);
+ InflateRect(
+ lpRect,
+ BorderSize.cx,
+ BorderSize.cy);
+
+ return TRUE;
+}
+
/*
* @implemented
*/
@@ -1067,26 +1095,27 @@
BOOL bMenu,
DWORD dwExStyle)
{
- SIZE BorderSize;
-
- if (bMenu)
- {
- lpRect->top -= GetSystemMetrics(SM_CYMENU);
- }
- if ((dwStyle & WS_CAPTION) == WS_CAPTION)
- {
- if (dwExStyle & WS_EX_TOOLWINDOW)
- lpRect->top -= GetSystemMetrics(SM_CYSMCAPTION);
- else
- lpRect->top -= GetSystemMetrics(SM_CYCAPTION);
- }
- UserGetWindowBorders(dwStyle, dwExStyle, &BorderSize, TRUE);
- InflateRect(
- lpRect,
- BorderSize.cx,
- BorderSize.cy);
-
- return TRUE;
+ BOOL Hook, Ret = FALSE;
+
+ LOADUSERAPIHOOK
+
+ Hook = BeginIfHookedUserApiHook();
+
+ /* Bypass SEH and go direct. */
+ if (!Hook) return RealAdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle);
+
+ _SEH2_TRY
+ {
+ Ret = guah.AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+
+ EndUserApiHook();
+
+ return Ret;
}
@@ -1110,7 +1139,27 @@
BOOL WINAPI
DrawCaption(HWND hWnd, HDC hDC, LPCRECT lprc, UINT uFlags)
{
- return NtUserDrawCaption(hWnd, hDC, lprc, uFlags);
+ BOOL Hook, Ret = FALSE;
+
+ LOADUSERAPIHOOK
+
+ Hook = BeginIfHookedUserApiHook();
+
+ /* Bypass SEH and go direct. */
+ if (!Hook) return NtUserDrawCaption(hWnd, hDC, lprc, uFlags);
+
+ _SEH2_TRY
+ {
+ Ret = guah.DrawCaption(hWnd, hDC, lprc, uFlags);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+
+ EndUserApiHook();
+
+ return Ret;
}
/*
Modified: trunk/reactos/dll/win32/user32/windows/paint.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/p…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/paint.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/paint.c [iso-8859-1] Tue Sep 15 17:24:09 2009
@@ -131,7 +131,6 @@
lprcUpdate);
}
-
/*
* @implemented
*/
@@ -142,9 +141,29 @@
HRGN hRgn,
BOOL bRedraw)
{
- return (int)NtUserSetWindowRgn(hWnd, hRgn, bRedraw);
-}
-
+ BOOL Hook;
+ int Ret = 0;
+
+ LOADUSERAPIHOOK
+
+ Hook = BeginIfHookedUserApiHook();
+
+ /* Bypass SEH and go direct. */
+ if (!Hook) return (int)NtUserSetWindowRgn(hWnd, hRgn, bRedraw);
+
+ _SEH2_TRY
+ {
+ Ret = guah.SetWindowRgn(hWnd, hRgn, bRedraw);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+ _SEH2_END;
+
+ EndUserApiHook();
+
+ return Ret;
+}
/*
* @implemented
Modified: trunk/reactos/dll/win32/user32/windows/window.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/w…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] Tue Sep 15 17:24:09 2009
@@ -1875,6 +1875,12 @@
return (HWND)NtUserGetThreadState(THREADSTATE_FOCUSWINDOW);
}
+DWORD WINAPI
+GetRealWindowOwner(HWND hwnd)
+{
+ return NtUserQueryWindow(hwnd, QUERY_WINDOW_REAL_ID);
+}
+
/*
* @implemented
*/
Modified: trunk/reactos/include/reactos/win32k/ntuser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntu…
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Tue Sep 15 17:24:09 2009
@@ -560,6 +560,7 @@
#define COLOR_LAST COLOR_MENUBAR
#define MAX_MB_STRINGS 11
+#define SRVINFO_APIHOOK 0x0010
#define SRVINFO_METRICS 0x0020
typedef struct tagOEMBITMAPINFO
@@ -2359,11 +2360,13 @@
IN UINT uiNumDevices,
IN UINT cbSize);
-DWORD
+BOOL
NTAPI
NtUserRegisterUserApiHook(
- DWORD dwUnknown1,
- DWORD dwUnknown2);
+ PUNICODE_STRING m_dllname1,
+ PUNICODE_STRING m_funname1,
+ DWORD dwUnknown3,
+ DWORD dwUnknown4);
BOOL
NTAPI
@@ -2875,7 +2878,7 @@
NtUserUnregisterHotKey(HWND hWnd,
int id);
-DWORD
+BOOL
NTAPI
NtUserUnregisterUserApiHook(VOID);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c [iso-8859-1] Tue Sep 15
17:24:09 2009
@@ -949,13 +949,17 @@
return 0;
}
-DWORD
+BOOL
APIENTRY
NtUserRegisterUserApiHook(
- DWORD dwUnknown1,
- DWORD dwUnknown2)
-{
- UNIMPLEMENTED;
+ PUNICODE_STRING m_dllname1,
+ PUNICODE_STRING m_funname1,
+ DWORD dwUnknown3,
+ DWORD dwUnknown4)
+{
+ UserEnterExclusive();
+ UNIMPLEMENTED;
+ UserLeave();
return 0;
}
@@ -1080,7 +1084,7 @@
return 0;
}
-DWORD
+BOOL
APIENTRY
NtUserUnregisterUserApiHook(VOID)
{
Modified: trunk/reactos/subsystems/win32/win32k/w32ksvc.db
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/w3…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] Tue Sep 15 17:24:09
2009
@@ -493,7 +493,7 @@
NtUserRealWaitMessageEx 2
NtUserRedrawWindow 4
NtUserRegisterClassExWOW 7
-NtUserRegisterUserApiHook 2
+NtUserRegisterUserApiHook 4
NtUserRegisterHotKey 4
NtUserRegisterRawInputDevices 3
NtUserRegisterTasklist 1