mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:52:57 +00:00
[WIN32SS/USER]
- Handle transferring buffer to user mode in WH_CALLWNDPROC(RET) hooks if lParam is a pointer. This fixes the gallium3d opengl ICD, so newest VMWare opengl Driver should now work. Please TEST! svn path=/trunk/; revision=56931
This commit is contained in:
parent
5cc65e64c7
commit
4be2c40f92
4 changed files with 77 additions and 23 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include <win32k.h>
|
#include <win32k.h>
|
||||||
DBG_DEFAULT_CHANNEL(UserCallback);
|
DBG_DEFAULT_CHANNEL(UserCallback);
|
||||||
|
|
||||||
|
|
||||||
/* CALLBACK MEMORY MANAGEMENT ************************************************/
|
/* CALLBACK MEMORY MANAGEMENT ************************************************/
|
||||||
|
|
||||||
typedef struct _INT_CALLBACK_HEADER
|
typedef struct _INT_CALLBACK_HEADER
|
||||||
|
@ -443,6 +444,7 @@ co_IntCallHookProc(INT HookId,
|
||||||
PWND pWnd;
|
PWND pWnd;
|
||||||
PMSG pMsg = NULL;
|
PMSG pMsg = NULL;
|
||||||
BOOL Hit = FALSE;
|
BOOL Hit = FALSE;
|
||||||
|
UINT lParamSize = 0;
|
||||||
|
|
||||||
ASSERT(Proc);
|
ASSERT(Proc);
|
||||||
|
|
||||||
|
@ -509,11 +511,21 @@ co_IntCallHookProc(INT HookId,
|
||||||
ArgumentLength += sizeof(MOUSEHOOKSTRUCT);
|
ArgumentLength += sizeof(MOUSEHOOKSTRUCT);
|
||||||
break;
|
break;
|
||||||
case WH_CALLWNDPROC:
|
case WH_CALLWNDPROC:
|
||||||
|
{
|
||||||
|
CWPSTRUCT* pCWP = (CWPSTRUCT*) lParam;
|
||||||
ArgumentLength += sizeof(CWPSTRUCT);
|
ArgumentLength += sizeof(CWPSTRUCT);
|
||||||
|
lParamSize = lParamMemorySize(pCWP->message, pCWP->wParam, pCWP->lParam);
|
||||||
|
ArgumentLength += lParamSize;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case WH_CALLWNDPROCRET:
|
case WH_CALLWNDPROCRET:
|
||||||
|
{
|
||||||
|
CWPRETSTRUCT* pCWPR = (CWPRETSTRUCT*) lParam;
|
||||||
ArgumentLength += sizeof(CWPRETSTRUCT);
|
ArgumentLength += sizeof(CWPRETSTRUCT);
|
||||||
|
lParamSize = lParamMemorySize(pCWPR->message, pCWPR->wParam, pCWPR->lParam);
|
||||||
|
ArgumentLength += lParamSize;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case WH_MSGFILTER:
|
case WH_MSGFILTER:
|
||||||
case WH_SYSMSGFILTER:
|
case WH_SYSMSGFILTER:
|
||||||
case WH_GETMESSAGE:
|
case WH_GETMESSAGE:
|
||||||
|
@ -583,12 +595,25 @@ co_IntCallHookProc(INT HookId,
|
||||||
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
|
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
|
||||||
break;
|
break;
|
||||||
case WH_CALLWNDPROC:
|
case WH_CALLWNDPROC:
|
||||||
|
/* For CALLWNDPROC and CALLWNDPROCRET, we must be wary of the fact that
|
||||||
|
* lParam could be a pointer to a buffer. This buffer must be exported
|
||||||
|
* to user space too */
|
||||||
RtlCopyMemory(Extra, (PVOID) lParam, sizeof(CWPSTRUCT));
|
RtlCopyMemory(Extra, (PVOID) lParam, sizeof(CWPSTRUCT));
|
||||||
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
|
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
|
||||||
|
if(lParamSize)
|
||||||
|
{
|
||||||
|
RtlCopyMemory(Extra + sizeof(CWPSTRUCT), (PVOID)((CWPSTRUCT*)lParam)->lParam, lParamSize);
|
||||||
|
((CWPSTRUCT*)Extra)->lParam = (LPARAM)lParamSize;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case WH_CALLWNDPROCRET:
|
case WH_CALLWNDPROCRET:
|
||||||
RtlCopyMemory(Extra, (PVOID) lParam, sizeof(CWPRETSTRUCT));
|
RtlCopyMemory(Extra, (PVOID) lParam, sizeof(CWPRETSTRUCT));
|
||||||
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
|
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
|
||||||
|
if(lParamSize)
|
||||||
|
{
|
||||||
|
RtlCopyMemory(Extra + sizeof(CWPRETSTRUCT), (PVOID)((CWPRETSTRUCT*)lParam)->lParam, lParamSize);
|
||||||
|
((CWPRETSTRUCT*)Extra)->lParam = (LPARAM)lParamSize;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case WH_MSGFILTER:
|
case WH_MSGFILTER:
|
||||||
case WH_SYSMSGFILTER:
|
case WH_SYSMSGFILTER:
|
||||||
|
|
|
@ -223,6 +223,13 @@ MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UINT lParamMemorySize(UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
PMSGMEMORY MsgMemory = FindMsgMemory(Msg);
|
||||||
|
if(MsgMemory == NULL) return 0;
|
||||||
|
return MsgMemorySize(MsgMemory, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolNeeded)
|
PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL NonPagedPoolNeeded)
|
||||||
{
|
{
|
||||||
|
|
|
@ -296,4 +296,6 @@ UserSetCursor(PCURICON_OBJECT NewCursor,
|
||||||
BOOL ForceChange);
|
BOOL ForceChange);
|
||||||
|
|
||||||
DWORD APIENTRY IntGetQueueStatus(DWORD);
|
DWORD APIENTRY IntGetQueueStatus(DWORD);
|
||||||
|
|
||||||
|
UINT lParamMemorySize(UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -558,8 +558,8 @@ User32CallHookProcFromKernel(PVOID Arguments, ULONG ArgumentLength)
|
||||||
MSLLHOOKSTRUCT MouseLlData, *pMouseLlData;
|
MSLLHOOKSTRUCT MouseLlData, *pMouseLlData;
|
||||||
MSG *pcMsg, *pMsg;
|
MSG *pcMsg, *pMsg;
|
||||||
PMOUSEHOOKSTRUCT pMHook;
|
PMOUSEHOOKSTRUCT pMHook;
|
||||||
CWPSTRUCT CWP, *pCWP;
|
CWPSTRUCT *pCWP;
|
||||||
CWPRETSTRUCT CWPR, *pCWPR;
|
CWPRETSTRUCT *pCWPR;
|
||||||
PRECTL prl;
|
PRECTL prl;
|
||||||
LPCBTACTIVATESTRUCT pcbtas;
|
LPCBTACTIVATESTRUCT pcbtas;
|
||||||
WPARAM wParam = 0;
|
WPARAM wParam = 0;
|
||||||
|
@ -666,14 +666,34 @@ User32CallHookProcFromKernel(PVOID Arguments, ULONG ArgumentLength)
|
||||||
break;
|
break;
|
||||||
case WH_CALLWNDPROC:
|
case WH_CALLWNDPROC:
|
||||||
// ERR("WH_CALLWNDPROC: Code %d, wParam %d\n",Common->Code,Common->wParam);
|
// ERR("WH_CALLWNDPROC: Code %d, wParam %d\n",Common->Code,Common->wParam);
|
||||||
pCWP = (PCWPSTRUCT)((PCHAR) Common + Common->lParam);
|
pCWP = HeapAlloc(GetProcessHeap(), 0, ArgumentLength - sizeof(HOOKPROC_CALLBACK_ARGUMENTS));
|
||||||
RtlCopyMemory(&CWP, pCWP, sizeof(CWPSTRUCT));
|
RtlCopyMemory(pCWP, (PCHAR) Common + Common->lParam, sizeof(CWPSTRUCT));
|
||||||
Result = Common->Proc(Common->Code, Common->wParam, (LPARAM) &CWP);
|
/* If more memory is reserved, then lParam is a pointer.
|
||||||
|
* Size of the buffer is stocked in the lParam member, and its content
|
||||||
|
* is at the end of the argument buffer */
|
||||||
|
if(ArgumentLength > (sizeof(CWPSTRUCT) + sizeof(HOOKPROC_CALLBACK_ARGUMENTS)))
|
||||||
|
{
|
||||||
|
RtlCopyMemory((PCHAR)pCWP + sizeof(CWPSTRUCT),
|
||||||
|
(PCHAR)Common + Common->lParam + sizeof(CWPSTRUCT),
|
||||||
|
pCWP->lParam);
|
||||||
|
pCWP->lParam = (LPARAM)((PCHAR)pCWP + sizeof(CWPSTRUCT));
|
||||||
|
}
|
||||||
|
Result = Common->Proc(Common->Code, Common->wParam, (LPARAM) pCWP);
|
||||||
|
HeapFree(GetProcessHeap(), 0, pCWP);
|
||||||
break;
|
break;
|
||||||
case WH_CALLWNDPROCRET:
|
case WH_CALLWNDPROCRET:
|
||||||
pCWPR = (PCWPRETSTRUCT)((PCHAR) Common + Common->lParam);
|
/* Almost the same as WH_CALLWNDPROC */
|
||||||
RtlCopyMemory(&CWPR, pCWPR, sizeof(CWPRETSTRUCT));
|
pCWPR = HeapAlloc(GetProcessHeap(), 0, ArgumentLength - sizeof(HOOKPROC_CALLBACK_ARGUMENTS));
|
||||||
Result = Common->Proc(Common->Code, Common->wParam, (LPARAM) &CWPR);
|
RtlCopyMemory(pCWPR, (PCHAR) Common + Common->lParam, sizeof(CWPRETSTRUCT));
|
||||||
|
if(ArgumentLength > (sizeof(CWPRETSTRUCT) + sizeof(HOOKPROC_CALLBACK_ARGUMENTS)))
|
||||||
|
{
|
||||||
|
RtlCopyMemory((PCHAR)pCWPR + sizeof(CWPRETSTRUCT),
|
||||||
|
(PCHAR)Common + Common->lParam + sizeof(CWPRETSTRUCT),
|
||||||
|
pCWPR->lParam);
|
||||||
|
pCWPR->lParam = (LPARAM)((PCHAR)pCWPR + sizeof(CWPRETSTRUCT));
|
||||||
|
}
|
||||||
|
Result = Common->Proc(Common->Code, Common->wParam, (LPARAM) pCWPR);
|
||||||
|
HeapFree(GetProcessHeap(), 0, pCWPR);
|
||||||
break;
|
break;
|
||||||
case WH_MSGFILTER: /* All SEH support */
|
case WH_MSGFILTER: /* All SEH support */
|
||||||
case WH_SYSMSGFILTER:
|
case WH_SYSMSGFILTER:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue