HyperDbg Debugger
Loading...
Searching...
No Matches
PerfApi.c File Reference

PMU routines for HyperPerf module. More...

#include "pch.h"

Functions

BOOLEAN HyperPerfInitCallback (HYPERPERF_CALLBACKS *HyperPerfCallbacks, BOOLEAN RunningOnHypervisorEnvironment)
 Initialize the hyperperf module callbacks.
VOID HyperPerfUninit ()
 Uninitialize the hypertrace module.

Detailed Description

PMU routines for HyperPerf module.

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.21
Date
2026-06-22

Function Documentation

◆ HyperPerfInitCallback()

BOOLEAN HyperPerfInitCallback ( HYPERPERF_CALLBACKS * HyperPerfCallbacks,
BOOLEAN RunningOnHypervisorEnvironment )

Initialize the hyperperf module callbacks.

This only for callback initialization, not for PMU, etc. initialization

Parameters
HyperPerfCallbacksPointer to the HyperPerf callbacks structure to be registered
RunningOnHypervisorEnvironmentWhether the initialization is being done for hypervisor environment or not, it can be used to skip some of the initialization steps if it is not for hypervisor environment and behave differently based on that
Returns
BOOLEAN
26{
27 //
28 // Check if any of the required callbacks are NULL
29 //
30 for (UINT32 i = 0; i < sizeof(HYPERPERF_CALLBACKS) / sizeof(UINT64); i++)
31 {
32 if (((PVOID *)HyperPerfCallbacks)[i] == NULL)
33 {
34 //
35 // The callback has null entry, so we cannot proceed
36 //
37 return FALSE;
38 }
39 }
40
41 //
42 // Save the callbacks
43 //
44 PlatformWriteMemory(&g_Callbacks, HyperPerfCallbacks, sizeof(HYPERPERF_CALLBACKS));
45
46 //
47 // Set the flag to indicate whether the initialization is being done for hypervisor environment or not
48 //
49 g_RunningOnHypervisorEnvironment = RunningOnHypervisorEnvironment;
50
51 //
52 // Enable callbacks and set the initialized flag
53 //
55
56 return TRUE;
57}
VOID PlatformWriteMemory(PVOID Address, PVOID Buffer, SIZE_T Size)
Writes data from a buffer to a memory address.
Definition PlatformMem.c:115
void * PVOID
Definition BasicTypes.h:56
#define TRUE
Definition BasicTypes.h:114
#define FALSE
Definition BasicTypes.h:113
unsigned int UINT32
Definition BasicTypes.h:54
struct _HYPERPERF_CALLBACKS HYPERPERF_CALLBACKS
Prototype of each function needed by hyperperf module.
HYPEREVADE_CALLBACKS g_Callbacks
List of callbacks.
Definition Transparency.h:23
BOOLEAN g_RunningOnHypervisorEnvironment
The flag indicating whether the initialization is being done for hypervisor environment or not.
Definition GlobalVariables.h:35
BOOLEAN g_HyperPerfCallbacksInitialized
The flag indicating whether the hyperperf module callbacks is initialized or not.
Definition GlobalVariables.h:29

◆ HyperPerfUninit()

VOID HyperPerfUninit ( )

Uninitialize the hypertrace module.

Returns
VOID
66{
67 //
68 // Check if the callbacks are initialized, if not, we don't need to handle anymore
69 //
71 {
72 return;
73 }
74
75 //
76 // Reset the environment flag to default value
77 //
79
80 //
81 // Set callbacks to not initialized
82 //
84}