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 


c# reading bytes

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
noxrawr
Newbie cheater
Reputation: 0

Joined: 15 Oct 2010
Posts: 13
Location: Netherlands

PostPosted: Fri Oct 15, 2010 10:31 am    Post subject: c# reading bytes Reply with quote

Hello folks,

I have found a particular adress I was looking for, however the same adress consists of 1 byte and 4 bytes both with different values.

replace the ** with tt, cant posts urls yet on this forum Sad
h**p://img140.imageshack.us/f/memreading.jpg/

Now I want to display the value of the 4 bytes in my own written application, heres a piece of code:

pReader.ReadProcess = myProcesses[0];
pReader.OpenProcess();
int myhp = 0x0EA902D4;
int bytesRead;
int gethp;
byte[] hp;
hp = pReader.ReadProcessMemory((IntPtr)myhp, 1, out bytesRead);
gethp = hp[0];
label1.Text = gethp.ToString();

currently it returns 113, but I want it to return 625, what should I adjust in this code to achieve this?

Thanks in advance.
Regards
Back to top
View user's profile Send private message
Deltron Z
Expert Cheater
Reputation: 1

Joined: 14 Jun 2009
Posts: 164

PostPosted: Fri Oct 15, 2010 10:54 am    Post subject: Reply with quote

Use BitConvertert methods to convert byte array to another type.
Back to top
View user's profile Send private message
noxrawr
Newbie cheater
Reputation: 0

Joined: 15 Oct 2010
Posts: 13
Location: Netherlands

PostPosted: Fri Oct 15, 2010 10:58 am    Post subject: Reply with quote

Could you please give an example?

Cheers.

EDIT:

I tried this but it gave me an exception:
int i = BitConverter.ToInt32(hp, 0);
label1.Text = i.ToString() + " bytes" + bytesRead.ToString();
Back to top
View user's profile Send private message
Deltron Z
Expert Cheater
Reputation: 1

Joined: 14 Jun 2009
Posts: 164

PostPosted: Fri Oct 15, 2010 12:34 pm    Post subject: Reply with quote

Notice that you've been reading only 1 byte. read 2 and convert to Int16 or read 4 and read Int32.
Back to top
View user's profile Send private message
noxrawr
Newbie cheater
Reputation: 0

Joined: 15 Oct 2010
Posts: 13
Location: Netherlands

PostPosted: Fri Oct 15, 2010 1:45 pm    Post subject: Reply with quote

Im really sorry for asking this but how do I read 2 or 4 bytes? I am very new to this Sad
Back to top
View user's profile Send private message
Jesper
Grandmaster Cheater Supreme
Reputation: 9

Joined: 21 Feb 2007
Posts: 1156

PostPosted: Fri Oct 15, 2010 1:48 pm    Post subject: Reply with quote

Do you have teamviewer?
Back to top
View user's profile Send private message
Deltron Z
Expert Cheater
Reputation: 1

Joined: 14 Jun 2009
Posts: 164

PostPosted: Fri Oct 15, 2010 1:55 pm    Post subject: Reply with quote

SwallowIt wrote:
Do you have teamviewer?

No need to spoon feed him.

Look at the ReadProcessMemory function, one of the parameters is the number of bytes to read - if you look at your code, you'll see it's set to 1. change it to 4 or whatever you want.
Anyway, I suggest you to first learn the language properly, start from the basics - variables, loops, functions and only after a while, when you master the language, try doing a little more complicated things, instead of getting confused from learning how to read memory, basics of hacking, data types and representations in memory, language syntax and functions - it's too much to do at once. take one step at a time.
Back to top
View user's profile Send private message
Jesper
Grandmaster Cheater Supreme
Reputation: 9

Joined: 21 Feb 2007
Posts: 1156

PostPosted: Fri Oct 15, 2010 1:59 pm    Post subject: Reply with quote

I don't intend to spoonfeed him, I'm simply bored and I enjoy programming.
Back to top
View user's profile Send private message
noxrawr
Newbie cheater
Reputation: 0

Joined: 15 Oct 2010
Posts: 13
Location: Netherlands

PostPosted: Fri Oct 15, 2010 2:18 pm    Post subject: Reply with quote

I have managed to make it work
Thanks to all who contributed <3
Back to top
View user's profile Send private message
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