G:/system files/ring0/kernel32/memorymap.asm
Code: Select all
label MemMapStart at 0x00000500
BootDevice db 0
SectorCount db 0
HeadCount db 0
CylinderCount dw 0
DriveCount db 0
MemorySize dd 0
MemoryAllocationTable:
AllocatedMemory dw 0
FreeMemory dw 0
TotalAllocatedEntries dw 0
TotalFreeEntries dw 0
;an alloc table entry is 8 bytes, 3 words and 2 bytes
;dw address start
;dw address end
;dw allocated bytes
;db system reserved
;db allocated flag (0 if unallocated, 1 if allocated)
times 2048 dq 0 ;dq = 8bytes, 8x2048=16384=16kb of Ram.
label MemMapEnd at 0x00001500
I know there could be problems with memory allocation being fragmented, for example:
[memory total=64bytes max-entries=8]
entry 1 allocated 9
entry 2 allocated 10+9 = 19
entry 3 unallocated 27+19=46
entry 4 allocated 1+46=47
entry 5 unallocated 1+47=48
entry 6 allocated 1+48=49
entry 7 allocated 1+49=50
entry 8 unallocated 14+50=64
if you wanted to allocate the remaining 32bytes, the allocations would have to be reorganized, except a program can't be notified easily in this system if it's allocations change. Any ideas or information pertaining to memory management techniques and models with this much detail would be much appreciated, thanks in advance.
EDIT: I forgot to mention that my allocation idea also reclaims memory if entries become filled up, and notify apps that they should do something about it. This is for in the event of (very unlikely) a virus gaining control (doubtedly but not unforeseen), so if a virus program was run successfully (like a trojan) and it tried to allocate all available memory, the system takes priority, so if memory is over allocated it will reclaim massive memory blocks that aren't already allocated by system components and notify the owner app to close. I want security in my memory management, so any advice, tips and ideas on this will help too thanks.