Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


string to long error

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
x_maddog_x
How do I cheat?
Reputation: 0

Joined: 14 Feb 2017
Posts: 2

PostPosted: Tue Feb 14, 2017 9:09 am    Post subject: string to long error Reply with quote

i need help in this error:








Code:
MemoryWR.WriteLong("game.exe", 0x03338B40, I NEED PUT HEX HERE, 5);


but i need creat Pointer!
my adress is = 0x03338B40
i need read VALUE in hex mode.
for put in my code
sample:

Code:
int Point;
            Point= MemoryWR.ReadInteger("game.exe", 0x03338B40);


//this read i get DECIMAL code:
928677808
and i convert this for HEX and i get 375A7FB0

//and write mode

Code:
MemoryWR.WriteLong("game.exe", 0x03338B40, Point, 5);


This code would work if I wanted DECIMAL!
But I want to convert the decimal to hex! And put where the point is!
And when placing

Code:
Point.ToString("X8")


get error:

Error 2 Argument '3': cannot convert from 'string' to 'long'

I'm going to post the WR code of reading and writing, maybe it's simple but I'm burning my head for two days

class MemoryWR

Code:
public static void WriteLong(string EXENAME, int Address, long Value, int zSize)
        {
            checked
            {
                try
                {
                    Process[] Proc = Process.GetProcessesByName(EXENAME);
                    if (Proc.Length != 0)
                    {
                        int Bytes = 0;
                        int Handle = OpenProcess(PROCESS_ALL_ACCESS, 0, Proc[0].Id);
                        if (Handle != 0)
                        {
                            WriteProcessMemoryLong(Handle, Address, ref Value, zSize, ref Bytes);
                        }
                        CloseHandle(Handle);
                    }
                }
                catch
                { }
            }
        }

public static int ReadInteger(string EXENAME, int Address)
        {
            int Value = 0;
            checked
            {
                try
                {
                    Process[] Proc = Process.GetProcessesByName(EXENAME);
                    if (Proc.Length != 0)
                    {
                        int Bytes = 0;
                        int Handle = OpenProcess(PROCESS_ALL_ACCESS, 0, Proc[0].Id);
                        if (Handle != 0)
                        {
                            ReadProcessMemoryInteger(Handle, Address, ref Value, 4, ref Bytes);
                            CloseHandle(Handle);
                        }
                    }
                }
                catch
                { }
            }
            return Value;
        }
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Thu Mar 02, 2017 3:45 am    Post subject: Reply with quote

You are converting a numeric value to a string when you use 'ToString' calls. The code you are using is expecting numeric values, not strings. Regardless if you pass the value as decimal or hex, it will work the same. You do not need to convert it to hex first to call the function.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites