diff options
author | Itamar <itamar8910@gmail.com> | 2020-04-05 22:58:44 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-13 00:53:22 +0200 |
commit | b306ac9b2be2692192a5dba9ea974a5cb41e7df4 (patch) | |
tree | 6308b8754cf3e28f84437d48e0bdf07cc3c5368e /Applications/Debugger/main.cpp | |
parent | 924fda19b0616a28e49ab28e99c4dea8a11bc758 (diff) | |
download | serenity-b306ac9b2be2692192a5dba9ea974a5cb41e7df4.zip |
ptrace: Add PT_POKE
PT_POKE writes a single word to the tracee's address space.
Some caveats:
- If the user requests to write to an address in a read-only region, we
temporarily change the page's protections to allow it.
- If the user requests to write to a region that's backed by a
SharedInodeVMObject, we replace the vmobject with a PrivateIndoeVMObject.
Diffstat (limited to 'Applications/Debugger/main.cpp')
-rw-r--r-- | Applications/Debugger/main.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Applications/Debugger/main.cpp b/Applications/Debugger/main.cpp index 9d9b341ba5..59d78719b0 100644 --- a/Applications/Debugger/main.cpp +++ b/Applications/Debugger/main.cpp @@ -122,6 +122,8 @@ VirtualAddress get_entry_point(int pid) int main(int argc, char** argv) { + // TODO: pledge & unveil + // TOOD: check that we didn't somehow hurt performance. boot seems slower? (or it's just laptop battey) if (argc == 1) return usage(); @@ -157,7 +159,12 @@ int main(int argc, char** argv) printf("eip:0x%x\n", regs.eip); uint32_t data = ptrace(PT_PEEK, g_pid, (void*)regs.eip, 0); - printf("data: 0x%x\n", data); + printf("peeked data: 0x%x\n", data); + + if (ptrace(PT_POKE, g_pid, (void*)regs.eip, data) < 0) { + perror("poke"); + return 1; + } if (ptrace(PT_CONTINUE, g_pid, 0, 0) == -1) { perror("continue"); |