Question Reading a string from memory.

Vertraag

Member
Joined
Jan 1, 2009
Messages
10
Programming Experience
3-5
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?):

VB.NET:
    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:
Back
Top