Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Read and Int or Float */
- public int ReadInt(int MemoryAddress)
- {
- byte[] buffer;
- int read = ReadMem(MemoryAddress, 4, out buffer);
- if (read == 0)
- return 0;
- else
- return BitConverter.ToInt32(buffer, 0);
- }
- public float ReadFloat(int MemoryAddress)
- {
- byte[] buffer;
- int read = ReadMem(MemoryAddress, 4, out buffer);
- if (read == 0)
- return 0;
- else
- return BitConverter.ToSingle(buffer, 0);
- }
- /* Getting a mem addr w/ or w/o multilevel points */
- [DllImport("kernel32.dll")]
- public static extern bool ReadProcessMemory(IntPtr hProcess, int lpBaseAddress, byte[] buffer, int size, int lpNumberOfBytesRead);
- public static int ReadAddress(string Process_Name, string Address_Offsets)
- {
- Process[] P;
- if ((P = Process.GetProcessesByName(Process_Name)).Length == 0)
- {
- return -1;
- }
- int Addy = -1;
- while (Address_Offsets.Contains(" "))
- {
- Address_Offsets = Address_Offsets.Replace(" ", " ");
- }
- int Index = -1;
- while ((Index = Address_Offsets.IndexOf("0x", StringComparison.OrdinalIgnoreCase)) != -1)
- {
- Address_Offsets = Address_Offsets.Replace(Address_Offsets.Substring(Index, 2), "");
- }
- string[] tmp = Address_Offsets.Split(' ');
- if (tmp[0].Contains("+"))
- {
- string[] AD = tmp[0].Split('+');
- foreach (ProcessModule M in P[0].Modules)
- if (M.ModuleName.ToLower() == AD[0].ToLower())
- Addy = M.BaseAddress.ToInt32() + int.Parse(AD[1], NumberStyles.HexNumber);
- }
- else
- {
- Addy = int.Parse(tmp[0], NumberStyles.HexNumber);
- }
- if (tmp.Length == 1) return Addy;
- byte[] buff = new byte[4];
- ReadProcessMemory(P[0].Handle, Addy, buff, 4, 0);
- Addy = BitConverter.ToInt32(buff, 0);
- for (int i = 1; i < tmp.Length; i++)
- {
- int Off = int.Parse(tmp[i], NumberStyles.HexNumber);
- ReadProcessMemory(P[0].Handle, Addy + Off, buff, 4, 0);
- Addy = i != (tmp.Length - 1) ? BitConverter.ToInt32(buff, 0) : Addy += Off;
- }
- return Addy;
- }
- /* Get a int from mem address */
- int playerHP = ReadAddress("ffxiv", "ffxiv.exe+00F8BBE0 14 1b8 0 188 a0");
- int playerCP = ReadAddress("ffxiv", "ffxiv.exe+00F8BBE0 14 1b8 0 194 a0");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement