I am not able to obtain the address of a variable

Recommended Posts

I thought that ptr() is the function to obtain the address of a variable.

But in the following toy script:

```\$T1="00"

for \$i=1 to 15
\$T1&=\$T1
Next

msgbox(0,"length \$T1",stringlen(\$T1))

\$T2=\$T1

So, what is my mistake?

Share on other sites

Ptr() can only decipher decimal number so any 0-9 are correct. However your can only count up to 4294967295 but you got to the power of 15 start with 00 so 00^15. Remember that 0 does mean something regardless to where it is so you end up with countless 00. Appro. 00 x 120000 as a rough estimate with great margin of error. However it does evaluate as long as T1 or T2 are under 4294967295

Here is a estimate that you were looking for:

\$T1="42949"

\$T2=\$T1

\$T1 &= \$T1

msgbox(0,"length \$T1",\$T1 & " " & stringlen(\$T1))

EndIf

EndIf

You are workign with a 32 bit system if you want higher up you need to go to 64 bit system else enumate two different as a Pointer

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Share on other sites

Ptr() can only decipher decimal number so any 0-9 are correct. However your can only count up to 4294967295 but you got to the power of 15 start with 00 so 00^15. Remember that 0 does mean something regardless to where it is so you end up with countless 00. Appro. 00 x 120000 as a rough estimate with great margin of error. However it does evaluate as long as T1 or T2 are under 4294967295

Sorry, I am not sure to have well understood. If Ptr() only converts a number, then I have used the wrong function. The content of \$T1 and \$T2 is not important. They can be "AAAAAAAAAAAA" and "AAAAAAAAAAAAA".

I have a string variable whose length is 65536. Now I have to pass its address as a parameter in a dll call. How have I to do?

Edited by Zomp
Share on other sites

I have a string variable whose length is 65536. Now I have to pass its address as a parameter in a dll call. How have I to do?

I have found the solution by myself. I have to use DllStruct* functions.

Here is a toy example:

```\$a=DllStructCreate("char FNI[10000]")

if @error Then
MsgBox(0,"","Error in DllStructCreate " & @error);
exit
endif

\$T1="00"
for \$i=1 to 15
\$T1&=\$T1
Next

DllStructSetData(\$a,1,\$T1)

if @error Then
MsgBox(0,"","Error in DllStructSetData " & @error);
exit
endif

MsgBox(0,"DllStruct","Struct Size: " & DllStructGetSize(\$a) & @CRLF & _
"Struct pointer: " & DllStructGetPtr(\$a) & @CRLF & _
"Data:" & @CRLF & DllStructGetData(\$a,1))```

I'm wondering if I can avoid to use DllStruct* and use for example "&" before the variable name as in AutoHotKey.

Edited by Zomp
Share on other sites

I have found the solution by myself. I have to use DllStruct* functions.

Here is a toy example:

```\$a=DllStructCreate("char FNI[10000]")

if @error Then
MsgBox(0,"","Error in DllStructCreate " & @error);
exit
endif

\$T1="00"
for \$i=1 to 15
\$T1&=\$T1
Next

DllStructSetData(\$a,1,\$T1)

if @error Then
MsgBox(0,"","Error in DllStructSetData " & @error);
exit
endif

MsgBox(0,"DllStruct","Struct Size: " & DllStructGetSize(\$a) & @CRLF & _
"Struct pointer: " & DllStructGetPtr(\$a) & @CRLF & _
"Data:" & @CRLF & DllStructGetData(\$a,1))```

I'm wondering if I can avoid to use DllStruct* and use for example "&" before the variable name as in AutoHotKey.

Unfortunately you cannot get the address of variables in AutoIt, only for DllStructs.

I though that I could beat the system because when you call a dll with a string parameter the string must be passed as a pointer. So I wrote a dll with a function to be called with a string from AUtoIt, then tried to use the value passed for the string in a memory read. I couldn't get it to work . Probably something wrong with my understanding.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Create an account

Register a new account