Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ReadMemory(MADDRESS, pOffset = 0, PROGRAM = "PokeMMO Hacked.exe")
- {
- Process, wait, %PROGRAM%, 0.5
- pid = %ErrorLevel%
- if pid = 0
- {
- return
- }
- VarSetCapacity(MVALUE,4)
- ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
- DllCall("ReadProcessMemory", "UInt", ProcessHandle, "UInt", MADDRESS+pOffset, "Str", MVALUE, "Uint",4, "Uint *",0)
- DllCall("CloseHandle", "int", ProcessHandle)
- Loop 4
- result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)
- return result
- }
- DecToHex(Value)
- {
- SetFormat IntegerFast, Hex
- Value += 0
- Value .= "" ;required due to 'fast' mode
- SetFormat IntegerFast, D
- Return Value
- }
- ReadMemory_Str(MADDRESS=0, pOffset = 0, PROGRAM = "League of Legends (TM) Client", length = 0 , terminator = "")
- {
- Static OLDPROC, ProcessHandle
- VarSetCapacity(MVALUE,4,0)
- If PROGRAM != %OLDPROC%
- {
- WinGet, pid, pid, % OLDPROC := PROGRAM
- ProcessHandle := ( ProcessHandle ? 0*(closed:=DllCall("CloseHandle"
- ,"UInt",ProcessHandle)) : 0 )+(pid ? DllCall("OpenProcess"
- ,"Int",16,"Int",0,"UInt",pid) : 0) ;PID is stored in value pid
- }
- If (MADDRESS = 0) ; the above expression/syntax does my head, hence easy close handle
- closed:=DllCall("CloseHandle","UInt",ProcessHandle)
- If ( length = 0) ; read until terminator found
- {
- teststr =
- Loop
- {
- Output := "x" ; Put exactly one character in as a placeholder. used to break loop on null
- tempVar := DllCall("ReadProcessMemory", "UInt", ProcessHandle, "UInt", MADDRESS+pOffset, "str", Output, "Uint", 1, "Uint *", 0)
- if (ErrorLevel or !tempVar)
- return teststr
- if (Output = terminator)
- break
- teststr .= Output
- MADDRESS++
- }
- return, teststr
- }
- Else ; will read until X length
- {
- teststr =
- Loop % length
- {
- Output := "x" ; Put exactly one character in as a memory placeholder.
- tempVar := DllCall("ReadProcessMemory", "UInt", ProcessHandle, "UInt", MADDRESS+pOffset, "str", Output, "Uint", 1, "Uint *", 0)
- if (ErrorLevel or !tempVar)
- return teststr
- teststr .= Output
- MADDRESS++
- }
- return, teststr
- }
- }
- getProcessBaseAddress(WindowTitle, Hex=1, MatchMode=3) ;WindowTitle can be anything ahk_exe ahk_class etc
- {
- SetTitleMatchMode, %MatchMode% ;mode 3 is an exact match
- WinGet, hWnd, ID, %WindowTitle%
- ; AHK32Bit A_PtrSize = 4 | AHK64Bit - 8 bytes
- BaseAddress := DllCall(A_PtrSize = 4
- ? "GetWindowLong"
- : "GetWindowLongPtr", "Uint", hWnd, "Uint", -6)
- if Hex
- return dectohex(BaseAddress)
- else return BaseAddress
- }
Advertisement
Add Comment
Please, Sign In to add comment