this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix xtrace when the injected code is at page boundary (#446)

+12 -4
+12 -4
src/xtrace/xtracelib.c
··· 53 53 static void xtrace_setup_mach(void) 54 54 { 55 55 uintptr_t area = (uintptr_t)_darling_mach_syscall_entry; 56 + uintptr_t areaEnd = area + sizeof(struct hook); 56 57 57 58 // __asm__("int3"); 58 59 area &= ~(4096-1); 60 + areaEnd &= ~(4096-1); 59 61 60 - mprotect((void*) area, 4096, PROT_READ | PROT_WRITE | PROT_EXEC); 62 + uintptr_t bytes = 4096 + (areaEnd-area); 63 + 64 + mprotect((void*) area, bytes, PROT_READ | PROT_WRITE | PROT_EXEC); 61 65 62 66 setup_hook(_darling_mach_syscall_entry, darling_mach_syscall_entry_trampoline); 63 67 setup_hook(_darling_mach_syscall_exit, darling_mach_syscall_exit_trampoline); 64 68 65 - mprotect((void*) area, 4096, PROT_READ | PROT_EXEC); 69 + mprotect((void*) area, bytes, PROT_READ | PROT_EXEC); 66 70 } 67 71 68 72 static void xtrace_setup_bsd(void) 69 73 { 70 74 uintptr_t area = (uintptr_t)_darling_bsd_syscall_entry; 75 + uintptr_t areaEnd = area + sizeof(struct hook); 71 76 72 77 // __asm__("int3"); 73 78 area &= ~(4096-1); 79 + areaEnd &= ~(4096-1); 74 80 75 - mprotect((void*) area, 4096, PROT_READ | PROT_WRITE | PROT_EXEC); 81 + uintptr_t bytes = 4096 + (areaEnd-area); 82 + 83 + mprotect((void*) area, bytes, PROT_READ | PROT_WRITE | PROT_EXEC); 76 84 77 85 setup_hook(_darling_bsd_syscall_entry, darling_bsd_syscall_entry_trampoline); 78 86 setup_hook(_darling_bsd_syscall_exit, darling_bsd_syscall_exit_trampoline); 79 87 80 - mprotect((void*) area, 4096, PROT_READ | PROT_EXEC); 88 + mprotect((void*) area, bytes, PROT_READ | PROT_EXEC); 81 89 } 82 90 83 91 void handle_generic_entry(const struct calldef* defs, const char* type, int nr, void* args[])