memoryReadInt

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Post Reply
Message
Author
el_dios85
Posts: 29
Joined: Tue Jul 07, 2009 8:43 pm

memoryReadInt

#1 Post by el_dios85 » Tue Oct 26, 2010 1:40 am

Hello,

Can memoryReadInt read null address?

Code: Select all

		pointer_offset = {0x8, 0x24, 0x18};
		local pointer = memoryReadIntPtr(proc, staticbase_ptr, pointer_offset);
		printf("pointer [%x].\n", pointer); 
		for i = 0, 768 do
  		  local tmp = memoryReadInt(proc, pointer  + i * 4);
		  local curbaseptr_addr = memoryReadInt(proc, tmp + 0x4);

			tarptr_addr = memoryReadInt(proc, curbaseptr_addr + 0x11C); --LINE 422
			if( tarptr_addr ~=  0 ) then
				tarbaseptr_addr = curbaseptr_addr;
				taridptr_addr = tartempptr_addr;
				coroutine.yield();
			end
		end

The Result is:

Code: Select all

pointer [8be0628]
WARNING: Failure reading memory from 0x2D4FDC0 at 0x4 in memoryReadInt(). Error code 299 (Only part of a ReadProcessMemory or WriteProcessMemory request  was completed.)
script\pwenak2.lua:422 attempt to perform arithmetic on local 'curbaseptr_addr' (a nill value)
because of the looping, local curbaseptr_addr = memoryReadInt(proc, tmp + 0x4); contain null value.

this is the result in auto it

Code: Select all

		Local $POINTER = memread(memread(memread(memread($APP_BASE_ADDRESS) + 0x8) + 0x24) + 0x18)
		ConsoleWrite("Pointer=" & Hex($POINTER) & @CRLF)
		For $I=0 To 768
			Local $CUR_BASE = memread(memread($POINTER + $I*0x4) + 0x4)
			ConsoleWrite("Cur Base=" & Hex($CUR_BASE) & @CRLF)
			ConsoleWrite("TAR Base=" & Hex(memread($cur_base + 0x11C)) & @CRLF)
			If $TAR = memread($cur_base + 0x11C) Then
				$TAR_BASE = $CUR_BASE
				$TARID = $TAR_TEMP
				ExitLoop
			EndIf
		Next
The result is

Code: Select all

Pointer=08BE0628
Cur Base=00000000
TAR Base=00000000
Cur Base=00000000
TAR Base=00000000
Cur Base=00000000
TAR Base=00000000
Cur Base=00000000
TAR Base=00000000
Cur Base=00000000
TAR Base=00000000
Cur Base=00000000
TAR Base=00000000
Cur Base=00000000
TAR Base=00000000
Cur Base=158BE160
TAR Base=80104961
Cur Base=13B2A6B8
TAR Base=80104962
Cur Base=159E2DF0
TAR Base=80104963
Cur Base=15F18958
TAR Base=80104964
Cur Base=08FD3740
TAR Base=80104965
Cur Base=15F2E800
TAR Base=80104966
Cur Base=08A08EE0
TAR Base=80104967
Cur Base=164B47F0
TAR Base=80104968
Thank you

User avatar
Administrator
Site Admin
Posts: 5331
Joined: Sat Jan 05, 2008 4:21 pm

Re: memoryReadInt

#2 Post by Administrator » Tue Oct 26, 2010 7:19 am

Just add

Code: Select all

if( curbaseptr_addr ) then ... end
around the section of code that relies on curbaseptr_addr to be valid.

And no, you cannot read from 'nil', because 'nil' is something that doesn't exist. It's not a number, therefor, cannot be used as an address.

el_dios85
Posts: 29
Joined: Tue Jul 07, 2009 8:43 pm

Re: memoryReadInt

#3 Post by el_dios85 » Tue Oct 26, 2010 9:11 am

Thanks, it works, now the problem only that warning... I try it first..

el_dios85
Posts: 29
Joined: Tue Jul 07, 2009 8:43 pm

Re: memoryReadInt

#4 Post by el_dios85 » Tue Oct 26, 2010 11:10 am

It already Solved. Thank You Admin

Auto IT:

Code: Select all

	Local $TAR_TEMP = memread(memread(memread($APP_BASE_ADDRESS) + 0x20) + $OFFSET_AT)
	Local $TARID_TEMP = memread(memread(memread($APP_BASE_ADDRESS) + 0x20) + $OFFSET_AT)
	
	If $TAR_TEMP = 0 Then
		$TAR = 0
		$TAR_BASE = 0
	ElseIf $TAR_TEMP <> $TAR Then
		$TAR = $TAR_TEMP
		Local $POINTER = memread(memread(memread(memread($APP_BASE_ADDRESS) + 0x8) + 0x24) + 0x18)

		For $I=0 To 768
			Local $CUR_BASE = memread(memread($POINTER + $I*0x4) + 0x4)
			If $TAR = memread($cur_base + 0x11C) Then
							ConsoleWrite("Pointer=" & Hex($POINTER) & @CRLF)
							ConsoleWrite("Cur Base=" & Hex($CUR_BASE) & @CRLF)
							ConsoleWrite("TAR Base=" & Hex($TAR) & @CRLF)
							ConsoleWrite("TAR Base1=" & Hex(memread($cur_base + 0x11C)) & @CRLF)
				$TAR_BASE = $CUR_BASE
				$TARID = $TAR_TEMP
				ExitLoop
			EndIf
		Next
	EndIf
Result:

Code: Select all

Pointer=08DD72F8
Cur Base=161B4CB0
TAR Base=80103E66
TAR Base1=80103E66
In MicroMacro:

Code: Select all

	if(tartemptptr_addr == 0) then 
		tarptr_addr = 0;
		tarbaseptr_addr = 0;
	elseif(tartempptr_addr ~= tarptr_addr) then
		tarptr_addr = tartempptr_addr;
		--printf("tarptr_addr [%x].\n", tarptr_addr); 	
		pointer_offset = {0x8, 0x24, 0x18};
		local pointer = memoryReadIntPtr(proc, staticbase_ptr, pointer_offset);

		for i = 0, 768 do
         		local tmp = memoryReadInt(proc, pointer + i * 4)
			--printf("tmp [%x].\n", tmp); 
                if (tmp ~= 0) then
        		local curbaseptr_addr = memoryReadInt(proc, tmp + 0x4);
		

		
			if(curbaseptr_addr) then
				tarptr_addr1 = memoryReadInt(proc, curbaseptr_addr + 0x11C);
				--printf("tarptr_addr1 [%x].\n", tarptr_addr1); 
			end
					if( tarptr_addr == tarptr_addr1 ) then 
						tarbaseptr_addr = curbaseptr_addr;
						printf("pointer [%x].\n", pointer); 
						printf("curbaseptr_addr [%x].\n", curbaseptr_addr); 
						printf("tarptr_addr [%x].\n", tarptr_addr); 
						printf("tarptr_addr1 [%x].\n", tarptr_addr1); 
						taridptr_addr = tartempptr_addr;
						break;
					end
		end

		       
		end
	end
Result:

Code: Select all

pointer [08DD72F8].
curbaseptr_addr [161B4CB0].
tarptr_addr [80103E66].
tarptr_addr1 [80103E66].

el_dios85
Posts: 29
Joined: Tue Jul 07, 2009 8:43 pm

Re: memoryReadInt

#5 Post by el_dios85 » Tue Oct 26, 2010 12:12 pm

I'm sorry, can anyone help me... I'm very confuse now... after success find the "target base offset", now the problem is, it cannot read the "Target HP". Is there something wrong about micromacro memoryReadIntPtr function?

This is the source and result (Auto IT)

Code: Select all

							ConsoleWrite("Pointer=" & Hex($POINTER) & @CRLF)
							ConsoleWrite("Cur Base=" & Hex($CUR_BASE) & @CRLF)
							ConsoleWrite("TAR Base=" & Hex($TAR) & @CRLF)
							ConsoleWrite("TAR Base1=" & Hex(memread($cur_base + 0x11C)) & @CRLF)
							ConsoleWrite("TARHP=" & Hex(memread($TAR_BASE + $OFFSET_TARHP)) & @CRLF)
							ConsoleWrite("HP=" & Hex(memread($CHAR_DATA_BASE + $OFFSET_HP)) & @CRLF)

Pointer=08DD72F8
Cur Base=16291010
TAR Base=80103DEF
TAR Base1=80103DEF
TARHP=0000001D
HP=0000034A
and This is from MicroMacro

Code: Select all

						printf("pointer [%x].\n", pointer); 
						printf("curbaseptr_addr [%x].\n", curbaseptr_addr); 
						printf("tarptr_addr [%x].\n", tarptr_addr); 
						printf("tarptr_addr1 [%x].\n", tarptr_addr1); 
						printf("TARHP [%x].\n", memoryReadIntPtr(proc, tarbaseptr_addr, TarHP_offset));
						printf("HP [%x].\n", memoryReadIntPtr(proc, charptr_addr, HP_offset));

pointer [08DD72F8].
curbaseptr_addr [161B4CB0].
tarptr_addr [80103E66].
tarptr_addr1 [80103E66].
TARHP [30000059].
HP [34A].
The value always 30000059.
I have try all of the function memoryReadUIntPtr, memoryReadBytePtr,memoryReadUBytePtr, memoryReadShortPtr, memoryReadUShortPtr, memoryReadFloatPtr, etc...

in auto IT the memread function source:

Code: Select all

Func memread($adress, $type = 'dword')
	Local $struct = DllStructCreate($type)
	DllCall($kernel32, 'int', 'ReadProcessMemory', 'int', $mid, 'int', $adress, 'ptr', DllStructGetPtr($struct), 'int', DllStructGetSize($struct), 'int', '')
	Return DllStructGetData($struct, 1)
EndFunc

User avatar
Administrator
Site Admin
Posts: 5331
Joined: Sat Jan 05, 2008 4:21 pm

Re: memoryReadInt

#6 Post by Administrator » Tue Oct 26, 2010 5:30 pm

memoryReadIntPtr(proc, tarbaseptr_addr, TarHP_offset)
Maybe that should be:

Code: Select all

memoryReadInt(proc, tarbaseptr_addr + TarHP_offset);
Also, a few of your other addresses are off. You're making progress at least.

el_dios85
Posts: 29
Joined: Tue Jul 07, 2009 8:43 pm

Re: memoryReadInt

#7 Post by el_dios85 » Tue Oct 26, 2010 8:24 pm

yes, it work.... i try the wrong way before.
like this memoryReadInt(proc, memoryReadInt(proc,tarbaseptr_addr ) + TarHP_offset);
and it didnt work....

Thank you very much, this target info session is completed.

I want to try to translate other function from Auto IT to micromacro.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests