Skip to content

Commit

Permalink
[Registry Preview] Update value parsing for split hex values (#25559)
Browse files Browse the repository at this point in the history
* Update value parsing for split hex values

* Fixing spelling typo in comments
  • Loading branch information
randyrants committed Apr 20, 2023
1 parent b203c3c commit 81cc132
Showing 1 changed file with 24 additions and 1 deletion.
Expand Up @@ -318,7 +318,7 @@ private bool ParseRegistryFile(string filenameText)
}
else if (value.StartsWith("hex(2):", StringComparison.InvariantCultureIgnoreCase))
{
registryValue.Type = "REG_EXAND_SZ";
registryValue.Type = "REG_EXPAND_SZ";
value = value.Replace("hex(2):", string.Empty);
}
else if (value.StartsWith("hex(7):", StringComparison.InvariantCultureIgnoreCase))
Expand All @@ -327,11 +327,34 @@ private bool ParseRegistryFile(string filenameText)
value = value.Replace("hex(7):", string.Empty);
}

// Parse for the case where a \ is added immediately after hex is declared
switch (registryValue.Type)
{
case "REG_QWORD":
case "REG_BINARY":
case "REG_EXPAND_SZ":
case "REG_MULTI_SZ":
if (value == @"\")
{
// pad the value, so the parsing below is triggered
value = @",\";
}

break;
}

// If the end of a decimal line ends in a \ then you have to keep
// reading the block as a single value!
while (value.EndsWith(@",\", StringComparison.InvariantCulture))
{
value = value.TrimEnd('\\');

// checking for a "blank" hex value so we can skip t
if (value == @",")
{
value = string.Empty;
}

index++;
if (index >= registryLines.Length)
{
Expand Down

0 comments on commit 81cc132

Please sign in to comment.