2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32k subsystem
4 * PURPOSE: Callback to usermode support
5 * FILE: subsystems/win32/win32k/ntuser/callback.c
6 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * Thomas Weidenmueller (w3seek@users.sourceforge.net)
8 * NOTES: Please use the Callback Memory Management functions for
9 * callbacks to make sure, the memory is freed on thread
14 DBG_DEFAULT_CHANNEL(UserCallback
);
17 /* CALLBACK MEMORY MANAGEMENT ************************************************/
19 typedef struct _INT_CALLBACK_HEADER
21 /* List entry in the THREADINFO structure */
24 INT_CALLBACK_HEADER
, *PINT_CALLBACK_HEADER
;
27 IntCbAllocateMemory(ULONG Size
)
29 PINT_CALLBACK_HEADER Mem
;
30 PTHREADINFO W32Thread
;
32 if(!(Mem
= ExAllocatePoolWithTag(PagedPool
, Size
+ sizeof(INT_CALLBACK_HEADER
),
38 W32Thread
= PsGetCurrentThreadWin32Thread();
41 /* Insert the callback memory into the thread's callback list */
43 InsertTailList(&W32Thread
->W32CallbackListHead
, &Mem
->ListEntry
);
49 IntCbFreeMemory(PVOID Data
)
51 PINT_CALLBACK_HEADER Mem
;
52 PTHREADINFO W32Thread
;
56 Mem
= ((PINT_CALLBACK_HEADER
)Data
- 1);
58 W32Thread
= PsGetCurrentThreadWin32Thread();
61 /* Remove the memory block from the thread's callback list */
62 RemoveEntryList(&Mem
->ListEntry
);
65 ExFreePoolWithTag(Mem
, USERTAG_CALLBACK
);
69 IntCleanupThreadCallbacks(PTHREADINFO W32Thread
)
71 PLIST_ENTRY CurrentEntry
;
72 PINT_CALLBACK_HEADER Mem
;
74 while (!IsListEmpty(&W32Thread
->W32CallbackListHead
))
76 CurrentEntry
= RemoveHeadList(&W32Thread
->W32CallbackListHead
);
77 Mem
= CONTAINING_RECORD(CurrentEntry
, INT_CALLBACK_HEADER
,
81 ExFreePoolWithTag(Mem
, USERTAG_CALLBACK
);
86 // Pass the Current Window handle and pointer to the Client Callback.
87 // This will help user space programs speed up read access with the window object.
90 IntSetTebWndCallback (HWND
* hWnd
, PWND
* pWnd
, PVOID
* pActCtx
)
93 PWND Window
= UserGetWindowObject(*hWnd
);
94 PCLIENTINFO ClientInfo
= GetWin32ClientInfo();
96 *hWnd
= ClientInfo
->CallbackWnd
.hWnd
;
97 *pWnd
= ClientInfo
->CallbackWnd
.pWnd
;
98 *pActCtx
= ClientInfo
->CallbackWnd
.pActCtx
;
100 ClientInfo
->CallbackWnd
.hWnd
= hWndS
;
101 ClientInfo
->CallbackWnd
.pWnd
= DesktopHeapAddressToUser(Window
);
102 ClientInfo
->CallbackWnd
.pActCtx
= Window
->pActCtx
;
106 IntRestoreTebWndCallback (HWND hWnd
, PWND pWnd
, PVOID pActCtx
)
108 PCLIENTINFO ClientInfo
= GetWin32ClientInfo();
110 ClientInfo
->CallbackWnd
.hWnd
= hWnd
;
111 ClientInfo
->CallbackWnd
.pWnd
= pWnd
;
112 ClientInfo
->CallbackWnd
.pActCtx
= pActCtx
;
115 /* FUNCTIONS *****************************************************************/
117 /* Calls ClientLoadLibrary in user32 */
120 co_IntClientLoadLibrary(PUNICODE_STRING pstrLibName
,
121 PUNICODE_STRING pstrInitFunc
,
127 ULONG ArgumentLength
;
128 PCLIENT_LOAD_LIBRARY_ARGUMENTS pArguments
;
131 ULONG_PTR pLibNameBuffer
= 0, pInitFuncBuffer
= 0;
133 /* Do not allow the desktop thread to do callback to user mode */
134 ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread
);
136 TRACE("co_IntClientLoadLibrary: %S, %S, %d, %d\n", pstrLibName
->Buffer
, pstrLibName
->Buffer
, Unload
, ApiHook
);
138 /* Calculate the size of the argument */
139 ArgumentLength
= sizeof(CLIENT_LOAD_LIBRARY_ARGUMENTS
);
142 pLibNameBuffer
= ArgumentLength
;
143 ArgumentLength
+= pstrLibName
->Length
+ sizeof(WCHAR
);
147 pInitFuncBuffer
= ArgumentLength
;
148 ArgumentLength
+= pstrInitFunc
->Length
+ sizeof(WCHAR
);
151 /* Allocate the argument */
152 pArguments
= IntCbAllocateMemory(ArgumentLength
);
153 if(pArguments
== NULL
)
158 /* Fill the argument */
159 pArguments
->Unload
= Unload
;
160 pArguments
->ApiHook
= ApiHook
;
163 /* Copy the string to the callback memory */
164 pLibNameBuffer
+= (ULONG_PTR
)pArguments
;
165 pArguments
->strLibraryName
.Buffer
= (PWCHAR
)pLibNameBuffer
;
166 pArguments
->strLibraryName
.MaximumLength
= pstrLibName
->Length
+ sizeof(WCHAR
);
167 RtlCopyUnicodeString(&pArguments
->strLibraryName
, pstrLibName
);
169 /* Fix argument pointer to be relative to the argument */
170 pLibNameBuffer
-= (ULONG_PTR
)pArguments
;
171 pArguments
->strLibraryName
.Buffer
= (PWCHAR
)(pLibNameBuffer
);
175 RtlZeroMemory(&pArguments
->strLibraryName
, sizeof(UNICODE_STRING
));
180 /* Copy the strings to the callback memory */
181 pInitFuncBuffer
+= (ULONG_PTR
)pArguments
;
182 pArguments
->strInitFuncName
.Buffer
= (PWCHAR
)pInitFuncBuffer
;
183 pArguments
->strInitFuncName
.MaximumLength
= pstrInitFunc
->Length
+ sizeof(WCHAR
);
184 RtlCopyUnicodeString(&pArguments
->strInitFuncName
, pstrInitFunc
);
186 /* Fix argument pointers to be relative to the argument */
187 pInitFuncBuffer
-= (ULONG_PTR
)pArguments
;
188 pArguments
->strInitFuncName
.Buffer
= (PWCHAR
)(pInitFuncBuffer
);
192 RtlZeroMemory(&pArguments
->strInitFuncName
, sizeof(UNICODE_STRING
));
195 /* Do the callback */
198 Status
= KeUserModeCallback(USER32_CALLBACK_CLIENTLOADLIBRARY
,
206 /* Free the argument */
207 IntCbFreeMemory(pArguments
);
209 if(!NT_SUCCESS(Status
))
216 /* Probe and copy the usermode result data */
217 ProbeForRead(ResultPointer
, sizeof(HMODULE
), 1);
218 bResult
= *(BOOL
*)ResultPointer
;
220 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
230 co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback
,
233 ULONG_PTR CompletionCallbackContext
,
236 SENDASYNCPROC_CALLBACK_ARGUMENTS Arguments
;
237 PVOID ResultPointer
, pActCtx
;
242 /* Do not allow the desktop thread to do callback to user mode */
243 ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread
);
245 Arguments
.Callback
= CompletionCallback
;
246 Arguments
.Wnd
= hWnd
;
248 Arguments
.Context
= CompletionCallbackContext
;
249 Arguments
.Result
= Result
;
251 IntSetTebWndCallback (&hWnd
, &pWnd
, &pActCtx
);
255 Status
= KeUserModeCallback(USER32_CALLBACK_SENDASYNCPROC
,
257 sizeof(SENDASYNCPROC_CALLBACK_ARGUMENTS
),
263 IntRestoreTebWndCallback (hWnd
, pWnd
, pActCtx
);
265 if (!NT_SUCCESS(Status
))
273 co_IntCallWindowProc(WNDPROC Proc
,
279 INT lParamBufferSize
)
281 WINDOWPROC_CALLBACK_ARGUMENTS StackArguments
;
282 PWINDOWPROC_CALLBACK_ARGUMENTS Arguments
;
284 PVOID ResultPointer
, pActCtx
;
287 ULONG ArgumentLength
;
290 /* Do not allow the desktop thread to do callback to user mode */
291 ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread
);
293 if (0 < lParamBufferSize
)
295 ArgumentLength
= sizeof(WINDOWPROC_CALLBACK_ARGUMENTS
) + lParamBufferSize
;
296 Arguments
= IntCbAllocateMemory(ArgumentLength
);
297 if (NULL
== Arguments
)
299 ERR("Unable to allocate buffer for window proc callback\n");
302 RtlMoveMemory((PVOID
) ((char *) Arguments
+ sizeof(WINDOWPROC_CALLBACK_ARGUMENTS
)),
303 (PVOID
) lParam
, lParamBufferSize
);
307 Arguments
= &StackArguments
;
308 ArgumentLength
= sizeof(WINDOWPROC_CALLBACK_ARGUMENTS
);
310 Arguments
->Proc
= Proc
;
311 Arguments
->IsAnsiProc
= IsAnsiProc
;
312 Arguments
->Wnd
= Wnd
;
313 Arguments
->Msg
= Message
;
314 Arguments
->wParam
= wParam
;
315 Arguments
->lParam
= lParam
;
316 Arguments
->lParamBufferSize
= lParamBufferSize
;
317 ResultPointer
= NULL
;
318 ResultLength
= ArgumentLength
;
320 IntSetTebWndCallback (&Wnd
, &pWnd
, &pActCtx
);
324 Status
= KeUserModeCallback(USER32_CALLBACK_WINDOWPROC
,
332 /* Simulate old behaviour: copy into our local buffer */
333 RtlMoveMemory(Arguments
, ResultPointer
, ArgumentLength
);
335 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
337 ERR("Failed to copy result from user mode!\n");
338 Status
= _SEH2_GetExceptionCode();
344 IntRestoreTebWndCallback (Wnd
, pWnd
, pActCtx
);
346 if (!NT_SUCCESS(Status
))
348 ERR("Call to user mode failed!\n");
349 if (0 < lParamBufferSize
)
351 IntCbFreeMemory(Arguments
);
355 Result
= Arguments
->Result
;
357 if (0 < lParamBufferSize
)
359 RtlMoveMemory((PVOID
) lParam
,
360 (PVOID
) ((char *) Arguments
+ sizeof(WINDOWPROC_CALLBACK_ARGUMENTS
)),
362 IntCbFreeMemory(Arguments
);
369 co_IntLoadSysMenuTemplate()
376 /* Do not allow the desktop thread to do callback to user mode */
377 ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread
);
379 ResultPointer
= NULL
;
380 ResultLength
= sizeof(LRESULT
);
384 Status
= KeUserModeCallback(USER32_CALLBACK_LOADSYSMENUTEMPLATE
,
389 if (NT_SUCCESS(Status
))
391 /* Simulate old behaviour: copy into our local buffer */
394 ProbeForRead(ResultPointer
, sizeof(LRESULT
), 1);
395 Result
= *(LRESULT
*)ResultPointer
;
397 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
406 return (HMENU
)Result
;
409 extern HCURSOR gDesktopCursor
;
412 co_IntLoadDefaultCursors(VOID
)
417 BOOL DefaultCursor
= TRUE
;
419 /* Do not allow the desktop thread to do callback to user mode */
420 ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread
);
422 ResultPointer
= NULL
;
423 ResultLength
= sizeof(HCURSOR
);
427 Status
= KeUserModeCallback(USER32_CALLBACK_LOADDEFAULTCURSORS
,
435 /* HACK: The desktop class doen't have a proper cursor yet, so set it here */
436 gDesktopCursor
= *((HCURSOR
*)ResultPointer
);
438 if (!NT_SUCCESS(Status
))
446 co_IntCallHookProc(INT HookId
,
454 PUNICODE_STRING ModuleName
)
456 ULONG ArgumentLength
;
457 PVOID Argument
= NULL
;
462 PHOOKPROC_CALLBACK_ARGUMENTS Common
;
463 CBT_CREATEWNDW
*CbtCreateWnd
= NULL
;
465 PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS CbtCreatewndExtra
= NULL
;
473 /* Do not allow the desktop thread to do callback to user mode */
474 ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread
);
476 pti
= PsGetCurrentThreadWin32Thread();
477 if (pti
->TIF_flags
& TIF_INCLEANUP
)
479 ERR("Thread is in cleanup and trying to call hook %d\n", Code
);
483 ArgumentLength
= sizeof(HOOKPROC_CALLBACK_ARGUMENTS
);
488 TRACE("WH_CBT: Code %d\n", Code
);
492 pWnd
= UserGetWindowObject((HWND
) wParam
);
495 ERR("WH_CBT HCBT_CREATEWND wParam bad hWnd!\n");
498 TRACE("HCBT_CREATEWND AnsiCreator %s, AnsiHook %s\n", pWnd
->state
& WNDS_ANSICREATOR
? "True" : "False", Ansi
? "True" : "False");
499 // Due to KsStudio.exe, just pass the callers original pointers
500 // except class which point to kernel space if not an atom.
501 // Found by, Olaf Siejka
502 CbtCreateWnd
= (CBT_CREATEWNDW
*) lParam
;
503 ArgumentLength
+= sizeof(HOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS
);
507 ArgumentLength
+= sizeof(RECTL
);
510 ArgumentLength
+= sizeof(CBTACTIVATESTRUCT
);
512 case HCBT_CLICKSKIPPED
:
513 ArgumentLength
+= sizeof(MOUSEHOOKSTRUCT
);
516 case HCBT_KEYSKIPPED
:
519 case HCBT_SYSCOMMAND
:
520 /* These types pass through. */
521 case HCBT_DESTROYWND
:
525 ERR("Trying to call unsupported CBT hook %d\n", Code
);
530 ArgumentLength
+= sizeof(KBDLLHOOKSTRUCT
);
533 ArgumentLength
+= sizeof(MSLLHOOKSTRUCT
);
536 ArgumentLength
+= sizeof(MOUSEHOOKSTRUCT
);
540 CWPSTRUCT
* pCWP
= (CWPSTRUCT
*) lParam
;
541 ArgumentLength
+= sizeof(CWPSTRUCT
);
542 lParamSize
= lParamMemorySize(pCWP
->message
, pCWP
->wParam
, pCWP
->lParam
);
543 ArgumentLength
+= lParamSize
;
546 case WH_CALLWNDPROCRET
:
548 CWPRETSTRUCT
* pCWPR
= (CWPRETSTRUCT
*) lParam
;
549 ArgumentLength
+= sizeof(CWPRETSTRUCT
);
550 lParamSize
= lParamMemorySize(pCWPR
->message
, pCWPR
->wParam
, pCWPR
->lParam
);
551 ArgumentLength
+= lParamSize
;
555 case WH_SYSMSGFILTER
:
557 ArgumentLength
+= sizeof(MSG
);
559 case WH_FOREGROUNDIDLE
:
564 ERR("Trying to call unsupported window hook %d\n", HookId
);
568 Argument
= IntCbAllocateMemory(ArgumentLength
);
569 if (NULL
== Argument
)
571 ERR("HookProc callback failed: out of memory\n");
574 Common
= (PHOOKPROC_CALLBACK_ARGUMENTS
) Argument
;
575 Common
->HookId
= HookId
;
577 Common
->wParam
= wParam
;
578 Common
->lParam
= lParam
;
581 Common
->offPfn
= offPfn
;
583 RtlZeroMemory(&Common
->ModuleName
, sizeof(Common
->ModuleName
));
584 RtlCopyMemory(&Common
->ModuleName
, ModuleName
->Buffer
, ModuleName
->Length
);
585 Extra
= (PCHAR
) Common
+ sizeof(HOOKPROC_CALLBACK_ARGUMENTS
);
591 { // Need to remember this is not the first time through! Call Next Hook?
593 CbtCreatewndExtra
= (PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS
) Extra
;
594 RtlCopyMemory( &CbtCreatewndExtra
->Cs
, CbtCreateWnd
->lpcs
, sizeof(CREATESTRUCTW
) );
595 CbtCreatewndExtra
->WndInsertAfter
= CbtCreateWnd
->hwndInsertAfter
;
596 CbtCreatewndExtra
->Cs
.lpszClass
= CbtCreateWnd
->lpcs
->lpszClass
;
597 CbtCreatewndExtra
->Cs
.lpszName
= CbtCreateWnd
->lpcs
->lpszName
;
598 Common
->lParam
= (LPARAM
) (Extra
- (PCHAR
) Common
);
600 case HCBT_CLICKSKIPPED
:
601 RtlCopyMemory(Extra
, (PVOID
) lParam
, sizeof(MOUSEHOOKSTRUCT
));
602 Common
->lParam
= (LPARAM
) (Extra
- (PCHAR
) Common
);
605 RtlCopyMemory(Extra
, (PVOID
) lParam
, sizeof(RECTL
));
606 Common
->lParam
= (LPARAM
) (Extra
- (PCHAR
) Common
);
609 RtlCopyMemory(Extra
, (PVOID
) lParam
, sizeof(CBTACTIVATESTRUCT
));
610 Common
->lParam
= (LPARAM
) (Extra
- (PCHAR
) Common
);
615 RtlCopyMemory(Extra
, (PVOID
) lParam
, sizeof(KBDLLHOOKSTRUCT
));
616 Common
->lParam
= (LPARAM
) (Extra
- (PCHAR
) Common
);
619 RtlCopyMemory(Extra
, (PVOID
) lParam
, sizeof(MSLLHOOKSTRUCT
));
620 Common
->lParam
= (LPARAM
) (Extra
- (PCHAR
) Common
);
623 RtlCopyMemory(Extra
, (PVOID
) lParam
, sizeof(MOUSEHOOKSTRUCT
));
624 Common
->lParam
= (LPARAM
) (Extra
- (PCHAR
) Common
);
627 /* For CALLWNDPROC and CALLWNDPROCRET, we must be wary of the fact that
628 * lParam could be a pointer to a buffer. This buffer must be exported
629 * to user space too */
630 RtlCopyMemory(Extra
, (PVOID
) lParam
, sizeof(CWPSTRUCT
));
631 Common
->lParam
= (LPARAM
) (Extra
- (PCHAR
) Common
);
634 RtlCopyMemory(Extra
+ sizeof(CWPSTRUCT
), (PVOID
)((CWPSTRUCT
*)lParam
)->lParam
, lParamSize
);
635 ((CWPSTRUCT
*)Extra
)->lParam
= (LPARAM
)lParamSize
;
638 case WH_CALLWNDPROCRET
:
639 RtlCopyMemory(Extra
, (PVOID
) lParam
, sizeof(CWPRETSTRUCT
));
640 Common
->lParam
= (LPARAM
) (Extra
- (PCHAR
) Common
);
643 RtlCopyMemory(Extra
+ sizeof(CWPRETSTRUCT
), (PVOID
)((CWPRETSTRUCT
*)lParam
)->lParam
, lParamSize
);
644 ((CWPRETSTRUCT
*)Extra
)->lParam
= (LPARAM
)lParamSize
;
648 case WH_SYSMSGFILTER
:
651 RtlCopyMemory(Extra
, (PVOID
) pMsg
, sizeof(MSG
));
652 Common
->lParam
= (LPARAM
) (Extra
- (PCHAR
) Common
);
654 case WH_FOREGROUNDIDLE
:
660 ResultPointer
= NULL
;
661 ResultLength
= sizeof(LRESULT
);
665 Status
= KeUserModeCallback(USER32_CALLBACK_HOOKPROC
,
677 ProbeForRead(ResultPointer
, sizeof(LRESULT
), 1);
678 /* Simulate old behaviour: copy into our local buffer */
679 Result
= *(LRESULT
*)ResultPointer
;
681 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
690 ERR("ERROR: Hook ResultPointer 0x%p ResultLength %u\n",ResultPointer
,ResultLength
);
693 if (!NT_SUCCESS(Status
))
695 ERR("Failure to make Callback! Status 0x%x",Status
);
698 /* Support write backs... SEH is in UserCallNextHookEx. */
702 if (Code
== HCBT_CREATEWND
)
704 if (CbtCreatewndExtra
)
706 The parameters could have been changed, include the coordinates
707 and dimensions of the window. We copy it back.
709 CbtCreateWnd
->hwndInsertAfter
= CbtCreatewndExtra
->WndInsertAfter
;
710 CbtCreateWnd
->lpcs
->x
= CbtCreatewndExtra
->Cs
.x
;
711 CbtCreateWnd
->lpcs
->y
= CbtCreatewndExtra
->Cs
.y
;
712 CbtCreateWnd
->lpcs
->cx
= CbtCreatewndExtra
->Cs
.cx
;
713 CbtCreateWnd
->lpcs
->cy
= CbtCreatewndExtra
->Cs
.cy
;
717 // "The GetMsgProc hook procedure can examine or modify the message."
721 RtlCopyMemory((PVOID
) pMsg
, Extra
, sizeof(MSG
));
729 ERR("Exception CallHookProc HookId %d Code %d\n",HookId
,Code
);
731 if (Argument
) IntCbFreeMemory(Argument
);
737 // Events are notifications w/o results.
741 co_IntCallEventProc(HWINEVENTHOOK hook
,
752 PEVENTPROC_CALLBACK_ARGUMENTS Common
;
753 ULONG ArgumentLength
, ResultLength
;
754 PVOID Argument
, ResultPointer
;
756 ArgumentLength
= sizeof(EVENTPROC_CALLBACK_ARGUMENTS
);
758 Argument
= IntCbAllocateMemory(ArgumentLength
);
759 if (NULL
== Argument
)
761 ERR("EventProc callback failed: out of memory\n");
764 Common
= (PEVENTPROC_CALLBACK_ARGUMENTS
) Argument
;
766 Common
->event
= event
;
768 Common
->idObject
= idObject
;
769 Common
->idChild
= idChild
;
770 Common
->dwEventThread
= dwEventThread
;
771 Common
->dwmsEventTime
= dwmsEventTime
;
774 ResultPointer
= NULL
;
775 ResultLength
= sizeof(LRESULT
);
779 Status
= KeUserModeCallback(USER32_CALLBACK_EVENTPROC
,
787 IntCbFreeMemory(Argument
);
789 if (!NT_SUCCESS(Status
))
798 // Callback Load Menu and results.
802 co_IntCallLoadMenu( HINSTANCE hModule
,
803 PUNICODE_STRING pMenuName
)
807 PLOADMENU_CALLBACK_ARGUMENTS Common
;
808 ULONG ArgumentLength
, ResultLength
;
809 PVOID Argument
, ResultPointer
;
811 ArgumentLength
= sizeof(LOADMENU_CALLBACK_ARGUMENTS
);
813 ArgumentLength
+= pMenuName
->Length
+ sizeof(WCHAR
);
815 Argument
= IntCbAllocateMemory(ArgumentLength
);
816 if (NULL
== Argument
)
818 ERR("LoadMenu callback failed: out of memory\n");
821 Common
= (PLOADMENU_CALLBACK_ARGUMENTS
) Argument
;
823 // Help Intersource check and MenuName is now 4 bytes + so zero it.
824 RtlZeroMemory(Common
, ArgumentLength
);
826 Common
->hModule
= hModule
;
827 if (pMenuName
->Length
)
828 RtlCopyMemory(&Common
->MenuName
, pMenuName
->Buffer
, pMenuName
->Length
);
830 RtlCopyMemory(&Common
->MenuName
, &pMenuName
->Buffer
, sizeof(WCHAR
));
832 ResultPointer
= NULL
;
833 ResultLength
= sizeof(LRESULT
);
837 Status
= KeUserModeCallback(USER32_CALLBACK_LOADMENU
,
845 Result
= *(LRESULT
*)ResultPointer
;
847 IntCbFreeMemory(Argument
);
849 if (!NT_SUCCESS(Status
))
854 return (HMENU
)Result
;
859 co_IntClientThreadSetup(VOID
)
862 ULONG ArgumentLength
, ResultLength
;
863 PVOID Argument
, ResultPointer
;
865 /* Do not allow the desktop thread to do callback to user mode */
866 ASSERT(PsGetCurrentThreadWin32Thread() != gptiDesktopThread
);
868 ArgumentLength
= ResultLength
= 0;
869 Argument
= ResultPointer
= NULL
;
873 Status
= KeUserModeCallback(USER32_CALLBACK_CLIENTTHREADSTARTUP
,
886 co_IntGetCharsetInfo(LCID Locale
, PCHARSETINFO pCs
)
889 ULONG ArgumentLength
, ResultLength
;
890 PVOID Argument
, ResultPointer
;
891 PGET_CHARSET_INFO Common
;
893 ArgumentLength
= sizeof(GET_CHARSET_INFO
);
895 Argument
= IntCbAllocateMemory(ArgumentLength
);
896 if (NULL
== Argument
)
898 ERR("GetCharsetInfo callback failed: out of memory\n");
901 Common
= (PGET_CHARSET_INFO
) Argument
;
903 Common
->Locale
= Locale
;
905 ResultPointer
= NULL
;
906 ResultLength
= ArgumentLength
;
910 Status
= KeUserModeCallback(USER32_CALLBACK_GETCHARSETINFO
,
918 /* Need to copy into our local buffer */
919 RtlMoveMemory(Argument
, ResultPointer
, ArgumentLength
);
921 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
923 ERR("Failed to copy result from user mode!\n");
924 Status
= _SEH2_GetExceptionCode();
930 RtlCopyMemory(pCs
, &Common
->Cs
, sizeof(CHARSETINFO
));
932 IntCbFreeMemory(Argument
);
934 if (!NT_SUCCESS(Status
))
936 ERR("GetCharsetInfo Failed!!\n");