1
1
#pragma once
2
2
3
3
#include < type_traits>
4
+ #include < cstdint>
4
5
5
6
// Types
6
7
@@ -14,35 +15,13 @@ const int PATH_MAXIMUM_LENGTH = 260;
14
15
15
16
// Enumerations
16
17
17
- enum class RequestFunction
18
- {
19
- IsProcessValid,
20
- OpenRemoteProcess,
21
- CloseRemoteProcess,
22
- ReadRemoteMemory,
23
- WriteRemoteMemory,
24
- EnumerateProcesses,
25
- EnumerateRemoteSectionsAndModules,
26
- DisassembleCode,
27
- ControlRemoteProcess
28
- };
29
-
30
18
enum class ProcessAccess
31
19
{
32
20
Read,
33
21
Write,
34
22
Full
35
23
};
36
24
37
- enum class SectionType
38
- {
39
- Unknown,
40
-
41
- Private,
42
- Mapped,
43
- Image
44
- };
45
-
46
25
enum class SectionProtection
47
26
{
48
27
NoAccess = 0 ,
@@ -66,19 +45,80 @@ inline SectionProtection& operator|=(SectionProtection& lhs, SectionProtection r
66
45
using T = std::underlying_type_t <SectionProtection>;
67
46
68
47
lhs = static_cast <SectionProtection>(static_cast <T>(lhs) | static_cast <T>(rhs));
69
-
48
+
70
49
return lhs;
71
50
}
72
51
52
+ enum class SectionType
53
+ {
54
+ Unknown,
55
+
56
+ Private,
57
+ Mapped,
58
+ Image
59
+ };
60
+
61
+ enum class SectionCategory
62
+ {
63
+ Unknown,
64
+ CODE,
65
+ DATA,
66
+ HEAP
67
+ };
68
+
73
69
enum class ControlRemoteProcessAction
74
70
{
75
71
Suspend,
76
72
Resume,
77
73
Terminate
78
74
};
79
75
76
+ enum class DebugContinueStatus
77
+ {
78
+ Handled,
79
+ NotHandled
80
+ };
81
+
82
+ enum class HardwareBreakpointRegister
83
+ {
84
+ InvalidRegister,
85
+
86
+ Dr0,
87
+ Dr1,
88
+ Dr2,
89
+ Dr3
90
+ };
91
+
92
+ enum class HardwareBreakpointTrigger
93
+ {
94
+ Execute,
95
+ Access,
96
+ Write,
97
+ };
98
+
99
+ enum class HardwareBreakpointSize
100
+ {
101
+ Size1 = 1 ,
102
+ Size2 = 2 ,
103
+ Size4 = 4 ,
104
+ Size8 = 8
105
+ };
106
+
107
+ enum class DebugEventType
108
+ {
109
+ CreateProcess,
110
+ ExitProcess,
111
+ CreateThread,
112
+ ExitThread,
113
+ LoadDll,
114
+ UnloadDll,
115
+ Exception
116
+ };
117
+
80
118
// Structures
81
119
120
+ #pragma pack(push, 1)
121
+
82
122
struct EnumerateProcessData
83
123
{
84
124
RC_Size Id;
@@ -88,6 +128,7 @@ struct EnumerateProcessData
88
128
struct InstructionData
89
129
{
90
130
int Length;
131
+ uint8_t Data[15 ];
91
132
RC_UnicodeChar Instruction[64 ];
92
133
};
93
134
@@ -96,6 +137,7 @@ struct EnumerateRemoteSectionData
96
137
RC_Pointer BaseAddress;
97
138
RC_Size Size ;
98
139
SectionType Type;
140
+ SectionCategory Category;
99
141
SectionProtection Protection;
100
142
RC_UnicodeChar Name[16 ];
101
143
RC_UnicodeChar ModulePath[PATH_MAXIMUM_LENGTH];
@@ -108,31 +150,110 @@ struct EnumerateRemoteModuleData
108
150
RC_UnicodeChar Path[PATH_MAXIMUM_LENGTH];
109
151
};
110
152
111
- // Callbacks
112
-
113
- typedef RC_Pointer (__stdcall *RequestFunctionPtrCallback)(RequestFunction request) ;
114
-
115
- typedef void (__stdcall *EnumerateProcessCallback)(EnumerateProcessData* data) ;
153
+ struct CreateProcessDebugInfo
154
+ {
155
+ RC_Pointer FileHandle ;
156
+ RC_Pointer ProcessHandle;
157
+ } ;
116
158
117
- typedef void (__stdcall EnumerateRemoteSectionsCallback)(EnumerateRemoteSectionData* data);
118
- typedef void (__stdcall EnumerateRemoteModulesCallback)(EnumerateRemoteModuleData* data);
159
+ struct ExitProcessDebugInfo
160
+ {
161
+ RC_Size ExitCode;
162
+ };
119
163
120
- // Delegates
164
+ struct CreateThreadDebugInfo
165
+ {
166
+ RC_Pointer ThreadHandle;
167
+ };
121
168
122
- typedef bool (__stdcall *IsProcessValid_Delegate)(RC_Pointer handle);
169
+ struct ExitThreadDebugInfo
170
+ {
171
+ RC_Size ExitCode;
172
+ };
123
173
124
- typedef RC_Pointer (__stdcall *OpenRemoteProcess_Delegate)(RC_Size processId, ProcessAccess desiredAccess);
174
+ struct LoadDllDebugInfo
175
+ {
176
+ RC_Pointer FileHandle;
177
+ RC_Pointer BaseOfDll;
178
+ };
125
179
126
- typedef void (__stdcall *CloseRemoteProcess_Delegate)(RC_Pointer handle);
180
+ struct UnloadDllDebugInfo
181
+ {
182
+ RC_Pointer BaseOfDll;
183
+ };
127
184
128
- typedef bool (__stdcall *ReadRemoteMemory_Delegate)(RC_Pointer handle, RC_Pointer address, RC_Pointer buffer, RC_Size size);
185
+ struct ExceptionDebugInfo
186
+ {
187
+ RC_Size ExceptionCode;
188
+ RC_Size ExceptionFlags;
189
+ RC_Pointer ExceptionAddress;
190
+
191
+ HardwareBreakpointRegister CausedBy;
192
+
193
+ bool IsFirstChance;
194
+
195
+ struct RegisterInfo
196
+ {
197
+ #ifdef _WIN64
198
+ RC_Pointer Rax;
199
+ RC_Pointer Rbx;
200
+ RC_Pointer Rcx;
201
+ RC_Pointer Rdx;
202
+ RC_Pointer Rdi;
203
+ RC_Pointer Rsi;
204
+ RC_Pointer Rsp;
205
+ RC_Pointer Rbp;
206
+ RC_Pointer Rip;
207
+
208
+ RC_Pointer R8;
209
+ RC_Pointer R9;
210
+ RC_Pointer R10;
211
+ RC_Pointer R11;
212
+ RC_Pointer R12;
213
+ RC_Pointer R13;
214
+ RC_Pointer R14;
215
+ RC_Pointer R15;
216
+ #else
217
+ RC_Pointer Eax;
218
+ RC_Pointer Ebx;
219
+ RC_Pointer Ecx;
220
+ RC_Pointer Edx;
221
+ RC_Pointer Edi;
222
+ RC_Pointer Esi;
223
+ RC_Pointer Esp;
224
+ RC_Pointer Ebp;
225
+ RC_Pointer Eip;
226
+ #endif
227
+ };
228
+ RegisterInfo Registers;
229
+ };
129
230
130
- typedef bool (__stdcall *WriteRemoteMemory_Delegate)(RC_Pointer handle, RC_Pointer address, RC_Pointer buffer, RC_Size size);
231
+ struct DebugEvent
232
+ {
233
+ DebugContinueStatus ContinueStatus;
234
+
235
+ RC_Pointer ProcessId;
236
+ RC_Pointer ThreadId;
237
+
238
+ DebugEventType Type;
239
+
240
+ union
241
+ {
242
+ CreateProcessDebugInfo CreateProcessInfo;
243
+ ExitProcessDebugInfo ExitProcessInfo;
244
+ CreateThreadDebugInfo CreateThreadInfo;
245
+ ExitThreadDebugInfo ExitThreadInfo;
246
+ LoadDllDebugInfo LoadDllInfo;
247
+ UnloadDllDebugInfo UnloadDllInfo;
248
+ ExceptionDebugInfo ExceptionInfo;
249
+ };
250
+ };
131
251
132
- typedef void (__stdcall *EnumerateProcesses_Delegate)(EnumerateProcessCallback callbackProcess);
252
+ # pragma pack(pop)
133
253
134
- typedef void (__stdcall *EnumerateRemoteSectionsAndModules_Delegate)(RC_Pointer handle, EnumerateRemoteSectionsCallback callbackSection, EnumerateRemoteModulesCallback callbackModule);
254
+ // Callbacks
135
255
136
- typedef bool (__stdcall *DisassembleCode_Delegate)(RC_Pointer address, RC_Size length, RC_Pointer virtualAddress, InstructionData* instruction );
256
+ typedef void (__stdcall *EnumerateProcessCallback)(EnumerateProcessData* data );
137
257
138
- typedef void (__stdcall *ControlRemoteProcess_Delegate)(RC_Pointer handle, ControlRemoteProcessAction action);
258
+ typedef void (__stdcall EnumerateRemoteSectionsCallback)(EnumerateRemoteSectionData* data);
259
+ typedef void (__stdcall EnumerateRemoteModulesCallback)(EnumerateRemoteModuleData* data);
0 commit comments