• Amused
  • Angry
  • Annoyed
  • Awesome
  • Bemused
  • Cocky
  • Cool
  • Crazy
  • Crying
  • Down
  • Drunk
  • Embarrased
  • Enraged
  • Friendly
  • Geeky
  • Godly
  • Happy
  • Hateful
  • Hungry
  • Innocent
  • Meh
  • Piratey
  • Poorly
  • Sad
  • Secret
  • Shy
  • Sneaky
  • Tired
  • Wtf
  • At Work
  • CodenzHub
  • Coding
  • Deejaying
  • Donating
  • Drinking
  • Eating
  • Editing
  • Hacking
  • Hate Mailing
  • Jamin'
  • Lagging
  • Live Streaming
  • Lurking
  • No Status
  • Pawning
  • PC Gaming
  • PS Gaming
  • Raging
  • Reversing
  • Sleeping
  • Steam Gaming
  • Trolling
  • TwitchStreamer
  • Vodka!
  • Watching TV/Movie
  • Xbox Gaming
  • Youtuber
  • Zombies
  • Page 1 of 2 12 LastLast
    Results 1 to 10 of 12
    1. #1
      Newbie
      Learning to hack games!
       
      Feeling Normal
       
      Chriko2502's Avatar
      Join Date
      Jul 2013
      Posts
      8
      Thanks (-->)
      0
      Thanks (<--)
      0

      Directx menu text

      Silent VPN
      Hi,

      following code will not work
      When i comment the "drawing text things" out it will work fine...

      So perhaps u can tell me why i get the following error:
      Code:
      Quelle.obj : error LNK2001: Nicht aufgelöstes externes Symbol "[email protected]".
      Thanks for helping!

      Code:
      #include <Windows.h> 
      #include <cstdio> 
      #include <time.h>
      #include <iostream>
      #include <d3d9.h> 
      #include <d3dx9.h>  
      
      const D3DCOLOR fontRed = D3DCOLOR_ARGB(255, 255, 0, 0);
      const D3DCOLOR fontGreen = D3DCOLOR_ARGB(255, 0, 255, 0);
      const D3DCOLOR fontBlue = D3DCOLOR_ARGB(255, 0, 0, 255);
      const D3DCOLOR fontWhite = D3DCOLOR_ARGB(255, 255, 255, 255);
      const D3DCOLOR fontBlack = D3DCOLOR_ARGB(255, 0, 0, 0);
      
      HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice); 
      
      typedef HRESULT(__stdcall* EndScene_t)(LPDIRECT3DDEVICE9); 
      EndScene_t pEndScene;  
      
      DWORD WINAPI HookThread();
      void CreateLog(char* format, ...); 
      void* DetourFunc(PBYTE src, const PBYTE dst, const int len);
      bool bDataCompare(const BYTE* pData, const BYTE* bMask, const char* szMask);
      DWORD dwFindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask);  
      
      void DrawFilledRectangle(int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9 *d3dDevice);
      void DrawBorderBox(int x, int y, int w, int h, int thickness, D3DCOLOR color, IDirect3DDevice9 *d3dDevice);
      void DrawFont (int X, int Y, D3DCOLOR Color, char *format, ...);
      
      HMODULE hModD3D9 = NULL; 
      FARPROC dwEndScene = NULL;
      HANDLE tmpHandle = NULL;
      DWORD* VTableStart = NULL;
      DWORD tempadd = NULL;
      
      ID3DXFont *pFont = NULL;
      
      BOOL WINAPI DllMain(HINSTANCE hinstDll,DWORD Reason,LPVOID Reserved) {  
      	switch(Reason) {  
      	case DLL_PROCESS_ATTACH:    
      		CreateLog("==========LOG START=========="); 
      		CreateLog("DLL Attached");    
      		CreateLog("Creating Thread...");    
      		tmpHandle = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&HookThread, 0, 0, 0);    
      		if (!tmpHandle) {    
      			CreateLog("ThreadCreation Failed!"); 
      		}    break;  
      	case DLL_PROCESS_DETACH:   
      		CreateLog("DLL Detached");  
      		CreateLog("==========LOG END==========\n\n\n");  
      		break;  
      	} 
      	return 1;
      }  
      
      DWORD WINAPI HookThread(void) {
      	CreateLog("Thread Created");  
      	
      	while (!hModD3D9) {   
      		CreateLog("Searching d3d9.dll..."); 
      		hModD3D9 = GetModuleHandle("d3d9.dll"); 
      		Sleep(100);  
      	}  
      	CreateLog("Found d3d9.dll: %x !", hModD3D9);  
      
      	tempadd = dwFindPattern((DWORD)hModD3D9, 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
      	CreateLog("PatternFound!"); 
      	VTableStart = (DWORD*) *(DWORD*)(tempadd+2);  
      
      	dwEndScene = (FARPROC) VTableStart[42]; 
      	pEndScene = (EndScene_t) DetourFunc((PBYTE) dwEndScene, (PBYTE)hkEndScene, 5); 
      
      	while (true)  { 
      		Sleep(500); 
      	} 
      	return 0;
      }  
      
      void CreateLog(char* format, ...) { 
      	HANDLE filehandle; 
      	DWORD dwReadBytes;  
      	char buffer[2048]; 
      	char writebuffer[2048]; 
      	va_list args;
      	va_start(args, format);
      	vsprintf (buffer, format, args);  
      	filehandle = CreateFile("Log.txt", GENERIC_WRITE, 0, 0, OPEN_ALWAYS, 0, 0); 
      	SetFilePointer(filehandle, 0, 0, FILE_END); 
      	char date[18]; 
      	_strdate(date); 
      	date[8] = ' ';  
      	_strtime(date+9);
      	sprintf_s(writebuffer, 2048, "Log Added (%s): %s\r\n", date, buffer);
      	WriteFile(filehandle, writebuffer, strlen(writebuffer), &dwReadBytes, 0);  
      	CloseHandle(filehandle);
      } 
      
       void* DetourFunc(PBYTE src, const PBYTE dst, const int len) { 
      	 DWORD dwback; 
      	 BYTE* jmp = (BYTE*)malloc(len+5); 
      	 VirtualProtect(src, len, PAGE_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; 
      	 VirtualProtect(src, len, dwback, &dwback); 
      	 VirtualProtect(jmp-len, len+5, PAGE_EXECUTE_READWRITE, &dwback); 
      	 return (jmp - len); 
       } 
      
      bool bDataCompare(const BYTE* pData, const BYTE* bMask, const char* szMask) { 
      	for(;*szMask;++szMask,++pData,++bMask)  { 
      		if(*szMask=='x' && *pData!=*bMask )   {  
      			return false;  
      		}  
      	} 
      	return (*szMask) == NULL; 
      }  
      
      DWORD dwFindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask) {  
      	for(DWORD i=0; i < dwLen; i++)  {  
      		if( bDataCompare( (BYTE*)( dwAddress+i ),bMask,szMask) )   { 
      			return (DWORD)(dwAddress+i);   
      		}  
      	} 
      	return 0; 
      }  
      
      HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice) { 
      	CreateLog("DrawIngameMenu"); 
      	
      	DrawFilledRectangle(55, 20, 200, 50, fontBlue, pDevice);
      	DrawBorderBox(55, 20, 200, 50, 4, fontBlack, pDevice);
      
      	D3DXCreateFont(pDevice, 14, 0, FW_NORMAL, 1, 0, DEFAULT_CHARSET,  OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &pFont );      
      	DrawFont( 300, 50, fontRed, "My first Text");
      
      
      	return pEndScene(pDevice); 
      } 
      
      void DrawFilledRectangle(int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9 *d3dDevice) {
      	CreateLog("DrawFilledRectangle"); 
      	D3DRECT rct = {x , y, x + w, y + h};
      	d3dDevice->Clear(1, &rct, D3DCLEAR_TARGET | D3DCLEAR_TARGET, color, 0, 0);
      }
      
      void DrawBorderBox(int x, int y, int w, int h, int thickness, D3DCOLOR color, IDirect3DDevice9 *d3dDevice){
      	CreateLog("DrawBorderBox");
      	DrawFilledRectangle(x, y, w, thickness, color, d3dDevice);
      	DrawFilledRectangle(x, y, thickness, h, color, d3dDevice);
      	DrawFilledRectangle(x + w, y, thickness, h, color, d3dDevice);
      	DrawFilledRectangle(x, y+h, thickness + w, thickness, color, d3dDevice);
      }
      
      
      void DrawFont (int X, int Y, D3DCOLOR Color, char *format, ...) { 
      	char buffer[256];        
      	va_list args; // deswegen: #include <cstdio>      
      	va_start (args, format);   
      	vsprintf (buffer,format, args);    
      	RECT FontRect = { X, Y, X + 120, Y + 16 };    
      	pFont->DrawText( NULL, buffer, -1, &FontRect, DT_NOCLIP , Color ); // Zeichnen  
      	va_end (args); 
      }

    2. #2
      Coder
      Learning to hack games!
       
      Feeling Normal
       
      brinkz's Avatar
      Join Date
      Sep 2012
      Posts
      213
      Thanks (-->)
      5
      Thanks (<--)
      74
      Probably because you didn't linked with d3d9.lib / d3dx9.lib?

    3. #3
      Respected Hacker
      Learning to hack games!
       
      Coding
       
      till0sch's Avatar
      Join Date
      Oct 2012
      Location
      Germany.
      Posts
      1,168
      Thanks (-->)
      179
      Thanks (<--)
      340
      Y u no have SDK included?

    4. #4
      Newbie
      Learning to hack games!
       
      Feeling Normal
       
      Chriko2502's Avatar
      Join Date
      Jul 2013
      Posts
      8
      Thanks (-->)
      0
      Thanks (<--)
      0
      i included the sdk/ d3d9.lib / d3dx9.lib...

      "why are you creating a font each frame?"
      yeah sure in final version i wont do that, this was only a test and he failed

      Some help left for me?

    5. #5
      Respected Hacker
      Learning to hack games!
       
      Coding
       
      till0sch's Avatar
      Join Date
      Oct 2012
      Location
      Germany.
      Posts
      1,168
      Thanks (-->)
      179
      Thanks (<--)
      340
      Just check what Fleep did on his d3d menu tutorial, how he included the SDK etc. You propably just did sth wrong.

    6. #6
      Newbie
      Learning to hack games!
       
      Feeling Normal
       
      Icyvel's Avatar
      Join Date
      Aug 2013
      Posts
      19
      Thanks (-->)
      3
      Thanks (<--)
      4
      Quote Originally Posted by Chriko2502 View Post
      i included the sdk/ d3d9.lib / d3dx9.lib...

      "why are you creating a font each frame?"
      yeah sure in final version i wont do that, this was only a test and he failed

      Some help left for me?
      Just do a static int DoOnce if statement, this is actually crucial, i did the same mistake in CSS through the engine and i ended up reaching maximum memory the game would allow pretty quickly, seeing as the standard heap-size is not that big.

      It's actually a memory leak, and you'll end up noticing it pretty quickly if you watch over your memory with the TaskManager or similar .

      Example::

      static int DoOnce = true;

      if(DoOnce)
      {

      CreateFont....

      DoOnce = false;

      }

    7. #7
      Newbie
      Learning to hack games!
       
      Feeling Normal
       
      Amphetamin's Avatar
      Join Date
      Aug 2013
      Posts
      5
      Thanks (-->)
      0
      Thanks (<--)
      0
      Quote Originally Posted by Chriko2502 View Post
      i included the sdk/ d3d9.lib / d3dx9.lib...

      "why are you creating a font each frame?"
      yeah sure in final version i wont do that, this was only a test and he failed

      Some help left for me?
      I create my Font in the StartUp function...
      Code:
      HRESULT CDirectX::StartUp( HWND hWnd )
      {
      		BOOL		bComposition			= false;
      		DWORD		msqAAQuality			= 0;
      		HRESULT		hResult;
      	
      		DwmIsCompositionEnabled( &bComposition );
      		if( !bComposition )
      			return E_FAIL;
      	
      		hResult = Direct3DCreate9Ex( D3D_SDK_VERSION, &Handle.p_D3D );
      		if( FAILED( hResult ) )
      			return E_FAIL;
      			
      		ZeroMemory( &Handle.p_Parameter, sizeof( Handle.p_Parameter ) );
      		Handle.p_Parameter.Windowed					= TRUE;
      		Handle.p_Parameter.SwapEffect				= D3DSWAPEFFECT_DISCARD;
      		Handle.p_Parameter.BackBufferFormat			= D3DFMT_A8R8G8B8;
      		Handle.p_Parameter.EnableAutoDepthStencil	= TRUE;
      		Handle.p_Parameter.AutoDepthStencilFormat	= D3DFMT_D16;
      		Handle.p_Parameter.MultiSampleType			= D3DMULTISAMPLE_NONE;
      		Handle.p_Parameter.PresentationInterval		= 0x80000000L;
      	
      		if( SUCCEEDED( Handle.p_D3D->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_A8R8G8B8,
      														  true, D3DMULTISAMPLE_NONMASKABLE, &msqAAQuality ) ) )
      		{
      			Handle.p_Parameter.MultiSampleType		= D3DMULTISAMPLE_NONMASKABLE;
      			Handle.p_Parameter.MultiSampleQuality	= msqAAQuality -1;
      		}
      		else
      		{
      			Handle.p_Parameter.MultiSampleType		= D3DMULTISAMPLE_NONE;
      		}
      	
      		hResult = Handle.p_D3D->CreateDeviceEx( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &Handle.p_Parameter, NULL, &Handle.p_Device );
      		if( FAILED( hResult ) )
      			return E_FAIL;
      	
      		if( FAILED( D3DXCreateFontA( Handle.p_Device, 14, 0, FW_NORMAL, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
      									 DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Arial", &Handle.p_Font ) ) )
      			return E_FAIL;		
      
      		return S_OK;
      }
      Quote Originally Posted by Icyvel View Post
      Example::
      static int DoOnce = true;
      Hm.. don't use an Integer for true/false check.. It works but it isnt correct
      Last edited by Amphetamin; 08-25-2013 at 04:45 PM.

    8. #8
      Coder
      Kappa
       
      Hacking
       
      Szaka's Avatar
      Join Date
      Mar 2013
      Posts
      168
      Thanks (-->)
      1
      Thanks (<--)
      6
      Wow there are non english compilers? :O

    9. #9
      Newbie
      Learning to hack games!
       
      Feeling Normal
       
      Icyvel's Avatar
      Join Date
      Aug 2013
      Posts
      19
      Thanks (-->)
      3
      Thanks (<--)
      4
      Quote Originally Posted by Amphetamin View Post

      Hm.. don't use an Integer for true/false check.. It works but it isnt correct
      It's as correct as anything else, TRUE & FALSE are just keywords to make it easier to understand programming, false is in fact equal to 0 in numeric value, and TRUE is 1 or anything positive. So each time you're using true / false you're comparing to 0 or a positive number, in which case here I'm actually assigning the value 1 to DoOnce, and the if statement checks if the DoOnce is 1 (not executed code yet) or 0 (it already executed the code).

    10. #10
      Newbie
      Learning to hack games!
       
      Feeling Normal
       
      Amphetamin's Avatar
      Join Date
      Aug 2013
      Posts
      5
      Thanks (-->)
      0
      Thanks (<--)
      0
      Silent VPN
      Quote Originally Posted by Icyvel View Post
      It's as correct as anything else, TRUE & FALSE are just keywords to make it easier to understand programming, false is in fact equal to 0 in numeric value, and TRUE is 1 or anything positive. So each time you're using true / false you're comparing to 0 or a positive number, in which case here I'm actually assigning the value 1 to DoOnce, and the if statement checks if the DoOnce is 1 (not executed code yet) or 0 (it already executed the code).
      I know that false is equal 0 / true equal is 1 in numeric value. Of course it works, but it's not the right way.

    Page 1 of 2 12 LastLast

    Similar Game Hacker Threads

    1. [Help] DirectX Text draw
      By traderain in forum Hacking Help
      Replies: 4
      Last Post: 02-21-2016, 12:26 PM
    2. [Help] Write simple text in DirectX
      By zoratz in forum Hacking Help
      Replies: 3
      Last Post: 01-10-2015, 09:49 PM
    3. [Help] DIRECTX MENU - Help
      By Chriko2502 in forum GH Tutorials Help
      Replies: 6
      Last Post: 08-15-2013, 02:33 PM
    4. DirectX Text in hwnd!
      By j3b in forum Hacking Help
      Replies: 5
      Last Post: 07-08-2013, 12:12 PM
    5. [Help] DirectX menu
      By wooolly in forum GH Tutorials Help
      Replies: 12
      Last Post: 01-22-2013, 05:32 AM

    Tags for this Thread