It works, thank you!
#include <mach/mach.h>
#include <mach/mach_vm.h>
int safe_memcpy(void* dst, const void* src, size_t size) {
mach_vm_size_t outSize = 0;
kern_return_t err = mach_vm_read_overwrite(mach_task_self(), (mach_vm_address_t)src, size, (mach_vm_address_t)dst, &outSize);
if (err) return err;
assert(outSize == size);
return true;
}
void dumpByte(const char* address) {
unsigned char buffer = 0;
int err = safe_memcpy(&buffer, address, 1);
printf("error: %d, byte: %02x\n", err, buffer);
}
Note that this is a relatively slow call, so it’d be best to tweak your dumpByte abstraction to return a block of bytes.
yep, got you.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: