本文介绍了需要帮助[readwritingmemory]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:

我可以更改名称但不能读取它..



i得到此错误(在阅读时MEMORY):

错误1'字节的1维数组'类型的值无法转换为'字符串'。



我尝试过:



Update:
i'm able to change the name but not read it..

i get this error (WHEN READING THE MEMORY):
Error1Value of type '1-dimensional array of Byte' cannot be converted to 'String'.

What I have tried:

Public Shared Function ReadMemory(Of T)(ByVal address As Integer) As T
        Return MemoryModule.ReadMemory(Of T)(address, 0, False)
    End Function

    Public Shared Function ReadMemory(ByVal address As Integer, ByVal length As Integer) As Byte()
        Return MemoryModule.ReadMemory(Of Byte())(address, length, False)
    End Function

    Public Shared Function ReadMemory(Of T)(ByVal address As Integer, ByVal value As Object, ByVal unicodeString As Boolean)
        Dim buffer As Byte()
        If (GetType(T) Is GetType(String)) Then
            If unicodeString Then
                buffer = Encoding.Unicode.GetBytes(value.ToString)
            Else
                buffer = Encoding.ASCII.GetBytes(value.ToString)
            End If
        ElseIf (GetType(T) Is GetType(Byte())) Then
            buffer = Encoding.Unicode.GetBytes(value.ToString)
        Else
            buffer = Encoding.ASCII.GetBytes(value.ToString)
        End If
        If Not MemoryModule.UpdateProcessHandle Then
            Return CType(Nothing, T)
        End If
        Dim lpBaseAddress As New IntPtr(address)
        Dim dwSize As New IntPtr(buffer.Length)
        If Not MemoryModule.ReadProcessMemory(MemoryModule.ProcessHandle, lpBaseAddress, buffer, dwSize, IntPtr.Zero) Then
            Return CType(Nothing, T)
        End If
        If (GetType(T) Is GetType(Byte())) Then
            Return Conversions.ToGenericParameter(Of T)(buffer)
        End If
        Dim handle As GCHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned)
        Dim local2 As T = Conversions.ToGenericParameter(Of T)(RuntimeHelpers.GetObjectValue(Marshal.PtrToStructure(handle.AddrOfPinnedObject, GetType(T))))
        handle.Free()
        Return local2
    End Function

    Public Shared Function WriteMemory(ByVal address As Integer, ByVal value As Object, ByVal [unicode] As Boolean) As Boolean
        Dim bytes As Byte()
        If Not MemoryModule.UpdateProcessHandle Then
            Return False
        End If
        If TypeOf value Is String Then
            If [unicode] Then
                bytes = Encoding.Unicode.GetBytes(value.ToString)
            Else
                bytes = Encoding.ASCII.GetBytes(value.ToString)
            End If
        Else
            bytes = MemoryModule.GetObjectBytes(RuntimeHelpers.GetObjectValue(value))
        End If
        Dim lpBaseAddress As New IntPtr(address)
        Dim nSize As New IntPtr(bytes.Length)
        Return MemoryModule.WriteProcessMemory(MemoryModule.ProcessHandle, lpBaseAddress, bytes, nSize, IntPtr.Zero)
    End Function

 Public Shared Function WriteMemory(ByVal address As Integer, ByVal value As Object) As Boolean
        Return MemoryModule.WriteMemory(address, RuntimeHelpers.GetObjectValue(value), False)
    End Function







And when trying to read the memory with that (HERE I GET THE ERROR)
Label2.Text = MemoryModule.ReadMemory(&H234BFD4, AscW((ChrW(0))))







and this is how i write memory:
MemoryModule.WriteMemory(&H234BFD4, (CrystalClearTextBox9.Text & ChrW(0)), False)
the write one is working fine

推荐答案

Label2.Text = System.Text.Encoding.Unicode.GetString(MemoryModule.ReadMemory(&H234BFD4, AscW((ChrW(0)))))


这篇关于需要帮助[readwritingmemory]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 15:44