Sign in to follow this  
Followers 0
Danyfirex

Nested Structure?

6 posts in this topic

#1 ·  Posted (edited)

Hi mates. it's me again.

I'm stuck trying with a nested structure, I can find the best way to do the structure, I Thought making a long byte structure and then Peek the byte that y need, but I thinks is not efficient.

I have this:

$pointer="here my pointer"
$str=DllStructCreate("long;word;byte[4];Ptr;long",$pointer)
$b1=DllStructCreate("byte",DllStructGetPtr($str,3))
$b2=DllStructCreate("byte",DllStructGetPtr($b1)+1)
$b3=DllStructCreate("byte",DllStructGetPtr($b2)+1)
$b4=DllStructCreate("byte",DllStructGetPtr($b3)+1)
;msgbox(0,"",DllStructGetData($b3,1))

My ask is: is there some best way to do it.

I mean something like this:

$pointer="here my poitner"
$STRB=DllStructCreate(DllStructCreate("byte;byte;byte;byte")
$stra=DllStructCreate("long;word;HELLO as $STRB;Ptr;long",$pointer)
;obviously this is wrong

:sweating:

any suggestions is wellcome.

Regards.

Edited by Danyfirex

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$Str = "here my pointer"
$iLen = StringLen($Str)

$tStr = DllStructCreate("char[" & $iLen & "]")

For $i = 1 To $iLen
DllStructSetData($tStr, 1, StringMid($Str, $i, 1), $i)
Next
$pStr = DllStructGetPtr($tStr)

MsgBox(64, "Ret", DllStructGetData($tStr, 1) )
MsgBox(64, "Ret", GetStringFromPtr($pStr) )

Func GetStringFromPtr($pStr)
$tStruct = DllStructCreate("char[" & 0xFF & "]",$pStr)
Return DllStructGetData($tStruct, 1)
EndFunc
I don't know much about Structs still this would get you go.

Regards :)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks for the answer. the problem is I need that my structure is complete because it will be fill it using his base pointer.

the only way that I think is making a long structure like this.

$s=DllStructCreate("long;word;byte b1;byte b2;byte b3;Byte b4;Ptr;long",$pointer)

or

$pointer="my pointer"
$sstr=";byte b1;byte b2;byte b3;Byte b4;"
$s=DllStructCreate("long;word" & $sstr & "Ptr;long",$pointer)

at least that there was another efficiently way.

Edited by Danyfirex

Share this post


Link to post
Share on other sites

$Str = "here my pointer"
$iLen = StringLen($Str)

$tStr = DllStructCreate("long;word;char[" & $iLen & "];ptr;long")

For $i = 1 To $iLen
DllStructSetData($tStr, 3, StringMid($Str, $i, 1), $i)
Next

MsgBox(64, "Ret", DllStructGetData($tStr, 3) )


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

thank PhoenixXL but I want avoid any Loop to fill my structure.

just like this:

$pointer="my pointer"
$sstr=";byte b1;byte b2;byte b3;Byte b4;"
$s=DllStructCreate("long;word" & $sstr & "Ptr;long",$pointer)

so, is there a better way?

Share this post


Link to post
Share on other sites

Share this post


Link to post
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
Sign in to follow this  
Followers 0