Thread: D3D Menu Help

Results 1 to 8 of 8
  1. #1
    ac1d_buRn's Avatar
    Join Date
    Aug 2009
    Gender
    female
    Location
    CA Source Section
    Posts
    3,404
    Reputation
    157
    Thanks
    4,003
    My Mood
    Flirty

    D3D Menu Help

    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

    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;
    }
    Can someone please help me?

    Thanks,
    acid_buRn

  2. #2
    MintSlice's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    52
    Reputation
    10
    Thanks
    2
    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

  3. #3
    AeroMan's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    Hell
    Posts
    3,294
    Reputation
    189
    Thanks
    3,049
    My Mood
    Busy
    i think Hans base is patched...
    also wrong addies i think,

  4. #4
    Zoom's Avatar
    Join Date
    May 2009
    Gender
    male
    Location
    Your going on my 24/7 DDoS hit list.
    Posts
    8,552
    Reputation
    127
    Thanks
    5,970
    My Mood
    Happy
    I guess you need to update the pDevice addie and make an undetected detour.

  5. #5
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    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

  6. #6
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    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]

  7. #7
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    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

  8. #8
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    But he did that already. And WINAPI == __stdcall, same thing.

Similar Threads

  1. [Help Request] D3D menu Help
    By SteamAss in forum CrossFire Help
    Replies: 5
    Last Post: 05-21-2011, 11:36 AM
  2. [Help]D3D Menu Development
    By why06 in forum DirectX/D3D Development
    Replies: 7
    Last Post: 01-21-2011, 06:54 PM
  3. [HELP]D3D Menu Won't Work
    By Lonly in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 31
    Last Post: 07-15-2010, 10:55 AM
  4. D3D menu Help Please....
    By ~InsaneWayne~ in forum C++/C Programming
    Replies: 14
    Last Post: 11-08-2009, 09:00 PM
  5. [Help]D3D Menu
    By cothen12 in forum C++/C Programming
    Replies: 13
    Last Post: 01-18-2008, 04:28 PM