Advertisement
Guest User

Untitled

a guest
Apr 4th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.63 KB | None | 0 0
  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.     // All are world coordinates
  60.     Pos *cam   = pos_new(mp, 0x039F713C, 0x039F7144); // Camera position
  61.     Pos *champ = pos_new(mp, 0x039F7318, 0x039F7320); // Champion position
  62.     Pos *mouse = pos_new(mp, 0x039F7324, 0x039F732C); // Mouse position
  63.     Pos *dest  = pos_new(mp, 0x039F73F8, 0x039F7400); // Right click destination position
  64.  
  65.     while (1)
  66.     {
  67.         // Get the position from the game
  68.         pos_refresh(mp, champ);
  69.         pos_refresh(mp, mouse);
  70.  
  71.         pos_set (mp, cam,
  72.             (champ->v.x + mouse->v.x) / 2.0,
  73.             (champ->v.y + mouse->v.y) / 2.0
  74.         );
  75.  
  76.         Sleep(5);
  77.     }
  78.  
  79.     return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement