i dont no much about D3D menu's so i couldn't tell you whats wrong.. ill copy the code and try mess around with it
Hey
Well im tryning to move on from hotkeys to a menu.
Im using hans base.
When i inject into CA, The menu shows up, But when i go ingame i DC.
I can stay in the lobby for as long as i want, But as soon as i go ingame, I DC
Could someone please tell me how to fix this?
Heres the source
Can someone please help me?Code:#include "d3dbase.h" #include "d3dfont9.cpp" oEndScene pEndScene; oReset pReset; CD3DFont *pFont=NULL; void PreReset(pD3DdeviceX pDevice) { if (pFont) { pFont->InvalidateDeviceObjects(); pFont->DeleteDeviceObjects(); pFont = NULL; } } void PostReset(pD3DdeviceX pDevice) { pFont = new CD3DFont("Tahoma", 10, D3DFONT_BOLD); if (pFont) { pFont->InitDeviceObjects(pDevice); pFont->RestoreDeviceObjects(); } } HRESULT WINAPI myReset ( pD3DdeviceX pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters ) { PreReset(pDevice); return pReset(pDevice, pPresentationParameters); } HRESULT WINAPI myEndScene (pD3DdeviceX pDevice) { if (pFont==NULL) PostReset(pDevice); // Create font else DoMenu(pDevice); return pEndScene(pDevice); } void DrawBox(pD3DdeviceX pDevice, int x, int y, int w, int h, D3DCOLOR col) { struct { float x,y,z,rhw; DWORD dwColor; } qV[4] = { { (float)x , (float)(y+h), 0.0f, 0.0f, col}, { (float)x , (float)y , 0.0f, 0.0f, col}, { (float)(x+w), (float)(y+h), 0.0f, 0.0f, col}, { (float)(x+w), (float)y , 0.0f, 0.0f, col} }; pDevice->SetPixelShader(NULL); pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true); pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA); pDevice->SetTexture(0, NULL); pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,qV,sizeof(qV[0])); } bool bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask) { for(;*szMask;++szMask,++pData,++bMask) if(*szMask=='x' && *pData!=*bMask) return 0; return (*szMask) == NULL; } DWORD FindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask) { for(DWORD i=0; i<dwLen; i++) if (bCompare((BYTE*)(dwAddress+i),bMask,szMask)) return (DWORD)(dwAddress+i); return 0; } void *DetourCreate(BYTE *src, const BYTE *dst, const int len) { BYTE *jmp = (BYTE*)malloc(len+5); DWORD dwBack; VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &dwBack); memcpy(jmp, src, len); jmp += len; jmp[0] = 0xE9; *(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5; src[0] = 0xE9; *(DWORD*)(src+1) = (DWORD)(dst - src) - 5; for (int i=5; i<len; i++) src[i]=0x90; VirtualProtect(src, len, dwBack, &dwBack); return (jmp-len); } int D3Dinit(void) { DWORD hD3D, adr, *vtbl; // wait for the d3dx dll hD3D=0; do { hD3D = (DWORD)GetModuleHandle(D3Ddllname); Sleep(10); } while(!hD3D); adr = FindPattern(hD3D, 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx"); if (adr) { memcpy(&vtbl,(void *)(adr+2),4); pReset = (oReset) DetourCreate((PBYTE)vtbl[RESET] , (PBYTE)myReset ,5); pEndScene = (oEndScene) DetourCreate((PBYTE)vtbl[ENDSCENE], (PBYTE)myEndScene,5); } CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)HACKthread, NULL, NULL, NULL); return 0; } BOOL WINAPI DllMain ( HMODULE hDll, DWORD dwReason, LPVOID lpReserved ) { DisableThreadLibraryCalls(hDll); if (dwReason == DLL_PROCESS_ATTACH) { CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)D3Dinit, NULL, NULL, NULL); } return TRUE; }
Thanks,
acid_buRn
i dont no much about D3D menu's so i couldn't tell you whats wrong.. ill copy the code and try mess around with it
i think Hans base is patched...
also wrong addies i think,
I guess you need to update the pDevice addie and make an undetected detour.
You might need to wait for: ClientFX.fxd and CShell.dll as well. it could be detected, but I don't think so.
Also for reset all you need to do is call OnLostDevice on pfont for preReset and OnResetDevice in PostReset. Also you don't include post reset in your reset.
My theory: SInce your reset is failing, the game probably calls reset once you enter the game, but at that time your pfont has already been lost and has not been restored because you failed to do so. For that reason your game crashes.
EDIT: and oh lord you have post reset in your endscene, though I suppose it works. It looks like you just stuck these function any old place. In quite a few places the logic is a tad off. Lastly you might want to draw something, just to see if you can. Finally I'd recommend using a test environment first. I found I was able to debug a lot faster with one. Props to Voltage for that.
Last edited by why06; 03-29-2010 at 12:35 PM.
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
I kind of suggest this to everyone having problems with hooking. =\
Remove everything from your hook function and return normally. See if that crashes, if it doesn't, then there is something wrong in your code. From there you can slowly debug everything.
Hmm..
[php]
HRESULT PresentHook(Params)
{
return pPresent(Params); //return normally
}
[/php]
No! No! No1 WINAPI or stdcall. Remember? like u told me you need to specify its stdcall D:
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
But he did that already. And WINAPI == __stdcall, same thing.