steven-michaud / HookCase

Tool for reverse engineering macOS/OS X

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When setting a patch hook in an executable, it must be invoked using a full path

steven-michaud opened this issue · comments

This issue is spun off from #10 (comment).

Working on issue #10, I discovered that, when setting a patch hook in an executable, HC_INSERT_LIBRARY won't work properly unless the executable is invoked using a full path. For example:

    HC_INSERT_LIBRARY=/full/path/to/hook.dylib /full/path/to/executable

When the executable is invoked using a relative path (for example ./executable), HookCase displays (in the Console app) the misleading error message 'Module "/full/path/to/executable" not (yet) present/loaded in process".

HC_INSERT_LIBRARY does need to be a full path. But it shouldn't be necessary also to specify one for the executable.

I have a fix for this, which I'll land shortly.

I was already canonicalizing paths passed in by the user. But now I've added code to canonicalize the paths in the all_image_info structure -- an array of all the modules loaded into a given task. Most of them are (I think) already canonicalized, but the executable's path is exactly what the user specified when invoking it, and this is often a relative path.