Actually Apoc91 is correct. This is exactly What I had in mind to get the PTC method working.. Difference is I will be using inline assembly in hooked EndScene Callback, As much as I would like to create DX device I wont be doing it as I dont want to even deal with DX9(not in Delphi anyway) thus I will not have any of the DX9 headers and units. I did'nt even want to hook from the start but after some info supplyed by freedompeace and other members I now relize you can'nt call the PTC method from your own thread, it must be called from a context of d3d9 thus the reason why I want to hook the simplest dx function(EndScene) as it only requires a pointer for arguments and will be passed straight to the original EndScene...
Hook(d3d9Base + EndSceneOffset, @NewEndScene, @OriginalEndScene)
Then in my NewEndScene Callback...
I have not tested this but now I think you get the what my mind set is to get PTC method working...
function NewEndScene(const Self: Pointer): HResult; stdcall;
FogOn = 'FogEnable 0';
FogOff = 'FogEnable 1';
Result := OriginalEndScene(Self); <-- forward on to original
//PTC console Method, I disassembled some working C++ hacks and ripped the assembly)
cmp dword ptr [bFogOnOff],0 <--- Check our Boolean
add esp, $00000004
Once I get PTC working I will go further and start using the DX9 Types and classes(there is a delphi implementation I seen on the net for the DX9). But for now I just want to be able to use PushToConsole.
I got rapped up in what I want to do that I forgot to tell you guys why I want to find out about the Vtables...
I dont understand why people are using a sig scanner on d3d9.dll to get the pointer to the vTable, Because in my head the Vtable address should always be the same offset from the d3d9 base address, As should the EndScene scene address, The only reason I can think why it would be different is because a different version of d3d9.dll for different OS's... And freedompeace even said some people get the pointer to the pointer of the pointer to the Vtable from Engine.exe, this in my mind makes no sense, why go through all that trouble? you should be only calculating from the base address of d3d9.dll when its loaded... So my question is what is the reason behind this because I lot of source I seen do this, So im guessing there must be a reason.... even if you wanted multiple d3d9 functions wouldn't it be easyer just to do something like d3d9base + OffsetToVTable which would land you on the first Vtable entry?
This Vtable is just DB pointers to function addresses, so im not sure why this is even used unless it changes which would make the d3d9.dll polymorphic code(which it is not)