ptos: pool: Add freeing of allocated memory
Signed-off-by: Chloe M <chloe@mensia.org>
This commit is contained in:
@@ -268,6 +268,41 @@ ExAllocatePoolWithTag(POOL_TYPE Type, USIZE ByteCount, ULONG Tag)
|
||||
return Base;
|
||||
}
|
||||
|
||||
VOID
|
||||
ExFreePoolWithTag(VOID *Ptr, ULONG Tag)
|
||||
{
|
||||
POOL_HEADER *Header;
|
||||
POOL_PAGE *Page;
|
||||
USHORT BitOff, BitMax;
|
||||
|
||||
if (Ptr == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Header = PTR_NOFFSET(Ptr, sizeof(POOL_HEADER));
|
||||
if (Header->Tag != Tag) {
|
||||
KeBugCheck(
|
||||
BUGCHECK_MISC,
|
||||
"tag does not match pool header\n"
|
||||
);
|
||||
}
|
||||
|
||||
Page = Header->Page;
|
||||
if (Page == NULL) {
|
||||
KeBugCheck(
|
||||
BUGCHECK_MISC,
|
||||
"attempted free on malformed header\n"
|
||||
);
|
||||
}
|
||||
|
||||
BitMax = Header->SizeBytes / Header->Gran;
|
||||
BitMax *= 8;
|
||||
|
||||
for (BitOff = Header->BitBase; BitOff < BitMax; ++BitOff) {
|
||||
CLRBIT(&Page->Bitmap, BitOff);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
ExPoolRegionInit(POOL_REGION *Region)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user