View Single Post
  #1 (permalink)  
Old 01-07-2009, 3:39 PM
Vertraag Vertraag is offline
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jan 2009
Posts: 10
Reputation: 17
Vertraag is on a distinguished programming path ahead
Default Reading a string from memory.

Hello,

I am creating a function that will read a string from another application's memory. However, the current function I have only returns a maximum of 15 characters (due to the max number of bytes being 15, apparently?):

Code:
    Public Function ReadMemory(ByVal address As String, ByVal retChars As Int32)
        Dim loc = ReadProcessMemory(processHandle, address, vBuffer(0), 15, 0)
        Dim bits() As Byte
        Dim newStr = ""

        bits = BitConverter.GetBytes(vBuffer(0))
        For x = 0 To 7
            If bits(x) >= 65 And bits(x) <= 90 Or bits(x) >= 97 And bits(x) <= 122 Or bits(x) = 32 Then
                newStr = newStr & Chr(bits(x))
            End If
        Next

        bits = BitConverter.GetBytes(vBuffer(1))
        For x = 0 To 7
            If bits(x) >= 65 And bits(x) <= 90 Or bits(x) >= 97 And bits(x) <= 122 Or bits(x) = 32 Then
                newStr = newStr & Chr(bits(x))
            End If
        Next

        Return newStr
    End Function
This is probably also a pretty "dirty" way of doing this to begin with.

Could someone please explain how I would go about reading a string of, say, 40 characters from memory?

Last edited by Vertraag; 01-08-2009 at 1:47 PM.
Reply With Quote