Made it work on Windows by using VirtualAlloc and VirtualFree.