Modify

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#3625 closed Bug (No Bug)

DllStructGetData() does not retrieve whole string containing null characters from array of WCHARs/CHARs

Reported by: tukangusil7 Owned by:
Milestone: Component: AutoIt
Version: 3.3.14.5 Severity: None
Keywords: DllStructGetData Cc:

Description

See my question on https://www.autoitscript.com/forum/topic/193532-is-it-possible-to-get-the-whole-string-containing-null-characters-from-array-of-wchars/.

I consider this as a bug because DllStructGetData() should retrieve an array of WCHARs/CHARs as it is.

To reduce script breaking changes, DllStructGetData() should by default only remove the last null character (if any). I also suggest there is an optional parameter to specify whether DllStructGetData() retrieves an array of WCHARs/CHARs as it is (including null terminator).

When using Native API functions in AutoIt, I found the current DllStructGetData() limitation annoys me because one of the reason to use Native API functions (i.e. registry operations) is that the Native API functions can deal with string containing null characters, which is an important ability for security programs.

Attachments (0)

Change History (4)

comment:1 by anonymous, 8 years ago

I realize there is a side effect of my proposal in the following example case:

  • A buffer for 2048 wchars is allocated using DllStructCreate(), then an API function returns the bytes length that is written to the buffer, for example, only 20 bytes (10 wchars) are written.
  • When the the 2048 wchars are retrieved using DllStructGetData(), there will be so many null characters at end the end of the final string.

If the above scenario is unwanted because of the possibility to cause script breaking changes, then DllStructGetData() can provides an option to retrieve characters by length. This way will not cause a script breaking change, I think.

comment:2 by anonymous, 8 years ago

Or perhaps, by implementing a new specialized function, i.e. DllStructGetString().

comment:3 by J-Paul Mesnage, 8 years ago

Resolution: No Bug
Status: newclosed

This ticket cannot considered as a bug as AutoIt fit MSDN WCHAR/CHAR behavior
If you want to catch Embedded Null Char just use Byte and do the conversion you want

comment:4 by tukangusil7, 8 years ago

Well, the Native API functions are also documented in MSDN (e.g. NtCreateKey/ZwCreateKey). Nearly all Native API functions does not require array of WCHARs to be null terminated because the functions work with UNICODE_STRING struct that has information about the length of the given array of WCHARs. Therefore, length of a string in the world of Microsoft Windows Native API is not based on position of null terminator.

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


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