I'm trying to use mprotect API on MacOSX 10.4 (tiger), I tried every possible way i know , it always returns -1, with errno 13, which means "permission denied" while I'm trying to add the write permission to some executable code.
The same code exactly works on MacOS X 10.5 (leopard).
the code is pretty simple
int ret = mprotect((void*)pFunc, 4096, PROT_WRITE | PROT_EXEC);
where pFunc is the address of any function loaded in the process address space. I tried to remove the PROT_EXEC before adding the PROT_WRITE access right, but no luck. I also tried aligning pFunc with the memory page size, no luck neither..
Any idea how to make this working? thanks alot in advance