Is there any better way to monitor memory address?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Is there any better way to monitor memory address?

11 Mar 2019, 21:31

My software monitors 20 memory addresses and reacts when none of them contains any of the pre-defined numbers, right now I'm using something like this:

Code: Select all

answer1 := 1
answer2 := 2
answer3 := 3
values := []
Loop
{
	Loop, 20
		values[a_index] := Readmemory(Addresses[a_index])
	Loop, 3
	{
		temp:=0
		Loop, 20
		{
			if (values[a_index]<>answer%a_index%)
				temp++
		}
		if temp=20
			gosub react
	}
	sleep, 10
}

ReadMemory(MADDRESS)
{
	global
	local MVALUE
	VarSetCapacity(MVALUE,4,0)
	DllCall("ReadProcessMemory", "Uint", ProcessHandle, "Uint", MADDRESS, "str" , MVALUE, "Uint", 4, "Uint*", 0)
	return *(&MVALUE+3)<<24 | *(&MVALUE+2)<<16 | *(&MVALUE+1)<<8 | *(&MVALUE)
}
Is there a better/faster/less consuming way to achieve this? Is this the correct way to do it?

Thanks in advance!

@edit: fixed some typos.
User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: Is there any better way to monitor memory address?

11 Mar 2019, 21:43

use this

Code: Select all

ReadMemory(MADDRESS,PROGRAM)
{
   Process, wait, %PROGRAM%, 0.5
   pid = %ErrorLevel%
   if pid = 0
   {
      MsgBox The specified process could not be found.
      return
   }

   VarSetCapacity(MVALUE,4,0)
   ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "Uint")
   DllCall("ReadProcessMemory","UInt",ProcessHandle,"Uint",MADDRESS,"Str",MVALUE,"UInt",4,"str P",0)

   Loop 4
   result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)

   DllCall("CloseHandle", "int", ProcessHandle)
   
   return, result 
}
:wave: There is always more than one way to solve a problem. ;)
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Is there any better way to monitor memory address?

11 Mar 2019, 21:45

YoucefHam wrote:
11 Mar 2019, 21:43
use this

Code: Select all

ReadMemory(MADDRESS,PROGRAM)
{
   Process, wait, %PROGRAM%, 0.5
   pid = %ErrorLevel%
   if pid = 0
   {
      MsgBox The specified process could not be found.
      return
   }

   VarSetCapacity(MVALUE,4,0)
   ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "Uint")
   DllCall("ReadProcessMemory","UInt",ProcessHandle,"Uint",MADDRESS,"Str",MVALUE,"UInt",4,"str P",0)

   Loop 4
   result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)

   DllCall("CloseHandle", "int", ProcessHandle)
   
   return, result 
}
Why use that instead of what I used? Is it faster, better? Also why would I close the handle if I'm always reading memory? Isn't this way slower?
User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: Is there any better way to monitor memory address?

11 Mar 2019, 21:54

you need to find the static memory address of that value and use it.

Code: Select all

Value := ReadMemory("0x01B91E58","calc.exe")
:wave: There is always more than one way to solve a problem. ;)
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Is there any better way to monitor memory address?

11 Mar 2019, 21:56

YoucefHam wrote:
11 Mar 2019, 21:54
you need to find the static memory address of that value and use it.

Code: Select all

Value := ReadMemory("0x01B91E58","calc.exe")
Oh okay, so you are a bot or you don't know how to read maybe.
Please, Can u read what I wrote? If not then gtfo, thank you!
Didn't want to be rude but I hate people like him.
User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: Is there any better way to monitor memory address?

11 Mar 2019, 21:57

xD

sorry, your software have a GUI?
:wave: There is always more than one way to solve a problem. ;)
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Is there any better way to monitor memory address?

11 Mar 2019, 22:00

Please! don't post again, thank you!
User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: Is there any better way to monitor memory address?

11 Mar 2019, 22:09

ok!
Just wanted to help and learn with you. Sorry.
:wave: There is always more than one way to solve a problem. ;)
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Is there any better way to monitor memory address?

11 Mar 2019, 22:45

YoucefHam wrote:
11 Mar 2019, 22:09
ok!
Just wanted to help and learn with you. Sorry.
I'm sorry for being rude but you didn't even read what I wrote, that's disrespectful.
Thanks anyway, but don't post anymore.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5, RandomBoy and 359 guests