HyperDbg/hyperdbg/hyperkd/code/debugger/memory/Allocations.c
Max Raulea 95389e46df A lot of platform function swaps and left hyperevade out of the build
Created a lot of new platform wrappers for windows only functions
also removed hyperevade from the linux module build and added a empty
stub for the transparent functions they provide which can be filled in
later.
2026-08-23 14:18:12 +02:00

95 lines
1.8 KiB
C

/**
* @file Allocations.c
* @author Behrooz Abbassi (BehroozAbbassi@hyperdbg.org)
* @author Sina Karvandi (sina@hyperdbg.org)
* @brief Management of global variables memory relating to debugger
* @details
* @version 0.2
* @date 2023-01-17
*
* @copyright This project is released under the GNU Public License v3.
*
*/
#include "pch.h"
/**
* @brief Allocate debugging state memory
*
* @return BOOLEAN
*/
BOOLEAN
GlobalDebuggingStateAllocateZeroedMemory(VOID)
{
SSIZE_T BufferSizeInByte = sizeof(PROCESSOR_DEBUGGING_STATE) * PlatformCpuGetActiveProcessorCount();
//
// Allocate global variable to hold Debugging(s) state
//
g_DbgState = PlatformMemAllocateZeroedNonPagedPool(BufferSizeInByte);
if (!g_DbgState)
{
//
// we use DbgPrint as the vmx-root or non-root is not initialized
//
LogInfo("err, insufficient memory for allocating debugging state\n");
return FALSE;
}
return TRUE;
}
/**
* @brief Free debugging state memory
*
* @return VOID
*/
VOID
GlobalDebuggingStateFreeMemory(VOID)
{
PlatformMemFreePool(g_DbgState);
g_DbgState = NULL;
}
/**
* @brief Allocate event store memory
*
* @return BOOLEAN
*/
BOOLEAN
GlobalEventsAllocateZeroedMemory(VOID)
{
//
// Allocate buffer for saving events
//
if (!g_Events)
{
g_Events = PlatformMemAllocateNonPagedPool(sizeof(DEBUGGER_CORE_EVENTS));
}
if (g_Events)
{
//
// Zero the buffer
//
RtlZeroBytes(g_Events, sizeof(DEBUGGER_CORE_EVENTS));
}
return g_Events != NULL;
}
/**
* @brief Free event store memory
*
* @return VOID
*/
VOID
GlobalEventsFreeMemory(VOID)
{
if (g_Events != NULL)
{
PlatformMemFreePool(g_Events);
g_Events = NULL;
}
}