Skip to content

Commit

Permalink
Update registry_value.dart (#22)
Browse files Browse the repository at this point in the history
Fix to null-termination at the end of string values. Fixes #21
  • Loading branch information
dancarrollg authored Sep 12, 2024
1 parent 612c8a4 commit 5696607
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/src/registry_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ class RegistryValue {
case RegistryValueType.link:
final strData = data as String;
final ptr = strData.toNativeUtf16();
return PointerData(ptr.cast<Uint8>(), strData.length * 2 + 1);
// To match the expected encoding for string values, reserve two
// bytes for all characters, plus an additional two bytes for
// the null-termination.
return PointerData(ptr.cast<Uint8>(), strData.length * 2 + 2);
case RegistryValueType.stringArray:
final strArray = (data as List<String>).map((s) => '$s\x00').join();
final ptr = strArray.toNativeUtf16();
Expand Down

0 comments on commit 5696607

Please sign in to comment.