Change intptr to float value
Hi,
I'm reading a pointer to get the Y coordinate of the player in a game, it works but returns as an INTPTR in a long ass 8 bytes. I want to make the value readable so I tried to convert it into a FLOAT, but can't seem to do that. Here's the code I'm using right now.
Code:
private void update_Click(object sender, EventArgs e)
{
ProcessMemory Mem = new ProcessMemory("--");
if (!Mem.CheckProcess())
{
info_Y.Text = "Make sure your application is running or try running this as Admin";
}
else
{
Mem.StartProcess();
}
String process = "--";
IntPtr[] offsets = { (IntPtr)0x4D19008 };
IntPtr value = readPtr(process, offsets, true);
info_Y.Text = "Final Value is " + value; -------------------------------------------------------- I want to turn this value into a FLOAT, or something readable
}
static IntPtr readPtr(string pname, IntPtr[] offsets, bool debug = false, string module = null)
{
IntPtr tmpptr = (IntPtr)0;
Process handle = Process.GetProcessesByName(pname)[0];
IntPtr Base = getBase(handle);
Console.WriteLine("Original base: " + Base);
if (module != null)
{
Base = getBase(handle, module);
Console.WriteLine("Module base: " + Base);
Console.WriteLine("");
}
for (int i = 0; i <= offsets.Length - 1; i++)
{
if (i == 0)
{
if (debug)
Console.Write(Base + "[Base] + " + offsets[i] + "[OFFSET 0]");
IntPtr ptr = IntPtr.Add(Base, (int)offsets[i]);
tmpptr = (IntPtr)ReadInt64(ptr, 8, handle.Handle);
if (debug)
Console.WriteLine(" is " + tmpptr);
}
else
{
if (debug)
Console.Write(tmpptr + " + " + offsets[i] + "[OFFSET " + i + "]");
IntPtr ptr2 = IntPtr.Add(tmpptr, (int)offsets[i]);
tmpptr = (IntPtr)ReadInt64(ptr2, 8, handle.Handle);
if (debug)
Console.WriteLine(" is " + tmpptr);
}
}
return tmpptr;
}
How can I turn the intptr into something readable, in cheat engine I can change the type to float and it'll return something like; 490.934967