Fix misleading version results

This commit is contained in:
Matt Nadareski
2021-03-22 16:25:40 -07:00
parent bc613a0413
commit e43423d2c9
8 changed files with 15 additions and 11 deletions

View File

@@ -91,8 +91,12 @@ namespace BurnOutSharp.Matching
// Otherwise, invoke the version method
else
{
string version = matcher.GetContentVersion(file, fileContent, positions) ?? "Unknown Version";
matchedProtections.Add($"{matcher.ProtectionName ?? "Unknown Protection"} {version}" + (includePosition ? $" (Index {positionsString})" : string.Empty));
// A null version returned means the check didn't pass at the version step
string version = matcher.GetContentVersion(file, fileContent, positions);
if (version == null)
continue;
matchedProtections.Add($"{matcher.ProtectionName ?? "Unknown Protection"} {version}".TrimEnd() + (includePosition ? $" (Index {positionsString})" : string.Empty));
}
// If we're stopping after the first protection, bail out here

View File

@@ -79,7 +79,7 @@ namespace BurnOutSharp.PackerType
if (!string.IsNullOrEmpty(version))
return version;
return null;
return "(Unknown Version)";
}
}
}

View File

@@ -61,7 +61,7 @@ namespace BurnOutSharp.ProtectionType
{
char[] version = new ArraySegment<byte>(fileContent, positions[0] + 15, 4).Select(b => (char)b).ToArray();
if (version[0] == 0x00)
return "";
return string.Empty;
return new string(version);
}

View File

@@ -27,7 +27,7 @@ namespace BurnOutSharp.ProtectionType
{
char[] version = new ArraySegment<byte>(fileContent, positions[0] + 15, 4).Select(b => (char)b).ToArray();
if (version[0] == 0x00)
return "";
return string.Empty;
return new string(version);
}

View File

@@ -160,7 +160,7 @@ namespace BurnOutSharp.ProtectionType
subsubVersion = BitConverter.ToInt32(fileContent, index);
if (version == 0)
return "";
return string.Empty;
return $"{version}.{subVersion:00}.{subsubVersion:000}";
}

View File

@@ -140,7 +140,7 @@ namespace BurnOutSharp.ProtectionType
subSubSubVersion[3] = (byte)(fileContent[index] ^ 22);
if (version == 0 || version > 9)
return "";
return string.Empty;
return $"{version}.{subVersion[0]}{subVersion[1]}.{subSubVersion[0]}{subSubVersion[1]}.{subSubSubVersion[0]}{subSubSubVersion[1]}{subSubSubVersion[2]}{subSubSubVersion[3]}";
}

View File

@@ -38,8 +38,8 @@ namespace BurnOutSharp.ProtectionType
if (char.IsNumber(version) && char.IsNumber(subVersion))
return $"{version}.{subVersion}";
else
return "";
return string.Empty;
}
}
}

View File

@@ -113,9 +113,9 @@ namespace BurnOutSharp.ProtectionType
return "5.5.0";
case 0x4:
return "5.5.2";
default:
return string.Empty;
}
return "";
}
}
}