Read kernel buffers using IRP Pending.
171{
173 ULONG ReturnedLength;
177 HANDLE Handle;
178
181
182
183
184
185
186
187
188
189
190 Handle = CreateFileA(
191 "\\\\.\\HyperDbgDebuggerDevice",
192 GENERIC_READ | GENERIC_WRITE,
193 FILE_SHARE_READ | FILE_SHARE_WRITE,
194 NULL,
195 OPEN_EXISTING,
196 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
197 NULL);
198
199 if (Handle == INVALID_HANDLE_VALUE)
200 {
201 ErrorNum = GetLastError();
202
203 if (ErrorNum == ERROR_ACCESS_DENIED)
204 {
205 ShowMessages(
"err, access denied\nare you sure you have administrator "
206 "rights?\n");
207 }
208 else if (ErrorNum == ERROR_GEN_FAILURE)
209 {
210 ShowMessages(
"err, a device attached to the system is not functioning\n"
211 "vmx feature might be disabled from BIOS or VBS/HVCI is active\n");
212 }
213 else
214 {
215 ShowMessages(
"err, CreateFile failed with (%x)\n", ErrorNum);
216 }
217
220
221 return;
222 }
223
224
225
226
228
229 try
230 {
232 {
234 {
235
236
237
239
241
242 Status = DeviceIoControl(
243 Handle,
245 &RegisterEvent,
247
248 OutputBuffer,
250 &ReturnedLength,
251 NULL
252 );
253
254 if (!Status)
255 {
256
257
258
259
260
261
262
263
264
265 continue;
266 }
267
268
269
270
271 OperationCode = 0;
272 memcpy(&OperationCode, OutputBuffer,
sizeof(
UINT32));
273
274
275
276
277
278
279 switch (OperationCode)
280 {
282
284 {
285
286
287
288
289 continue;
290 }
291
293
294 break;
296
298 {
299
300
301
302
303 continue;
304 }
305
307
308 break;
311 {
312
313
314
315
316 continue;
317 }
318
320
321 break;
323
325 {
326
327
328
329
330 continue;
331 }
332
334
335 break;
336
338
340
341 break;
342
344
346
347 break;
348
350
353 ReturnedLength);
354
355 break;
356
358
361 ReturnedLength);
362
363 break;
364
366
370
371 break;
372
374
378
379 break;
380
382
383
384
385
387
388 break;
389
391
392
393
394
395 break;
396
398
399
400
401
404
405 break;
406
408
409
410
411
414
415 break;
416
417 default:
418
419
420
421
423 OutputBuffer +
sizeof(
UINT32),
424 ReturnedLength -
sizeof(
UINT32) - 1))
425 {
427 {
428
429
430
431
432 continue;
433 }
434
436 }
437
438 break;
439 }
440 }
441 else
442 {
443
444
445
446 free(OutputBuffer);
447
448
449
450
451 if (!CloseHandle(Handle))
452 {
453 ShowMessages(
"err, closing handle 0x%x\n", GetLastError());
454 }
455
456 return;
457 }
458 }
459 }
460 catch (const std::exception &)
461 {
462 ShowMessages(
"err, exception occurred in creating handle or parsing buffer\n");
463 }
464
465 free(OutputBuffer);
466
467
468
469
470 if (!CloseHandle(Handle))
471 {
472 ShowMessages(
"err, closing handle 0x%x\n", GetLastError());
473 };
474}
unsigned int UINT32
Definition BasicTypes.h:48
unsigned long ULONG
Definition BasicTypes.h:37
#define OPERATION_DEBUGGEE_USER_INPUT
Definition Constants.h:374
#define OPERATION_HYPERVISOR_DRIVER_END_OF_IRPS
Definition Constants.h:382
#define OPERATION_LOG_ERROR_MESSAGE
Definition Constants.h:368
#define OPERATION_COMMAND_FROM_DEBUGGER_RELOAD_SYMBOL
Definition Constants.h:384
#define UsermodeBufferSize
size of user-mode buffer
Definition Constants.h:187
#define OPERATION_DEBUGGEE_ADD_ACTION_TO_EVENT
Definition Constants.h:376
#define OPERATION_NOTIFICATION_FROM_USER_DEBUGGER_PAUSE
Definition Constants.h:387
#define OPERATION_LOG_WARNING_MESSAGE
Definition Constants.h:367
#define OPERATION_DEBUGGEE_REGISTER_EVENT
Definition Constants.h:375
#define OPERATION_HYPERVISOR_DRIVER_IS_SUCCESSFULLY_LOADED
Definition Constants.h:380
#define OPERATION_LOG_INFO_MESSAGE
Message logs id that comes from kernel-mode to user-mode.
Definition Constants.h:366
#define OPERATION_DEBUGGEE_CLEAR_EVENTS_WITHOUT_NOTIFYING_DEBUGGER
Definition Constants.h:379
#define OPERATION_DEBUGGEE_CLEAR_EVENTS
Definition Constants.h:378
#define OPERATION_LOG_NON_IMMEDIATE_MESSAGE
Definition Constants.h:369
#define OPERATION_COMMAND_FROM_DEBUGGER_CLOSE_AND_UNLOAD_VMM
Definition Constants.h:372
@ IRP_BASED
Definition DataTypes.h:255
#define DefaultSpeedOfReadingKernelMessages
The speed delay for showing messages from kernel-mode to user-mode in VMI-mode, using a lower value c...
Definition Definition.h:72
#define IOCTL_REGISTER_EVENT
ioctl, register a new event
Definition Ioctls.h:64
BOOLEAN ForwardingCheckAndPerformEventForwarding(UINT32 OperationCode, CHAR *Message, UINT32 MessageLength)
Check and send the event result to the corresponding sources.
Definition forwarding.cpp:439
BOOLEAN g_OutputSourcesInitialized
it shows whether the debugger started using output sources or not or in other words,...
Definition globals.h:408
BOOLEAN g_BreakPrintingOutput
Shows whether the pause command or CTRL+C or CTRL+Break is executed or not.
Definition globals.h:499
The structure of .sym reload packet in HyperDbg.
Definition RequestStructures.h:1047
The structure of pausing packet in uHyperDbg.
Definition DataTypes.h:229
The structure of user-input packet in HyperDbg.
Definition DataTypes.h:140
Each event can have multiple actions.
Definition Events.h:406
Each command is like the following struct, it also used for tracing works in user mode and sending it...
Definition Events.h:350
request for modifying events (enable/disable/clear)
Definition Events.h:242
Used to register event for transferring buffer between user-to-kernel.
Definition DataTypes.h:279
NOTIFY_TYPE Type
Definition DataTypes.h:280
HANDLE hEvent
Definition DataTypes.h:281
VOID UdHandleUserDebuggerPausing(PDEBUGGEE_UD_PAUSED_PACKET PausePacket)
Handle pause packets from user debugger.
Definition user-listening.cpp:29