yifanlu / taiHEN

CFW framework for PS Vita
MIT License
302 stars 46 forks source link

Implement hooking of shared modules #6

Open yifanlu opened 7 years ago

yifanlu commented 7 years ago

Right now you cannot hook anything in the >= 0xE0000000 region because the pages mapped there are shared between processes. It increases the complexity as we would have to map the trampoline pages to all processes that use a specific module. Right now, I believe that most plugins would not need to hook any shared modules (they can make do with hooking imports from the main module). If we want to support this going forward, it would make sense to hook modulemgr to always allocate 1-2 additional pages at the end of the .text segment for any shared module. That would serve as the trampoline for the hooks as well as metadata for hooks.

CelesteBlue-dev commented 6 years ago

Maybe that's a crazy question but when you say "shared modules" you mean shared between what and what ? Also does this limit also applies to taiHookModuleExportForKernel() ? Thanks for the clarification.

yifanlu commented 6 years ago

Between processes. Like SceLibKernel is used in every process.

devnoname120 commented 6 years ago

Currently, hooking an export from a shared module returns TAI_ERROR_NOT_FOUND which is not explicit enough in my opinion. I suggest that a special error code be added, for instance TAI_ERROR_SHARED_MODULE, with a comment linking to this issue.

yifanlu commented 6 years ago

No that's another issue. You can hook shared modules but it might crash another app.

devnoname120 commented 6 years ago

I see. Unfortunately I don't have the code to reproduce this anymore.

It would be great if it failed and returned an error, rather than returning a valid hook and then crashing other apps.

yifanlu commented 6 years ago

Yeah see if I could easily detect when it's a shared module then I would just hook it differently and resolve this ticket...