Jump to content

Taking value from memory adress


Archon
 Share

Recommended Posts

Is in AutoIt function or possibility to take value from specific memory adress like pointers (ptr*) in C/Cpp? I know that DllStructCreate can do this but is's slow. I dont want make structures, only get value from adress.

There must be a structure to divide the memory data , but it possible

to get the value directly from the Ptr .

Check out this example

$str = "int var1;ushort var2;ushort var3;char var4[128]"

$a = DllStructCreate($str)

DllStructSetData($a,"var3",10554)

MsgBox(0,"DllStructSetData","var3 = " & DllStructGetData($a,"var3"))

$Ptr = DllStructGetPtr($a)

;int var1;ushort var2

$IntSize = DllStructGetSize(DllStructCreate("int"))

;int_var1 ==> int Size ==> 4 BYTE

$Size = $IntSize ;4 BYTE

$ushortSize = DllStructGetSize(DllStructCreate("ushort"))

;ushort_var2 ==> ushort Size ==> 2 BYTE

$Size += $ushortSize ;2 BYTE

$OutPtr = $Ptr + $Size ;Move Ptr To First Or Start ushort_var3 BYTE ==> 4 + 2 = 6

$b = DllStructCreate("ushort var3",$OutPtr)

$var3 = DllStructGetData($b,"var3")

MsgBox(0,"Get Data From Ptr","var3 = " & $var3)

$str = "int var1;ushort var2;ushort var3;char var4[128]"
$a = DllStructCreate($str)
DllStructSetData($a,"var3",10554)
MsgBox(0,"DllStructSetData","var3 = " & DllStructGetData($a,"var3"))
$Ptr = DllStructGetPtr($a)

;int var1;ushort var2

$IntSize = DllStructGetSize(DllStructCreate("int"))
;int_var1 ==> int Size ==> 4 BYTE
$Size = $IntSize ;4 BYTE

$ushortSize = DllStructGetSize(DllStructCreate("ushort"))
;ushort_var2 ==> ushort Size ==> 2 BYTE
$Size += $ushortSize ;2 BYTE

$OutPtr = $Ptr + $Size ;Move Ptr To First Or Start ushort_var3 BYTE ==> 4 + 2 = 6

$b = DllStructCreate("ushort var3",$OutPtr)
$var3 = DllStructGetData($b,"var3")
MsgBox(0,"Get Data From Ptr","var3 = " & $var3)
Edited by wolf9228

صرح السماء كان هنا

 

Link to comment
Share on other sites

wolf9228, It works of course, but is still solution based on structures.

Negative1, I found this UDF and checked it. There were also used structures :( And some Dll's but useless for me in this case, howewer it look interesting.

I am going to start thinking that in AutoIt there is no simple and faster solution to get value from pointer like pass by structure. It's strange because in other way it's possible by Ptr() function :mellow:

Someone have any ideas?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...