Hooking doesn't work on UPX packed EXE files

The place for all discussion of the Oculus Rift compatible open source 3D drivers.
Post Reply
2EyeGuy
Certif-Eyable!
Posts: 1139
Joined: Tue Sep 18, 2012 10:32 pm

Hooking doesn't work on UPX packed EXE files

Post by 2EyeGuy »

I made a new class and was trying to make Perception work in another game, (any shareware one by TLK), and for some reason my code was never getting called, even though the Hijack reported success. I worked out the game is packed with UPX (it's a trial version so they want to protect it from hacking), which seems to be why the hooking wasn't working.

So I think some games won't be compatible, or if we want them to be compatible, we would need to use a different kind of hooking in those cases.
User avatar
cybereality
3D Angel Eyes (Moderator)
Posts: 11407
Joined: Sat Apr 12, 2008 8:18 pm

Re: Hooking doesn't work on UPX packed EXE files

Post by cybereality »

There are actually 3 different methods being used to hook/proxy DirectX.

1) The HijackDLL method, which uses SetWindowsHookEx to inject itself into a game exe (provided it has a profile listed in the XML) and then attaches to IDirect3D9::CreateDevice to inset the proxy version of DirectX.

2) If that fails, it will then use the same HijackDLL method to hook into the system32's LoadLibrary calls, and checks if the game is trying to load something call "d3d9.dll" and then actually loads the proxy dll from the Perception folder.

3) Lastly, is both of those fail it will use the Windows function SetDllDirectory to point to the Perception bin folder (so it will get loaded before the real d3d9.dll).

4) If all else fails you can try copying "d3d9.dll" to the game's directory (either next to the exe or in the game bin/binaries folder).

Some methods work on some games, and not on others. I believe Source engine titles are using the #3 method, and the other games using #1.

In theory, the #1 and #2 methods should cover everything (it did with my little test D3D apps, a spinning box) but real games seem to sometime do different things, so I'm not sure.

Also, I don't know much about UPX packed EXEs, so I'm not sure I can help there. But maybe my explanation will shed some light. However I somewhat doubt that is the issue. It looks to be more of a packing format, not so much protection. Anyway, the hook is within Windows, the driver does not really mess with the exe or the game memory much at all.
geekmaster
Petrif-Eyed
Posts: 2708
Joined: Sat Sep 01, 2012 10:47 pm

Re: Hooking doesn't work on UPX packed EXE files

Post by geekmaster »

You can use upx.exe to unpack them.
Post Reply

Return to “Development / General Discussion”