Fix capture and restore of signed dword/qword registry values

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Jeffrey
2026-05-11 19:14:08 +02:00
parent 8ac664e45f
commit 24a6f1bcf8
3 changed files with 27 additions and 9 deletions

View File

@@ -157,8 +157,14 @@ function Convert-RegistryValueDataFromBackup {
)
switch ($Kind) {
([Microsoft.Win32.RegistryValueKind]::DWord) { return [uint32]$Data }
([Microsoft.Win32.RegistryValueKind]::QWord) { return [uint64]$Data }
([Microsoft.Win32.RegistryValueKind]::DWord) {
$unsigned = [uint32]$Data
return [BitConverter]::ToInt32([BitConverter]::GetBytes($unsigned), 0)
}
([Microsoft.Win32.RegistryValueKind]::QWord) {
$unsigned = [uint64]$Data
return [BitConverter]::ToInt64([BitConverter]::GetBytes($unsigned), 0)
}
([Microsoft.Win32.RegistryValueKind]::MultiString) { return @($Data | ForEach-Object { [string]$_ }) }
([Microsoft.Win32.RegistryValueKind]::Binary) {
$bytes = Convert-BackupDataToByteArray -Data $Data