Sign in to follow this  
Followers 0
hendrikhe

NomadMemory.au3

39 posts in this topic

#1 ·  Posted (edited)

I put NomadMemory.au3 in my Include foulder (C:\Programme\AutoIt3\Include) but still error

C:\Programme\AutoIt3\beta\Include\NomadMemory.au3(232,41) : ERROR: $SE_PRIVILEGE_ENABLED previously declared as a 'Const'

Const $SE_PRIVILEGE_ENABLED = 0x0002

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Programme\AutoIt3\MyScripts\pointer.au3 - 1 error(s), 0 warning(s)

CODE
include <GUIConstants.au3>

#include <GUIListBox.au3>

#include <Misc.au3>

#include <Array.au3>

#include <NomadMemory.au3>

sleep(25000)

Global $Pointer=0x07F70778

Global $Offset=0x000004B4

Global $ID

Func _FindNewAddress(ByRef $P,ByRef $OSet)

$ID=_MemoryOpen(0x7F7223C)

$New_Address=_MemoryRead($P,$ID) +$OSet

_MemoryClose($ID)

Return $New_Address

EndFunc

Func _RefillMoney()

$ID=_MemoryOpen(0x7F7223C)

$Address=_FindNewAddress($Pointer,$Offset)

$MaxMoney=_MemoryRead($Address,$ID)

sleep(5000)

MsgBox(0,"Value", $MaxMoney)

_MemoryClose($ID)

EndFunc

While 1

_RefillMoney()

Sleep(1000)

WEnd

_MemoryClose($ID)

How can I fix it?

Edited by hendrikhe

Share this post


Link to post
Share on other sites



Change line 232 (Const $SE_PRIVILEGE_ENABLED = 0x0002) to

If Not IsDeclared("SE_PRIVILEGE_ENABLED") THen Const $SE_PRIVILEGE_ENABLED = 0x0002

or comment it out :D


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Thnx it works now.

I changed my code a bit and I need to know if it is right.

The game is called Rappelz but the process is Sframe.exe.

I am not sure if I am reading the right memory, cause the message box always show Value : 0

CODE
#include <GUIConstants.au3>

#include <GUIListBox.au3>

#include <Misc.au3>

#include <Array.au3>

#include <NomadMemory.au3>

sleep(5000)

Global $Pointer=0x07F607A8

Global $Offset=0x000004B4

Global $ID

Func _FindNewAddress(ByRef $P,ByRef $OSet)

$ID=_MemoryOpen(ProcessExists("SFrame.exe"))

$New_Address=_MemoryRead($P,$ID) +$OSet

_MemoryClose($ID)

Return $New_Address

EndFunc

Func _RefillMoney()

$ID=_MemoryOpen(ProcessExists("SFrame.exe"))

$Address=_FindNewAddress($Pointer,$Offset)

$MaxMoney=_MemoryRead($Address,$ID)

sleep(5000)

MsgBox(0,"Value", $MaxMoney)

_MemoryClose($ID)

EndFunc

While 1

_RefillMoney()

Sleep(1000)

WEnd

_MemoryClose($ID)

Share this post


Link to post
Share on other sites

Change line 232 (Const $SE_PRIVILEGE_ENABLED = 0x0002) to

If Not IsDeclared("SE_PRIVILEGE_ENABLED") THen Const $SE_PRIVILEGE_ENABLED = 0x0002

or comment it out :D

If Not IsDeclared("SE_PRIVILEGE_ENABLED") THen Const $SE_PRIVILEGE_ENABLED = 0x0002

I think you will find that if $SE_PRIVEGE_ENABLE is already defined then you will still get the same error.

The only way I know round it is

If Not IsDeclared("SE_PRIVILEGE_ENABLED") Then Assign("SE_PRIVILEGE_ENABLED",0x0002,2)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

And my code is correct?

Cause even trying with the currently address (without pointer) I still get Value : 0 in Message box :D

#include <GUIConstants.au3>

#include <GUIListBox.au3>

#include <Misc.au3>

#include <Array.au3>

#include <NomadMemory.au3>

$ID=_MemoryOpen(ProcessExists("SFrame.exe"))

$Address=0x0826893C

$CurrentGold=_MemoryRead($Address,$ID)

sleep(5000)

MsgBox(0,"Value", $CurrentGold)

_MemoryClose($ID)

Edited by hendrikhe

Share this post


Link to post
Share on other sites

Hai!

If i execute the following script it should display the available minerals from starcraft by a MsgBox.

Posted Image

Line 10 returns with @Error = 0, i think its works fine

Line 24's _MemoryRead should return with 64, but it is 0.

Line 25 @Error is also 0.

What's wrong with it?

(Sorry for bad english)


And sorry for bad English :P

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Can you try this, it works for me, change the process name and address accordingly :

$progname = "Memory reading"

$target_pid = ProcessExists ( "calc.exe" )
If $target_pid=0 Then 
    MsgBox (16, $progname, "Process not found !")
    Exit
EndIf

$Nomad_struct = _MemoryOpen($target_pid)
If Not @error=0 Then
    MsgBox (16, $progname, "Process could not be opened !")
    Exit
EndIf

MsgBox(4096, $progname, Hex(_MemoryRead(0x401000,$Nomad_struct)))
Edited by Inverted

Share this post


Link to post
Share on other sites

Can you try this, it works for me, change the process name and address accordingly :

$progname = "Memory reading"

$target_pid = ProcessExists ( "calc.exe" )
If $target_pid=0 Then 
    MsgBox (16, $progname, "Process not found !")
    Exit
EndIf

$Nomad_struct = _MemoryOpen($target_pid)
If Not @error=0 Then
    MsgBox (16, $progname, "Process could not be opened !")
    Exit
EndIf

MsgBox(4096, $progname, Hex(_MemoryRead(0x401000,$Nomad_struct)))
No luck :)

Memory reading: 00000000


And sorry for bad English :P

Share this post


Link to post
Share on other sites

I only get 00 if I'm reading from empty/unallocated memory. Try with a simple process like Calculator (calc.exe)

Because that code I posted is working ! Heh.

If you still can't get it to work, maybe you have an old version of the .au3 , I can post mine to be sure.

Share this post


Link to post
Share on other sites

I tried it with calc and starcraft too, it does the same result with both. Can you post your NomadMemory.au3 please?


And sorry for bad English :P

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Here is the version I use, test with this.

I can read and write to processes just fine, can't think of what could be wrong in your setup.

NomadMemory.zip

Edited by Inverted

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Nothing changed... strange. Maybe something wrong with my environment, can you post your compiled exe too, to let me check it please?

Edited by Lazarushun

And sorry for bad English :P

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

This works for me, input any process name and any address in hex :

http://www.sendspace.com/file/zoh720

(I posted something and deleted my previous post, hope you didn't download that, it wasn't working, this is)

Edited by Inverted

Share this post


Link to post
Share on other sites

Thanks. Tried it on WinXP and Vista too. The result was the same on both:

Momory reading: 00000000

Maybe some dependency missing? dll, .net framework or something blocks memory reading? I can read everything with Cheat Engine, so i don't know wtf is going on :/


And sorry for bad English :P

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

What the heck, strange. I tested it on XP and my Vista virtual machine. Are you using an antivirus or something ? AutoIt doesn't have any dependencies asaik.

Try to test on another PC if possible. Anyone reading this, test also please ! :)

Edited by Inverted

Share this post


Link to post
Share on other sites

Tried on other computer, no change. However it is contains completely the same hardwares as mine. I'll try it on a different one soon.


And sorry for bad English :P

Share this post


Link to post
Share on other sites

It would be helpful if someone else could test ... :)

You just need a memory editor or a debugger to validate the addresses/values.

Share this post


Link to post
Share on other sites

Tried on the 3rd computer, it's not working. Im going try different methods then NomadMemory.au3, i'll report back if i find a working solution :) Thanks for the help anyway!


And sorry for bad English :P

Share this post


Link to post
Share on other sites

Man... this is working.

#include <NomadMemory.au3>

$process = _MemoryOpen(ProcessExists("NG.exe"))
If @Error == 0 then
MsgBox(0,"","Successful open")
elseif @Error == 1 then
MsgBox(0,"","Invalid Process ID.")
elseif @Error == 2 then
MsgBox(0,"","Failed to open Kernel32.dll.")
elseif @Error == 3 then
MsgBox(0,"","Failed to open the specified process.")
endif

_MemoryWrite(0x00DD1FA0, $process, 50)
MsgBox(0,"","Write Error:"& @Error)

MsgBox(0,"",_MemoryRead(0x00DD1FA0, $process))
MsgBox(0,"","Read Error:"& @Error)

_MemoryClose($process)

Starcraft's memory probably locked, i tried it on a noname game and it works perfectly. :)

p.s: Your script is also good, i just tested it on an over-protected application.


And sorry for bad English :P

Share this post


Link to post
Share on other sites

You guys sure that you're using static addresses? :party:

Otherwise read up on DMA, and find some tuts on how to 'counter' it. :idea:

Otherwise, if you're using static - ie. 'green', addresses then make sure that you're using module-relative addresses rather than absolute addresses and offsets.

In other words, make sure that you're taking the allocation base of the modules into account:

Find what module the address you want to read from is located inside(such as game.exe+123), then use this function to resolve the allocation base of the module into an address:

Dim $SomeAddress = _ProcessGetModuleBase("calc.exe", "calc.exe")+123; Get the address calc.exe is allocated at and add the offset to the returned address.
; Read from $SomeAddress or something below - as long as the address you first of all specified

Func _ProcessGetModuleBase($ivPID, $svModuleName)
    $ivPID = ProcessExists($ivPID)
    If Not $ivPID Then Return(SetError(1, 0, 0)); Process does not exist
    
    Local Const $TH32CS_SNAPMODULE = 0x00000008
    Local Const $sMODULEENTRY32Struct = "dword Size;" & _
                            "dword 32ModuleID;" & _
                            "dword 32ProcessID;" & _
                            "dword GlblcntUsage;" & _
                            "dword ProccntUsage;" & _
                            "ptr modBaseAddr;" & _; <---- hmm ?
                            "dword modBaseSize;" & _
                            "hwnd hModule;" & _
                            "char Module[255];" & _
                            "char ExePath[260]"
    
    Local $hvSnapShot = DllCall("Kernel32.dll", "hwnd", "CreateToolhelp32Snapshot", "dword", $TH32CS_SNAPMODULE, "dword", $ivPID)
    If Not $hvSnapShot[0] Then Return(SetError(2, 0, 0)); Could not create snapshot?

    Local $stMODULEENTRY32 = DllStructCreate($sMODULEENTRY32Struct)
    DllStructSetData($stMODULEENTRY32, "Size", DllStructGetSize($stMODULEENTRY32))

    Local $ivState = DllCall("Kernel32.dll", "int", "Module32First", "hwnd", $hvSnapShot[0], "long_ptr", DllStructGetPtr($stMODULEENTRY32))
    If Not $ivState[0] Then Return(SetError(3, _WinAPI_CloseHandle($hvSnapShot[0]), 0)); Could not enumerate first module in list?
    Local $ivRet = 0
    Local $svModule
    
    Do
        $ivRet = DllStructGetData($stMODULEENTRY32, "modBaseAddr")
        $svModule = DllStructGetData($stMODULEENTRY32, "Module")
        If $svModule = $svModuleName Then ExitLoop
        $ivState = DllCall("Kernel32.dll", "int", "Module32Next", "hwnd", $hvSnapShot[0], "long_ptr", DllStructGetPtr($stMODULEENTRY32))
        Sleep(1)
    Until Not $ivState[0]
    
    DllCall("Kernel32.dll", "int", "CloseHandle", "int", $hvSnapShot[0])
    
    Return $ivRet
EndFunc

I hope that made sense. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0