Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


_MemoryPointerRead Autoit

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
insomnia215
How do I cheat?
Reputation: 0

Joined: 04 Feb 2014
Posts: 1

PostPosted: Tue Feb 04, 2014 8:27 pm    Post subject: _MemoryPointerRead Autoit Reply with quote

Ok well im trying to read a pointer to get a dynamic address to base all my memory reading off of.
Pointer: "name.bin" + 0000CB78 + 0 + 1f4 + 9c + 60C + 30
So in that saying this is what i have come up with but for some reason it always returns a wrong end address.

Code:

#RequireAdmin
#include "[Includes]\NomadMemory.au3"
$INI=@ScriptDir&"\options.ini" ;declare the INI directory
$ProcName=IniRead($INI,"GameClient","ProcName",0) ;read ini to get $ProcName = WhatEverProccess.BIN
$BaseOffset=IniRead($INI,"Offsets","BaseOffset",0) ;read ini to get $BaseOffset = 0000CB78
$Offset1=IniRead($INI,"Offsets","Offset1",0) ;read ini to get offfset 1
$Offset2=IniRead($INI,"Offsets","Offset2",0) ;read ini to get offfset 2
$Offset3=IniRead($INI,"Offsets","Offset3",0) ;read ini to get offfset 3
$Offset4=IniRead($INI,"Offsets","Offset4",0) ;read ini to get offfset 4
$Offset5=IniRead($INI,"Offsets","Offset5",0) ;read ini to get offfset 5
SetPrivilege("SeDebugPrivilege", 1)

$pid = ProcessExists($ProcName) ; Get Process Handle  TESTED WORKS GOOD
$OpenProcMemory = _MemoryOpen($pid) ; Open Process Handle  TESTED WORKS GOOD
$BaseAddress="0x"&StringRight(hex(_MemoryModuleGetBaseAddress($pid, $ProcName) + dec($BaseOffset)),8) ; Get Base Address  TESTED WORKS GOOD
$ReadBaseAddress="0x"&hex(StringRight(_MemoryRead($BaseAddress, $OpenProcMemory),8)) ; Read Base Address  TESTED WORKS GOOD





#region ~~~~~~~~~~~~~~~~~~ POINTER RETURNS WRONG ADDRESS ~~~~~~~~~~~~~~~~~~~~~~~ ; This Region Returns Wrong Addresses
local $Offsets[5] = [0, Dec(Offset1), Dec(Offset2),dec(Offset3),dec(Offset4)]; declare offsets

$PointerReadAddress = _MemoryPointerRead($ReadBaseAddress, $OpenProcMemory, $Offsets) ;Read Pointer
$Read=StringRight ( $PointerReadAddress[0], 8); Only uses last 8 digits of string "Removes uneeded 0's"
MsgBox(0,"TEST READ","Pointer Read: "&$Read,-1,"") ;Show me address of this pointer

_MemoryClose($OpenProcMemory)
#endregion ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~












;=================================================================================================
; Function:   _MemoryModuleGetBaseAddress($iPID, $sModule)
; Description:     Found this on the internets, seems to open up a DLL running within a process and
;               gets the base offset?
; Parameter(s):  $PID - process id
;               $sModule String representing the name of the DLL (not entireley sure)
; Requirement(s):   The $ah_Handle returned from _MemoryOpen.
; Return Value(s):  On Success - Returns the destination address.
;               On Failure - Returns 0.
; Author(s):        Unknown
; Note(s):      This is NOT my code, and im not even sure if its what is required
;=================================================================================================

   Func _MemoryModuleGetBaseAddress($iPID, $sModule)
   If Not ProcessExists($iPID) Then Return SetError(1, 0, 0)
   If Not IsString($sModule) Then Return SetError(2, 0, 0)
   Local   $PSAPI = DllOpen("psapi.dll")
   ;Get Process Handle

   Local   $hProcess
   Local   $PERMISSION = BitOR(0x0002, 0x0400, 0x0008, 0x0010, 0x0020) ; CREATE_THREAD, QUERY_INFORMATION, VM_OPERATION, VM_READ, VM_WRITE
   If $iPID > 0 Then
      Local $hProcess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $PERMISSION, "int", 0, "dword", $iPID)
      If $hProcess[0] Then
         $hProcess = $hProcess[0]
      EndIf
   EndIf
   ;EnumProcessModules
   Local   $Modules = DllStructCreate("ptr[1024]")
   Local   $aCall = DllCall($PSAPI, "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($Modules), "dword", DllStructGetSize($Modules), "dword*", 0)
   If $aCall[4] > 0 Then
      Local   $iModnum = $aCall[4] / 4
      Local   $aTemp
      For $i = 1 To $iModnum
         $aTemp =  DllCall($PSAPI, "dword", "GetModuleBaseNameW", "ptr", $hProcess, "ptr", Ptr(DllStructGetData($Modules, 1, $i)), "wstr", "", "dword", 260)
         If $aTemp[3] = $sModule Then
            DllClose($PSAPI)
            Return Ptr(DllStructGetData($Modules, 1, $i))
         EndIf
      Next
   EndIf
   DllClose($PSAPI)
   Return SetError(-1, 0, 0)
EndFunc
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites