Modify

Opened 16 years ago

Closed 15 years ago

#1586 closed Bug (Fixed)

DllStructSetData(char, 1, string-with-NUL-character), junk data(?)

Reported by: anonymous Owned by: Jon
Milestone: 3.3.7.7 Component: AutoIt
Version: 3.3.6.1 Severity: None
Keywords: Cc:

Description

kinda expect the character part to end up with 0x61.00.63.00.64 or 0x61.00.00.00.00
anything else (junk data?) seems like a bug to me.

Local $sOrg = 'a' & Chr(0) & 'c' & Chr(0) & 'd' ;; -> a[NUL]c[NUL]d
ConsoleWrite('StringLen($sOrg) = ' & StringLen($sOrg) & @CRLF) ;; 5
$sCnv = StringReplace($sOrg, Chr(0), Chr(0), 0, 1) ;; -> a[NUL]c[NUL]d
$sCnv = StringReplace($sOrg, Chr(0), '[nul]', 0, 1) ;; -> a[nul]c[nul]d
ConsoleWrite('$sCnv = ' & $sCnv & @CRLF)

Local $tChar = DllStructCreate('char[5]')
Local $tByte = DllStructCreate('byte[5]', DllStructGetPtr($tChar)) ;; assuming ansi.
DllStructSetData($tByte, 1, $sOrg) ;; -> 0x61.00.63.00.64
ConsoleWrite('$tByte = ' & DllStructGetData($tByte, 1) & @CRLF)
DllStructSetData($tChar, 1, $sOrg) ;; -> 0x61.00.99.01.20 -> a.NUL.(junk?)
ConsoleWrite('$tByte = ' & DllStructGetData($tByte, 1) & @CRLF)

;; $sOrg still unchanged. just making sure.
$sCnv = StringReplace($sOrg, Chr(0), '[nul]', 0, 1) ;; -> a[nul]c[nul]d
ConsoleWrite('$sCnv = ' & $sCnv & @CRLF)

but than again ...

Attachments (0)

Change History (7)

comment:1 by J-Paul Mesnage, 16 years ago

in fact the rewriting thru tchar will assume that your $sOrg is a real string.
So for me 0x6100... is correct.
I will investigate to see why the last byte is changed I get a 0x61.00.00.00.10

comment:2 by J-Paul Mesnage, 16 years ago

Milestone: 3.3.7.0
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [5925] in version: 3.3.7.0

comment:3 by mvg, 16 years ago

Thanks.
Just curious. What will the resulting stored data be now for "DllStructSetData($tChar, ...)"
1) 0x61.00.63.00.64
2) 0x61.00.00.00.00
3) ...

comment:4 by J-Paul Mesnage, 16 years ago

1)

comment:5 by Jon, 15 years ago

Resolution: Fixed
Status: closedreopened

comment:6 by TicketCleanup, 15 years ago

Milestone: 3.3.7.0

Automatic ticket cleanup.

comment:7 by Jon, 15 years ago

Milestone: 3.3.7.7
Owner: changed from J-Paul Mesnage to Jon
Resolution: Fixed
Status: reopenedclosed

Fixed by revision [6086] in version: 3.3.7.7

Modify Ticket

Action
as closed The owner will remain Jon.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.