SolvedReadProcessMemory Win 7

Posts 1–5 of 5 · Page 1 of 1
ReadProcessMemory Win 7
Hey I am making a teleporter for Terraria and I have all what I need in Cheat Engine, but I ran into a problem when I started coding the actual program.
I copied the code I needed from an old trainer I made on Win XP.
The code works fine on XP, but not on 7, and after a lot of thinking and looking I've found out that its because ReadProcessMemory doesn't work on 7.
I know the code works, because I read an address from notepad on xp to be sure.

Does anyone know why it doesn't work on Win 7?

Code:
Private Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
    

    Public Function ReadLong(ByVal Address As Integer, ByVal Bytes As Integer)
        Dim BlackOpsLookUp As Process() = Process.GetProcessesByName("notepad")
        If BlackOpsLookUp.Length = 0 Then
            MsgBox("Terraria was not found", MsgBoxStyle.Information, "M-efti's Trainer - Error")
            Return Nothing
            Exit Function
        End If
        Dim processHandle As IntPtr = KGCDGTJAWN(&H1F0FFF, 0, BlackOpsLookUp(0).Id)
        ReadProcessMemory(processHandle, Address, GWXUSXTOUE, Bytes, Nothing)
        Return GWXUSXTOUE
        EFJKPZAUQL(processHandle)
    End Function
I initially got the function from PheNix's Undetected Module Maker, but I made some changes to it a long time ago, and thats probably why there is a problem.

I have another piece of code with the exact same problem:

Code:
Private Declare Function ReadProcessMemory Lib "KERNEL32" (ByVal Handle As Int32, ByVal address As Int32, ByRef Value As Int32, Optional ByVal Size As Int32 = 4, Optional ByVal lpNumberOfBytesWritten As Int64 = 0) As Long

Public Function ReadByte(ByVal address As Int32) As Integer
        Dim value As Integer
        ReadProcessMemory(pHandle, address, value, 1, 0)
        Return value
    End Function
Well.. I don't know much in this category, but all I can say is, this code here - Private Declare Function ReadProcessMemory Lib "KERNEL32" (ByVal Handle As Int32, ByVal address As Int32, ByRef Value As Int32, Optional ByVal Size As Int32 = 4, Optional ByVal lpNumberOfBytesWritten As Int64 = 0) As Long - probably doesn't work with win7. Just like how the SendKeys don't work properly unless you have the right declaring code for win7.
Make sure you're compiling as x86, not AnyCPU, otherwise the debugging functions may run into issues. Also, try to avoid using PROCESS_ALL_ACCESS (&H1F0FFF) when calling OpenProcess. &H43A should work for most read/write/query/execute operations.
Quote Originally Posted by Jason View Post
Make sure you're compiling as x86, not AnyCPU, otherwise the debugging functions may run into issues. Also, try to avoid using PROCESS_ALL_ACCESS (&H1F0FFF) when calling OpenProcess. &H43A should work for most read/write/query/execute operations.
Changing the target platform to x86 made it work
Solved
Not sure if you noticed this in your code but
Dim BlackOpsLookUp As Process() = Process.GetProcessesByName("notepad")
You did change this right?
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?