Getting a hook into the HL2 Client.dll

The place for all discussion of the Oculus Rift compatible open source 3D drivers.
Post Reply
lukesmith
One Eyed Hopeful
Posts: 4
Joined: Thu Apr 11, 2013 2:17 pm

Getting a hook into the HL2 Client.dll

Post by lukesmith »

Hi guys,

I had the idea that if I could get a hook into the source sdk Client.dll for a source game I could update the view (for the roll) on the engine side to fix the issues that are created with shadows/reflections. As the problems are occurring because the shader calculations for shadows/reflections take the view into consideration.

However I fell at the first hurdle. I can see that the Client/Server dlls for the source engine only export one method called CreateInterface. I cant find this method in the engine source and it all gets pretty confusing.

I thought it was worth posting here to see if anyone was willing/able to lend a hand getting into the actual dll. I would be prepared to do the leg work of copying over the engine code needed on the vireio side. And the view setup area looks to be very straightforward.

There would be other benefits to getting into the source dlls too. I know its a BIG stretch but it would be theoretically possible to setup a second camera view to create full stereo 3D with source games.

Its just the process of getting the hook into the dll that has me stumped. I was expecting to find a CreateInterface method in the source sdk but none exists. Hopefully someone can help!
User avatar
cybereality
3D Angel Eyes (Moderator)
Posts: 11407
Joined: Sat Apr 12, 2008 8:18 pm

Re: Getting a hook into the HL2 Client.dll

Post by cybereality »

Well I guess you could proxy the DLL, but you will need to know the exact interface of the API (meaning the function signature for 'CreateInterface'). But even if you knew that, I am not sure how that would get you the camera or matrix values. I admit, I don't know much about the Source SDK, so I wouldn't know where to go from here. Sorry.
lukesmith
One Eyed Hopeful
Posts: 4
Joined: Thu Apr 11, 2013 2:17 pm

Re: Getting a hook into the HL2 Client.dll

Post by lukesmith »

That's what I mean, I cant find the CreateInterface function In the engine source which is really odd.

Sorry I'm new to this dll hijacking concept. I had been thinking it would be possible to hijack a function in the engine and replace it with a custom function, namely the RenderView function that passes in the ViewSetup. The idea then would be to modify the ViewSetup to add the roll adjustment.

Is this only possible for functions that are exported by the dll?

The dlls are all different for different source engine games so it would be no use replacing the dll with a modified version.


Otherwise, I wonder if theres any way to intercept the shader and pass the new view to it on that side of things.
User avatar
cybereality
3D Angel Eyes (Moderator)
Posts: 11407
Joined: Sat Apr 12, 2008 8:18 pm

Re: Getting a hook into the HL2 Client.dll

Post by cybereality »

You may want to look into memory hacking. Like the kind of stuff you can do with CheatEngine. Basically finding where in the memory the game stores a variable (for example, the view matrix) and altering it's value manually. Might be overkill but maybe worth a look.
lukesmith
One Eyed Hopeful
Posts: 4
Joined: Thu Apr 11, 2013 2:17 pm

Re: Getting a hook into the HL2 Client.dll

Post by lukesmith »

That's not a bad idea but I think it would be more or less impossible to find the address of the member in memory.

Instead I am decompiling and patching the dll. I was able to get mem address's of functions etc using the pdb files from the compiled engine source for clues.

I think the best way to do this would be to add the functions I'm interested in to the exports table and then hook it in vireio perception like you have with d3d9.dll. This would still mean the user would have to copy dlls over to the game directorys though which is annoying.

But then multiple issues could be solved this way, for example translating the view position with the head tracker (rather than rotating the view in place) to reduce motion sickeness. And potentially rendering the view a second time by the actual engine, so as to render it from an offset position to get true stereo 3d. - That would be a massive job though!
Post Reply

Return to “Development / General Discussion”