SomeoneHere Posted July 29, 2009 Posted July 29, 2009 (edited) i'm trying to allocate some virtual memory so i can save information to it... is there a way to do it in AutoIt such as a function that AutoIt contains or perhaps one that someone has wrote? kind of like VirtualAllocEx? Edited July 29, 2009 by SomeoneHere
Izebize Posted July 29, 2009 Posted July 29, 2009 (edited) Look for DllCall in the help file or try this. Edited July 29, 2009 by Izebize
Authenticity Posted July 29, 2009 Posted July 29, 2009 >_< heh. Read the help file, the function is _MemVirtualAllocEx() which is defined in the Memory.au3 library.
SomeoneHere Posted July 29, 2009 Author Posted July 29, 2009 heh. Read the help file, the function is _MemVirtualAllocEx() which is defined in the Memory.au3 library.thanks, exactly what i was looking for *ignores Izebize's ego* >_<
SomeoneHere Posted July 29, 2009 Author Posted July 29, 2009 (edited) alright, so i'm having trouble... no matter what i do, i always get 0x00000000 returned as the allocated memory's address... i tried setting $pAddress to both 0 and -1 (to have hopefully have it choose for me like VirtualAllocEx()) but nothing >_< ... #include "NomadMemory.au3" #Include <Memory.au3> Opt("WinTitleMatchMode", 2) While 1 If WinActive("Conquer") == 1 Then ;check if CO is the active window $PID = WinGetProcess("[ACTIVE]", "") $MemID = _MemoryOpen($PID) $baseAddrs = _MemVirtualAllocEx($MemID,0x00800000,128,$MEM_COMMIT,$PAGE_EXECUTE_READWRITE) _MemoryWrite($baseAddrs, $MemID, 0x1a7f8ae8) MsgBox(0,"",$baseAddrs) MsgBox(0,"","0x" & hex(_MemoryRead($MemID,$baseAddrs),8)) EndIf WEnd this is NomadMemory.au3 http://pastebin.com/mb725101 Edited July 29, 2009 by SomeoneHere
Authenticity Posted July 29, 2009 Posted July 29, 2009 _MemoryOpen() returns an array type, but the _MemVirtualAllocEx() expects a handle. If the call to _MemoryOpen() was successful then the handle is stored in $MemID[1]. Read the description of each function (even the UDF's which are not part of the AutoIt native UDF) before you're using it.
SomeoneHere Posted July 29, 2009 Author Posted July 29, 2009 (edited) _MemoryOpen() returns an array type, but the _MemVirtualAllocEx() expects a handle. If the call to _MemoryOpen() was successful then the handle is stored in $MemID[1]. Read the description of each function (even the UDF's which are not part of the AutoIt native UDF) before you're using it. thank you for the explanation id rather much prefer a "this is what your doing wrong" then "this is what you have to do", that explains y i could never get anything from MsgBox(0,"",$MemID)... i should of done MsgBox(0,"",$MemID[1])... but anyway i changed it, and i still get the same results... also... if i leave $pAddress at 0, will it allocate the memory to a region for me? lpAddress [in, optional] The pointer that specifies a desired starting address for the region of pages that you want to allocate. If you are reserving memory, the function rounds this address down to the nearest multiple of the allocation granularity. If you are committing memory that is already reserved, the function rounds this address down to the nearest page boundary. To determine the size of a page and the allocation granularity on the host computer, use the GetSystemInfo function. If lpAddress is NULL, the function determines where to allocate the region. this is my code now, and i'm still getting the same results . . . both MsgBoxes give me 0x00000000 #include <NomadMemory.au3> #Include <Memory.au3> Opt("WinTitleMatchMode", 2) While 1 If WinActive("Conquer") == 1 Then ;check if CO is the active window $PID = WinGetProcess("[ACTIVE]", "") $MemID = _MemoryOpen($PID) $baseAddrs = _MemVirtualAllocEx($MemID[1],0x00800000,128,$MEM_COMMIT,$PAGE_EXECUTE_READWRITE) _MemoryWrite($baseAddrs, $MemID, 0x1a7f8ae8) MsgBox(0,"",$baseAddrs) MsgBox(0,"","0x" & hex(_MemoryRead($MemID,$baseAddrs),8)) EndIf WEnd Edited July 29, 2009 by SomeoneHere
Authenticity Posted July 29, 2009 Posted July 29, 2009 #include <NomadMemory.au3> #Include <Memory.au3> Opt("WinTitleMatchMode", 2) While 1 If WinActive("Conquer") == 1 Then ;check if CO is the active window $PID = WinGetProcess("[ACTIVE]", "") $MemID = _MemoryOpen($PID) $baseAddrs = _MemVirtualAllocEx($MemID[1],0,128,BitOR($MEM_COMMIT, $MEM_RESERVE),$PAGE_EXECUTE_READWRITE) _MemoryWrite($baseAddrs, $MemID, 0x1a7f8ae8) ; MsgBox(0,"",$baseAddrs) Array type not supported by this function. Read the function description. MsgBox(0,"","0x" & hex(_MemoryRead($MemID,$baseAddrs),8)) EndIf WEnd If you won't read the documentation you'll never get the idea. Try to spend a few minutes to see how a function should be invoked. Sorry for boring topic. >_<
SomeoneHere Posted July 29, 2009 Author Posted July 29, 2009 (edited) #include <NomadMemory.au3> #Include <Memory.au3> Opt("WinTitleMatchMode", 2) While 1 If WinActive("Conquer") == 1 Then ;check if CO is the active window $PID = WinGetProcess("[ACTIVE]", "") $MemID = _MemoryOpen($PID) $baseAddrs = _MemVirtualAllocEx($MemID[1],0,128,BitOR($MEM_COMMIT, $MEM_RESERVE),$PAGE_EXECUTE_READWRITE) _MemoryWrite($baseAddrs, $MemID, 0x1a7f8ae8) ; MsgBox(0,"",$baseAddrs) Array type not supported by this function. Read the function description. MsgBox(0,"","0x" & hex(_MemoryRead($MemID,$baseAddrs),8)) EndIf WEnd If you won't read the documentation you'll never get the idea. Try to spend a few minutes to see how a function should be invoked. Sorry for boring topic. >_< i've read it already . . . and i was right . . . but for some reason it wasn't working... idk, i rewrote it all (cuz i realized i would of continuously be allocating memory) and this is what i have, and it works fine now ty #include <NomadMemory.au3> #Include <Memory.au3> HotKeySet("x", "Allocate") Opt("WinTitleMatchMode", 2) $baseAddrs = 0 While 1 ToolTip($baseAddrs,10,10) sleep(500) WEnd Func Allocate() If WinActive("Conquer") == 1 Then ;check if CO is the active window $PID = WinGetProcess("[ACTIVE]", "") $MemID = _MemoryOpen($PID) $baseAddrs = _MemVirtualAllocEx($MemID[1],0,128,$MEM_COMMIT,$PAGE_EXECUTE_READWRITE) _MemoryWrite($baseAddrs, $MemID, 0x1a7f8ae8) EndIf EndFunc Edited July 29, 2009 by SomeoneHere
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now