HyperDbg Debugger
Toggle main menu visibility
Loading...
Searching...
No Matches
Common.h
Go to the documentation of this file.
1
12
#pragma once
13
18
#define __CPU_INDEX__ KeGetCurrentProcessorNumberEx(NULL)
19
24
#define ALIGNMENT_PAGE_SIZE 4096
25
30
#define MAXIMUM_ADDRESS 0xffffffffffffffff
31
36
#define DPL_USER 3
37
#define DPL_SYSTEM 0
38
43
#define RPL_MASK 3
44
45
#define BITS_PER_LONG (sizeof(ULONG) * 8)
46
#define ORDER_LONG (sizeof(ULONG) == 4 ? 5 : 6)
47
48
#define BITMAP_ENTRY(_nr, _bmap) ((_bmap))[(_nr) / BITS_PER_LONG]
49
#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)
50
55
#define PAGE_OFFSET(Va) ((PVOID)((ULONG_PTR)(Va) & (PAGE_SIZE - 1)))
56
61
#define _XBEGIN_STARTED (~0u)
62
#define _XABORT_EXPLICIT (1 << 0)
63
#define _XABORT_RETRY (1 << 1)
64
#define _XABORT_CONFLICT (1 << 2)
65
#define _XABORT_CAPACITY (1 << 3)
66
#define _XABORT_DEBUG (1 << 4)
67
#define _XABORT_NESTED (1 << 5)
68
69
#ifndef _XABORT_CODE
70
# define _XABORT_CODE(x) (((x) >> 24) & 0xFF)
71
#endif
// !_XABORT_CODE
72
74
// Structures //
76
77
typedef
SEGMENT_DESCRIPTOR_32 *
PSEGMENT_DESCRIPTOR
;
78
83
typedef
struct
_CPUID
84
{
85
INT
eax
;
86
INT
ebx
;
87
INT
ecx
;
88
INT
edx
;
89
}
CPUID
, *
PCPUID
;
90
91
typedef
union
_CR_FIXED
92
{
93
UINT64
Flags
;
94
95
struct
96
{
97
ULONG
Low
;
98
LONG
High
;
99
100
}
Fields
;
101
102
}
CR_FIXED
, *
PCR_FIXED
;
103
105
// Windows-specific structures //
107
112
typedef
struct
_NT_KPROCESS
113
{
114
DISPATCHER_HEADER
Header
;
115
LIST_ENTRY
ProfileListHead
;
116
ULONG_PTR
DirectoryTableBase
;
117
UCHAR
Data
[1];
118
}
NT_KPROCESS
, *
PNT_KPROCESS
;
119
121
// Function Types //
123
128
typedef
VOID (*
RunOnLogicalCoreFunc
)(
ULONG
ProcessorId);
129
131
// External Functions //
133
134
UCHAR
*
135
PsGetProcessImageFileName
(IN PEPROCESS Process);
136
138
// Function Definitions //
140
141
// ----------------------------------------------------------------------------
142
// Private Interfaces
143
//
144
145
static
NTSTATUS
146
CommonGetHandleFromProcess(_In_
UINT32
ProcessId, _Out_ PHANDLE Handle);
147
148
// ----------------------------------------------------------------------------
149
// Public Interfaces
150
//
151
152
BOOLEAN
153
CommonAffinityBroadcastToProcessors
(_In_
ULONG
ProcessorNumber, _In_
RunOnLogicalCoreFunc
Routine);
154
155
BOOLEAN
156
CommonIsStringStartsWith
(
const
CHAR
* pre,
const
CHAR
* str);
157
158
BOOLEAN
159
CommonIsGuestOnUsermode32Bit
();
160
161
PCHAR
162
CommonGetProcessNameFromProcessControlBlock
(PEPROCESS eprocess);
163
164
VOID
165
CommonCpuidInstruction
(
UINT32
Func,
UINT32
SubFunc,
INT
* CpuInfo);
166
167
VOID
168
CommonWriteDebugInformation
(
VIRTUAL_MACHINE_STATE
* VCpu);
169
170
BOOLEAN
171
CommonIsXCr0Valid
(XCR0 XCr0);
BOOLEAN
UCHAR BOOLEAN
Definition
BasicTypes.h:35
LONG
long LONG
Definition
BasicTypes.h:28
INT
int INT
Definition
BasicTypes.h:43
UCHAR
unsigned char UCHAR
Definition
BasicTypes.h:34
UINT32
unsigned int UINT32
Definition
BasicTypes.h:54
CHAR
char CHAR
Definition
BasicTypes.h:33
ULONG
unsigned long ULONG
Definition
BasicTypes.h:31
CommonIsGuestOnUsermode32Bit
BOOLEAN CommonIsGuestOnUsermode32Bit()
determines if the guest was in 32-bit user-mode or 64-bit (long mode)
Definition
Common.c:97
CPUID
struct _CPUID CPUID
CPUID Registers.
RunOnLogicalCoreFunc
VOID(* RunOnLogicalCoreFunc)(ULONG ProcessorId)
Prototype to run a function on a logical core.
Definition
Common.h:128
CommonIsXCr0Valid
BOOLEAN CommonIsXCr0Valid(XCR0 XCr0)
Check correctness of the XCR0 register value.
Definition
Common.c:202
PCR_FIXED
union _CR_FIXED * PCR_FIXED
PSEGMENT_DESCRIPTOR
SEGMENT_DESCRIPTOR_32 * PSEGMENT_DESCRIPTOR
Definition
Common.h:77
PNT_KPROCESS
struct _NT_KPROCESS * PNT_KPROCESS
PCPUID
struct _CPUID * PCPUID
CommonGetProcessNameFromProcessControlBlock
PCHAR CommonGetProcessNameFromProcessControlBlock(PEPROCESS eprocess)
Get process name by eprocess.
Definition
Common.c:48
CommonWriteDebugInformation
VOID CommonWriteDebugInformation(VIRTUAL_MACHINE_STATE *VCpu)
Produce debug information from unrecoverable bugs.
Definition
Common.c:149
CommonIsStringStartsWith
BOOLEAN CommonIsStringStartsWith(const CHAR *pre, const CHAR *str)
Detects whether the string starts with another string.
Definition
Common.c:69
CommonAffinityBroadcastToProcessors
BOOLEAN CommonAffinityBroadcastToProcessors(_In_ ULONG ProcessorNumber, _In_ RunOnLogicalCoreFunc Routine)
NT_KPROCESS
struct _NT_KPROCESS NT_KPROCESS
KPROCESS Brief structure.
PsGetProcessImageFileName
UCHAR * PsGetProcessImageFileName(IN PEPROCESS Process)
CR_FIXED
union _CR_FIXED CR_FIXED
CommonCpuidInstruction
VOID CommonCpuidInstruction(UINT32 Func, UINT32 SubFunc, INT *CpuInfo)
Get cpuid results.
Definition
Common.c:85
VIRTUAL_MACHINE_STATE
struct _VIRTUAL_MACHINE_STATE VIRTUAL_MACHINE_STATE
The status of each core after and before VMX.
_CPUID
CPUID Registers.
Definition
Common.h:84
_CPUID::eax
INT eax
Definition
Common.h:85
_CPUID::ebx
INT ebx
Definition
Common.h:86
_CPUID::edx
INT edx
Definition
Common.h:88
_CPUID::ecx
INT ecx
Definition
Common.h:87
_NT_KPROCESS
KPROCESS Brief structure.
Definition
Common.h:113
_NT_KPROCESS::DirectoryTableBase
ULONG_PTR DirectoryTableBase
Definition
Common.h:116
_NT_KPROCESS::Data
UCHAR Data[1]
Definition
Common.h:117
_NT_KPROCESS::Header
DISPATCHER_HEADER Header
Definition
Common.h:114
_NT_KPROCESS::ProfileListHead
LIST_ENTRY ProfileListHead
Definition
Common.h:115
_CR_FIXED
Definition
Common.h:92
_CR_FIXED::Flags
UINT64 Flags
Definition
Common.h:93
_CR_FIXED::Low
ULONG Low
Definition
Common.h:97
_CR_FIXED::High
LONG High
Definition
Common.h:98
_CR_FIXED::Fields
struct _CR_FIXED::@007200302366232112033323335144251163245112120214 Fields
hyperdbg
hyperhv
header
common
Common.h
Generated by
1.17.0