Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 4th, 2013  |  syntax: C  |  size: 1.55 KB  |  views: 66  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include "../Win32Tools/Win32Tools.h"
  2. #include "../MemProc/MemProc.h"
  3. #include "../Vector/Vector2D.h"
  4.  
  5. typedef struct {
  6.         DWORD addrX, addrY;
  7.         Vector2D v;
  8. } Pos;
  9.  
  10. Pos *
  11. pos_new (MemProc *mp, DWORD addrX, DWORD addrY)
  12. {
  13.         Pos *p;
  14.  
  15.         if ((p = malloc(sizeof(Pos))) == NULL)
  16.                 return NULL;
  17.  
  18.         p->addrX = addrX + mp->base_addr;
  19.         p->addrY = addrY + mp->base_addr;
  20.  
  21.         vector2D_set_pos (
  22.                 &p->v,
  23.                 read_memory_as_float(mp->proc, p->addrX),
  24.                 read_memory_as_float(mp->proc, p->addrY)
  25.         );
  26.  
  27.         return p;
  28. }
  29.  
  30. void
  31. pos_refresh (MemProc *mp, Pos *p)
  32. {
  33.         vector2D_set_pos (
  34.                 &p->v,
  35.                 read_memory_as_float(mp->proc, p->addrX),
  36.                 read_memory_as_float(mp->proc, p->addrY)
  37.         );
  38. }
  39.  
  40. void
  41. pos_set (MemProc *mp, Pos *p, float newX, float newY)
  42. {
  43.         vector2D_set_pos (&p->v, newX, newY);
  44.  
  45.         write_memory_as_float(mp->proc, p->addrX, newX);
  46.         write_memory_as_float(mp->proc, p->addrY, newY);
  47. }
  48.  
  49. int main()
  50. {
  51.         MemProc *mp = memproc_new("League of Legends.exe", "League of Legends (TM) Client");
  52.  
  53.         if (!mp->proc)
  54.         {
  55.                 error("Please launch a game");
  56.                 return 0;
  57.         }
  58.  
  59.         Pos *cam   = pos_new(mp, 0x039F713C, 0x039F7144);
  60.         Pos *champ = pos_new(mp, 0x039F7318, 0x039F7320);
  61.         Pos *mouse = pos_new(mp, 0x039F7324, 0x039F732C);
  62.  
  63.         float xoff = 0.0, yoff = 0.0;
  64.  
  65.         while (1)
  66.         {
  67.                 // Get the position from the game
  68.                 pos_refresh(mp, cam);
  69.                 pos_refresh(mp, champ);
  70.                 pos_refresh(mp, mouse);
  71.  
  72.                 xoff = (mouse->v.x - cam->v.x) / 2.0;
  73.                 yoff = (mouse->v.y - cam->v.y) / 2.0;
  74.  
  75.                 pos_set(mp, cam, champ->v.x + xoff, champ->v.y + yoff);
  76.  
  77.                 Sleep(1);
  78.         }
  79.  
  80.     return 0;
  81. }