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 


VB 2010 Readopenprocess Converting Strings

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

Joined: 18 Feb 2011
Posts: 7

PostPosted: Fri Feb 18, 2011 6:27 am    Post subject: VB 2010 Readopenprocess Converting Strings Reply with quote

Hello, Im looking for a little help. I have an address that im reading a string from and trying to convert the string. Now I can manage to get only the first couple letters of the string and not the rest. Not exactly sure how to widen up the buffer a bit. Below is my code. and thanks for any help! Smile



Public Function Readmem2(ByVal Address As Integer)

Dim myProcesses As Process() = Process.GetProcessesByName("elementclient")

If myProcesses.Length = 0 Then
Status2.Text = "Process is not opened."
End
End If

Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, myProcesses(0).Id)
If myProcesses.Length = 0 Then
Status2.Text = "Can not open Process."
End
End If

ReadProcessMemory(processHandle, Address, rBuff, 4, Nothing)

CloseHandle(processHandle)

Return rBuff

End Function

Readmem2(&H63FC830)
ret = BitConverter.GetBytes(rBuff)
CharName = System.Text.Encoding.ASCII.GetString(ret).Replace("RAW", "")
Status2.Text = CharName
Back to top
View user's profile Send private message
Jesper
Grandmaster Cheater Supreme
Reputation: 9

Joined: 21 Feb 2007
Posts: 1156

PostPosted: Fri Feb 18, 2011 7:06 am    Post subject: Reply with quote

You're reading 4 bytes of memory, which is 4 characters.

Code:

Public Function Readmem2(ByVal Address As Integer, ByVal len as Integer)

Dim myProcesses As Process() = Process.GetProcessesByName("elementclient")

If myProcesses.Length = 0 Then
Status2.Text = "Process is not opened."
End
End If

Dim processHandle As IntPtr = OpenProcess(&H1F0FFF, 0, myProcesses(0).Id)
If myProcesses.Length = 0 Then
Status2.Text = "Can not open Process."
End
End If

ReadProcessMemory(processHandle, Address, rBuff, len, Nothing)

CloseHandle(processHandle)

Return rBuff

End Function


Try using that instead, and pass the length of the string you want to read.
Back to top
View user's profile Send private message
SlowPoke69
How do I cheat?
Reputation: 0

Joined: 18 Feb 2011
Posts: 7

PostPosted: Fri Feb 18, 2011 7:30 am    Post subject: Reply with quote

Okay, so I made the changes. I know my string is 6 bytes, 6 characters, and it still came back with the first 4. So for shits and giggles I put len value to 25 and the program crashed.

Here's my declare, check to see if thats defined correctly.

Private Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Fri Feb 18, 2011 1:32 pm    Post subject: This post has 1 review(s) Reply with quote

You don't need to use OpenProcess with the Process class in .NET, you are already given a handle when you locate the process. Just use myProcess.Handle instead.
_________________
- 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