Skip to content

Commit 89710ae

Browse files
authored
replace dyld lldb hook (#1)
1 parent fcd3ef7 commit 89710ae

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Sources/SimpleDebugger/SimpleDebugger.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#import <mach/mach.h>
1515
#import <libgen.h>
1616
#import <os/log.h>
17+
#import <mach-o/dyld_images.h>
1718

1819
#include "mach_messages.h"
1920

@@ -22,7 +23,15 @@
2223

2324
SimpleDebugger::SimpleDebugger() : exceptionPort(MACH_PORT_NULL) {}
2425

26+
void replace_image_notifier(enum dyld_image_mode mode, uint32_t infoCount, const struct dyld_image_info info[]) { }
27+
2528
bool SimpleDebugger::startDebugging() {
29+
struct task_dyld_info dyld_info;
30+
mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT;
31+
task_info(mach_task_self_, TASK_DYLD_INFO, (task_info_t)&dyld_info, &count);
32+
struct dyld_all_image_infos *infos = (struct dyld_all_image_infos *)dyld_info.all_image_info_addr;
33+
infos->notification = replace_image_notifier;
34+
2635
if (mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &exceptionPort) != KERN_SUCCESS) {
2736
return false;
2837
}

0 commit comments

Comments
 (0)