Modify

Opened 7 years ago

Closed 7 years ago

Last modified 7 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 Changed 7 years ago by anonymous

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 Changed 7 years ago by anonymous

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

comment:3 Changed 7 years ago by Jpm

  • Resolution set to No Bug
  • Status changed from new to closed

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 Changed 7 years ago by tukangusil7

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.

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 ticket will remain with no owner.
Author


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

 
Note: See TracTickets for help on using tickets.