using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace Game.Memory
{
class Memory
{
[DllImport("kernel32.dll")]
static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Boolean bInheritHandle, UInt32 dwProcessId);
[DllImport("kernel32.dll")]
static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress,
byte[] lpBuffer, UIntPtr nSize, uint lpNumberOfBytesWritten);
[DllImport("Kernel32.dll")]
public static extern bool ReadProcessMemory(IntPtr handle, int address, byte[] bytes, int nsize, ref int op);
[DllImport("Kernel32.dll")]
public static extern bool WriteProcessMemory(IntPtr hwind, int Address, byte[] bytes, int nsize, out int output);
[DllImport("Kernel32.dll")]
public static extern IntPtr OpenProcess(int Token, bool inheritH, int ProcID);
IntPtr Handle;
public Memory(int sprocess)
{
Process Processes = Process.GetProcessById(sprocess);
Handle = OpenProcess(0x10, false, (uint)Processes.Id);
}
public string ReadString(int address, int nsize)
{
int Outp = 0;
byte[] BytesToRead = new byte[nsize];
ReadProcessMemory(Handle, address, BytesToRead, BytesToRead.Length, ref Outp);
return System.Text.Encoding.ASCII.GetString(BytesToRead);
}
public int ReadInt(int address, int nsize)
{
int OP = 0;
byte[] BytesToRead = new byte[nsize];
ReadProcessMemory(Handle, address, BytesToRead, BytesToRead.Length, ref OP);
return BitConverter.ToInt32(BytesToRead, 0);
}
public float ReadFloat(int address, int nsize)
{
int OP = 0;
byte[] BytesToRead = new byte[nsize];
ReadProcessMemory(Handle, address, BytesToRead, BytesToRead.Length, ref OP);
return (float)BitConverter.ToSingle(BytesToRead, 0);
}
public int ReadIntPtr(int address, int[] offsets, int Size = 4)
{
int MainAddress = address;
for (int i = 0; i < offsets.Length; i++)
{
MainAddress = ReadInt(MainAddress, Size) + offsets[i];
}
return MainAddress;
}
public float ReadFloatPtr( int address, int[] offsets, int Size = 4)
{
int AddressToWriteToo = ReadIntPtr(address, offsets);
float Data = ReadFloat(AddressToWriteToo, 4);
return Data;
}
public string ReadStringPtr(int address, int[] offsets, int ExspectedLength)
{
int AddressToRead = ReadIntPtr(address, offsets);
string TheString = ReadString(AddressToRead, ExspectedLength);
return TheString;
}
}
}
Now I have some pointer with differen types. Some are texts, some are numbers.
I already did it to read my Charactername (Pointer + Offset):
Code:
int pID= 13700;
int PlayerPointer = 0x16c0c18;
int GameTimePtr = 0x16c3cbc;
int GoldAddresse = 0x16c3fdc;
Memory mem = new Memory(LoLID);
Process GameProcess = Process.GetProcessById(pID);
IntPtr BaseAddress = GameProcess.MainModule.BaseAddress;
//Name
string Name = mem.ReadStringPtr( BaseAddress.ToInt32() + PlayerPointer, new int[] { 0x20}, 10);
textBox1.Text = Name;
This works.
Also I got the healthreader working:
Code:
int MaxHealth = (int)mem.ReadFloatPtr(BaseAddress.ToInt32() + PlayerPointer, new int[] { 0x660 });
But now i have some strange problems.
The first is another pointer (Value is 1-20).
I tried to get my Level with this:
Code:
int Level = mem.ReadIntPtr(BaseAddress.ToInt32() + PlayerPointer, new int[] { 0x3C5C });
The offset is right, but I get this:
1,401298E-45
Another problem is another number pointer with 2 offsets. Tried this:
Help with reading memory with offsets from game 11/21/2013 - AutoIt - 17 Replies As title say
I have next problem, i have base pointer + adress for solitaire on windows xp 32 bit
but when i enter it in script it returns me 0, but when i start computer and reload cheat engine it shows exact values from game
here is code
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
[C#]Reading Memory / Pointer with multiple Offsets. 01/12/2013 - .NET Languages - 23 Replies I am used to coding in AutoIt. I am trying to move my project into C# but I have only about 2-3 weeks of experience.
In AutoIt, I have this code here that reads the process memory and returns a value.
$map = _MemoryRead(0x00B5CCB8, $handle) // Pointer address 0x00B5CCB8
$map = _MemoryRead($map + 0x02, $handle) // Offset 0x02
$map = _MemoryRead($map + 0xBD, $handle) // Second Offset 0xBD
I am trying desperately to convert this to C# language and I need some help. Here is what I have...
neue offsets/pointers... compilen? bwh/bot... etc. 01/20/2006 - World of Warcraft - 0 Replies hi leutz
also mein frage ist
wie und woher krieg ich die aktuellen pointers/offsets
wie baue ich das z.b in bwh ein..
oder den bot... etc.
ich hoffe ihr versteht was ich will...
wenn ich es falsch gepostet habe einfach verschieben...
da sich aber meine frage mehr auf wow bezieht denke ich mal das das hier her gehört...