Jump to content

Photo

Reading Double Memory


  • Please log in to reply
4 replies to this topic

#1 basanoviat Posted 28 March 2014 - 02:01 PM

basanoviat

    Soldier

  • Members
  • Pip
  • 3 posts

I have been able to successfully get most other functions working with Memory Sharp, but I am having trouble trying to read a double memory location.  

 

This is the memory variable I am using in the main form:

 

public static MemorySharp sharp;

 

Procs = Process.GetProcessesByName("notepad");
sharp = new MemorySharp(Procs.First());
 
 

 

 

This is where I am having trouble in this function in a different class:

 

        //Read Double Address
        private static double ReadDoubleMemory(IntPtr staticPointer, int[] offsetArray)
        {
            //in case of an error return just 0.0
            try
            {
                // Read the static address
                var address = Form1.sharp.Read<IntPtr>((IntPtr)staticPointer);
                
                // Find the destination address by using the offsets but the last one
                for (var i = 0; i < offsetArray.Length; i++)
                {
                    address = Form1.sharp.Read<IntPtr>(address + offsetArray[i], false);
                }
 
                return Convert.ToDouble(Form1.sharp.Read<IntPtr>(address, false));
            }
            catch (Exception) { return 0.0; }
        }
 
 
Would appreciate a point in the right direction.

  • Back to top
  • Report

#2 Hatschi Posted 29 March 2014 - 09:02 AM

Hatschi

    Soldier

  • Members
  • Pip
  • 12 posts

If you're using a 64 bit environment you must compile your project as 64 bit or will not being able to read anything out of the process (because you're reading from notepad which is a 64 bit executable on 64 bit systems...).

Could you please tell us whats the debugger says? Perhaps remove the try-catch and see where the debugger stopps and what it claims.


Edited by Hatschi, 29 March 2014 - 09:02 AM.

  • Back to top
  • Report

#3 basanoviat Posted 30 March 2014 - 06:30 PM

basanoviat

    Soldier

  • Members
  • Pip
  • 3 posts
Like I said I am already reading memory just fine. I can read int and string memory. When I try to read a double (decimal point number) it just comes out as a integer which is an incorrect value. I need to know what the syntax is to read a double from memory.
  • Back to top
  • Report

#4 basanoviat Posted 09 April 2014 - 07:23 AM

basanoviat

    Soldier

  • Members
  • Pip
  • 3 posts

bump? but there is no activity on these forums.  Still not sure how to read a double memory value from the memory using memory sharp.  i need the value to be returned as a double with a decimal value.  Going to look for another memory library if this is the case.


  • Back to top
  • Report

#5 ZenLulz Posted 26 April 2014 - 04:04 PM

ZenLulz

    Lead Developer

  • Administrators
  • 67 posts
  • LocationSwitzerland

Hey Basanoviat, wlecome on the board !

 

Sorry for the delay. Did you try to directly read the memory using the type double ?

 

Instead of

 

return Convert.ToDouble(Form1.sharp.Read<IntPtr>(address, false));

 

write

 

return Form1.sharp.Read<double>(address, false);

 

Cheers,

ZenLulz


ZenLulz

  • Back to top
  • Report




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users