mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-05-26 15:46:17 +00:00
Enhance registry value handling for Hex and Binary types in Convert-RegOperationToValueKind function
This commit is contained in:
@@ -21,19 +21,31 @@ function Convert-RegOperationToValueKind {
|
|||||||
'String' {
|
'String' {
|
||||||
return @{ Name = $valueName; Kind = [Microsoft.Win32.RegistryValueKind]::String; Value = [string]$Operation.ValueData }
|
return @{ Name = $valueName; Kind = [Microsoft.Win32.RegistryValueKind]::String; Value = [string]$Operation.ValueData }
|
||||||
}
|
}
|
||||||
'Hex2' {
|
|
||||||
return @{ Name = $valueName; Kind = [Microsoft.Win32.RegistryValueKind]::ExpandString; Value = [string]$Operation.ValueData }
|
|
||||||
}
|
|
||||||
'Hex1' {
|
|
||||||
$stringValue = ([System.Text.Encoding]::Unicode.GetString([byte[]]$Operation.ValueData)).TrimEnd([char]0)
|
|
||||||
return @{ Name = $valueName; Kind = [Microsoft.Win32.RegistryValueKind]::String; Value = $stringValue }
|
|
||||||
}
|
|
||||||
'Hex7' {
|
|
||||||
return @{ Name = $valueName; Kind = [Microsoft.Win32.RegistryValueKind]::MultiString; Value = [string[]]@($Operation.ValueData | ForEach-Object { [string]$_ }) }
|
|
||||||
}
|
|
||||||
'Binary' {
|
'Binary' {
|
||||||
return @{ Name = $valueName; Kind = [Microsoft.Win32.RegistryValueKind]::Binary; Value = [byte[]]$Operation.ValueData }
|
return @{ Name = $valueName; Kind = [Microsoft.Win32.RegistryValueKind]::Binary; Value = [byte[]]$Operation.ValueData }
|
||||||
}
|
}
|
||||||
|
'Hex0' {
|
||||||
|
return @{ Name = $valueName; Kind = [Microsoft.Win32.RegistryValueKind]::None; Value = [byte[]]$Operation.ValueData }
|
||||||
|
}
|
||||||
|
'Hex3' {
|
||||||
|
return @{ Name = $valueName; Kind = [Microsoft.Win32.RegistryValueKind]::Binary; Value = [byte[]]$Operation.ValueData }
|
||||||
|
}
|
||||||
|
'HexB' {
|
||||||
|
$qwordBytes = [byte[]]$Operation.ValueData
|
||||||
|
if ($qwordBytes.Count -gt 8) {
|
||||||
|
throw "Unsupported hex value type '$valueType' with invalid byte count '$($qwordBytes.Count)' while applying reg operation for '$($Operation.KeyPath)'."
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($qwordBytes.Count -lt 8) {
|
||||||
|
$paddedBytes = New-Object byte[] 8
|
||||||
|
[Array]::Copy($qwordBytes, $paddedBytes, $qwordBytes.Count)
|
||||||
|
$qwordBytes = $paddedBytes
|
||||||
|
}
|
||||||
|
|
||||||
|
$unsigned = [BitConverter]::ToUInt64($qwordBytes, 0)
|
||||||
|
$signed = [BitConverter]::ToInt64([BitConverter]::GetBytes($unsigned), 0)
|
||||||
|
return @{ Name = $valueName; Kind = [Microsoft.Win32.RegistryValueKind]::QWord; Value = $signed }
|
||||||
|
}
|
||||||
default {
|
default {
|
||||||
if ($valueType -like 'Hex*') {
|
if ($valueType -like 'Hex*') {
|
||||||
throw "Unsupported hex value type '$valueType' while applying reg operation for '$($Operation.KeyPath)'."
|
throw "Unsupported hex value type '$valueType' while applying reg operation for '$($Operation.KeyPath)'."
|
||||||
|
|||||||
Reference in New Issue
Block a user