14 lines
280 B
Plaintext

extern kernel32 {
VirtualAlloc(address int, size uint, flags uint32, protection uint32) -> *any
}
alloc(length int) -> []byte {
x := kernel32.VirtualAlloc(0, length+8, mem.commit|mem.reserve, page.readwrite)
if x < 0x1000 {
return x
}
store(x, 8, length)
return x + 8
}