Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 14:22

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Question] VB.Net and process memory

Discussion on [Question] VB.Net and process memory within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2006
Posts: 136
Received Thanks: 15
[Question] VB.Net and process memory

Hello, Im having some trouble with read/write process Memory and Im hoping someone here could help me out a little.

Code:

Code:
        Dim iMoneyAddress As Integer
        iMoneyAddress = 90720324
        Dim Reader As New MemReader.ProcessMemoryReader()
        Dim MyProcs As System.Diagnostics.Process() = System.Diagnostics.Process.GetProcessesByName("Conquer")

        If MyProcs.Length = 0 Then
            MessageBox.Show("No Conquer Client found!")
            Return
        End If
        Reader.ReadProcess = MyProcs(0)
        Reader.OpenProcess()
        Dim bytesRead As Integer
        Dim Memory As Byte()
        Dim iMoney As Integer

        Memory = Reader.ReadProcessMemory(iMoneyAddress, 1, bytesRead)
        iMoney = Memory(0)
        txtMoney.Text = iMoney.ToString()
now there must be something wrong with my code because it is supposed to read the memory address 90720324 (&H56BE7C) *tried both but both didnt succeed..*

So if anyone could provide me some help or a working sample in VB.Net it would be very appreciated

P.S dont look at my sloppy coding and if need further info just ask, the class just contains the declarations and such
purplehaze is offline  
Old 07/27/2008, 23:28   #2
 
link's Avatar
 
elite*gold: 1
Join Date: Jul 2005
Posts: 553
Received Thanks: 451
56BE7C => 5684860
5684844 => 90720324

56BE7C => 90720324?


Dim Memory As Byte()
|| Label for a Row of Bytes in Memory

Dim iMoney As Integer
|| Label for 4 Bytes in Memory

ReadProcessMemory(iMoneyAddress, 1, bytesRead)
|| Read 1 Byte at iMoneyAddress

iMoney = Memory(0)
|| mov al, [Memory]
|| mov BYTE ptr [iMoney], al
||
|| iMoney gets the first Byte at Address of Memory


1 BYTE = FF = 255
2 BYTE = FFFF = 65535
3 BYTE = FFFFFF = 16777215
4 BYTE = FFFFFFFF = 4294967295


Money : 288901 Currency
In Hex: 46885
First Byte: 133


1. Read more Bytes
2. Allocate more Bytes of Memory to iMoney
link is offline  
Old 07/28/2008, 00:45   #3
 
elite*gold: 0
Join Date: Feb 2006
Posts: 136
Received Thanks: 15
Quote:
Originally Posted by link View Post
56BE7C => 5684860
5684844 => 90720324

56BE7C => 90720324?


Dim Memory As Byte()
|| Label for a Row of Bytes in Memory

Dim iMoney As Integer
|| Label for 4 Bytes in Memory

ReadProcessMemory(iMoneyAddress, 1, bytesRead)
|| Read 1 Byte at iMoneyAddress

iMoney = Memory(0)
|| mov al, [Memory]
|| mov BYTE ptr [iMoney], al
||
|| iMoney gets the first Byte at Address of Memory


1 BYTE = FF = 255
2 BYTE = FFFF = 65535
3 BYTE = FFFFFF = 16777215
4 BYTE = FFFFFFFF = 4294967295


Money : 288901 Currency
In Hex: 46885
First Byte: 133


1. Read more Bytes
2. Allocate more Bytes of Memory to iMoney
I appreciate your help a lot, but I dont really understand it.
This table and such only confused me more.
Could you maybe explain it easier, i have no experience with Memory reading but im trying

This is what i understand I need to read 4 bytes apparently im reading 1 so how do I read 4? because changing that 1 to 4 doesnt work lol.
If you have the time please explain it
And if you have a code sample for VB.Net that would help me a lot!

Im really stuck at this for days lol

edit:

Is this what you meant:

Memory = Reader.ReadProcessMemory(iMoneyAddress, 4, bytesRead)
iMoney = Memory(0)
iMoney = Memory(1)
iMoney = Memory(2)
iMoney = Memory(3)

That returns a value of 255 so making progress here lol not quite right yet tho
purplehaze is offline  
Old 07/28/2008, 02:30   #4
 
link's Avatar
 
elite*gold: 1
Join Date: Jul 2005
Posts: 553
Received Thanks: 451
Quote:
56BE7C => 5684860
5684844 => 90720324

56BE7C => 90720324?
"address 90720324 (&H56BE7C) *tried both but both didnt succeed..*"
90720324 is not 56BE7C in hexa.

Quote:
Dim Memory As Byte()
|| Label for a Row of Bytes in Memory

Dim iMoney As Integer
|| Label for 4 Bytes in Memory

ReadProcessMemory(iMoneyAddress, 1, bytesRead)
|| Read 1 Byte at iMoneyAddress

iMoney = Memory(0)
|| mov al, [Memory]
|| mov BYTE ptr [iMoney], al
||
|| iMoney gets the first Byte at Address of Memory


1 BYTE = FF = 255
2 BYTE = FFFF = 65535
3 BYTE = FFFFFF = 16777215
4 BYTE = FFFFFFFF = 4294967295


Money : 288901 Currency
In Hex: 46885
First Byte: 133
Explanation of your mistake.


Quote:
1. Read more Bytes
2. Allocate more Bytes of Memory to iMoney
Solution.


Try to read 4 Bytes (I don't know if the money requires 4, 2 or 8 Bytes, try it yourself [288901 are 3 Bytes]) and parse Memory to 32bit (4 Bytes) Value.
link is offline  
Old 07/28/2008, 03:20   #5
 
elite*gold: 0
Join Date: Feb 2006
Posts: 136
Received Thanks: 15
Quote:
Originally Posted by link View Post
"address 90720324 (&H56BE7C) *tried both but both didnt succeed..*"
90720324 is not 56BE7C in hexa.


Explanation of your mistake.



Solution.


Try to read 4 Bytes (I don't know if the money requires 4, 2 or 8 Bytes, try it yourself [288901 are 3 Bytes]) and parse Memory to 32bit (4 Bytes) Value.
I think this is too deep for me, because i have absolutely no clue what you just said lol, so if i get this straight depending on the amount of money u have the amounts of bytes change, that i didnt know!
so if i have 1 mill money with me thats still 3? or 4?
See now im even more confused lol.
All i want is to retrieve a value from a specific address and well it will always change i mean you get more money and less, you get the point its not really something i can "set" so no matter how many.
And parsing memory to 4 bytes I have no clue how to do that, i got experience with VB.Net just not with this whole memory thing.

I just cant believe reading a value is this difficult to understand for me, it sounds so easy.
I dont want to give up on this and i really need some code example, I googled for forever and all i find is for VB6 and C# just not a complete sample for vb.net

About the 2 values, must have copied wrong 1 from ini file
All values stored in a ini file so when i can read a value i can experiment with more just need the base of this to work

I changed my code to this:
Code:
        Dim iMoneyAddress As Integer
        iMoneyAddress = 90720324
        Dim Reader As New ProcessMemoryReader()
        Dim MyProcs As System.Diagnostics.Process() = System.Diagnostics.Process.GetProcessesByName("Conquer")

        If MyProcs.Length = 0 Then
            MessageBox.Show("No Conquer Client found!")
            Return
        End If
        Reader.ReadProcess = MyProcs(0)
        Reader.OpenProcess()
        Dim bytesRead As Integer
        Dim Memory As Byte()
        Dim iMoney As Integer

        Memory = Reader.ReadProcessMemory(iMoneyAddress, 4, 4, bytesRead)
        iMoney = Memory(0)

        For i = 0 To Memory.Length - 1
            txtMoney.Text += Memory(i).ToString
        Next
But still not receiving the value i should get
I also changed my function for ReadProcessMemory for the size of the bytes
wich i have set to 4 :
Memory = Reader.ReadProcessMemory(iMoneyAddress, 4, 4, bytesRead)

Anyway thanks again for your help sorry im a pain in the ass, but i just dont get it lol
purplehaze is offline  
Old 07/28/2008, 14:33   #6
 
link's Avatar
 
elite*gold: 1
Join Date: Jul 2005
Posts: 553
Received Thanks: 451
4 Byte/32bit : 00000000 00000000 00000000 00000000

288901 : 00000000 00000100 01101000 10000101 (Since 3 is not a power of 2, it's 4 Byte)

Reading the first Byte/eight Bit : 10000101

Reading the next Bytes : 01101000, then 00000100

x (4 Byte) : 100b

x << 8

[x = 100 00000000b]

x (in first Byte) : 1101000b

x << 8

[x = 100 01101000 00000000b]

x (in first Byte) : 10000101b

[x = 100 01101000 10000101b]


Code:
	mov pp, 100b
	shl pp, 8
	mov BYTE ptr [pp], 1101000b
	shl pp, 8
	mov BYTE ptr [pp], 10000101b
Or with direct Memory Access:

Code:
	mov BYTE ptr [pp], 10000101b
	mov BYTE ptr [pp + 1], 1101000b
	mov BYTE ptr [pp + 2], 100b
You have to know, how to access directly the Bytes in VB :-)

Visualization:
Reversed in Memory, Value 288901 : 10000101 01101000 00000100 00000000

ReadProcessMemory, 4 Bytes.

Memory[0] = 10000101

Memory[1] = 01101000

Memory[3] = 00000100

Memory[4] = 00000000

Now put these Bytes with the principle FIFO in iMoney (Memory[0] in first Byte of iMoney, Memory[1] in second, etc.).
link is offline  
Reply


Similar Threads Similar Threads
write memory process problem
10/28/2009 - General Coding - 3 Replies
Hey Leute Habe mir ebem mal das tut von Blackfog angeschaut. Verstehe es auch, bloss will mein compi nich so wie ich will XD habe es au scho mit copy and paste versucht, das ding macht einfach nix
Need a process/memory search tool
09/10/2008 - CO2 Programming - 1 Replies
Hi, I need a good program (full version ofcourse) for digging up the memory addresses to use in CO bots. Plz help. ty.
C# Write process memory
08/16/2008 - CO2 Programming - 6 Replies
ok so i have a question about how do i use the api function writeprocessmemory in C#, i already have readprocessmemory but i can't seem to get writeprocessmemory... so if anyone could show me the call and an example (preferably a pinball example) it would be very helpful :) heres what i have so far: //================================================ ==============================================// // Function: MemoryOpen(int ProcessID])) // ...
Getting info from Game Process Memory
04/13/2006 - General Coding - 8 Replies
Any of you coders here could help me out? From my program, I'm trying to retrieve/get the SERVER_NAME of the memory of the game. Ex, Conquer-online's Conquer.exe ReadProcessMemory() could help, but still it confuses me. Anybody can share detailed info about this?
Read Process memory in Conquer.exe
04/13/2006 - Conquer Online 2 - 6 Replies
Any of you coders here could help me out? From my program, I'm trying to retrieve/get the SERVER_NAME of the memory of the game. Ex, Conquer-online's Conquer.exe ReadProcessMemory() could help, but still it confuses me. Anybody can share detailed info about this?



All times are GMT +2. The time now is 14:22.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.