HelpChange intptr to float value

Posts 18 of 8 · Page 1 of 1
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
You're using ReadInt64, use ReadFloat instead.
Quote Originally Posted by Hell_Demon View Post
You're using ReadInt64, use ReadFloat instead.
ReadInt64 is a custom function, ReadFloat doesn't exist.
Quote Originally Posted by FootLetus View Post
ReadInt64 is a custom function, ReadFloat doesn't exist.
Make your own readfloat fucktion, should be basically the same, just change the bitcoverter.tolong to ...tofloat.

Typing it on iPad, so the method names in bit converter are probably wrong
Quote Originally Posted by Silent View Post
fucktion
lmao, didn't know they were called that
Quote Originally Posted by Allura View Post
lmao, didn't know they were called that
auto-correct works when you dont want it to, and doesnt when you want it to.
One of your questions got answered above but I still see a question to answer:

"Change intptr to float value"
Tbh I don't really see a clear reason why would you change Int Pointer value into a Float as you wan't get any sensible result from it but here it is:

Code:
IntPtr input = (IntPtr)0x1234;
float output;

byte[] inputBytes = Convert.GetBytes(input);
output = Convert.ToSingle(inputBytes, 0);
Also this should be in c# section~
Why not just reference it? Unless Im wrong
Posts 18 of 8 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?