• 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
  • Results 1 to 5 of 5
    1. #1
      Hacker
      ^.^
       
      Eating
       
      NTvalk's Avatar
      Join Date
      Jul 2013
      Location
      Your RAM
      Posts
      512
      Thanks (-->)
      176
      Thanks (<--)
      145

      Post Easy OpenGL hooking [Linux]

      John Kittz
      For people looking for a very easy way to hook OpenGL in linux: use dlsym().

      Code:
      #define _GNU_SOURCE
      
      /* These libraries are necessary for the hook */
      #include <dlfcn.h>
      #include <stdlib.h>
      #include <GL/gl.h>
      
      /* "Injected" stuff */
      #include <stdio.h>
      #include <stdint.h>
      #include <string.h>
      
      static int framecnt = 0;
      
      // our detour function
      void HackFrame() {
              // do our stuff
      	framecnt++;
      	
      	printf("frame %d... \n", framecnt);
      }
      
      // hook glClear
      void glClear(GLbitfield mask) {
      		static void (*lib_glClear)(GLbitfield mask) = NULL;
      	void* handle;
      	char* errorstr;
      
      	if(!lib_glClear) {
      		/* Load real libGL */
      		handle = dlopen("/usr/lib/i386-linux-gnu/libGL.so", RTLD_LAZY);
      		if(!handle) {
      			fputs(dlerror(), stderr);
      			exit(1);
      		}
      		/* Fetch pointer of real glClear() func */
      		lib_glClear = dlsym(handle, "glClear");
      		if( (errorstr = dlerror()) != NULL ) {
      			fprintf(stderr, "dlsym fail: %s\n", errorstr);
      			exit(1);
      		}
      	}
      
      	/* Woot */
      	HackFrame();
      
      	/* Call real glClear() */
      	lib_glClear(mask);
      }
      It is very easy to use and also very powerful.
      Use it with:
      Code:
      LD_PRELOAD=./our_library ./our_game

      If you are hooking a game that uses wine:
      Code:
      #define _GNU_SOURCE
      #include <dlfcn.h>
      
      #include <stdlib.h>
      #include <stdio.h>
      #include <string.h>
      
      #include <GL/gl.h>
      #include <GL/glx.h>
      
      void hookfunc();
      
      /* 
       * Unfortunately WINE needs to be patched to allow hooking this via
       * LD_PRELOAD.
       *
       * 1) Instead of using the default RTLD loader, WINE retrieves the address
       *    for glXGetProcAddressARB directly from the OpenGL library.
       *    This is done to enable binary compatibility to systems with or without
       *    OpenGL.
       *
       *    Solution: patch WINE to use the default loader
       *
       * 2) WINE gets the pointers to glx functions via glXGetProcAddressARB
       *    
       *    => I'm hooking glXGetProcAddressARB and return my own
       *       pointer to glXSwapBuffers.
       *
       */
      
      typedef __GLXextFuncPtr (*fp_glXGetProcAddressARB) (const GLubyte*);
      typedef __GLXextFuncPtr (*fp_glXSwapBuffers)(Display* dpy, GLXDrawable drawable);
      
      // glXSwapBuffers
      fp_glXSwapBuffers real_glXSwapBuffers;
      
      void my_glXSwapBuffers(Display* dpy, GLXDrawable drawable) {
      	real_glXSwapBuffers(dpy, drawable);
      	hookfunc();
      }
      
      // glXGetProcAddressARB
      __GLXextFuncPtr glXGetProcAddressARB (const GLubyte* procName)
      {
      	__GLXextFuncPtr result;
      	printf("* hook-glx.c: glXGetProcAddressARB(\"%s\")\n", procName);
      
      	// Fetch pointer of actual glXGetProcAddressARB() function
      	static fp_glXGetProcAddressARB lib_getprocaddr = NULL;
      	if(!lib_getprocaddr)
      	{
      		char* errorstr;
      		lib_getprocaddr = (fp_glXGetProcAddressARB) 
      			dlsym(RTLD_NEXT, "glXGetProcAddressARB");
      		if( (errorstr = dlerror()) != NULL )
      		{
      			fprintf(stderr, "dlsym fail: %s\n", errorstr);
      			exit(1);
      		}
      	}
      	result = lib_getprocaddr(procName);
      
      	// Return our own function pointers
      	if( strcmp( (const char*) procName, "glXSwapBuffers" ) == 0 )
      	{
      		real_glXSwapBuffers = (fp_glXSwapBuffers) result;
      		return (__GLXextFuncPtr) my_glXSwapBuffers;
      	}
      	
      	// Return default function pointer
      	return lib_getprocaddr(procName);
      }
      You will also need to patch wine:
      Code:
      diff -Nru wine-1.1.39.orig/dlls/winex11.drv/opengl.c wine-1.1.39/dlls/winex11.drv/opengl.c
      --- wine-1.1.39.orig/dlls/winex11.drv/opengl.c	2010-02-27 02:21:02.973526893 +0100
      +++ wine-1.1.39/dlls/winex11.drv/opengl.c	2010-02-27 02:27:11.231401387 +0100
      @@ -412,7 +412,7 @@
               return FALSE;
           }
       
      -    pglXGetProcAddressARB = wine_dlsym(opengl_handle, "glXGetProcAddressARB", NULL, 0);
      +    pglXGetProcAddressARB = wine_dlsym(RTLD_DEFAULT, "glXGetProcAddressARB", NULL, 0);
           if (pglXGetProcAddressARB == NULL) {
               ERR("Could not find glXGetProcAddressARB in libGL, disabling OpenGL.\n");
               goto failed;
      We basicly get a pointer to the glXSwapBuffers function by hooking glXGetProcAddressARB. We do this because wine uses glXGetProcAddressARB to do it, so thats the best way.

      credits:
      RoKFenris WINE patch
      Sednogmah glswapbuffer hook
      NOTE: the address to the libGL library may vary on different systems. "/usr/lib/i386-linux-gnu/libGL.so" for me (ubuntu 32bit).
      Last edited by NTvalk; 10-02-2013 at 09:30 AM.

    2. #2
      Kim Kong Trasher
      I don't have status.
       
      Raging
       
      c5's Avatar
      Join Date
      Jul 2012
      Location
      Mankei Iland
      Posts
      1,221
      Thanks (-->)
      97
      Thanks (<--)
      491
      Sweet, thanks for sharing
      Easy OpenGL hooking  [Linux]

    3. #3
      Hacker
      ^.^
       
      Eating
       
      NTvalk's Avatar
      Join Date
      Jul 2013
      Location
      Your RAM
      Posts
      512
      Thanks (-->)
      176
      Thanks (<--)
      145
      i hope more people will make hacks for linux..

    4. #4
      Kim Kong Trasher
      I don't have status.
       
      Raging
       
      c5's Avatar
      Join Date
      Jul 2012
      Location
      Mankei Iland
      Posts
      1,221
      Thanks (-->)
      97
      Thanks (<--)
      491
      Quote Originally Posted by NTvalk View Post
      i hope more people will make hacks for linux..
      I think Linux is just for enthusiast, if you want job to be done, stick with windows
      Easy OpenGL hooking  [Linux]

    5. #5
      Hacker
      ^.^
       
      Eating
       
      NTvalk's Avatar
      Join Date
      Jul 2013
      Location
      Your RAM
      Posts
      512
      Thanks (-->)
      176
      Thanks (<--)
      145
      Cheats'n'Trainers
      Quote Originally Posted by c5 View Post
      I think Linux is just for enthusiast, if you want job to be done, stick with windows
      But why? i think you just need to get used to the OS, which takes some time but once you understand how to use it, you dont go back to windows.

    Similar Game Hacker Threads

    1. [Release] OpenGL ModelLogger (fast, simple, easy to use)
      By Liduen in forum Direct-X, OpenGL
      Replies: 7
      Last Post: 02-19-2016, 12:17 PM
    2. [Help] OpenGL hooking issue
      By Liduen in forum Direct-X, OpenGL
      Replies: 8
      Last Post: 11-24-2014, 07:34 AM
    3. [Help] Simple/Easy question to answer!
      By meteor in forum GH Tutorials Help
      Replies: 1
      Last Post: 06-03-2014, 01:23 AM
    4. OpenGL Hooking ( Mac-OSX)
      By NTvalk in forum Direct-X, OpenGL
      Replies: 3
      Last Post: 03-07-2014, 12:54 PM
    5. BattlEye Bypass? How Easy? Any Suggestions?
      By necrohhh in forum Hacking Help
      Replies: 4
      Last Post: 01-12-2013, 12:37 PM

    Tags for this Thread