jacekPUT How do I cheat?
Reputation: 0
Joined: 02 Oct 2009 Posts: 1
|
Posted: Fri Oct 02, 2009 5:59 pm Post subject: Ms detours and Direct3DCreate9 |
|
|
I am trying to replace original Direct3DCreate9 function in an application with a piece of code provided by me. I read an article sticked at this site (i cannot post links) saying how to do it using Ms Detours 1.5, but i want to use version 2.1.
The task seems simple and i prepared this short piece of code:
| Code: |
IDirect3D9* iDirect3D9;
//extern "C" {
static IDirect3D9* (* RealDirect3DCreate9)(UINT) = Direct3DCreate9;
//};
IDirect3D9 * MyDirect3DCreate9(UINT SDKVersion){
return NULL;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
LONG DetourAttachResult;
LONG DetourTransactionCommitResult;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
DetourRestoreAfterWith();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttachResult = DetourAttach(&(PVOID&)RealDirect3DCreate9, MyDirect3DCreate9);
switch(DetourAttachResult){
case NO_ERROR:
std::cout << "Detouring Direct3DCreate9 successful" << std::endl;
break;
case ERROR_INVALID_BLOCK:
std::cout << "Detouring Direct3DCreate9 UNSUCCESSFUL: ERROR_INVALID_BLOCK" << std::endl;
break;
case ERROR_INVALID_HANDLE:
std::cout << "Detouring Direct3DCreate9 UNSUCCESSFUL: ERROR_INVALID_HANDLE" << std::endl;
break;
case ERROR_INVALID_OPERATION:
std::cout << "Detouring Direct3DCreate9 UNSUCCESSFUL: ERROR_INVALID_OPERATION" << std::endl;
break;
case ERROR_NOT_ENOUGH_MEMORY:
std::cout << "Detouring Direct3DCreate9 UNSUCCESSFUL: ERROR_NOT_ENOUGH_MEMORY" << std::endl;
break;
}
DetourTransactionCommitResult = DetourTransactionCommit();
std::cout << "After DetourTransactionCommit" << std::endl;
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
|
I know that MyDirect3DCreate9 certainly does not get invoked.
When i use the same "pattern" to replace timeGetTime function, everything works fine. I probably don't know or don't understand sth concerning hooking using Detours or way the Dx gets loaded. I'd appreciate if someone could tell me why this piece of code does not work as I'd wish...
Thanks
And maybe some of you know if i could catch WPF renderinf calls, as it uses Dx?
|
|