Warnings and memory allocation fixes

This commit is contained in:
Benjamin Höglinger-Stelzer 2023-07-03 01:54:12 +02:00
parent 1e7e4007de
commit 7fc654769e
2 changed files with 21 additions and 7 deletions

View File

@ -288,7 +288,13 @@ DomitoCalculatePortableExecutableDigest(
// TODO: Not sure if 16 * 512 * 512 is right. Do something better! // TODO: Not sure if 16 * 512 * 512 is right. Do something better!
// //
ULONG copySize = phDos->e_lfanew + sizeof(IMAGE_FILE_HEADER) + 4 + 0x40; ULONG copySize = phDos->e_lfanew + sizeof(IMAGE_FILE_HEADER) + 4 + 0x40;
const PUCHAR pBuf = (PUCHAR)G_Memory.Allocate(16 * 512 * 512); #pragma warning(disable:4996)
const PUCHAR pBuf = (PUCHAR)ExAllocatePoolWithTag(
NonPagedPool,
16 * 512 * 512,
DOMITO_POOL_TAG
);
#pragma warning(default:4996)
if (!pBuf) if (!pBuf)
{ {
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
@ -344,7 +350,9 @@ DomitoCalculatePortableExecutableDigest(
// //
// Allocate a buffer to store the resulting hash // Allocate a buffer to store the resulting hash
// //
pHash = (PUCHAR)G_Memory.Allocate(hashLength); #pragma warning(disable:4996)
pHash = (PUCHAR)ExAllocatePoolWithTag(NonPagedPool, hashLength, DOMITO_POOL_TAG);
#pragma warning(default:4996)
if (!pHash) if (!pHash)
{ {
status = STATUS_INSUFFICIENT_RESOURCES; status = STATUS_INSUFFICIENT_RESOURCES;
@ -495,7 +503,7 @@ DomitoCalculatePortableExecutableDigest(
cleanup: cleanup:
if (pBuf) if (pBuf)
{ {
G_Memory.Free(pBuf); ExFreePoolWithTag(pBuf, DOMITO_POOL_TAG);
} }
if (hbHash) if (hbHash)
@ -555,7 +563,13 @@ DomitoValidateFileLegacyMode(
if (SecurityDirectory->Size != 0u && if (SecurityDirectory->Size != 0u &&
SecurityDirectory->VirtualAddress != 0u) SecurityDirectory->VirtualAddress != 0u)
{ {
certDirectory = G_Memory.Allocate(SecurityDirectory->Size); #pragma warning(disable:4996)
certDirectory = ExAllocatePoolWithTag(
PagedPool,
SecurityDirectory->Size,
DOMITO_POOL_TAG
);
#pragma warning(default:4996)
if (certDirectory == NULL) if (certDirectory == NULL)
{ {
status = STATUS_INSUFFICIENT_RESOURCES; status = STATUS_INSUFFICIENT_RESOURCES;
@ -659,7 +673,7 @@ DomitoValidateFileLegacyMode(
if (certDirectory) if (certDirectory)
{ {
G_Memory.Free(certDirectory); ExFreePoolWithTag(certDirectory, DOMITO_POOL_TAG);
} }
return status; return status;

View File

@ -11,13 +11,13 @@
static PVOID NTAPI DomitoDefaultMalloc(size_t s) static PVOID NTAPI DomitoDefaultMalloc(size_t s)
{ {
#pragma warning(disable:4996) #pragma warning(disable:4996)
PVOID mem = ExAllocatePoolWithTag(NonPagedPool, s, DOMITO_POOL_TAG); const PVOID mem = ExAllocatePoolWithTag(PagedPool, s, DOMITO_POOL_TAG);
if (mem) if (mem)
{ {
RtlZeroMemory(mem, s); RtlZeroMemory(mem, s);
} }
return mem; return mem;
#pragma warninf(default:4996) #pragma warning(default:4996)
} }
static void NTAPI DomitoDefaultFree(PVOID p) static void NTAPI DomitoDefaultFree(PVOID p)