You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RegQueryValueExW doesn't guarantee the returned buffer for the `lpcbData`
parameter is null terminated, so ensure that it is.
For REG_SZ & REG_EXPAND_SZ extend the buffer by 1 wchar (2 bytes) so we can
write a wide null terminator that is guaranteed not to overwrite user data. If
Windows doesn't null terminate the string, then it will have the following byte
sequence (as UTF-16LE):
\x41 \x00 \x42 \x00 \x00
If Windows does null terminate, then we will add an extra wide null terminator,
which won't hurt anything:
\x41 \x00 \x42 \x00 \x00 \x00 \x00
The same applies to REG_MULTI_SZ, except it is supposed to have two wide null
terminators (4 bytes). One terminator is for the last string in the array, and
one terminator is for the entire array. For example, if the array contains the
strings ['A', 'B'], then in UTF-16LE it should be represented as the following:
\x41 \x00 \x00 \x00
\x42 \x00 \x00 \x00
\x00 \x00
Where the overall binary string ends with 2 wide null terminators.
0 commit comments