theos/logos

[Feature request] Support for specfiying image name for dynamic lookup of functions in %hookf

Closed this issue · 7 comments

(dd5477a)

Logos should also optimize multiple dynamic lookups with the same image name to increase performance. (e.g. MSGetImageByName should only be called once for two dynamic lookups with the same image name)

The return value of MSGetImageByName/MSFindSymbol should also be compared against NULL before calling MSFindSymbol/MSHookFunction to prevent a possible NULL pointer dereference.

kirb commented

I think @uroboro was considering whether to did remove the dynamic lookup feature of %hookf, to encourage using dlsym()/MSFindSymbol() directly via %init (that bit was implemented in 0eb6602). Which fixes this problem in a different, probably slightly unintuitive way.

Logos should still verify that it isn't passing NULL to MSHookFunction IMO.

I should have probably opened a new issue for that... But is there a way to access the original function (What you get when you call %orig inside the hook) outside of the hook without having to do dirty things like hardcoding the name logos generates for the old function pointer? e.g. hook func1 and call the original func1 inside of func2

See the syntax page on this repository’s wiki on &%orig.

That's not exactly what I asked for -- I need to be able to get the original function pointer without requiring the hooked function to be called, not even for once. Maybe something like %orig(func, args...)

kirb commented

That’s what &%orig is - the & is part of the syntax preprocessed by Logos to signal that you want to get the original function pointer, you aren’t dereferencing the return value of the original function even though it does almost look that way.

Docs: https://github.com/theos/logos/wiki/Syntax#orig-1

I’m closing this as the original issue was solved. Please open a new issue for different problems.