Skip to content

Add registry Key.get_bytes() method for reading REG_BINARY types#4410

Open
zanedp wants to merge 6 commits into
microsoft:masterfrom
zanedp:add-get_bytes-back
Open

Add registry Key.get_bytes() method for reading REG_BINARY types#4410
zanedp wants to merge 6 commits into
microsoft:masterfrom
zanedp:add-get_bytes-back

Conversation

@zanedp
Copy link
Copy Markdown
Collaborator

@zanedp zanedp commented May 12, 2026

Adds a "safe" way to read registry values of type REG_BINARY.

Fixes: #3884

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reintroduces a safe, typed registry getter for REG_BINARY values (Type::Bytes) in windows-registry, addressing the regression noted in #3884.

Changes:

  • Add Key::get_bytes() to read REG_BINARY/Type::Bytes values as Vec<u8>.
  • Extend the registry test suite to validate successful reads (including embedded zero bytes) and type-mismatch error behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
crates/libs/registry/src/key.rs Adds Key::get_bytes() typed getter for Type::Bytes registry values.
crates/tests/libs/registry/tests/bytes.rs Adds coverage for get_bytes() success and failure cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/libs/registry/src/key.rs Outdated
Comment thread crates/tests/libs/registry/tests/bytes.rs
Comment thread crates/libs/registry/src/key.rs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

match ty {
Type::Bytes => {
let mut value = vec![0; sz];
unsafe { self.raw_get_bytes(name.as_raw(), &mut value)? };
Copy link
Copy Markdown
Collaborator

@kennykerr kennykerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just nitpicks - looks great thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[windows-registry] Key.get_bytes() removed

3 participants