summaryrefslogtreecommitdiff
path: root/src/Agent.Windows/Diagnostics
diff options
context:
space:
mode:
Diffstat (limited to 'src/Agent.Windows/Diagnostics')
-rw-r--r--src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs b/src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs
index 89a2106..32086d3 100644
--- a/src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs
+++ b/src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs
@@ -36,9 +36,9 @@ public static class WindowsPlatformCheck
bfe = true;
if (helper)
{
- string current = Assembly.GetEntryAssembly()?.GetName().Version?.ToString(3) ?? "";
+ Version? current = Assembly.GetEntryAssembly()?.GetName().Version;
string candidate = FileVersionInfo.GetVersionInfo(helperPath).FileVersion ?? "";
- version = candidate.StartsWith(current, StringComparison.Ordinal);
+ version = current is not null && HasSameReleaseIdentity(current, candidate);
}
return new(platform, profile, bfe, helper, version, null, null);
}
@@ -47,6 +47,12 @@ public static class WindowsPlatformCheck
{ return new(platform, profile, bfe, helper, version, ex.HResult, ex.Message); }
}
+ internal static bool HasSameReleaseIdentity(Version current, string candidate)
+ {
+ if (!Version.TryParse(candidate, out Version? parsed)) return false;
+ return current.Major == parsed.Major && current.Minor == parsed.Minor && current.Build == parsed.Build;
+ }
+
private static FwpmEngineClose0SafeHandle OpenBfeReadOnly()
{
uint result = PInvoke.FwpmEngineOpen0(10, null, null, out FwpmEngineClose0SafeHandle engine);