ReactOS 0.4.16-dev-197-g92996da
callback.c File Reference
#include <win32k.h>
Include dependency graph for callback.c:

Go to the source code of this file.

Classes

struct  _INT_CALLBACK_HEADER
 

Typedefs

typedef struct _INT_CALLBACK_HEADER INT_CALLBACK_HEADER
 
typedef struct _INT_CALLBACK_HEADERPINT_CALLBACK_HEADER
 

Functions

 DBG_DEFAULT_CHANNEL (UserCallback)
 
PVOID FASTCALL IntCbAllocateMemory (ULONG Size)
 
VOID FASTCALL IntCbFreeMemory (PVOID Data)
 
VOID FASTCALL IntCleanupThreadCallbacks (PTHREADINFO W32Thread)
 
static VOID IntSetTebWndCallback (HWND *hWnd, PWND *pWnd, PVOID *pActCtx)
 
static VOID IntRestoreTebWndCallback (HWND hWnd, PWND pWnd, PVOID pActCtx)
 
BOOL NTAPI co_IntClientLoadLibrary (PUNICODE_STRING pstrLibName, PUNICODE_STRING pstrInitFunc, BOOL Unload, BOOL ApiHook)
 
VOID APIENTRY co_IntCallSentMessageCallback (SENDASYNCPROC CompletionCallback, HWND hWnd, UINT Msg, ULONG_PTR CompletionCallbackContext, LRESULT Result)
 
LRESULT APIENTRY co_IntCallWindowProc (WNDPROC Proc, BOOLEAN IsAnsiProc, HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam, INT lParamBufferSize)
 
HMENU APIENTRY co_IntLoadSysMenuTemplate (VOID)
 
BOOL APIENTRY co_IntLoadDefaultCursors (VOID)
 
LRESULT APIENTRY co_IntCallHookProc (INT HookId, INT Code, WPARAM wParam, LPARAM lParam, HOOKPROC Proc, INT Mod, ULONG_PTR offPfn, BOOLEAN Ansi, PUNICODE_STRING ModuleName)
 
LRESULT APIENTRY co_IntCallEventProc (HWINEVENTHOOK hook, DWORD event, HWND hWnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime, WINEVENTPROC Proc, INT Mod, ULONG_PTR offPfn)
 
HMENU APIENTRY co_IntCallLoadMenu (HINSTANCE hModule, PUNICODE_STRING pMenuName)
 
NTSTATUS APIENTRY co_IntClientThreadSetup (VOID)
 
HANDLE FASTCALL co_IntCopyImage (HANDLE hnd, UINT type, INT desiredx, INT desiredy, UINT flags)
 
BOOL APIENTRY co_IntGetCharsetInfo (LCID Locale, PCHARSETINFO pCs)
 
BOOL FASTCALL co_IntSetWndIcons (VOID)
 
VOID FASTCALL co_IntDeliverUserAPC (VOID)
 
VOID FASTCALL co_IntSetupOBM (VOID)
 
LRESULT APIENTRY co_UserCBClientPrinterThunk (PVOID pkt, INT InSize, PVOID pvOutData, INT OutSize)
 
DWORD APIENTRY co_IntImmProcessKey (HWND hWnd, HKL hKL, UINT vKey, LPARAM lParam, DWORD dwHotKeyID)
 
BOOL APIENTRY co_ClientImmLoadLayout (_In_ HKL hKL, _Inout_ PIMEINFOEX pImeInfoEx)
 

Variables

HCURSOR gDesktopCursor
 
static INT iTheId = -2
 

Typedef Documentation

◆ INT_CALLBACK_HEADER

◆ PINT_CALLBACK_HEADER

Function Documentation

◆ co_ClientImmLoadLayout()

BOOL APIENTRY co_ClientImmLoadLayout ( _In_ HKL  hKL,
_Inout_ PIMEINFOEX  pImeInfoEx 
)

Definition at line 1278 of file callback.c.

1281{
1282 BOOL ret;
1284 IMMLOADLAYOUT_CALLBACK_ARGUMENTS Common = { hKL };
1286 PIMMLOADLAYOUT_CALLBACK_OUTPUT ResultPointer = NULL;
1287
1288 RtlZeroMemory(pImeInfoEx, sizeof(IMEINFOEX));
1289
1290 UserLeaveCo();
1291 Status = KeUserModeCallback(USER32_CALLBACK_IMMLOADLAYOUT,
1292 &Common,
1293 sizeof(Common),
1294 (PVOID*)&ResultPointer,
1295 &ResultLength);
1296 UserEnterCo();
1297
1298 if (!NT_SUCCESS(Status) || !ResultPointer ||
1300 {
1301 ERR("0x%lX, %p, %lu\n", Status, ResultPointer, ResultLength);
1302 return FALSE;
1303 }
1304
1305 _SEH2_TRY
1306 {
1307 ProbeForRead(ResultPointer, ResultLength, 1);
1308 ret = ResultPointer->ret;
1309 if (ret)
1310 RtlCopyMemory(pImeInfoEx, &ResultPointer->iiex, sizeof(IMEINFOEX));
1311 }
1313 {
1314 ret = FALSE;
1315 }
1316 _SEH2_END;
1317
1318 return ret;
1319}
NTSTATUS NTAPI KeUserModeCallback(IN ULONG RoutineIndex, IN PVOID Argument, IN ULONG ArgumentLength, OUT PVOID *Result, OUT PULONG ResultLength)
Definition: usercall.c:229
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
#define UserEnterCo
Definition: ntuser.h:3
#define UserLeaveCo
Definition: ntuser.h:4
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
struct _IMMLOADLAYOUT_CALLBACK_OUTPUT IMMLOADLAYOUT_CALLBACK_OUTPUT

Referenced by co_UserImmLoadLayout().

◆ co_IntCallEventProc()

LRESULT APIENTRY co_IntCallEventProc ( HWINEVENTHOOK  hook,
DWORD  event,
HWND  hWnd,
LONG  idObject,
LONG  idChild,
DWORD  dwEventThread,
DWORD  dwmsEventTime,
WINEVENTPROC  Proc,
INT  Mod,
ULONG_PTR  offPfn 
)

Definition at line 838 of file callback.c.

848{
849 LRESULT Result = 0;
852 ULONG ArgumentLength, ResultLength;
853 PVOID Argument, ResultPointer;
854
855 ArgumentLength = sizeof(EVENTPROC_CALLBACK_ARGUMENTS);
856
857 Argument = IntCbAllocateMemory(ArgumentLength);
858 if (NULL == Argument)
859 {
860 ERR("EventProc callback failed: out of memory\n");
861 return 0;
862 }
863 Common = (PEVENTPROC_CALLBACK_ARGUMENTS) Argument;
864 Common->hook = hook;
865 Common->event = event;
866 Common->hwnd = hWnd;
867 Common->idObject = idObject;
868 Common->idChild = idChild;
869 Common->dwEventThread = dwEventThread;
870 Common->dwmsEventTime = dwmsEventTime;
871 Common->Proc = Proc;
872 Common->Mod = Mod;
873 Common->offPfn = offPfn;
874
875 ResultPointer = NULL;
876 ResultLength = sizeof(LRESULT);
877
878 UserLeaveCo();
879
880 Status = KeUserModeCallback(USER32_CALLBACK_EVENTPROC,
881 Argument,
882 ArgumentLength,
883 &ResultPointer,
884 &ResultLength);
885
886 UserEnterCo();
887
888 IntCbFreeMemory(Argument);
889
890 if (!NT_SUCCESS(Status))
891 {
892 return 0;
893 }
894
895 return Result;
896}
@ hook
Definition: SystemMenu.c:35
HWND hWnd
Definition: settings.c:17
struct _cl_event * event
Definition: glext.h:7739
#define LRESULT
Definition: ole.h:14
struct _EVENTPROC_CALLBACK_ARGUMENTS * PEVENTPROC_CALLBACK_ARGUMENTS
struct _EVENTPROC_CALLBACK_ARGUMENTS EVENTPROC_CALLBACK_ARGUMENTS
PVOID FASTCALL IntCbAllocateMemory(ULONG Size)
Definition: callback.c:27
VOID FASTCALL IntCbFreeMemory(PVOID Data)
Definition: callback.c:50
LONG_PTR LRESULT
Definition: windef.h:209
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by co_EVENT_CallEvents(), and IntNotifyWinEvent().

◆ co_IntCallHookProc()

LRESULT APIENTRY co_IntCallHookProc ( INT  HookId,
INT  Code,
WPARAM  wParam,
LPARAM  lParam,
HOOKPROC  Proc,
INT  Mod,
ULONG_PTR  offPfn,
BOOLEAN  Ansi,
PUNICODE_STRING  ModuleName 
)

Definition at line 508 of file callback.c.

517{
518 ULONG ArgumentLength;
519 PVOID Argument = NULL;
520 LRESULT Result = 0;
522 PVOID ResultPointer;
525 CBT_CREATEWNDW *CbtCreateWnd = NULL;
526 PCHAR Extra;
528 PTHREADINFO pti;
529 PWND pWnd;
530 PMSG pMsg = NULL;
531 BOOL Hit = FALSE;
532 UINT lParamSize = 0;
533 CWPSTRUCT* pCWP = NULL;
534 CWPRETSTRUCT* pCWPR = NULL;
535
536 ASSERT(Proc);
537 /* Do not allow the desktop thread to do callback to user mode */
539
541 if (pti->TIF_flags & TIF_INCLEANUP)
542 {
543 ERR("Thread is in cleanup and trying to call hook %d\n", Code);
544 return 0;
545 }
546
547 ArgumentLength = sizeof(HOOKPROC_CALLBACK_ARGUMENTS);
548
549 switch(HookId)
550 {
551 case WH_CBT:
552 TRACE("WH_CBT: Code %d\n", Code);
553 switch(Code)
554 {
555 case HCBT_CREATEWND:
557 if (!pWnd)
558 {
559 ERR("WH_CBT HCBT_CREATEWND wParam bad hWnd!\n");
560 goto Fault_Exit;
561 }
562 TRACE("HCBT_CREATEWND AnsiCreator %s, AnsiHook %s\n", pWnd->state & WNDS_ANSICREATOR ? "True" : "False", Ansi ? "True" : "False");
563 // Due to KsStudio.exe, just pass the callers original pointers
564 // except class which point to kernel space if not an atom.
565 // Found by, Olaf Siejka
566 CbtCreateWnd = (CBT_CREATEWNDW *) lParam;
567 ArgumentLength += sizeof(HOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS);
568 break;
569
570 case HCBT_MOVESIZE:
571 ArgumentLength += sizeof(RECTL);
572 break;
573 case HCBT_ACTIVATE:
574 ArgumentLength += sizeof(CBTACTIVATESTRUCT);
575 break;
577 ArgumentLength += sizeof(MOUSEHOOKSTRUCT);
578 break;
579/* ATM pass on */
580 case HCBT_KEYSKIPPED:
581 case HCBT_MINMAX:
582 case HCBT_SETFOCUS:
583 case HCBT_SYSCOMMAND:
584/* These types pass through. */
585 case HCBT_DESTROYWND:
586 case HCBT_QS:
587 break;
588 default:
589 ERR("Trying to call unsupported CBT hook %d\n", Code);
590 goto Fault_Exit;
591 }
592 break;
593 case WH_KEYBOARD_LL:
594 ArgumentLength += sizeof(KBDLLHOOKSTRUCT);
595 break;
596 case WH_MOUSE_LL:
597 ArgumentLength += sizeof(MSLLHOOKSTRUCT);
598 break;
599 case WH_MOUSE:
600 ArgumentLength += sizeof(MOUSEHOOKSTRUCT);
601 break;
602 case WH_CALLWNDPROC:
603 {
604 pCWP = (CWPSTRUCT*) lParam;
605 ArgumentLength = sizeof(CWP_Struct);
606 if ( pCWP->message == WM_CREATE || pCWP->message == WM_NCCREATE )
607 {
608 lParamSize = sizeof(CREATESTRUCTW);
609 }
610 else
611 lParamSize = lParamMemorySize(pCWP->message, pCWP->wParam, pCWP->lParam);
612 ArgumentLength += lParamSize;
613 break;
614 }
616 {
617 pCWPR = (CWPRETSTRUCT*) lParam;
618 ArgumentLength = sizeof(CWPR_Struct);
619 if ( pCWPR->message == WM_CREATE || pCWPR->message == WM_NCCREATE )
620 {
621 lParamSize = sizeof(CREATESTRUCTW);
622 }
623 else
624 lParamSize = lParamMemorySize(pCWPR->message, pCWPR->wParam, pCWPR->lParam);
625 ArgumentLength += lParamSize;
626 break;
627 }
628 case WH_MSGFILTER:
629 case WH_SYSMSGFILTER:
630 case WH_GETMESSAGE:
631 ArgumentLength += sizeof(MSG);
632 break;
634 case WH_KEYBOARD:
635 case WH_SHELL:
636 break;
637 default:
638 ERR("Trying to call unsupported window hook %d\n", HookId);
639 goto Fault_Exit;
640 }
641
642 Argument = IntCbAllocateMemory(ArgumentLength);
643 if (NULL == Argument)
644 {
645 ERR("HookProc callback %d failed: out of memory %d\n",HookId,ArgumentLength);
646 goto Fault_Exit;
647 }
648 Common = (PHOOKPROC_CALLBACK_ARGUMENTS) Argument;
649 Common->HookId = HookId;
650 Common->Code = Code;
651 Common->wParam = wParam;
652 Common->lParam = lParam;
653 Common->Proc = Proc;
654 Common->Mod = Mod;
655 Common->offPfn = offPfn;
656 Common->Ansi = Ansi;
657 Common->lParamSize = lParamSize;
658 if (ModuleName->Buffer && ModuleName->Length)
659 {
661 // If ModuleName->Buffer NULL while in destroy,
662 // this will make User32:Hook.c complain about not loading the library module.
663 // Fix symptom for CORE-10549.
664 }
665 Extra = (PCHAR) Common + sizeof(HOOKPROC_CALLBACK_ARGUMENTS);
666
667 switch(HookId)
668 {
669 case WH_CBT:
670 switch(Code)
671 { // Need to remember this is not the first time through! Call Next Hook?
672 case HCBT_CREATEWND:
673 CbtCreatewndExtra = (PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS) Extra;
674 RtlCopyMemory( &CbtCreatewndExtra->Cs, CbtCreateWnd->lpcs, sizeof(CREATESTRUCTW) );
675 CbtCreatewndExtra->WndInsertAfter = CbtCreateWnd->hwndInsertAfter;
676 CbtCreatewndExtra->Cs.lpszClass = CbtCreateWnd->lpcs->lpszClass;
677 CbtCreatewndExtra->Cs.lpszName = CbtCreateWnd->lpcs->lpszName;
678 Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
679 //ERR("HCBT_CREATEWND: hWnd %p Csw %p Name %p Class %p\n", Common->wParam, CbtCreateWnd->lpcs, CbtCreateWnd->lpcs->lpszName, CbtCreateWnd->lpcs->lpszClass);
680 break;
682 RtlCopyMemory(Extra, (PVOID) lParam, sizeof(MOUSEHOOKSTRUCT));
683 Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
684 break;
685 case HCBT_MOVESIZE:
686 RtlCopyMemory(Extra, (PVOID) lParam, sizeof(RECTL));
687 Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
688 break;
689 case HCBT_ACTIVATE:
690 RtlCopyMemory(Extra, (PVOID) lParam, sizeof(CBTACTIVATESTRUCT));
691 Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
692 break;
693 }
694 break;
695 case WH_KEYBOARD_LL:
696 RtlCopyMemory(Extra, (PVOID) lParam, sizeof(KBDLLHOOKSTRUCT));
697 Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
698 break;
699 case WH_MOUSE_LL:
700 RtlCopyMemory(Extra, (PVOID) lParam, sizeof(MSLLHOOKSTRUCT));
701 Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
702 break;
703 case WH_MOUSE:
704 RtlCopyMemory(Extra, (PVOID) lParam, sizeof(MOUSEHOOKSTRUCT));
705 Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
706 break;
707 case WH_CALLWNDPROC:
708 {
709 PCWP_Struct pcwps = (PCWP_Struct)Common;
710 RtlCopyMemory( &pcwps->cwps, pCWP, sizeof(CWPSTRUCT));
711 /* For CALLWNDPROC and CALLWNDPROCRET, we must be wary of the fact that
712 * lParam could be a pointer to a buffer. This buffer must be exported
713 * to user space too */
714 if ( lParamSize )
715 {
716 RtlCopyMemory( &pcwps->Extra, (PVOID)pCWP->lParam, lParamSize );
717 }
718 }
719 break;
721 {
722 PCWPR_Struct pcwprs = (PCWPR_Struct)Common;
723 RtlCopyMemory( &pcwprs->cwprs, pCWPR, sizeof(CWPRETSTRUCT));
724 if ( lParamSize )
725 {
726 RtlCopyMemory( &pcwprs->Extra, (PVOID)pCWPR->lParam, lParamSize );
727 }
728 }
729 break;
730 case WH_MSGFILTER:
731 case WH_SYSMSGFILTER:
732 case WH_GETMESSAGE:
733 pMsg = (PMSG)lParam;
734 RtlCopyMemory(Extra, (PVOID) pMsg, sizeof(MSG));
735 Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
736 break;
738 case WH_KEYBOARD:
739 case WH_SHELL:
740 break;
741 }
742
743 ResultPointer = NULL;
744 ResultLength = ArgumentLength;
745
746 UserLeaveCo();
747
748 Status = KeUserModeCallback(USER32_CALLBACK_HOOKPROC,
749 Argument,
750 ArgumentLength,
751 &ResultPointer,
752 &ResultLength);
753
754 UserEnterCo();
755
756 if (!NT_SUCCESS(Status))
757 {
758 if ( iTheId != HookId ) // Hook ID can change.
759 {
760 ERR("Failure to make Callback %d! Status 0x%x ArgumentLength %d\n",HookId,Status,ArgumentLength);
761 iTheId = HookId;
762 }
763 goto Fault_Exit;
764 }
765
766 if (ResultPointer)
767 {
769 {
770 /* Simulate old behaviour: copy into our local buffer */
771 RtlMoveMemory(Argument, ResultPointer, ArgumentLength);
772 Result = Common->Result;
773 }
775 {
776 Result = 0;
777 Hit = TRUE;
778 }
779 _SEH2_END;
780 }
781 else
782 {
783 ERR("ERROR: Hook %d Code %d ResultPointer 0x%p ResultLength %u\n",HookId,Code,ResultPointer,ResultLength);
784 }
785
786 /* Support write backs... SEH is in UserCallNextHookEx. */
787 switch (HookId)
788 {
789 case WH_CBT:
790 {
791 switch (Code)
792 {
793 case HCBT_CREATEWND:
794 if (CbtCreatewndExtra)
795 {/*
796 The parameters could have been changed, include the coordinates
797 and dimensions of the window. We copy it back.
798 */
799 CbtCreateWnd->hwndInsertAfter = CbtCreatewndExtra->WndInsertAfter;
800 CbtCreateWnd->lpcs->x = CbtCreatewndExtra->Cs.x;
801 CbtCreateWnd->lpcs->y = CbtCreatewndExtra->Cs.y;
802 CbtCreateWnd->lpcs->cx = CbtCreatewndExtra->Cs.cx;
803 CbtCreateWnd->lpcs->cy = CbtCreatewndExtra->Cs.cy;
804 }
805 break;
806 case HCBT_MOVESIZE:
807 if (Extra && lParam)
808 {
809 RtlCopyMemory((PVOID) lParam, Extra, sizeof(RECTL));
810 }
811 break;
812 }
813 }
814 // "The GetMsgProc hook procedure can examine or modify the message."
815 case WH_GETMESSAGE:
816 if (pMsg)
817 {
818 RtlCopyMemory((PVOID) pMsg, Extra, sizeof(MSG));
819 }
820 break;
821 }
822
823Fault_Exit:
824 if (Hit)
825 {
826 ERR("Exception CallHookProc HookId %d Code %d\n",HookId,Code);
827 }
828 if (Argument) IntCbFreeMemory(Argument);
829
830 return Result;
831}
#define MSG
Definition: Mailslot.c:11
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1280
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define Code
Definition: deflate.h:80
#define TRUE
Definition: types.h:120
#define TIF_INCLEANUP
Definition: ntuser.h:263
#define WNDS_ANSICREATOR
Definition: ntuser.h:634
#define PCHAR
Definition: match.c:90
#define ASSERT(a)
Definition: mode.c:44
unsigned int UINT
Definition: ndis.h:50
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define TRACE(s)
Definition: solgame.cpp:4
FLONG TIF_flags
Definition: win32.h:95
Definition: ntuser.h:694
DWORD state
Definition: ntuser.h:701
ACPI_SIZE Length
Definition: actypes.h:1053
LPCREATESTRUCTW lpcs
Definition: winuser.h:2978
HWND hwndInsertAfter
Definition: winuser.h:2979
LPCWSTR lpszClass
Definition: winuser.h:2968
LPCWSTR lpszName
Definition: winuser.h:2967
WPARAM wParam
Definition: winuser.h:3022
LPARAM lParam
Definition: winuser.h:3021
CWPRETSTRUCT cwprs
Definition: callback.h:83
PBYTE Extra[4]
Definition: callback.h:84
LPARAM lParam
Definition: winuser.h:3028
WPARAM wParam
Definition: winuser.h:3029
UINT message
Definition: winuser.h:3030
PBYTE Extra[4]
Definition: callback.h:77
CWPSTRUCT cwps
Definition: callback.h:76
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
char * PCHAR
Definition: typedefs.h:51
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:124
_In_ UCHAR _In_ UCHAR _In_ ULONG Code
Definition: wdfdevice.h:1701
struct tagCWPR_Struct * PCWPR_Struct
struct _HOOKPROC_CALLBACK_ARGUMENTS HOOKPROC_CALLBACK_ARGUMENTS
struct _HOOKPROC_CALLBACK_ARGUMENTS * PHOOKPROC_CALLBACK_ARGUMENTS
struct _HOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS HOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS
struct _HOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS * PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS
struct tagCWP_Struct * PCWP_Struct
struct tagCWP_Struct CWP_Struct
struct tagCWPR_Struct CWPR_Struct
static INT iTheId
Definition: callback.c:505
PTHREADINFO gptiDesktopThread
Definition: desktop.c:54
UINT lParamMemorySize(UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:276
LONG_PTR LPARAM
Definition: windef.h:208
#define HCBT_MINMAX
Definition: winuser.h:56
#define WH_KEYBOARD
Definition: winuser.h:32
#define WH_CALLWNDPROCRET
Definition: winuser.h:42
struct tagMOUSEHOOKSTRUCT MOUSEHOOKSTRUCT
#define WM_CREATE
Definition: winuser.h:1611
#define HCBT_ACTIVATE
Definition: winuser.h:60
#define WH_MSGFILTER
Definition: winuser.h:29
struct tagMSG * PMSG
#define HCBT_DESTROYWND
Definition: winuser.h:59
struct tagCBTACTIVATESTRUCT CBTACTIVATESTRUCT
struct tagCREATESTRUCTW CREATESTRUCTW
#define WH_SHELL
Definition: winuser.h:40
#define WH_CBT
Definition: winuser.h:35
#define HCBT_CREATEWND
Definition: winuser.h:58
#define WM_NCCREATE
Definition: winuser.h:1686
#define WH_MOUSE_LL
Definition: winuser.h:44
#define WH_MOUSE
Definition: winuser.h:37
#define HCBT_SETFOCUS
Definition: winuser.h:64
#define HCBT_CLICKSKIPPED
Definition: winuser.h:61
#define HCBT_QS
Definition: winuser.h:57
#define HCBT_MOVESIZE
Definition: winuser.h:55
#define WH_KEYBOARD_LL
Definition: winuser.h:43
#define WH_GETMESSAGE
Definition: winuser.h:33
#define WH_SYSMSGFILTER
Definition: winuser.h:36
struct tagMSLLHOOKSTRUCT MSLLHOOKSTRUCT
struct tagKBDLLHOOKSTRUCT KBDLLHOOKSTRUCT
#define WH_FOREGROUNDIDLE
Definition: winuser.h:41
#define HCBT_SYSCOMMAND
Definition: winuser.h:63
#define HCBT_KEYSKIPPED
Definition: winuser.h:62
#define WH_CALLWNDPROC
Definition: winuser.h:34

Referenced by co_CallHook(), co_HOOK_CallHookNext(), co_HOOK_CallHooks(), and NtUserMessageCall().

◆ co_IntCallLoadMenu()

HMENU APIENTRY co_IntCallLoadMenu ( HINSTANCE  hModule,
PUNICODE_STRING  pMenuName 
)

Definition at line 903 of file callback.c.

905{
906 LRESULT Result = 0;
909 ULONG ArgumentLength, ResultLength;
910 PVOID Argument, ResultPointer;
911
912 ArgumentLength = sizeof(LOADMENU_CALLBACK_ARGUMENTS);
913
914 ArgumentLength += pMenuName->Length + sizeof(WCHAR);
915
916 Argument = IntCbAllocateMemory(ArgumentLength);
917 if (NULL == Argument)
918 {
919 ERR("LoadMenu callback failed: out of memory\n");
920 return 0;
921 }
922 Common = (PLOADMENU_CALLBACK_ARGUMENTS) Argument;
923
924 Common->hModule = hModule;
925 if (pMenuName->Length)
926 RtlCopyMemory(&Common->MenuName, pMenuName->Buffer, pMenuName->Length);
927 else
928 Common->InterSource = pMenuName->Buffer;
929
930 ResultPointer = NULL;
931 ResultLength = sizeof(LRESULT);
932
933 UserLeaveCo();
934
935 Status = KeUserModeCallback(USER32_CALLBACK_LOADMENU,
936 Argument,
937 ArgumentLength,
938 &ResultPointer,
939 &ResultLength);
940
941 UserEnterCo();
942
943 if (NT_SUCCESS(Status))
944 {
945 Result = *(LRESULT*)ResultPointer;
946 }
947 else
948 {
949 Result = 0;
950 }
951
952 IntCbFreeMemory(Argument);
953
954 return (HMENU)Result;
955}
HMODULE hModule
Definition: animate.c:44
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
struct _LOADMENU_CALLBACK_ARGUMENTS * PLOADMENU_CALLBACK_ARGUMENTS
struct _LOADMENU_CALLBACK_ARGUMENTS LOADMENU_CALLBACK_ARGUMENTS
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by IntCreateWindow(), and MENU_GetSystemMenu().

◆ co_IntCallSentMessageCallback()

VOID APIENTRY co_IntCallSentMessageCallback ( SENDASYNCPROC  CompletionCallback,
HWND  hWnd,
UINT  Msg,
ULONG_PTR  CompletionCallbackContext,
LRESULT  Result 
)

Definition at line 238 of file callback.c.

243{
245 PVOID ResultPointer, pActCtx;
246 PWND pWnd;
249
250 /* Do not allow the desktop thread to do callback to user mode */
252
253 Arguments.Callback = CompletionCallback;
254 Arguments.Wnd = hWnd;
255 Arguments.Msg = Msg;
256 Arguments.Context = CompletionCallbackContext;
257 Arguments.Result = Result;
258
259 IntSetTebWndCallback (&hWnd, &pWnd, &pActCtx);
260
261 UserLeaveCo();
262
263 Status = KeUserModeCallback(USER32_CALLBACK_SENDASYNCPROC,
264 &Arguments,
266 &ResultPointer,
267 &ResultLength);
268
269 UserEnterCo();
270
271 IntRestoreTebWndCallback (hWnd, pWnd, pActCtx);
272
273 if (!NT_SUCCESS(Status))
274 {
275 ERR("KeUserModeCallback failed with %lx\n", Status);
276 return;
277 }
278 return;
279}
const TCHAR * CompletionCallback(unsigned __int64 &rnIndex, const BOOL *pblnForward, const TCHAR *pszContext, const TCHAR *pszBegin)
Definition: Completion.cpp:439
struct @1636 Msg[]
static VOID IntSetTebWndCallback(HWND *hWnd, PWND *pWnd, PVOID *pActCtx)
Definition: callback.c:97
static VOID IntRestoreTebWndCallback(HWND hWnd, PWND pWnd, PVOID pActCtx)
Definition: callback.c:122

Referenced by co_IntSendMessageWithCallBack(), and co_MsqDispatchOneSentMessage().

◆ co_IntCallWindowProc()

LRESULT APIENTRY co_IntCallWindowProc ( WNDPROC  Proc,
BOOLEAN  IsAnsiProc,
HWND  Wnd,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam,
INT  lParamBufferSize 
)

Definition at line 282 of file callback.c.

289{
290 WINDOWPROC_CALLBACK_ARGUMENTS StackArguments = { 0 };
293 PVOID ResultPointer, pActCtx;
294 PWND pWnd;
296 ULONG ArgumentLength;
298
299 TRACE("co_IntCallWindowProc(Proc %p, IsAnsiProc: %s, Wnd %p, Message %u, wParam %Iu, lParam %Id, lParamBufferSize %d)\n",
300 Proc, IsAnsiProc ? "TRUE" : "FALSE", Wnd, Message, wParam, lParam, lParamBufferSize);
301
302 /* Do not allow the desktop thread to do callback to user mode */
304
305 if (lParamBufferSize != -1)
306 {
307 ArgumentLength = sizeof(WINDOWPROC_CALLBACK_ARGUMENTS) + lParamBufferSize;
308 Arguments = IntCbAllocateMemory(ArgumentLength);
309 if (NULL == Arguments)
310 {
311 ERR("Unable to allocate buffer for window proc callback\n");
312 return -1;
313 }
314 RtlMoveMemory((PVOID) ((char *) Arguments + sizeof(WINDOWPROC_CALLBACK_ARGUMENTS)),
315 (PVOID) lParam, lParamBufferSize);
316 }
317 else
318 {
319 Arguments = &StackArguments;
320 ArgumentLength = sizeof(WINDOWPROC_CALLBACK_ARGUMENTS);
321 }
322 Arguments->Proc = Proc;
323 Arguments->IsAnsiProc = IsAnsiProc;
324 Arguments->Wnd = Wnd;
325 Arguments->Msg = Message;
326 Arguments->wParam = wParam;
327 Arguments->lParam = lParam;
328 Arguments->lParamBufferSize = lParamBufferSize;
329 ResultPointer = NULL;
330 ResultLength = ArgumentLength;
331
332 IntSetTebWndCallback (&Wnd, &pWnd, &pActCtx);
333
334 UserLeaveCo();
335
336 Status = KeUserModeCallback(USER32_CALLBACK_WINDOWPROC,
337 Arguments,
338 ArgumentLength,
339 &ResultPointer,
340 &ResultLength);
341 if (!NT_SUCCESS(Status))
342 {
343 ERR("Error Callback to User space Status %lx Message %d\n",Status,Message);
344 UserEnterCo();
345 return 0;
346 }
347
349 {
350 /* Simulate old behaviour: copy into our local buffer */
351 RtlMoveMemory(Arguments, ResultPointer, ArgumentLength);
352 }
354 {
355 ERR("Failed to copy result from user mode, Message %u lParam size %d!\n", Message, lParamBufferSize);
357 }
358 _SEH2_END;
359
360 UserEnterCo();
361
362 IntRestoreTebWndCallback (Wnd, pWnd, pActCtx);
363
364 if (!NT_SUCCESS(Status))
365 {
366 ERR("Call to user mode failed! 0x%08lx\n",Status);
367 if (lParamBufferSize != -1)
368 {
369 IntCbFreeMemory(Arguments);
370 }
371 return -1;
372 }
373 Result = Arguments->Result;
374
375 if (lParamBufferSize != -1)
376 {
378 // Is this message being processed from inside kernel space?
379 BOOL InSendMessage = (pti->pcti->CTI_flags & CTI_INSENDMESSAGE);
380
381 TRACE("Copy lParam Message %u lParam %d!\n", Message, lParam);
382 switch (Message)
383 {
384 default:
385 TRACE("Don't copy lParam, Message %u Size %d lParam %d!\n", Message, lParamBufferSize, lParam);
386 break;
387 // Write back to user/kernel space. Also see g_MsgMemory.
388 case WM_CREATE:
389 case WM_GETMINMAXINFO:
390 case WM_GETTEXT:
391 case WM_NCCALCSIZE:
392 case WM_NCCREATE:
393 case WM_STYLECHANGING:
395 case WM_SIZING:
396 case WM_MOVING:
397 case WM_MEASUREITEM:
398 case WM_NEXTMENU:
399 TRACE("Copy lParam, Message %u Size %d lParam %d!\n", Message, lParamBufferSize, lParam);
400 if (InSendMessage)
401 // Copy into kernel space.
403 (PVOID) ((char *) Arguments + sizeof(WINDOWPROC_CALLBACK_ARGUMENTS)),
404 lParamBufferSize);
405 else
406 {
408 { // Copy into user space.
410 (PVOID) ((char *) Arguments + sizeof(WINDOWPROC_CALLBACK_ARGUMENTS)),
411 lParamBufferSize);
412 }
414 {
415 ERR("Failed to copy lParam to user space, Message %u!\n", Message);
416 }
417 _SEH2_END;
418 }
419 break;
420 }
421 IntCbFreeMemory(Arguments);
422 }
423
424 return Result;
425}
static const WCHAR Message[]
Definition: register.c:74
#define CTI_INSENDMESSAGE
Definition: ntuser.h:162
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:91
struct _WINDOWPROC_CALLBACK_ARGUMENTS WINDOWPROC_CALLBACK_ARGUMENTS
#define WM_NEXTMENU
Definition: winuser.h:1809
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1664
#define WM_GETTEXT
Definition: winuser.h:1621
BOOL WINAPI InSendMessage(void)
Definition: message.c:1372
#define WM_GETMINMAXINFO
Definition: winuser.h:1643
#define WM_MEASUREITEM
Definition: winuser.h:1649
#define WM_SIZING
Definition: winuser.h:1810
#define WM_MOVING
Definition: winuser.h:1812
#define WM_NCCALCSIZE
Definition: winuser.h:1688

Referenced by co_IntSendMessageTimeoutSingle(), co_IntSendMessageWithCallBack(), and IntDispatchMessage().

◆ co_IntClientLoadLibrary()

BOOL NTAPI co_IntClientLoadLibrary ( PUNICODE_STRING  pstrLibName,
PUNICODE_STRING  pstrInitFunc,
BOOL  Unload,
BOOL  ApiHook 
)

Definition at line 136 of file callback.c.

140{
141 PVOID ResultPointer;
143 ULONG ArgumentLength;
146 BOOL bResult;
147 ULONG_PTR pLibNameBuffer = 0, pInitFuncBuffer = 0;
148
149 /* Do not allow the desktop thread to do callback to user mode */
151
152 TRACE("co_IntClientLoadLibrary: %S, %S, %d, %d\n", pstrLibName->Buffer, pstrLibName->Buffer, Unload, ApiHook);
153
154 /* Calculate the size of the argument */
155 ArgumentLength = sizeof(CLIENT_LOAD_LIBRARY_ARGUMENTS);
156 if(pstrLibName)
157 {
158 pLibNameBuffer = ArgumentLength;
159 ArgumentLength += pstrLibName->Length + sizeof(WCHAR);
160 }
161 if(pstrInitFunc)
162 {
163 pInitFuncBuffer = ArgumentLength;
164 ArgumentLength += pstrInitFunc->Length + sizeof(WCHAR);
165 }
166
167 /* Allocate the argument */
168 pArguments = IntCbAllocateMemory(ArgumentLength);
169 if(pArguments == NULL)
170 {
171 return FALSE;
172 }
173
174 /* Fill the argument */
175 pArguments->Unload = Unload;
176 pArguments->ApiHook = ApiHook;
177 if(pstrLibName)
178 {
179 /* Copy the string to the callback memory */
180 pLibNameBuffer += (ULONG_PTR)pArguments;
181 pArguments->strLibraryName.Buffer = (PWCHAR)pLibNameBuffer;
182 pArguments->strLibraryName.MaximumLength = pstrLibName->Length + sizeof(WCHAR);
183 RtlCopyUnicodeString(&pArguments->strLibraryName, pstrLibName);
184
185 /* Fix argument pointer to be relative to the argument */
186 pLibNameBuffer -= (ULONG_PTR)pArguments;
187 pArguments->strLibraryName.Buffer = (PWCHAR)(pLibNameBuffer);
188 }
189
190 if(pstrInitFunc)
191 {
192 /* Copy the strings to the callback memory */
193 pInitFuncBuffer += (ULONG_PTR)pArguments;
194 pArguments->strInitFuncName.Buffer = (PWCHAR)pInitFuncBuffer;
195 pArguments->strInitFuncName.MaximumLength = pstrInitFunc->Length + sizeof(WCHAR);
196 RtlCopyUnicodeString(&pArguments->strInitFuncName, pstrInitFunc);
197
198 /* Fix argument pointers to be relative to the argument */
199 pInitFuncBuffer -= (ULONG_PTR)pArguments;
200 pArguments->strInitFuncName.Buffer = (PWCHAR)(pInitFuncBuffer);
201 }
202
203 /* Do the callback */
204 UserLeaveCo();
205
206 Status = KeUserModeCallback(USER32_CALLBACK_CLIENTLOADLIBRARY,
207 pArguments,
208 ArgumentLength,
209 &ResultPointer,
210 &ResultLength);
211
212 UserEnterCo();
213
214 /* Free the argument */
215 IntCbFreeMemory(pArguments);
216
217 if(!NT_SUCCESS(Status))
218 {
219 return FALSE;
220 }
221
223 {
224 /* Probe and copy the usermode result data */
225 ProbeForRead(ResultPointer, sizeof(HMODULE), 1);
226 bResult = *(BOOL*)ResultPointer;
227 }
229 {
230 bResult = FALSE;
231 }
232 _SEH2_END;
233
234 return bResult;
235}
#define ULONG_PTR
Definition: config.h:101
static VOID NTAPI Unload(PDRIVER_OBJECT DriverObject)
Definition: floppy.c:377
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
UNICODE_STRING strLibraryName
Definition: callback.h:119
UNICODE_STRING strInitFuncName
Definition: callback.h:120
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint16_t * PWCHAR
Definition: typedefs.h:56
struct _CLIENT_LOAD_LIBRARY_ARGUMENTS CLIENT_LOAD_LIBRARY_ARGUMENTS

Referenced by IntLoadHookModule().

◆ co_IntClientThreadSetup()

NTSTATUS APIENTRY co_IntClientThreadSetup ( VOID  )

Definition at line 959 of file callback.c.

960{
962 ULONG ArgumentLength, ResultLength;
963 PVOID Argument, ResultPointer;
964
965 /* Do not allow the desktop thread to do callback to user mode */
967
968 ArgumentLength = ResultLength = 0;
969 Argument = ResultPointer = NULL;
970
971 UserLeaveCo();
972
973 Status = KeUserModeCallback(USER32_CALLBACK_CLIENTTHREADSTARTUP,
974 Argument,
975 ArgumentLength,
976 &ResultPointer,
977 &ResultLength);
978
979 UserEnterCo();
980
981 return Status;
982}

Referenced by InitThreadCallback().

◆ co_IntCopyImage()

HANDLE FASTCALL co_IntCopyImage ( HANDLE  hnd,
UINT  type,
INT  desiredx,
INT  desiredy,
UINT  flags 
)

Definition at line 985 of file callback.c.

986{
989 ULONG ArgumentLength, ResultLength;
990 PVOID Argument, ResultPointer;
992
993 ArgumentLength = ResultLength = 0;
994 Argument = ResultPointer = NULL;
995
996 ArgumentLength = sizeof(COPYIMAGE_CALLBACK_ARGUMENTS);
997
998 Argument = IntCbAllocateMemory(ArgumentLength);
999 if (NULL == Argument)
1000 {
1001 ERR("CopyImage callback failed: out of memory\n");
1002 return 0;
1003 }
1004 Common = (PCOPYIMAGE_CALLBACK_ARGUMENTS) Argument;
1005
1006 Common->hImage = hnd;
1007 Common->uType = type;
1008 Common->cxDesired = desiredx;
1009 Common->cyDesired = desiredy;
1010 Common->fuFlags = flags;
1011
1012 UserLeaveCo();
1013
1014 Status = KeUserModeCallback(USER32_CALLBACK_COPYIMAGE,
1015 Argument,
1016 ArgumentLength,
1017 &ResultPointer,
1018 &ResultLength);
1019
1020
1021 UserEnterCo();
1022
1023 if (NT_SUCCESS(Status))
1024 {
1025 Handle = *(HANDLE*)ResultPointer;
1026 }
1027 else
1028 {
1029 ERR("CopyImage callback failed!\n");
1030 Handle = NULL;
1031 }
1032
1033 IntCbFreeMemory(Argument);
1034
1035 return Handle;
1036}
ULONG Handle
Definition: gdb_input.c:15
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLbitfield flags
Definition: glext.h:7161
struct _COPYIMAGE_CALLBACK_ARGUMENTS * PCOPYIMAGE_CALLBACK_ARGUMENTS
struct _COPYIMAGE_CALLBACK_ARGUMENTS COPYIMAGE_CALLBACK_ARGUMENTS

Referenced by IntCreateWindow(), and UserSetClassLongPtr().

◆ co_IntDeliverUserAPC()

VOID FASTCALL co_IntDeliverUserAPC ( VOID  )

Definition at line 1157 of file callback.c.

1158{
1160 PVOID ResultPointer;
1162 UserLeaveCo();
1163
1164 Status = KeUserModeCallback(USER32_CALLBACK_DELIVERUSERAPC,
1165 0,
1166 0,
1167 &ResultPointer,
1168 &ResultLength);
1169
1170
1171 UserEnterCo();
1172
1173 if (!NT_SUCCESS(Status))
1174 {
1175 ERR("Delivering User APC callback failed!\n");
1176 }
1177}

Referenced by co_MsqSendMessage(), and co_MsqWaitForNewMessages().

◆ co_IntGetCharsetInfo()

BOOL APIENTRY co_IntGetCharsetInfo ( LCID  Locale,
PCHARSETINFO  pCs 
)

Definition at line 1040 of file callback.c.

1041{
1043 ULONG ArgumentLength, ResultLength;
1044 PVOID Argument, ResultPointer;
1045 PGET_CHARSET_INFO Common;
1046
1047 ArgumentLength = sizeof(GET_CHARSET_INFO);
1048
1049 Argument = IntCbAllocateMemory(ArgumentLength);
1050 if (NULL == Argument)
1051 {
1052 ERR("GetCharsetInfo callback failed: out of memory\n");
1053 return 0;
1054 }
1055 Common = (PGET_CHARSET_INFO) Argument;
1056
1057 Common->Locale = Locale;
1058
1059 ResultPointer = NULL;
1060 ResultLength = ArgumentLength;
1061
1062 UserLeaveCo();
1063
1064 Status = KeUserModeCallback(USER32_CALLBACK_GETCHARSETINFO,
1065 Argument,
1066 ArgumentLength,
1067 &ResultPointer,
1068 &ResultLength);
1069
1070 if (NT_SUCCESS(Status))
1071 {
1072 _SEH2_TRY
1073 {
1074 /* Need to copy into our local buffer */
1075 RtlMoveMemory(Argument, ResultPointer, ArgumentLength);
1076 }
1078 {
1079 ERR("Failed to copy result from user mode!\n");
1081 }
1082 _SEH2_END;
1083 }
1084
1085 UserEnterCo();
1086
1087 RtlCopyMemory(pCs, &Common->Cs, sizeof(CHARSETINFO));
1088
1089 IntCbFreeMemory(Argument);
1090
1091 if (!NT_SUCCESS(Status))
1092 {
1093 ERR("GetCharsetInfo Failed!!\n");
1094 return FALSE;
1095 }
1096
1097 return TRUE;
1098}
CHARSETINFO Cs
Definition: callback.h:128
struct _GET_CHARSET_INFO GET_CHARSET_INFO
struct _GET_CHARSET_INFO * PGET_CHARSET_INFO

Referenced by co_UserLoadKbdLayout().

◆ co_IntImmProcessKey()

DWORD APIENTRY co_IntImmProcessKey ( HWND  hWnd,
HKL  hKL,
UINT  vKey,
LPARAM  lParam,
DWORD  dwHotKeyID 
)

Definition at line 1253 of file callback.c.

1254{
1255 DWORD ret = 0;
1257 ULONG ResultLength = sizeof(DWORD);
1258 PVOID ResultPointer = NULL;
1259 IMMPROCESSKEY_CALLBACK_ARGUMENTS Common = { hWnd, hKL, vKey, lParam, dwHotKeyID };
1260
1261 UserLeaveCo();
1262 Status = KeUserModeCallback(USER32_CALLBACK_IMMPROCESSKEY,
1263 &Common,
1264 sizeof(Common),
1265 &ResultPointer,
1266 &ResultLength);
1267 UserEnterCo();
1268
1269 if (NT_SUCCESS(Status))
1270 ret = *(LPDWORD)ResultPointer;
1271
1272 return ret;
1273}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LPDWORD
Definition: nt_native.h:46
#define DWORD
Definition: nt_native.h:44

Referenced by IntImmProcessKey().

◆ co_IntLoadDefaultCursors()

BOOL APIENTRY co_IntLoadDefaultCursors ( VOID  )

Definition at line 471 of file callback.c.

472{
474 PVOID ResultPointer;
476 BOOL DefaultCursor = TRUE;
477
478 /* Do not allow the desktop thread to do callback to user mode */
480
481 ResultPointer = NULL;
482 ResultLength = sizeof(HCURSOR);
483
484 UserLeaveCo();
485
486 Status = KeUserModeCallback(USER32_CALLBACK_LOADDEFAULTCURSORS,
487 &DefaultCursor,
488 sizeof(BOOL),
489 &ResultPointer,
490 &ResultLength);
491
492 UserEnterCo();
493
494 if (!NT_SUCCESS(Status))
495 {
496 return FALSE;
497 }
498
499 /* HACK: The desktop class doen't have a proper cursor yet, so set it here */
500 gDesktopCursor = *((HCURSOR*)ResultPointer);
501
502 return TRUE;
503}
HCURSOR gDesktopCursor
Definition: desktop.c:55
HICON HCURSOR
Definition: windef.h:299

Referenced by co_IntInitializeDesktopGraphics().

◆ co_IntLoadSysMenuTemplate()

HMENU APIENTRY co_IntLoadSysMenuTemplate ( VOID  )

Definition at line 428 of file callback.c.

429{
430 LRESULT Result = 0;
432 PVOID ResultPointer;
434
435 /* Do not allow the desktop thread to do callback to user mode */
437
438 ResultPointer = NULL;
439 ResultLength = sizeof(LRESULT);
440
441 UserLeaveCo();
442
443 Status = KeUserModeCallback(USER32_CALLBACK_LOADSYSMENUTEMPLATE,
444 &ResultPointer,
445 0,
446 &ResultPointer,
447 &ResultLength);
448 if (NT_SUCCESS(Status))
449 {
450 /* Simulate old behaviour: copy into our local buffer */
452 {
453 ProbeForRead(ResultPointer, sizeof(LRESULT), 1);
454 Result = *(LRESULT*)ResultPointer;
455 }
457 {
458 Result = 0;
459 }
460 _SEH2_END;
461 }
462
463 UserEnterCo();
464
465 return (HMENU)Result;
466}

◆ co_IntSetupOBM()

VOID FASTCALL co_IntSetupOBM ( VOID  )

Definition at line 1180 of file callback.c.

1181{
1183 ULONG ArgumentLength, ResultLength;
1184 PVOID Argument, ResultPointer;
1186
1187 ResultPointer = NULL;
1188 ResultLength = ArgumentLength = sizeof(SETOBM_CALLBACK_ARGUMENTS);
1189
1190 Argument = IntCbAllocateMemory(ArgumentLength);
1191 if (NULL == Argument)
1192 {
1193 ERR("Set Window Icons callback failed: out of memory\n");
1194 return;
1195 }
1196 Common = (PSETOBM_CALLBACK_ARGUMENTS) Argument;
1197
1198 UserLeaveCo();
1199
1200 Status = KeUserModeCallback(USER32_CALLBACK_SETOBM,
1201 Argument,
1202 ArgumentLength,
1203 &ResultPointer,
1204 &ResultLength);
1205
1206
1207 UserEnterCo();
1208
1209 if (!NT_SUCCESS(Status))
1210 {
1211 ERR("Set Window Icons callback failed!\n");
1212 IntCbFreeMemory(Argument);
1213 return;
1214 }
1215
1216 RtlMoveMemory(Common, ResultPointer, ArgumentLength);
1217 RtlCopyMemory(gpsi->oembmi, Common->oembmi, sizeof(gpsi->oembmi));
1218
1219 IntCbFreeMemory(Argument);
1220}
PSERVERINFO gpsi
Definition: imm.c:18
struct tagOEMBITMAPINFO oembmi[93]
Definition: callback.h:153
struct _SETOBM_CALLBACK_ARGUMENTS * PSETOBM_CALLBACK_ARGUMENTS
struct _SETOBM_CALLBACK_ARGUMENTS SETOBM_CALLBACK_ARGUMENTS

Referenced by MenuInit().

◆ co_IntSetWndIcons()

BOOL FASTCALL co_IntSetWndIcons ( VOID  )

Definition at line 1101 of file callback.c.

1102{
1104 ULONG ArgumentLength, ResultLength;
1105 PVOID Argument, ResultPointer;
1107
1108 ResultPointer = NULL;
1109 ResultLength = ArgumentLength = sizeof(SETWNDICONS_CALLBACK_ARGUMENTS);
1110
1111 Argument = IntCbAllocateMemory(ArgumentLength);
1112 if (NULL == Argument)
1113 {
1114 ERR("Set Window Icons callback failed: out of memory\n");
1115 return FALSE;
1116 }
1117 Common = (PSETWNDICONS_CALLBACK_ARGUMENTS) Argument;
1118
1119 UserLeaveCo();
1120
1121 Status = KeUserModeCallback(USER32_CALLBACK_SETWNDICONS,
1122 Argument,
1123 ArgumentLength,
1124 &ResultPointer,
1125 &ResultLength);
1126
1127
1128 UserEnterCo();
1129
1130 if (!NT_SUCCESS(Status))
1131 {
1132 ERR("Set Window Icons callback failed!\n");
1133 IntCbFreeMemory(Argument);
1134 return FALSE;
1135 }
1136
1137 RtlMoveMemory(Common, ResultPointer, ArgumentLength);
1138 gpsi->hIconSmWindows = Common->hIconSmWindows;
1139 gpsi->hIconWindows = Common->hIconWindows;
1140
1141 IntLoadSystenIcons(Common->hIconSample, OIC_SAMPLE);
1142 IntLoadSystenIcons(Common->hIconHand, OIC_HAND);
1143 IntLoadSystenIcons(Common->hIconQuestion, OIC_QUES);
1144 IntLoadSystenIcons(Common->hIconBang, OIC_BANG);
1145 IntLoadSystenIcons(Common->hIconNote, OIC_NOTE);
1146 IntLoadSystenIcons(gpsi->hIconWindows, OIC_WINLOGO);
1147 IntLoadSystenIcons(gpsi->hIconSmWindows, OIC_WINLOGO+1);
1148
1149 ERR("hIconSmWindows %p hIconWindows %p \n",gpsi->hIconSmWindows,gpsi->hIconWindows);
1150
1151 IntCbFreeMemory(Argument);
1152
1153 return TRUE;
1154}
struct _SETWNDICONS_CALLBACK_ARGUMENTS SETWNDICONS_CALLBACK_ARGUMENTS
struct _SETWNDICONS_CALLBACK_ARGUMENTS * PSETWNDICONS_CALLBACK_ARGUMENTS
VOID IntLoadSystenIcons(HICON hcur, DWORD id)
Definition: cursoricon.c:137

Referenced by co_IntInitializeDesktopGraphics().

◆ co_UserCBClientPrinterThunk()

LRESULT APIENTRY co_UserCBClientPrinterThunk ( PVOID  pkt,
INT  InSize,
PVOID  pvOutData,
INT  OutSize 
)

Definition at line 1227 of file callback.c.

1228{
1230 PVOID ResultPointer;
1231
1232 Status = KeUserModeCallback( USER32_CALLBACK_UMPD,
1233 pkt,
1234 InSize,
1235 &ResultPointer,
1236 (PULONG)&OutSize );
1237
1238
1239 if (!NT_SUCCESS(Status))
1240 {
1241 ERR("User UMPD callback failed!\n");
1242 return 1;
1243 }
1244
1245 if (OutSize) RtlMoveMemory( pvOutData, ResultPointer, OutSize );
1246
1247 return 0;
1248}
uint32_t * PULONG
Definition: typedefs.h:59

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserCallback  )

◆ IntCbAllocateMemory()

PVOID FASTCALL IntCbAllocateMemory ( ULONG  Size)

Definition at line 27 of file callback.c.

28{
30 PTHREADINFO W32Thread;
31
34 {
35 return NULL;
36 }
37
40 ASSERT(W32Thread);
41
42 /* Insert the callback memory into the thread's callback list */
43
45
46 return (Mem + 1);
47}
#define InsertTailList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
LIST_ENTRY ListEntry
Definition: callback.c:22
LIST_ENTRY W32CallbackListHead
Definition: win32.h:156
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#define USERTAG_CALLBACK
Definition: tags.h:201

Referenced by co_IntCallEventProc(), co_IntCallHookProc(), co_IntCallLoadMenu(), co_IntCallWindowProc(), co_IntClientLoadLibrary(), co_IntCopyImage(), co_IntGetCharsetInfo(), co_IntSetupOBM(), co_IntSetWndIcons(), IntDDEGetCallback(), and IntDDEPostCallback().

◆ IntCbFreeMemory()

VOID FASTCALL IntCbFreeMemory ( PVOID  Data)

Definition at line 50 of file callback.c.

51{
53 PTHREADINFO W32Thread;
54
56 ASSERT(W32Thread);
57
58 if (W32Thread->TIF_flags & TIF_INCLEANUP)
59 {
60 ERR("CbFM Thread is already in cleanup\n");
61 return;
62 }
63
64 ASSERT(Data);
65
66 Mem = ((PINT_CALLBACK_HEADER)Data - 1);
67
68 /* Remove the memory block from the thread's callback list */
70
71 /* Free memory */
73}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
struct _INT_CALLBACK_HEADER * PINT_CALLBACK_HEADER

Referenced by co_IntCallEventProc(), co_IntCallHookProc(), co_IntCallLoadMenu(), co_IntCallWindowProc(), co_IntClientLoadLibrary(), co_IntCopyImage(), co_IntGetCharsetInfo(), co_IntSetupOBM(), co_IntSetWndIcons(), IntDDEGetCallback(), and IntDDEPostCallback().

◆ IntCleanupThreadCallbacks()

VOID FASTCALL IntCleanupThreadCallbacks ( PTHREADINFO  W32Thread)

Definition at line 76 of file callback.c.

77{
78 PLIST_ENTRY CurrentEntry;
80
81 while (!IsListEmpty(&W32Thread->W32CallbackListHead))
82 {
83 CurrentEntry = RemoveHeadList(&W32Thread->W32CallbackListHead);
84 Mem = CONTAINING_RECORD(CurrentEntry, INT_CALLBACK_HEADER,
85 ListEntry);
86
87 /* Free memory */
89 }
90}
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
Definition: typedefs.h:120
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by ExitThreadCallback().

◆ IntRestoreTebWndCallback()

static VOID IntRestoreTebWndCallback ( HWND  hWnd,
PWND  pWnd,
PVOID  pActCtx 
)
static

Definition at line 122 of file callback.c.

123{
125
126 ClientInfo->CallbackWnd.hWnd = hWnd;
127 ClientInfo->CallbackWnd.pWnd = pWnd;
128 ClientInfo->CallbackWnd.pActCtx = pActCtx;
129}
#define GetWin32ClientInfo()
Definition: ntuser.h:352
CLIENT_DATA ClientInfo

Referenced by co_IntCallSentMessageCallback(), and co_IntCallWindowProc().

◆ IntSetTebWndCallback()

static VOID IntSetTebWndCallback ( HWND hWnd,
PWND pWnd,
PVOID pActCtx 
)
static

Definition at line 97 of file callback.c.

98{
99 HWND hWndS = *hWnd;
102
103 *hWnd = ClientInfo->CallbackWnd.hWnd;
104 *pWnd = ClientInfo->CallbackWnd.pWnd;
105 *pActCtx = ClientInfo->CallbackWnd.pActCtx;
106
107 if (Window)
108 {
109 ClientInfo->CallbackWnd.hWnd = hWndS;
110 ClientInfo->CallbackWnd.pWnd = DesktopHeapAddressToUser(Window);
111 ClientInfo->CallbackWnd.pActCtx = Window->pActCtx;
112 }
113 else
114 {
115 ClientInfo->CallbackWnd.hWnd = hWndS;
116 ClientInfo->CallbackWnd.pWnd = Window;
117 ClientInfo->CallbackWnd.pActCtx = 0;
118 }
119}
Definition: window.c:28
static __inline PVOID DesktopHeapAddressToUser(PVOID lpMem)
Definition: desktop.h:308

Referenced by co_IntCallSentMessageCallback(), and co_IntCallWindowProc().

Variable Documentation

◆ gDesktopCursor

HCURSOR gDesktopCursor
extern

Definition at line 55 of file desktop.c.

Referenced by co_IntLoadDefaultCursors(), and DesktopWindowProc().

◆ iTheId

INT iTheId = -2
static

Definition at line 505 of file callback.c.

Referenced by co_IntCallHookProc().