HyperDbg Debugger
Loading...
Searching...
No Matches
Constants.h
Go to the documentation of this file.
1
13#pragma once
14
16// Version Information //
18
19#define VERSION_MAJOR 0
20#define VERSION_MINOR 10
21#define VERSION_PATCH 0
22
23//
24// Example of __DATE__ string: "Jul 27 2012"
25// 01234567890
26
27#define BUILD_YEAR_CH0 (__DATE__[7])
28#define BUILD_YEAR_CH1 (__DATE__[8])
29#define BUILD_YEAR_CH2 (__DATE__[9])
30#define BUILD_YEAR_CH3 (__DATE__[10])
31
32#define BUILD_MONTH_IS_JAN (__DATE__[0] == 'J' && __DATE__[1] == 'a' && __DATE__[2] == 'n')
33#define BUILD_MONTH_IS_FEB (__DATE__[0] == 'F')
34#define BUILD_MONTH_IS_MAR (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'r')
35#define BUILD_MONTH_IS_APR (__DATE__[0] == 'A' && __DATE__[1] == 'p')
36#define BUILD_MONTH_IS_MAY (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'y')
37#define BUILD_MONTH_IS_JUN (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'n')
38#define BUILD_MONTH_IS_JUL (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'l')
39#define BUILD_MONTH_IS_AUG (__DATE__[0] == 'A' && __DATE__[1] == 'u')
40#define BUILD_MONTH_IS_SEP (__DATE__[0] == 'S')
41#define BUILD_MONTH_IS_OCT (__DATE__[0] == 'O')
42#define BUILD_MONTH_IS_NOV (__DATE__[0] == 'N')
43#define BUILD_MONTH_IS_DEC (__DATE__[0] == 'D')
44
45#define BUILD_MONTH_CH0 \
46 ((BUILD_MONTH_IS_OCT || BUILD_MONTH_IS_NOV || BUILD_MONTH_IS_DEC) ? '1' : '0')
47
48#define BUILD_MONTH_CH1 \
49 ( \
50 (BUILD_MONTH_IS_JAN) ? '1' : (BUILD_MONTH_IS_FEB) ? '2' \
51 : (BUILD_MONTH_IS_MAR) ? '3' \
52 : (BUILD_MONTH_IS_APR) ? '4' \
53 : (BUILD_MONTH_IS_MAY) ? '5' \
54 : (BUILD_MONTH_IS_JUN) ? '6' \
55 : (BUILD_MONTH_IS_JUL) ? '7' \
56 : (BUILD_MONTH_IS_AUG) ? '8' \
57 : (BUILD_MONTH_IS_SEP) ? '9' \
58 : (BUILD_MONTH_IS_OCT) ? '0' \
59 : (BUILD_MONTH_IS_NOV) ? '1' \
60 : (BUILD_MONTH_IS_DEC) ? '2' \
61 : /* error default */ '?')
62
63#define BUILD_DAY_CH0 ((__DATE__[4] >= '0') ? (__DATE__[4]) : '0')
64#define BUILD_DAY_CH1 (__DATE__[5])
65
66//
67// Example of __TIME__ string: "21:06:19"
68// 01234567
69
70#define BUILD_HOUR_CH0 (__TIME__[0])
71#define BUILD_HOUR_CH1 (__TIME__[1])
72
73#define BUILD_MIN_CH0 (__TIME__[3])
74#define BUILD_MIN_CH1 (__TIME__[4])
75
76#define BUILD_SEC_CH0 (__TIME__[6])
77#define BUILD_SEC_CH1 (__TIME__[7])
78
79#ifndef HYPERDBG_KERNEL_MODE
80
81const unsigned char BuildDateTime[] = {
86 '-',
89 '-',
92 ' ',
95 ':',
98 ':',
101
102 '\0'};
103
104// Macro to convert a number to a string
105# define STRINGIFY(x) #x
106# define TOSTRING(x) STRINGIFY(x)
107
108// Complete version as a string
109# define HYPERDBG_COMPLETE_VERSION "v" TOSTRING(VERSION_MAJOR) "." TOSTRING(VERSION_MINOR) "." TOSTRING(VERSION_PATCH) "\0"
110
112
113const unsigned char BuildVersion[] = {
122 '.',
127
128 '\0'};
129
130const unsigned char BuildSignature[] = {
132 '.',
134 '.',
136 '-',
145 '.',
150
151 '\0'};
152
153#endif // SCRIPT_ENGINE_KERNEL_MODE
154
156// Message Tracing //
158
163#define MaximumPacketsCapacity 1000
164
169#define MaximumPacketsCapacityPriority 50
170
174#define NORMAL_PAGE_SIZE 4096 // PAGE_SIZE
175
179#define PacketChunkSize NORMAL_PAGE_SIZE
180
187#define UsermodeBufferSize sizeof(UINT32) + PacketChunkSize + 1
188
194#define MaxSerialPacketSize 20 * NORMAL_PAGE_SIZE
195
200#define LogBufferSize \
201 MaximumPacketsCapacity *(PacketChunkSize + sizeof(BUFFER_HEADER))
202
207#define LogBufferSizePriority \
208 MaximumPacketsCapacityPriority *(PacketChunkSize + sizeof(BUFFER_HEADER))
209
215#define DbgPrintLimitation 512
216
222#define DebuggerEventTagStartSeed 0x1000000
223
229#define DebuggerThreadDebuggingTagStartSeed 0x1000000
230
236#define DebuggerOutputSourceTagStartSeed 0x1
237
243#define DebuggerOutputSourceMaximumRemoteSourceForSingleEvent 0x5
244
250#define DebuggerScriptEngineMemcpyMovingBufferSize 64
251
253// EPT Hook //
255
260#define MAXIMUM_NUMBER_OF_INITIAL_PREALLOCATED_EPT_HOOKS 5
261
263// Instant Event Configs //
265
270#define MAXIMUM_REGULAR_INSTANT_EVENTS 20
271
276#define MAXIMUM_BIG_INSTANT_EVENTS 0
277
282#define REGULAR_INSTANT_EVENT_CONDITIONAL_BUFFER sizeof(DEBUGGER_EVENT) + 100
283
288#define BIG_INSTANT_EVENT_CONDITIONAL_BUFFER sizeof(DEBUGGER_EVENT) + PAGE_SIZE
289
294#define REGULAR_INSTANT_EVENT_ACTION_BUFFER sizeof(DEBUGGER_EVENT_ACTION) + (PAGE_SIZE * 2)
295
300#define BIG_INSTANT_EVENT_ACTION_BUFFER sizeof(DEBUGGER_EVENT_ACTION) + MaxSerialPacketSize
301
306#define REGULAR_INSTANT_EVENT_REQUESTED_SAFE_BUFFER PAGE_SIZE
307
312#define BIG_INSTANT_EVENT_REQUESTED_SAFE_BUFFER MaxSerialPacketSize
313
315// Remote Connection //
317
323#define DEFAULT_PORT "50000"
324
330#define COMMUNICATION_BUFFER_SIZE PacketChunkSize + 0x100
331
333// VMCALL Numbers //
335
341#define TOP_LEVEL_DRIVERS_VMCALL_STARTING_NUMBER 0x00000200
342
348#define TOP_LEVEL_DRIVERS_VMCALL_ENDING_NUMBER TOP_LEVEL_DRIVERS_VMCALL_STARTING_NUMBER + 0x100
349
351// Operation Codes //
353
359#define OPERATION_MANDATORY_DEBUGGEE_BIT (1 << 31)
360
366#define OPERATION_LOG_INFO_MESSAGE 1U
367#define OPERATION_LOG_WARNING_MESSAGE 2U
368#define OPERATION_LOG_ERROR_MESSAGE 3U
369#define OPERATION_LOG_NON_IMMEDIATE_MESSAGE 4U
370#define OPERATION_LOG_WITH_TAG 5U
371
372#define OPERATION_COMMAND_FROM_DEBUGGER_CLOSE_AND_UNLOAD_VMM \
373 6U | OPERATION_MANDATORY_DEBUGGEE_BIT
374#define OPERATION_DEBUGGEE_USER_INPUT 7U | OPERATION_MANDATORY_DEBUGGEE_BIT
375#define OPERATION_DEBUGGEE_REGISTER_EVENT 8U | OPERATION_MANDATORY_DEBUGGEE_BIT
376#define OPERATION_DEBUGGEE_ADD_ACTION_TO_EVENT \
377 9 | OPERATION_MANDATORY_DEBUGGEE_BIT
378#define OPERATION_DEBUGGEE_CLEAR_EVENTS 10U | OPERATION_MANDATORY_DEBUGGEE_BIT
379#define OPERATION_DEBUGGEE_CLEAR_EVENTS_WITHOUT_NOTIFYING_DEBUGGER 11U | OPERATION_MANDATORY_DEBUGGEE_BIT
380#define OPERATION_HYPERVISOR_DRIVER_IS_SUCCESSFULLY_LOADED \
381 12U | OPERATION_MANDATORY_DEBUGGEE_BIT
382#define OPERATION_HYPERVISOR_DRIVER_END_OF_IRPS \
383 13U | OPERATION_MANDATORY_DEBUGGEE_BIT
384#define OPERATION_COMMAND_FROM_DEBUGGER_RELOAD_SYMBOL \
385 14U | OPERATION_MANDATORY_DEBUGGEE_BIT
386
387#define OPERATION_NOTIFICATION_FROM_USER_DEBUGGER_PAUSE \
388 15U | OPERATION_MANDATORY_DEBUGGEE_BIT
389
391// Breakpoints & Debug Breakpoints //
393
398#define MAXIMUM_BREAKPOINTS_WITHOUT_CONTINUE 100
399
407#define MAXIMUM_NUMBER_OF_THREAD_INFORMATION_FOR_TRAPS 200
408
410// Pool tags used in HyperDbg //
412
417#define POOLTAG 0x48444247 // [H]yper[DBG] (HDBG)
418
420// End of Buffer Detection //
422
426#define SERIAL_END_OF_BUFFER_CHARS_COUNT 0x4
427
432#define SERIAL_END_OF_BUFFER_CHAR_1 0x00
433#define SERIAL_END_OF_BUFFER_CHAR_2 0x80
434#define SERIAL_END_OF_BUFFER_CHAR_3 0xEE
435#define SERIAL_END_OF_BUFFER_CHAR_4 0xFF
436
440#define TCP_END_OF_BUFFER_CHARS_COUNT 0x4
441
446#define TCP_END_OF_BUFFER_CHAR_1 0x10
447#define TCP_END_OF_BUFFER_CHAR_2 0x20
448#define TCP_END_OF_BUFFER_CHAR_3 0x33
449#define TCP_END_OF_BUFFER_CHAR_4 0x44
450
452// Name of OS //
454
459#define MAXIMUM_CHARACTER_FOR_OS_NAME 256
460
462// Processor Details //
464
468#define MAXIMUM_INSTR_SIZE 16
469
473#define MAXIMUM_CALL_INSTR_SIZE 7
474
476// Symbols Details //
478
483#define MAXIMUM_SUPPORTED_SYMBOLS 1000
484
491#define MAXIMUM_GUID_AND_AGE_SIZE 60
492
494// Debuggee Communication //
496
502#define INDICATOR_OF_HYPERDBG_PACKET \
503 0x4859504552444247 // HYPERDBG = 0x4859504552444247
504
506// Command Details //
508
514#define MaximumSearchResults 0x1000
515
517// Script Engine //
519
524#define X86_FLAGS_CF (1 << 0)
525#define X86_FLAGS_PF (1 << 2)
526#define X86_FLAGS_AF (1 << 4)
527#define X86_FLAGS_ZF (1 << 6)
528#define X86_FLAGS_SF (1 << 7)
529#define X86_FLAGS_TF (1 << 8)
530#define X86_FLAGS_IF (1 << 9)
531#define X86_FLAGS_DF (1 << 10)
532#define X86_FLAGS_OF (1 << 11)
533#define X86_FLAGS_STATUS_MASK (0xfff)
534#define X86_FLAGS_IOPL_MASK (3 << 12)
535#define X86_FLAGS_IOPL_SHIFT (12)
536#define X86_FLAGS_IOPL_SHIFT_2ND_BIT (13)
537#define X86_FLAGS_NT (1 << 14)
538#define X86_FLAGS_RF (1 << 16)
539#define X86_FLAGS_VM (1 << 17)
540#define X86_FLAGS_AC (1 << 18)
541#define X86_FLAGS_VIF (1 << 19)
542#define X86_FLAGS_VIP (1 << 20)
543#define X86_FLAGS_ID (1 << 21)
544#define X86_FLAGS_RESERVED_ONES 0x2
545#define X86_FLAGS_RESERVED 0xffc0802a
546
547#define X86_FLAGS_RESERVED_BITS 0xffc38028
548#define X86_FLAGS_FIXED 0x00000002
549
550#ifndef LOWORD
551# define LOWORD(l) ((WORD)(l))
552#endif // !LOWORD
553
554#ifndef HIWORD
555# define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))
556#endif // !HIWORD
557
558#ifndef LOBYTE
559# define LOBYTE(w) ((BYTE)(w))
560#endif // !LOBYTE
561
562#ifndef HIBYTE
563# define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
564#endif // !HIBYTE
565
566#define MAX_TEMP_COUNT 128
567
568#define MAX_STACK_BUFFER_COUNT 256
569
570#define MAX_EXECUTION_COUNT 1000000
571
572// TODO: Extract number of variables from input of ScriptEngine
573// and allocate variableList Dynamically.
574#define MAX_VAR_COUNT 512
575
576#define MAX_FUNCTION_NAME_LENGTH 32
577
579// Debugger //
581
586#define DEBUGGER_MODIFY_EVENTS_APPLY_TO_ALL_TAG 0xffffffffffffffff
587
593#define DISASSEMBLY_MAXIMUM_DISTANCE_FROM_OBJECT_NAME 0xffff
594
599#define DEBUGGER_READ_AND_WRITE_ON_MSR_APPLY_ALL_CORES 0xffffffff
600
605#define DEBUGGER_DEBUGGEE_IS_RUNNING_NO_CORE 0xffffffff
606
611#define DEBUGGER_EVENT_APPLY_TO_ALL_CORES 0xffffffff
612
617#define DEBUGGER_EVENT_APPLY_TO_ALL_PROCESSES 0xffffffff
618
623#define DEBUGGER_EVENT_MSR_READ_OR_WRITE_ALL_MSRS 0xffffffff
624
629#define DEBUGGER_EVENT_EXCEPTIONS_ALL_FIRST_32_ENTRIES 0xffffffff
630
635#define DEBUGGER_EVENT_SYSCALL_ALL_SYSRET_OR_SYSCALLS 0xffffffff
636
641#define DEBUGGER_EVENT_ALL_IO_PORTS 0xffffffff
642
647#define DEBUGGEE_BP_APPLY_TO_ALL_CORES 0xffffffff
648
653#define DEBUGGEE_BP_APPLY_TO_ALL_PROCESSES 0xffffffff
654
659#define DEBUGGEE_BP_APPLY_TO_ALL_THREADS 0xffffffff
660
665#define DEBUGGEE_SHOW_ALL_REGISTERS 0xffffffff
#define BUILD_YEAR_CH3
Definition Constants.h:30
#define BUILD_YEAR_CH2
Definition Constants.h:29
#define BUILD_HOUR_CH1
Definition Constants.h:71
#define BUILD_MONTH_CH1
Definition Constants.h:48
#define BUILD_YEAR_CH1
Definition Constants.h:28
#define VERSION_MAJOR
Definition Constants.h:19
#define BUILD_MIN_CH0
Definition Constants.h:73
#define BUILD_YEAR_CH0
Definition Constants.h:27
#define BUILD_MIN_CH1
Definition Constants.h:74
#define BUILD_SEC_CH0
Definition Constants.h:76
const unsigned char BuildVersion[]
Definition Constants.h:113
#define BUILD_DAY_CH0
Definition Constants.h:63
#define VERSION_PATCH
Definition Constants.h:21
#define TOSTRING(x)
Definition Constants.h:106
const unsigned char CompleteVersion[]
Definition Constants.h:111
const unsigned char BuildDateTime[]
Definition Constants.h:81
#define BUILD_DAY_CH1
Definition Constants.h:64
#define BUILD_SEC_CH1
Definition Constants.h:77
#define HYPERDBG_COMPLETE_VERSION
Definition Constants.h:109
#define BUILD_HOUR_CH0
Definition Constants.h:70
#define VERSION_MINOR
Definition Constants.h:20
const unsigned char BuildSignature[]
Definition Constants.h:130
#define BUILD_MONTH_CH0
Definition Constants.h:45