Started splitting code into more modular forms
This commit is contained in:
77
src/Domito.Memory.cpp
Normal file
77
src/Domito.Memory.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/* __ __ __ __ _
|
||||
* | \/ |___ _ __ ___ _ _ _ _ | \/ |__ _ _ _ __ _ __ _ ___ _ __ ___ _ _| |_
|
||||
* | |\/| / -_) ' \/ _ \ '_| || | | |\/| / _` | ' \/ _` / _` / -_) ' \/ -_) ' \ _|
|
||||
* |_| |_\___|_|_|_\___/_| \_, | |_| |_\__,_|_||_\__,_\__, \___|_|_|_\___|_||_\__|
|
||||
* |__/ |___/
|
||||
*/
|
||||
|
||||
#include "Domito.Internal.h"
|
||||
|
||||
|
||||
static PVOID NTAPI DomitoDefaultMalloc(size_t s)
|
||||
{
|
||||
#pragma warning(disable:4996)
|
||||
return ExAllocatePoolWithTag(NonPagedPool, s, DOMITO_POOL_TAG);
|
||||
#pragma warninf(default:4996)
|
||||
}
|
||||
|
||||
static void NTAPI DomitoDefaultFree(PVOID p)
|
||||
{
|
||||
ExFreePoolWithTag(p, DOMITO_POOL_TAG);
|
||||
}
|
||||
|
||||
DOMITO_MEMORY G_Memory = {
|
||||
DomitoDefaultMalloc,
|
||||
DomitoDefaultFree
|
||||
};
|
||||
|
||||
void
|
||||
DomitoGetOriginalMemoryFunctions(
|
||||
_Out_opt_ PFN_DOMITO_ALLOCATE_ROUTINE* Allocator,
|
||||
_Out_opt_ PFN_DOMITO_FREE_ROUTINE* Free
|
||||
)
|
||||
{
|
||||
if (Allocator)
|
||||
{
|
||||
*Allocator = DomitoDefaultMalloc;
|
||||
}
|
||||
|
||||
if (Free)
|
||||
{
|
||||
*Free = DomitoDefaultFree;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DomitoGetMemoryFunctions(
|
||||
_Out_opt_ PFN_DOMITO_ALLOCATE_ROUTINE* Allocator,
|
||||
_Out_opt_ PFN_DOMITO_FREE_ROUTINE* Free
|
||||
)
|
||||
{
|
||||
if (Allocator)
|
||||
{
|
||||
*Allocator = G_Memory.Allocate;
|
||||
}
|
||||
|
||||
if (Free)
|
||||
{
|
||||
*Free = G_Memory.Free;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DomitoSetMemoryFunctions(
|
||||
_In_opt_ PFN_DOMITO_ALLOCATE_ROUTINE Allocator,
|
||||
_In_opt_ PFN_DOMITO_FREE_ROUTINE Free
|
||||
)
|
||||
{
|
||||
if (Allocator)
|
||||
{
|
||||
G_Memory.Allocate = Allocator;
|
||||
}
|
||||
|
||||
if (Free)
|
||||
{
|
||||
G_Memory.Free = Free;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user