OpenGL Hooking

This is a discussion on OpenGL Hooking within the Game Programming forums, part of the General Programming Boards category; OK, Ive been having some problems trying to hook an OpenGL table within a process only to recieve crashing. I ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    2

    OpenGL Hooking

    OK, Ive been having some problems trying to hook an OpenGL table within a process only to recieve crashing. I believe its due to my cast conversions and such, but I am clueless on how to fix it.

    Code:
    glViewport_t	 pglViewport;
    
    //OpenGL function to hook
    void APIENTRY hooked_glViewport( GLint x, GLint y, GLsizei width, GLsizei height )
    {
    	return pglViewport( x, y, width, height );
    }
    
    
    //Keeps crashing here
    void CodeWalk( DWORD dwStartAddress, DWORD dwEndAddress )
    {
    	for ( DWORD dwCurrentAddress = dwStartAddress; dwCurrentAddress <= dwEndAddress-0x6; dwCurrentAddress+=0x6 )
    	{
    
    
    		PDWORD pdwTempAddress = ( PDWORD ) dwCurrentAddress + 0x2;
    
    		PDWORD pdwTableAddress = ( PDWORD ) *pdwTempAddress;
    
    		HMODULE hmOpenGL = LoadLibrary( "opengl32.dll" );
    
    		if ( *pdwTableAddress == ( DWORD ) GetProcAddress( hmOpenGL, "glViewport" ) )
    		{
    			pglViewport = ( glViewport_t ) *pdwTableAddress;
    			*pdwTableAddress = ( DWORD ) &hooked_glViewport;
    		}
    	}
    
    }
    //Hooked with CreateThread after sleeping for 2 seconds
    void SetupOpenGLHooks( void )
    {
    	DWORD dwImportCode = (DWORD)0x01D7AFA0;
    
    	if(dwImportCode != NULL)
    	{
    	CodeWalk(dwImportCode,dwImportCode + 0x870); //Lets go through the table
    	}
    	else
    	{
    		MessageBox(NULL,"Couldnt Find the TLS","newhook",NULL);
    	}
    
    }

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    And just why are you hooking a DLL in this fashion?

  3. #3
    using namespace Trooper; St0rmTroop3er's Avatar
    Join Date
    Sep 2003
    Posts
    77
    Quote Originally Posted by Bubba
    And just why are you hooking a DLL in this fashion?

    Generally, hooking a OpenGL program, is basicaly how hackers get all the cool stuff on the screen for hacks. I'm not accusing anyone tho.

  4. #4
    Registered User
    Join Date
    Dec 2005
    Posts
    2
    I'm trying to write an in-game Visual Gameboy for OpenGL games. Thats why I need the new viewport. Any code suggestions?

    StormTrooper: Most modern games are written in DirectX, I am just a simple minded programmer.
    Last edited by Kalvin; 12-29-2005 at 10:38 PM.

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Code:
    //Keeps crashing here
    void CodeWalk( DWORD dwStartAddress, DWORD dwEndAddress )
    {
    	for ( DWORD dwCurrentAddress = dwStartAddress; dwCurrentAddress <= dwEndAddress-0x6; dwCurrentAddress+=0x6 )
    	{
    
    
    		PDWORD pdwTempAddress = ( PDWORD ) dwCurrentAddress + 0x2;
    
    		PDWORD pdwTableAddress = ( PDWORD ) *pdwTempAddress;
    
    		HMODULE hmOpenGL = LoadLibrary( "opengl32.dll" );
    
    		if ( *pdwTableAddress == ( DWORD ) GetProcAddress( hmOpenGL, "glViewport" ) )
    		{
    			pglViewport = ( glViewport_t ) *pdwTableAddress;
    			*pdwTableAddress = ( DWORD ) &hooked_glViewport;
    		}
    	}
    
    }
    Suspicious at best.

    This isn't a hacking forum.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 06:57 PM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21