Address Pointed to by Value in an Offset

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
lmstearn
Posts: 694
Joined: 11 Aug 2016, 02:32
Contact:

Address Pointed to by Value in an Offset

30 Dec 2016, 01:42

Hi there, working with some code from here:

Code: Select all

SeekProc(stream, offset, type)
{
stream.Seek(offset)
VarSetCapacity(v,8)
bytesToRead := NumPut(0,v,0,type) - &v ; Numput returns the address to the "right" of item just written


bytesRead := stream.RawRead(v, bytesToRead)
if (v)
{
MsgBox, 4096, , % " Read failed"
return 0
}
else
{
if (offset)
	{
if (offset)
	{
	absOffset := NumGet(v, 0, type)
	stream.Seek(absOffset)
	Pos := stream.Tell()
	v := 0
	VarSetCapacity(v,8)
	bytesToRead := NumPut(0,v,0,type) - &v
	bytesRead := stream.RawRead(v, bytesToRead)
	}
	MsgBox, 4096, , % "NumGet(v, 0, type): " NumGet(v, 0, type) " v: " v " Curr. Pos: " Pos " bytesToRead: " bytesToRead " offset: " offset " absOffset: " absOffset
	return % NumGet(v, 0, type)
}
}
Is there some way to harness MemoryRead or the like to obtain a Location_Pointed_To_By_AddressOf(absOffset)?
Thanks for response.
Last edited by lmstearn on 30 Dec 2016, 03:24, edited 2 times in total.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
JJohnston2
Posts: 204
Joined: 24 Jun 2015, 23:38

Re: Address Pointed to by Value in an Offset

30 Dec 2016, 02:56

Have you looked into possible Dll Calls that might be able to do that?
User avatar
lmstearn
Posts: 694
Joined: 11 Aug 2016, 02:32
Contact:

Re: Address Pointed to by Value in an Offset

30 Dec 2016, 03:37

@JJohnston2: Yes, it's easiest to keep within the AHK file object. Think I know where the problem is:

Code: Select all

stream.Seek(&absOffset) ;
Is intended, but it's giving out of range addresses as it seems all that is required for Header reads is one byte addresses. So to strip the second half, reduce the VarSetCapacity. :)
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Address Pointed to by Value in an Offset

30 Dec 2016, 03:49

If the adresses/offsets are stored in x86 format (reversed byte order) you should consider to use ReadNum() instead of RawRead().

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, ShatterCoder and 113 guests