Modify

Opened 15 years ago

Closed 15 years ago

#1288 closed Bug (Fixed)

DLLStructSetData behavior with binary variant data

Reported by: evilertoaster Owned by: Valik
Milestone: 3.3.1.6 Component: AutoIt
Version: 3.3.0.0 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:

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

These two lines:

DllStructSetData($a,1,Binary('0xAABB'),2)

and

DllStructSetData($a,1,Number(Binary('0xAABB'),2)

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

DllStructSetData($a,1,Binary('0xFFFFFFFF'),1)

and

DllStructSetData($a,1,Binary('0xFFFFFFFF'))

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 15 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 15 years ago by Valik

  • Description modified (diff)

comment:3 Changed 15 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 15 years ago by Valik

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

Fixed by revision [5373] in version: 3.3.1.6

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

Action
as closed The owner will remain Valik.
Author


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

 
Note: See TracTickets for help on using tickets.