Skip to content

Commit 0ea10e8

Browse files
committed
add: dynamic lookup information
1 parent 6d652ee commit 0ea10e8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

hookf.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ __attribute__((constructor)) static void initialize() {
4040
}
4141
```
4242
43+
If we are not able to directly link with the binary, we can dynamically look up the symbol. Logos has syntax for doing this:
44+
```objc
45+
%hookf(CGFontRef, CGFontCreateWithFontName, CFStringRef name) {
46+
// code
47+
return %orig;
48+
}
49+
50+
%ctor {
51+
%init(CGFontCreateWithFontName=dlsym(RTLD_DEFAULT, "CGFontCreateWithFontName"));
52+
}
53+
```
54+
For non-exported symbols, we can use `MSFindSymbol` instead of `dlsym`. Do note that we will need an extra `_` at the beginning of the symbol if we're using `MSFindSymbol`.
55+
4356
For further information about `%hookf`, please go [here](https://theos.dev/docs/logos-syntax).
4457

4558
[Previous Page (Old ABI)](./oldabi.md)

0 commit comments

Comments
 (0)