Update:
i'm able to change the name but not read it..
i get this error (WHEN READING THE MEMORY):
Error 1 Value 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