I'm writing a DLL that hooks certain D3D-functions by changing needed pointers in the VMT of the injected process. The algorythm is like:
- Obtain a dummy window handle.
- Init a dummmy D3D-object, create a D3D-device.
- Grab the needed offsets (VMT - D3D base address).
- Destroy the D3D object and the window handle.
- Get the D3D*.dll base of the injected process.
- Construct the actual VMT pointers (offsets + base).
- Search for them in the process heap.
- If found - change the pointers to my own.
It works totally fine within the application, where I init D3D, start the drawing loop and then fire the hooking procedure, but it doesn't work from a DLL - for some reason it crashes while trying to create a dummy device with last error code = 126 ("The specified module could not be found", though D3D*.dll loads correctly).
I know that at the same moment there can be only one D3DDevice inited, but in my test app I can create more of 1 - only 1 works, but I still can grab the VMT.
So, the question is - what is the difference between running the same code from EXE and from DLL?
I'm writing a DLL that hooks certain D3D-functions by changing needed pointers in the VMT of the injected process. The algorythm is like:
- Obtain a dummy window handle.
- Init a dummmy D3D-object, create a D3D-device.
- Grab the needed offsets (VMT - D3D base address).
- Destroy the D3D object and the window handle.
- Get the D3D*.dll base of the injected process.
- Construct the actual VMT pointers (offsets + base).
- Search for them in the process heap.
- If found - change the pointers to my own.
It works totally fine within the application, where I init D3D, start the drawing loop and then fire the hooking procedure, but it doesn't work from a DLL - for some reason it crashes while trying to create a dummy device with last error code = 126 ("The specified module could not be found", though D3D*.dll loads correctly).
I know that at the same moment there can be only one D3DDevice inited, but in my test app I can create more of 1 - only 1 works, but I still can grab the VMT.
So, the question is - what is the difference between running the same code from EXE and from DLL?
0 commentaires:
Enregistrer un commentaire