This file defines heap memory management functions of PwnOS.
| HeapMemory.asm | This file defines heap memory management functions of PwnOS. |
| Functions | |
| InitializeHeapMemory | This procedure allocates the heap memory, and initializes the header and first free range node. |
| AllocateAlignedMemory | This procedure allocates a range of memory on the heap, aligned to a multiple of a power of 2 bytes. |
| AllocateMemory | This procedure allocates a range of memory on the heap. |
| FreeMemory | This procedure frees a range of memory that is allocated on the heap. |
| AddHeapMemoryAddressNode | This procedure adds a node to the address tree. |
| AddHeapMemoryFreeNode | This procedure adds a node to the free tree. |
| RemoveHeapMemoryFreeNode | This procedure removes a node from the free tree. |
| RemoveHeapMemoryAddressNode | This procedure removes a node from the address tree. |
| RebalanceHeapMemoryFreeNode | This procedure rebalances from a node in the free tree. |
| RebalanceHeapMemoryAddressNode | This procedure rebalances from a node in the address tree. |
| Gateway Functions of HeapMemory.asm | |
| Functions | |
| AllocateMemoryU | Gateway function for AllocateMemory |
| AllocateAlignedMemoryU | Gateway function for AllocateAlignedMemory |
| FreeMemoryU | Gateway function for FreeMemory |
This procedure allocates the heap memory, and initializes the header and first free range node.
This is intended to only be called by CreateProcess
| nPages | number of pages for heap and its trees |
| pHeap | address of the heap memory header |
This procedure allocates a range of memory on the heap, aligned to a multiple of a power of 2 bytes.
TODO: Still need to adjust size of last free range due to change in size of Address Tree TODO: Check for best fit instead of doing the faster option of rounding up size to multiple of alignment.
| nBytes | number of bytes to allocate |
| Alignment | minimum required power of 2 bytes to which the memory range must be aligned |
| pHeap | address of the heap memory header |
This procedure allocates a range of memory on the heap.
TODO: Still need to adjust size of last free range due to change in size of Address Tree
| nBytes | number of bytes to allocate |
| pHeap | address of the heap memory header |
This procedure frees a range of memory that is allocated on the heap.
TODO: Still need to adjust size of last free range due to change in size of Address Tree
| Address | address of memory range on the heap |
| pHeap | address of the heap memory header |
This procedure adds a node to the address tree.
| edx | address of the node to add (not the address it represents) |
| eax | address of the node in the tree at which to start the search for placement |
| ebx | address of heap memory header |
This procedure adds a node to the free tree.
| edx | address of the node to add (not the address it represents) |
| eax | address of the node in the tree at which to start the search for placement |
| ebx | address of heap memory header |
This procedure removes a node from the free tree.
| edx | address of the node to remove (not the address it represents) |
| ebx | address of heap memory header |
This procedure removes a node from the address tree.
| edx | address of the node to remove (not the address it represents) |
| ebx | address of heap memory header |
This procedure rebalances from a node in the free tree.
| edx | address of the node at which to start rebalancing (not the address it represents) |
| ebx | address of heap memory header |
| eax | address of the node that is now in the position of the given node |
This procedure rebalances from a node in the address tree.
| edx | address of the node at which to start rebalancing (not the address it represents) |
| ebx | address of heap memory header |
| eax | address of the node that is now in the position of the given node |
| Functions | |
| AllocateMemoryU | Gateway function for AllocateMemory |
| AllocateAlignedMemoryU | Gateway function for AllocateAlignedMemory |
| FreeMemoryU | Gateway function for FreeMemory |
Gateway function for AllocateMemory
TODO: Check parameter.
Gateway function for AllocateAlignedMemory
TODO: Check parameters.
Gateway function for FreeMemory
TODO: Check parameter.