Opened 14 years ago

Closed 14 years ago

#1288 closed Bug (Fixed)

DLLStructSetData behavior with binary variant data

Reported by: evilertoaster Owned by: Valik
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description (last modified by Valik)

As demonstrated in this thread

There might be some expected behavior when using DLLStructSetData with binary variants. Some examples:
Consider $a:


These two lines:




Produce different results. (The first only sets 0xAA).




Also produce different results, the first only sets 0xFF. Even though according to the documentation, omitting the 1 as the index argument should be identical to specifying 1.

Help file says:
"If the element is an array, you need to specify which index to set, otherwise it sets index 1."

Attachments (0)

Change History (4)

comment:1 Changed 14 years ago by anonymous

Sorry I didn't check the claims made in the post avidly enough. The 2nd and 3rd code blocks do set the same data, but DllStructSetData($a,1,0xAABB,2) sets it differently. to me, I would have though all 3 to set the data to: 0xFFAABBFF.

comment:2 Changed 14 years ago by Valik

  • Description modified (diff)

comment:3 Changed 14 years ago by Valik

From my reply on the forum:

This is a documentation error. The documentation claims that the index defaults to 1 when not specified. This is wrong. AutoIt defaults to writing as much of the source string into as much of the destination buffer as it can. That's why these two lines behave differently:

Local $a=DllStructCreate('byte[4]')

DllStructSetData($a,1,Binary('0xAABB'), 1)    ; Writes only 0xAA because it was explicitly told to write to index 1.
ConsoleWrite(DllStructGetData($a, 1) & @CRLF)

DllStructSetData($a,1,Binary('0xAABB'))    ; Writes the entire string.
ConsoleWrite(DllStructGetData($a, 1) & @CRLF)

I will correct the documentation to describe the actual behavior.

comment:4 Changed 14 years ago by Valik

  • Milestone set to
  • Owner set to Valik
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [5373] in version:

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The owner will remain Valik.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.