In Windows, you can do this using the GlobalAlloc and VirtualAlloc APIs.