I've never used these particular API before but I've had a quick go a a couple of untested functions based on your code and the MSDN reference.
reading a non unicode string would work like this...Code:Public Function ReadProcessBytes(ByVal hWnd As Long, ByVal Address As Long, ByVal Size As Long) As Byte() Dim pId As Long Dim pHandle As Long Dim readsz As Long Dim buf() As Byte If Address <> 0 And Size > 0 Then GetWindowThreadProcessId hWnd, pId pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pId) If pHandle Then ReDim buf(Size - 1) ReadProcessMemory pHandle, Address, buf(0), Size, readsz CloseHandle pHandle End If End If If readsz Then If readsz <> Size Then ReDim Preserve buf(readsz - 1) Else buf = vbNullString End If ReadProcessBytes = buf End Function Public Function WriteProcessBytes(ByVal hWnd As Long, ByVal Address As Long, Bytes() As Byte) As Long Dim pId As Long Dim pHandle As Long Dim writesz As Long If Address <> 0 Then GetWindowThreadProcessId hWnd, pId pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pId) If pHandle Then WriteProcessMemory pHandle, Address, Bytes(LBound(Bytes)), UBound(Bytes) - LBound(Bytes) + 1, writesz CloseHandle pHandle End If End If WriteProcessBytes = writesz End Functionhave you considered that you might be reading a pointer value?Code:Dim sTest As String sTest = StrConv(ReadProcessBytes(hWnd, Address, Size), vbUnicode)




Reply With Quote