-
Notifications
You must be signed in to change notification settings - Fork 29
/
desktop_hook.h
200 lines (141 loc) · 4.44 KB
/
desktop_hook.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/*
Copyright (C) 2011 Jay Satiro <[email protected]>
All rights reserved.
This file is part of GetHooks.
GetHooks is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
GetHooks is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GetHooks. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _DESKTOP_HOOK_H
#define _DESKTOP_HOOK_H
#include <windows.h>
/* ReactOS structures and supporting functions */
#include "reactos.h"
/* desktop store (linked list of desktops' heap and thread info) */
#include "desktop.h"
/* snapshot store (system process info, gui threads, desktop hooks) */
#include "snapshot.h"
#ifdef __cplusplus
extern "C" {
#endif
/** Forward declaration for snapshot store due to circular dependency.
*/
struct snapshot;
/** This is the info to keep track of when a HOOK object is found.
For each HANDLEENTRY traversed if its bType == TYPE_HOOK then the handle entry is for a HOOK.
*/
struct hook
{
/* nonzero if this hook is filtered out by the user-specified configuration lists */
unsigned ignore;
/* what was the HANDLEENTRY's index position in the list of user handles */
unsigned entry_index;
/* a copy of the HANDLEENTRY struct for the HOOK */
HANDLEENTRY entry;
/* a copy of the HOOK struct */
HOOK object;
/* the thread that owns the handle entry to the HOOK */
const struct gui *owner;
/* the thread where the HOOK originated */
const struct gui *origin;
/* the thread that's hooked */
const struct gui *target;
};
/** This is the info needed for each item in the desktop hook list.
Each item has information on a desktop and its hooks.
*/
struct desktop_hook_item
{
/* the desktop */
struct desktop_item *desktop;
/** an array of hook structs. these are the hooks on desktop.
*/
/* the hook array */
struct hook *hook; // calloc(), free()
/* the allocated/maximum number of elements in the hook array */
unsigned hook_max;
/* how many handle entries for HOOK objects were found.
this is also the number of elements written to in the hook array.
*/
unsigned hook_count;
/* The next item in the list */
struct desktop_hook_item *next;
};
/** The desktop hook store.
The desktop hook store holds a linked list of desktops and their hooks.
*/
struct desktop_hook_list
{
/* linked list of desktop_hook_item.
this is a pointer to the first item in the desktop hook list.
*/
struct desktop_hook_item *head; // items calloc'd. the list is freed when the store is freed.
/* the last item in the desktop hook list */
struct desktop_hook_item *tail;
/* the desktop list type */
//enum desktop_hook_type type;
/* the system utc time in FILETIME format immediately after this store has been initialized.
this is nonzero when this store has been initialized.
*/
__int64 init_time;
};
/**
these functions are documented in the comment block above their definitions in desktop_hook.c
*/
void create_desktop_hook_store(
struct desktop_hook_list **const out // out deref
);
int match_hook_process_name(
const struct hook *const hook, // in
const WCHAR *const name // in
);
int match_hook_process_id(
const struct hook *const hook, // in
const unsigned __int64 pid // in
);
int match_hook_thread_id(
const struct hook *const hook, // in
const unsigned __int64 tid // in
);
int is_HOOK_id_wanted(
const int id // in
);
int is_hook_wanted(
const struct hook *const hook // in
);
int compare_hook(
const void *const p1, // in
const void *const p2 // in
);
int init_desktop_hook_store(
const struct snapshot *const parent // in
);
void print_hook_anomalies(
const struct hook *const hook // in
);
void print_hook(
const struct hook *const hook // in
);
void print_hook_array(
const struct desktop_hook_item *const item // in
);
void print_desktop_hook_item(
const struct desktop_hook_item *const item // in
);
void print_desktop_hook_store(
const struct desktop_hook_list *const store // in
);
void free_desktop_hook_store(
struct desktop_hook_list **const in // in deref
);
#ifdef __cplusplus
}
#endif
#endif // _DESKTOP_HOOK_H