|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
rublisk19 How do I cheat? Reputation: 0
Joined: 31 Mar 2017 Posts: 2
|
Posted: Fri Mar 31, 2017 9:04 am Post subject: Memory reading |
|
|
So first of all i want to say sorry if i am posting this in wrong section.
So i found pointer which value is in float type.
Then i try to read memory with my little program, it shows me value in int(1153925120) but it should be float(1596).
so how could i manage to show it in float type value?
on cheat engine is fine because i can change type manually.
my program:
Code: |
namespace Memory
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
static string process = "game";
int[] hpOffs = new int[] { 0x11c, 0x370,0x390,0x388,0x74};
private void start_Click(object sender, EventArgs e)
{
Process[] localByName = Process.GetProcessesByName(process);
VAMemory vam = new VAMemory(process);
vam.CheckProcess();
if (localByName.Length > 0)
{
Process MYPROCESS = localByName[0];
IntPtr BaseAddress = IntPtr.Zero;
foreach (ProcessModule Module in MYPROCESS.Modules)
{
if (Module.ModuleName.Contains("game"))
BaseAddress = Module.BaseAddress;
}
if(BaseAddress != IntPtr.Zero)
{
IntPtr hpAddress = (IntPtr)vam.ReadInt32(BaseAddress+ 0x10485A4);
for(int i = 0; i < hpOffs.Length; i++)
{
hpAddress = (IntPtr)vam.ReadInt32(hpAddress + hpOffs[i]);
}
chp.Text = "HP: " + hpAddress;
}
}
}
}
} |
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Fri Mar 31, 2017 11:15 am Post subject: |
|
|
I don't usually do anything outside CE but um... don't use IntPtr for a float aka Single? Based on what little knowledge I have I'm going to assume this is C# (mostly due to the use of partial lol)... and from googling I really don't see any SinglePtr/FloatPtr like IntPtr for you to use so my only real suggestion (other than googling yourself or waiting for someone who knows more than I) is to "cast"/convert it from an int to a float
From this: https://stackoverflow.com/questions/12722840/c-sharp-unsafe-function-floatresult-vs-floatresult
It looks like you'll have to use unsafe code to achieve the right result. Or "manually" assign the value as if it was an integer using something like http://www.binaryconvert.com/convert_float.html (or just CE)... for doubles you'd need to use an Int64 type since they are 8 bytes long, not 4 like floats.
You basically want to read a float/Single for the last offset (the one that points to the value itself) instead of an int32.
|
|
Back to top |
|
|
rublisk19 How do I cheat? Reputation: 0
Joined: 31 Mar 2017 Posts: 2
|
Posted: Sat Apr 01, 2017 2:42 am Post subject: |
|
|
Hi thanks for help, i found a solution. I had to read address as a float.
If anyone interested this is my new cleaned code:
Code: |
namespace game
{
public partial class Form1 : Form
{
static string process = "game";
bool canRun = false;
int[] chpOffs = new int[] { 0x11c, 0x370,0x390,0x388,0x74};
float cHp;
VAMemory vam = new VAMemory(process);
static Process gameProcess = Process.GetProcessesByName(process).FirstOrDefault();
IntPtr baseAddress = gameProcess.MainModule.BaseAddress + 0x10485A4;
private void start_Click(object sender, EventArgs e)
{
canRun = !canRun;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (canRun)
{
for (int i = 0; i < chpOffs.Length; i++)
{
baseAddress = IntPtr.Add((IntPtr)vam.ReadInt32(baseAddress), chpOffs[i]);
}
cHp = vam.ReadFloat(baseAddress); // <-------- Solution
chp.Text = "HP: " + cHp;
}
}
}
}
|
i am using VAmemory.dll.
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|