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

      Cool OpenGL Hooking ( Mac-OSX)

      Silent VPN
      I'll post some source of a way to make a game overlay in OSX (opengl). Since i could not find anything on google.
      After a while I actually managed to hook functions on OSX (https://guidedhacking.com/showthread...ermediate-way)), but I didn't make it stable enough yet to release the code for it, so for now I'm using https://github.com/rentzsch/mach_override , which is an excellent library, similar to detours on windows.

      The function (on OSX) that is equivalent for endscene is called CGLFlushDrawable (not really equivalent but we don't care).
      To test the overlay I created a small dummy program (just a green square):

      [PHP]
      -(void) drawRect: (NSRect) bounds
      {
      glClearColor(0, 20, 0, 0);
      glClear(GL_COLOR_BUFFER_BIT);

      puts("now calling real puts");
      CGLContextObj ctx = 0;
      CGLFlushDrawable(ctx); // games usually call this function once a frame.
      glFlush();

      }[/PHP]

      And the hook (note, we inject the dylib at start-up time with DYLD_INSERT_LIBRARIES (google it)):
      hook.dylib
      [PHP]#include "overlay.h"
      #include "mach_override.h"

      #include <dlfcn.h>
      #include <stdio.h>
      #include <unistd.h>

      #include <OpenGL/OpenGL.h>

      static void drawAnObject ()
      {
      glColor3f(1.0f, 0.85f, 0.35f);
      glBegin(GL_TRIANGLES);
      {
      glVertex3f( 0.0, 0.6, 0.0);
      glVertex3f( -0.2, -0.3, 0.0);
      glVertex3f( 0.2, -0.3 ,0.0);
      }
      glEnd();
      }

      typedef void (*CGLFlushDrawable_s)(CGLContextObj ctx);
      CGLFlushDrawable_s oCGLFlushDrawable;

      typedef int (*puts_s)(const char*str);
      puts_s oputs;

      void CGLFlushDrawableOverride(CGLContextObj ctx) {
      drawAnObject();
      oCGLFlushDrawable(ctx);
      }

      __attribute__ ((visibility("default")))
      __attribute__((constructor))
      void OverlayEntryPoint()
      {
      printf("attempting to hook ogl\n");


      if (mach_override_ptr(dlsym(RTLD_DEFAULT, "CGLFlushDrawable"), CGLFlushDrawableOverride, (void **) &oCGLFlushDrawable) != 0)
      printf("CGLFlushDrawable override failed.");
      else
      printf("Up running.\n");

      }[/PHP]

      drawAnObject () just draws a triangle, this is the result:

      Click image for larger version. 

Name:	Naamloos.png 
Views:	12 
Size:	17.8 KB 
ID:	2512

      PS: I have not tried injecting at runtime yet, but this https://github.com/tpurtell/machinject/ looks promising.
      Last edited by NTvalk; 03-07-2014 at 12:39 PM.

    2. Thanks c5, squeenie thanked for this post
    3. #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 (<--)
      492
      CGLFlushDrawable = SwapBuffers?

      also dlsym = GetProcAddress?
      OpenGL Hooking ( Mac-OSX)

    4. Thanks NTvalk thanked for this post
    5. #3
      Hacker
      ^.^
       
      Eating
       
      NTvalk's Avatar
      Join Date
      Jul 2013
      Location
      Your RAM
      Posts
      512
      Thanks (-->)
      176
      Thanks (<--)
      146
      Quote Originally Posted by c5 View Post
      CGLFlushDrawable = SwapBuffers?

      also dlsym = GetProcAddress?
      Exactly, thanks for making this clear

    6. #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 (<--)
      492
      Silent VPN
      Quote Originally Posted by NTvalk View Post
      Exactly, thanks for making this clear
      Was just checking myself, thanks for confirming. Have never touched a mac for that matter
      OpenGL Hooking ( Mac-OSX)

    Similar Game Hacker Threads

    1. [Tutorial] VEH Hooking (aka PageGuard Hooking) - An In-depth Look
      By Zuva in forum Game Hacking Tutorials
      Replies: 7
      Last Post: 08-02-2016, 01:02 PM
    2. Drawing In OpenGL
      By Solaire in forum Direct-X, OpenGL
      Replies: 3
      Last Post: 01-27-2015, 07:00 PM
    3. [Help] OpenGL hooking issue
      By Liduen in forum Direct-X, OpenGL
      Replies: 8
      Last Post: 11-24-2014, 07:34 AM
    4. [Tutorial] vTable Hooking / VMT hooking
      By c5 in forum Game Hacking Tutorials
      Replies: 4
      Last Post: 11-06-2013, 12:25 AM
    5. Easy OpenGL hooking [Linux]
      By NTvalk in forum Direct-X, OpenGL
      Replies: 4
      Last Post: 10-03-2013, 07:24 AM

    Tags for this Thread