Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/byakugan/heapStructs.h
Views: 11766
#define ALLOCATESTRUCT 0x01#define REALLOCATESTRUCT 0x12#define FREESTRUCT 0x23#define CREATESTRUCT 0x34#define DESTROYSTRUCT 0x45#define COALESCESTRUCT 0x567#define SPACEBETWEEN 0x1889#define CHUNK(x) (heap->chunks[x])1011#define NEXTADDR(x) (PVOID)(*((ULONG *)(&(CHUNK(i).addr))) + CHUNK(i).size + SPACEBETWEEN)1213#define NULLNODE 0xffffffff1415#define MODEL 116#define LOG 217#define RUNNING 41819// Space between chunks on vista2021// Dont use a direct access list here because looping should22// be faster for our number of heaps (I think!)23struct HeapState {24BYTE state;25ULONG numHeaps;26ULONG hPoolListLen;27HANDLE hLogFile;28struct HPool *heaps;2930};3132struct HPool {33PVOID base;34ULONG numChunks;35ULONG chunkListLen;36ULONG flags;37ULONG reserve;38ULONG commit;39BOOLEAN lock;40ULONG *map;41struct HeapChunk *chunks;42ULONG inUseHead;43ULONG lastInUse;44BOOLEAN inUse;45};4647struct LookAsideList {48DWORD placeHolder;49};5051struct HeapCache {52ULONG NumBuckets;53unsigned __int8 *pBitmap;54ULONG **pBuckets;55};5657struct HeapChunk {58PVOID addr;59PVOID heapHandle;60ULONG size;61ULONG flags;62ULONG nextBucket;63ULONG nextInUse;64ULONG nextFreeListChunk;65BOOLEAN free;66BOOLEAN inUse;67};6869struct AllocateStruct {70BYTE type;71PVOID heapHandle;72ULONG flags;73ULONG size;74PVOID ret;75PVOID caller;76};7778struct ReallocateStruct {79BYTE type;80PVOID heapHandle;81ULONG flags;82PVOID memoryPointer;83ULONG size;84PVOID ret;85PVOID caller;86};8788struct FreeStruct {89BYTE type;90PVOID heapHandle;91ULONG flags;92PVOID memoryPointer;93PVOID ret;94PVOID caller;95};9697struct CreateStruct {98BYTE type;99ULONG flags;100PVOID base;101ULONG reserve;102ULONG commit;103BOOLEAN lock;104PVOID RtlHeapParams; // Wont get this info back now - maybe later105PVOID ret; // if we think we really need it?106107};108109struct DestroyStruct {110BYTE type;111PVOID heapHandle;112NTSTATUS ret;113};114115struct CoalesceStruct {116BYTE type;117PVOID heapHandle;118ULONG arg2;119ULONG arg3;120ULONG arg4;121PVOID ret;122};123124void initializeHeapModel(struct HeapState *);125void heapAllocate(struct HeapState *heapModel, struct AllocateStruct *aStruct);126void logAllocate(struct HeapState *heapModel, struct AllocateStruct *aStruct);127128void heapReallocate(struct HeapState *heapModel, struct ReallocateStruct *aStruct);129void logReallocate(struct HeapState *heapModel, struct ReallocateStruct *aStruct);130131void heapFree(struct HeapState *heapModel, struct FreeStruct *fStruct);132void logFree(struct HeapState *heapModel, struct FreeStruct *fStruct);133134void heapCreate(struct HeapState *heapModel, struct CreateStruct *cStruct);135void heapDestroy(struct HeapState *heapModel, struct DestroyStruct *dStruct);136void heapCoalesce(struct HeapState *heapModel, struct CoalesceStruct *cfbStruct);137struct HPool *getHeap(struct HeapState *heapModel, PVOID heapHandle);138struct HeapChunk *getChunk(struct HPool *heap, PVOID memoryPointer, ULONG inAfter);139int FindOffsetForChunk(struct HPool *heap, PVOID memoryPointer); //quickly match a (heap, chunkAddress) into an offset in heap.chunks140141142143