Advertisement
Guest User

Untitled

a guest
Oct 1st, 2013
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.77 KB | None | 0 0
  1.         /* Read and Int or Float */
  2.        
  3.         public int ReadInt(int MemoryAddress)
  4.         {
  5.             byte[] buffer;
  6.             int read = ReadMem(MemoryAddress, 4, out buffer);
  7.             if (read == 0)
  8.                 return 0;
  9.             else
  10.                 return BitConverter.ToInt32(buffer, 0);
  11.         }
  12.        
  13.         public float ReadFloat(int MemoryAddress)
  14.         {
  15.             byte[] buffer;
  16.             int read = ReadMem(MemoryAddress, 4, out buffer);
  17.             if (read == 0)
  18.                 return 0;
  19.             else
  20.                 return BitConverter.ToSingle(buffer, 0);
  21.         }
  22.        
  23.         /* Getting a mem addr w/ or w/o multilevel points */
  24.         [DllImport("kernel32.dll")]
  25.         public static extern bool ReadProcessMemory(IntPtr hProcess, int lpBaseAddress, byte[] buffer, int size, int lpNumberOfBytesRead);
  26.        
  27.        
  28.         public static int ReadAddress(string Process_Name, string Address_Offsets)
  29.         {
  30.             Process[] P;
  31.             if ((P = Process.GetProcessesByName(Process_Name)).Length == 0)
  32.             {
  33.                 return -1;
  34.             }
  35.  
  36.             int Addy = -1;
  37.             while (Address_Offsets.Contains("  "))
  38.             {
  39.                 Address_Offsets = Address_Offsets.Replace("  ", " ");
  40.             }
  41.  
  42.             int Index = -1;
  43.             while ((Index = Address_Offsets.IndexOf("0x", StringComparison.OrdinalIgnoreCase)) != -1)
  44.             {
  45.                 Address_Offsets = Address_Offsets.Replace(Address_Offsets.Substring(Index, 2), "");
  46.             }
  47.  
  48.  
  49.             string[] tmp = Address_Offsets.Split(' ');
  50.             if (tmp[0].Contains("+"))
  51.             {
  52.                 string[] AD = tmp[0].Split('+');
  53.                 foreach (ProcessModule M in P[0].Modules)
  54.                     if (M.ModuleName.ToLower() == AD[0].ToLower())
  55.                         Addy = M.BaseAddress.ToInt32() + int.Parse(AD[1], NumberStyles.HexNumber);
  56.             }
  57.             else
  58.             {
  59.                 Addy = int.Parse(tmp[0], NumberStyles.HexNumber);
  60.             }
  61.  
  62.             if (tmp.Length == 1) return Addy;
  63.             byte[] buff = new byte[4];
  64.             ReadProcessMemory(P[0].Handle, Addy, buff, 4, 0);
  65.             Addy = BitConverter.ToInt32(buff, 0);
  66.             for (int i = 1; i < tmp.Length; i++)
  67.             {
  68.                 int Off = int.Parse(tmp[i], NumberStyles.HexNumber);
  69.                 ReadProcessMemory(P[0].Handle, Addy + Off, buff, 4, 0);
  70.                 Addy = i != (tmp.Length - 1) ? BitConverter.ToInt32(buff, 0) : Addy += Off;
  71.             }
  72.             return Addy;
  73.         }
  74.        
  75.         /* Get a int from mem address */
  76.         int playerHP = ReadAddress("ffxiv", "ffxiv.exe+00F8BBE0 14 1b8 0 188 a0");
  77.         int playerCP = ReadAddress("ffxiv", "ffxiv.exe+00F8BBE0 14 1b8 0 194 a0");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement