开发者

Interpose OS X API in a plugin

开发者 https://www.devze.com 2023-04-01 09:50 出处:网络
I have an app that loads a CFPlugin, not a problem, using the Apple boiler plate code. The plugin has a bug - and its someone else\'s binary...

I have an app that loads a CFPlugin, not a problem, using the Apple boiler plate code.

The plugin has a bug - and its someone else's binary...

The plugin makes some calls into an Apple System Framework. If I could intercept the calls that the plugin wants to make to the framework, then all would be well. I don't even need to then call the 'real' vers开发者_JAVA技巧ions. Essentially I want to call my version instead of Apple's CF based routine.

Intercepting calls to a framework call works in my code in my app, but the plugin still calls the 'real' framework call instead of my interception.

I'm not really a dyld expert, but it seems that the plugin, although in the address space of my app, somehow loads its own version of the Apple Framework?

Is there some magic I can do when loading the plugin, etc to have it call my interception code?


1) do DYLD interposing in a separate libFix.dylib as described in Amit's book: http://osxbook.com (involving __interpose DATA section)

2) use DYLD_INSERT_LIBRARIES=/path/to/libFix.dylib prior launching your app

this guy's comment may also help: http://www.mikeash.com/pyblog/friday-qa-2009-01-30-code-injection.html#comment-3fb6e4b8cf65ec984e7836e2b86a2875

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号