HyperDbg Debugger
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
77typedef SEGMENT_DESCRIPTOR_32 * PSEGMENT_DESCRIPTOR;
78
90
91typedef union _CR_FIXED
92{
93 UINT64 Flags;
94
95 struct
96 {
99
101
103
105// Windows-specific structures //
107
112typedef struct _NT_KPROCESS
113{
114 DISPATCHER_HEADER Header;
115 LIST_ENTRY ProfileListHead;
119
121// Function Types //
123
128typedef VOID (*RunOnLogicalCoreFunc)(ULONG ProcessorId);
129
131// External Functions //
133
134UCHAR *
135PsGetProcessImageFileName(IN PEPROCESS Process);
136
138// Function Definitions //
140
141// ----------------------------------------------------------------------------
142// Private Interfaces
143//
144
145static NTSTATUS
146CommonGetHandleFromProcess(_In_ UINT32 ProcessId, _Out_ PHANDLE Handle);
147
148// ----------------------------------------------------------------------------
149// Public Interfaces
150//
151
154
156CommonIsStringStartsWith(const CHAR * pre, const CHAR * str);
157
160
161PCHAR
163
164VOID
165CommonCpuidInstruction(UINT32 Func, UINT32 SubFunc, INT * CpuInfo);
166
167VOID
169
171CommonIsXCr0Valid(XCR0 XCr0);
UCHAR BOOLEAN
Definition BasicTypes.h:35
long LONG
Definition BasicTypes.h:28
int INT
Definition BasicTypes.h:43
unsigned char UCHAR
Definition BasicTypes.h:34
unsigned int UINT32
Definition BasicTypes.h:54
char CHAR
Definition BasicTypes.h:33
unsigned long ULONG
Definition BasicTypes.h:31
BOOLEAN CommonIsGuestOnUsermode32Bit()
determines if the guest was in 32-bit user-mode or 64-bit (long mode)
Definition Common.c:97
struct _CPUID CPUID
CPUID Registers.
VOID(* RunOnLogicalCoreFunc)(ULONG ProcessorId)
Prototype to run a function on a logical core.
Definition Common.h:128
BOOLEAN CommonIsXCr0Valid(XCR0 XCr0)
Check correctness of the XCR0 register value.
Definition Common.c:202
union _CR_FIXED * PCR_FIXED
SEGMENT_DESCRIPTOR_32 * PSEGMENT_DESCRIPTOR
Definition Common.h:77
struct _NT_KPROCESS * PNT_KPROCESS
struct _CPUID * PCPUID
PCHAR CommonGetProcessNameFromProcessControlBlock(PEPROCESS eprocess)
Get process name by eprocess.
Definition Common.c:48
VOID CommonWriteDebugInformation(VIRTUAL_MACHINE_STATE *VCpu)
Produce debug information from unrecoverable bugs.
Definition Common.c:149
BOOLEAN CommonIsStringStartsWith(const CHAR *pre, const CHAR *str)
Detects whether the string starts with another string.
Definition Common.c:69
BOOLEAN CommonAffinityBroadcastToProcessors(_In_ ULONG ProcessorNumber, _In_ RunOnLogicalCoreFunc Routine)
struct _NT_KPROCESS NT_KPROCESS
KPROCESS Brief structure.
UCHAR * PsGetProcessImageFileName(IN PEPROCESS Process)
union _CR_FIXED CR_FIXED
VOID CommonCpuidInstruction(UINT32 Func, UINT32 SubFunc, INT *CpuInfo)
Get cpuid results.
Definition Common.c:85
struct _VIRTUAL_MACHINE_STATE VIRTUAL_MACHINE_STATE
The status of each core after and before VMX.
CPUID Registers.
Definition Common.h:84
INT eax
Definition Common.h:85
INT ebx
Definition Common.h:86
INT edx
Definition Common.h:88
INT ecx
Definition Common.h:87
KPROCESS Brief structure.
Definition Common.h:113
ULONG_PTR DirectoryTableBase
Definition Common.h:116
UCHAR Data[1]
Definition Common.h:117
DISPATCHER_HEADER Header
Definition Common.h:114
LIST_ENTRY ProfileListHead
Definition Common.h:115
Definition Common.h:92
UINT64 Flags
Definition Common.h:93
ULONG Low
Definition Common.h:97
LONG High
Definition Common.h:98
struct _CR_FIXED::@007200302366232112033323335144251163245112120214 Fields