-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusrapihk.h
95 lines (84 loc) · 2.5 KB
/
usrapihk.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* * * * * * * *\
USRAPIHK.H -
Copyright © 2024 Brady McDermott, Vortesys
DESCRIPTION -
User32 UserApiHook function prototypes. Info
and structures sourced primarily from the ReactOS
wiki, source code and Mozilla's bug tracker.
LICENSE INFORMATION -
MIT License, see LICENSE.txt in the root folder
\* * * * * * * */
/* Pragmas */
#pragma once
/* Definitions */
#define WM_UAHINIT 0x0000031b
#define WM_UAHDRAWMENU 0x00000091
#define WM_UAHDRAWITEM 0x00000092 // WM_DRAWITEM
#define WM_UAHINITMENU 0x00000093
#define WM_UAHMEASUREITEM 0x00000094 // WM_MEASUREITEM
#define WM_UAHDRAWMENUNC 0x00000095
#define WM_NCUAHDRAWCAPTION 0x000000AE
#define WM_NCUAHDRAWFRAME 0x000000AF
#define UAH_HOOK_MESSAGE(uahowp, msg) uahowp.MsgBitArray[msg/8] |= (1 << (msg % 8));
#define UAH_IS_MESSAGE_HOOKED(uahowp, msg) (uahowp.MsgBitArray[msg/8] & (1 << (msg % 8)))
#define UAHOWP_MAX_SIZE WM_USER/8
/* Structures */
// RegisterUserApiHook signature
// NT 5.1
typedef struct _USERAPIHOOKINFO_XP
{
HINSTANCE hInstance; // hInstance
FARPROC CallbackFunc; // Callback function
} USERAPIHOOKINFO_XP, * PUSERAPIHOOKINFO_XP;
typedef BOOL(WINAPI* RUAH_XP)(PUSERAPIHOOKINFO_XP);
// NT 5.2 and newer
typedef struct _USERAPIHOOKINFO
{
DWORD m_size; // Size of the structure
LPCWSTR m_dllname1; // DLL 1
LPCWSTR m_funname1; // Callback function
LPCWSTR m_dllname2; // DLL 2
LPCWSTR m_funname2; // Callback function
} USERAPIHOOKINFO, * PUSERAPIHOOKINFO;
typedef BOOL(WINAPI* RUAH)(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;
/* Function Prototypes */
BOOL WINAPI RegisterUserApiHook(PUSERAPIHOOKINFO ApiHookInfo);
BOOL WINAPI UnregisterUserApiHook(VOID);