Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in %hookf #67

Open
dom-lgtm opened this issue Aug 27, 2020 · 4 comments
Open

Regression in %hookf #67

dom-lgtm opened this issue Aug 27, 2020 · 4 comments

Comments

@dom-lgtm
Copy link

What are the steps to reproduce this issue?

Create a Tweak with the following code:

%hookf(void, "afunction"){
}

What happens?

MSHookFunction((void *)_logos_symbol$_ungrouped$"afunction", (void *)&_logos_function$_ungrouped$"afunction", (void **)&_logos_orig$_ungrouped$"afunction");

This obviously doesn't compile.

What were you expecting to happen?

MSHookFunction((void *)MSFindSymbol(NULL, "afunction"), (void *)&_logos_function$_ungrouped$lookup$afunction, (void **)&_logos_orig$_ungrouped$lookup$afunction);

Any logs, error output, etc?

Compilation errors due to missing MSFindSymbol and unwanted quotes.

Any other comments?

It worked perfectly until I updated theos.

What versions of software are you using?

Latest git master.

@dom-lgtm dom-lgtm changed the title Regression in %hoof Regression in %hookf Aug 27, 2020
@kirb kirb transferred this issue from theos/theos Aug 27, 2020
@kirb
Copy link
Member

kirb commented Aug 27, 2020

This is by design. It’s not recommended to use MSFindSymbol() or dlsym() with NULL passed as the image argument, as looking up a symbol across the entire set of images loaded in the processes is slow. Unfortunately the initial design of %hookf encouraged this. Instead, define it yourself by passing the pointer into %init:

%hookf(void, afunction) {
  //
}

%ctor {
  void *myLib = dlopen("/System/Library/PrivateFrameworks/Awesome.framework/Awesome", RTLD_NOLOAD);
  void *myFunc = dlsym(myLib, "afunction");
  %init(afunction = myFunc);
}

@NSExceptional
Copy link
Contributor

@kirb I actually got the OK from @uroboro to revert this regression when I have time

@dom-lgtm
Copy link
Author

Thanks @NSExceptional .

What about adding an optional:

%hooklib "/System/Library/PrivateFrameworks/Awesome.framework/Awesome"
%hookf ....
%end

Best of both world?

@kirb I write most of my tweaks without logos, but I love to have logos when I need to do a quick and dirty proof of concept or a throw away analysis tweak. Having to write the constructor defeats the purpose of %hookf as I may as well call MSHookFunction by hand at this point.

@uroboro
Copy link
Member

uroboro commented Aug 28, 2020

An idea that floated around when I originally introduced this feature was to specify the library along with the function name:

%hookf(void, "/System/Library/PrivateFrameworks/Awesome.framework/Awesome:aFunction") {
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants