Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我做了一个例子,使用 task_for_pid() 和 mach_vm_write() 写入进程内存。
task_for_pid(mach_task_self(), pid, &target_task); mach_vm_write(target_task, address, '?', local_size);
如果某些进程将数据写入我的应用程序任务中的指定地址,我如何监控内存的变化?
你不能。使用 mach_vm_write(如在 Windows 中使用 WriteProcessMemory 或在 Linux 中使用 ptrace(2))不会为写入的进程提供通知。您唯一的选择是:
A)在写入任务和受害任务之间使用 IPC 对象 B)在受害任务中生成一个线程来监视该内存区域的变化。这具有连续轮询的明显缺点。虽然更高级的解决方案是在您正在写入的任务中创建一个远程线程(您可以这样做,因为您现在已经获得了任务端口),并让它做一些事情。