Last active
May 1, 2021 09:58
-
-
Save jakobrs/a76162f5f1f5f1988b1b359a9beb7661 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
gcc ./dyldfunclookuphelper.c /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/dylib1.o \ | |
-shared -o ./libdyldfunclookuphelper.dylib -target x86_64-apple-macos10.7 | |
# OR (untested) | |
#ld /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/dylib1.o \ | |
# -dylib -o ./libdyldfunclookuphelper.dylib -alias __dyld_func_lookup _dyld_func_lookup_helper | |
g++ ./example.cpp -ldyldfunclookuphelper -L. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int _dyld_func_lookup(const char *name, void **address); | |
int dyld_func_lookup_helper(const char *name, void **address) { | |
return _dyld_func_lookup(name, address); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
extern "C" int dyld_func_lookup_helper(const char *file, void **address); | |
int main() { | |
void *origdlsym; | |
if (!dyld_func_lookup_helper("__dyld_dlsym", &origdlsym)) { | |
printf("dyld_func_lookup_helper failed\n"); | |
} else { | |
printf("origdlsym: %lx", origdlsym); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment