Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 21:48

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

Advertisement



Reading integer from memory

Discussion on Reading integer from memory within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Dec 2012
Posts: 10
Received Thanks: 0
Reading integer from memory

i us VB and "ReadWritingMemory.VB"

WriteInteger("PurblePlace", &H5D0060, 23)
so i use this code to write an integer to an memory and in this case the value is "23"

but i cant get " ReadInteger("PurblePlace", &H5D0060, x)" to work
and in this case i wanna read the value from the address that in this case is
&H5D0060 and store the value in the integer "x"

but cant get it to work can someone help me ??

BUMP
stranded123 is offline  
Old 01/06/2013, 18:12   #2


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,902
Received Thanks: 25,407
Arrow General Coding -> .NET Languages

#moved
MrSm!th is offline  
Old 01/07/2013, 20:14   #3
 
.NoThx's Avatar
 
elite*gold: 0
Join Date: Jun 2010
Posts: 3,146
Received Thanks: 583
I dotn know so much about Vb's Read/Write Process memory, but usually u need just one argument to read from teh Memory..?
.NoThx is offline  
Thanks
1 User
Old 01/08/2013, 03:30   #4
 
»jD«'s Avatar
 
elite*gold: 237
Join Date: Sep 2010
Posts: 1,152
Received Thanks: 4,910
I never heard of any of those VB functions, but generally the way to go is importing Windows API DLLs and calling them.

EDIT: I would still use my below classes, but I think that 'x' in your ReadMemory call is an "out" parameter. Could be wrong tho...

If you have to read and write from/to a specific address that is known, then you could use something like what I generally use:

Code:
<Flags> _
Public Enum ProcessAccessFlags As UInteger
	All = &H1f0fff
	Terminate = &H1
	CreateThread = &H2
	VMOperation = &H8
	VMRead = &H10
	VMWrite = &H20
	DupHandle = &H40
	SetInformation = &H200
	QueryInformation = &H400
	Synchronize = &H100000
End Enum

<DllImport("kernel32.dll")> _
Private Shared Function OpenProcess(dwDesiredAccess As ProcessAccessFlags, <MarshalAs(UnmanagedType.Bool)> bInheritHandle As Boolean, dwProcessId As Integer) As IntPtr
End Function

<DllImport("kernel32.dll", SetLastError := True)> _
Private Shared Function WriteProcessMemory(hProcess As IntPtr, lpBaseAddress As IntPtr, lpBuffer As Byte(), nSize As UInteger, lpNumberOfBytesWritten As Integer) As Boolean
End Function

<DllImport("kernel32.dll", SetLastError := True)> _
Private Shared Function ReadProcessMemory(hProcess As IntPtr, lpBaseAddress As IntPtr, <Out> lpBuffer As Byte(), dwSize As Integer, lpNumberOfBytesRead As Integer) As Boolean
End Function

<DllImport("kernel32.dll")> _
Public Shared Function CloseHandle(hProcess As IntPtr) As Int32
End Function

Public Function ReadMemory(proc As Process, MemoryAddress As IntPtr, bytesToRead As UInteger, bytesRead As Integer) As Byte()
	Dim pointerProc As IntPtr = OpenProcess(ProcessAccessFlags.All, False, proc.Id)
	Dim buffer As Byte() = New Byte(bytesToRead - 1) {}

	Dim ptrBytesRead As IntPtr
	ReadProcessMemory(pointerProc, MemoryAddress, buffer, bytesToRead, ptrBytesRead)
	CloseHandle(pointerProc)

	bytesRead = ptrBytesRead.ToInt32()

	Return buffer
End Function

Public Sub WriteMemory(proc As Process, MemoryAddress As IntPtr, bytesToWrite As Byte(), bytesWritten As Integer)
	Dim pointerProc As IntPtr = OpenProcess(ProcessAccessFlags.All, False, proc.Id)

	Dim ptrBytesWritten As IntPtr
	WriteProcessMemory(pointerProc, MemoryAddress, bytesToWrite, CUInt(bytesToWrite.Length), ptrBytesWritten)
	CloseHandle(pointerProc)


	bytesWritten = ptrBytesWritten.ToInt32()
End Sub
You could then use it like this:

Code:
Dim proc As Process = Process.GetProcessesByName("SomeRandomProcess").FirstOrDefault()
Dim memaddr As Integer = &H1234567
Dim bytesRead As Integer
Dim value As Byte() = ReadMemory(process, address, 4, bytesRead)
Dim memoryValue As Integer = BitConverter.ToInt32(value, 0)
Hope it compiles, haven't written VB in years!!

-jD
»jD« is offline  
Thanks
1 User
Old 01/17/2013, 20:52   #5
 
elite*gold: 0
Join Date: Dec 2012
Posts: 10
Received Thanks: 0
Read Memory working VB 2008

Thx for showing intress »jD«
but did figur it ut by using a other code



the just change "target" in Module1.VB to ur exe name with out the ".exe"

if u get error in Module1.VB it can be becuse he forgot the " _" on

<DllImport("kernel32.dll", SetLastError:=True)> " _ " <----- her
Private Function CloseHandle(ByVal hObject As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function

and add to an buttom or any thing ells as an exampel

Code:
    Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  
Dim myIntValue1 As Integer = ReadMemory(Of Integer)(&HF013F8C) ' Read memory &HF013F8C
    Label1.Text = myIntValue1
    End Sub

hope this post will help someone
stranded123 is offline  
Reply


Similar Threads Similar Threads
[Vb.NET] WoW Memory Reading
11/20/2010 - World of Warcraft - 1 Replies
Hallo, Ist es irgendwie möglich mit VB.NET die Memory von WoW auszulesen wie bei C# mit der BlackMagic.dll Danke m vorraus
VB 08 Memory Reading
07/06/2010 - .NET Languages - 2 Replies
Hallo, Ich wollte in einem Spiel die HP auslesen lasse, dabei bin ich aber auf ein Problem gestoßen. Das Problem ist, das die Pointer Adresse so aussieht : "Hero.exe+".. http://www.imagebanana.com/img/o0org9ha/Problem.p ng Kann mir vllt. jmd sagen, wei ich das hinbekomme ?
C++ Memory Reading
01/02/2010 - C/C++ - 4 Replies
huhu ich wollte jetzt von Autoit auf C++ umsteigen ... nun weis ich nur leider nicht wie die befehle fürs process id und memory aulesen usw bei c++ sind :) hat da jmd ne kleine übersicht oder sowas .. wäre toll x) mfg karl
Memory reading etc.
06/18/2008 - General Coding - 11 Replies
-
VB.Net Memory Reading
11/03/2006 - .NET Languages - 0 Replies
Basically I'm doing a course in VB.Net and I'm wondering if theres anyone here who can teach me or show me how to read memory values in my project. My course does not cover this, so I'm stuck with either self-research or asking questions. If anyone can help then I'd be very grateful. PS: The target game I'll be testing on is Conquer Online 2



All times are GMT +1. The time now is 21:50.


Powered by vBulletin®
Copyright ©2000 - 2025, 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 ©2025 elitepvpers All Rights Reserved.