How can I ask Mac OS to allocate memory at a specific address?

0

On Linux, you can allocate memory at a specific address like so:

void *foo = (void *)0xDEADBEEF;
size_t MyLength = 1024;
void *bar = mmap(foo, MyLength, PROT_READ | PROT_WRITE | MAP_ANONYMOUS | MAP_FIXED, MAP_PRIVATE, -1, 0);

Is this same method also possible on Mac OS, or if not, how does one do this on Mac OS?

My goal is to write a kernel extension to map out (and thus disable) a region of defective memory on a MacBook Pro with a non-removable defective RAM chip.

macos
memory
asked on Stack Overflow Jun 29, 2020 by Haydentech

1 Answer

1

This is std C. It compiles fine on Xcode. Make sure to add:

#include <sys/mman.h>

Before you invest too much time writing a kernel extension for macOS be aware of its deprecation.

answered on Stack Overflow Jun 29, 2020 by Anubis

User contributions licensed under CC BY-SA 3.0