diff --git a/tracer/src/Datadog.Trace.Tools.Runner/Checks/ProcessBasicCheck.cs b/tracer/src/Datadog.Trace.Tools.Runner/Checks/ProcessBasicCheck.cs index 4c6e49c44d45..645220541cec 100644 --- a/tracer/src/Datadog.Trace.Tools.Runner/Checks/ProcessBasicCheck.cs +++ b/tracer/src/Datadog.Trace.Tools.Runner/Checks/ProcessBasicCheck.cs @@ -156,12 +156,17 @@ internal static bool CheckRegistry(IRegistryService? registry = null) bool foundKey = false; - foreach (var name in registry.GetLocalMachineValueNames(@"SOFTWARE\Microsoft\.NETFramework")) + var parentKeys = new[] { @"SOFTWARE\Microsoft\.NETFramework", @"SOFTWARE\WOW6432Node\Microsoft\.NETFramework" }; + + foreach (var parentKey in parentKeys) { - if (suspiciousNames.Contains(name)) + foreach (var name in registry.GetLocalMachineValueNames(parentKey)) { - Utils.WriteWarning(SuspiciousRegistryKey(name)); - foundKey = true; + if (suspiciousNames.Contains(name)) + { + Utils.WriteWarning(SuspiciousRegistryKey(parentKey, name)); + foundKey = true; + } } } diff --git a/tracer/src/Datadog.Trace.Tools.Runner/Checks/Resources.cs b/tracer/src/Datadog.Trace.Tools.Runner/Checks/Resources.cs index 534e54b0d6d0..38d7c779d488 100644 --- a/tracer/src/Datadog.Trace.Tools.Runner/Checks/Resources.cs +++ b/tracer/src/Datadog.Trace.Tools.Runner/Checks/Resources.cs @@ -50,7 +50,7 @@ internal static class Resources public static string ErrorCheckingRegistry(string error) => $"Error trying to read the registry: {error}"; - public static string SuspiciousRegistryKey(string key) => $@"The registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\{key} is defined and could prevent the tracer from working properly. Please check that all external profilers have been uninstalled properly."; + public static string SuspiciousRegistryKey(string parentKey, string key) => $@"The registry key HKEY_LOCAL_MACHINE\{parentKey}\{key} is defined and could prevent the tracer from working properly. Please check that all external profilers have been uninstalled properly."; public static string MissingRegistryKey(string key) => $@"The registry key {key} is missing. Make sure the tracer has been properly installed with the MSI."; diff --git a/tracer/test/Datadog.Trace.Tools.Runner.IntegrationTests/Checks/ProcessBasicChecksTests.cs b/tracer/test/Datadog.Trace.Tools.Runner.IntegrationTests/Checks/ProcessBasicChecksTests.cs index 516ee31e0e5c..4b0ae206855b 100644 --- a/tracer/test/Datadog.Trace.Tools.Runner.IntegrationTests/Checks/ProcessBasicChecksTests.cs +++ b/tracer/test/Datadog.Trace.Tools.Runner.IntegrationTests/Checks/ProcessBasicChecksTests.cs @@ -197,10 +197,12 @@ public void GoodRegistry() console.Output.Should().NotContain(MissingProfilerRegistry(ClsidKey, ProfilerPath)); } - [SkippableFact] - public void BadRegistryKey() + [SkippableTheory] + [InlineData(true)] + [InlineData(false)] + public void BadRegistryKey(bool wow64) { - var registryService = MockRegistryService(new[] { "cor_profiler" }, ProfilerPath); + var registryService = MockRegistryService(new[] { "cor_profiler" }, ProfilerPath, wow64); using var console = ConsoleHelper.Redirect(); @@ -208,7 +210,9 @@ public void BadRegistryKey() result.Should().BeFalse(); - console.Output.Should().Contain(SuspiciousRegistryKey("cor_profiler")); + var netFrameworkKey = wow64 ? @"SOFTWARE\WOW6432Node\Microsoft\.NETFramework" : @"SOFTWARE\Microsoft\.NETFramework"; + + console.Output.Should().Contain(SuspiciousRegistryKey(netFrameworkKey, "cor_profiler")); } [SkippableFact] @@ -255,10 +259,13 @@ public void WrongProfilerRegistry() console.Output.Should().Contain(Resources.WrongProfilerRegistry(ClsidKey, "wrongProfiler.dll")); } - private static IRegistryService MockRegistryService(string[] frameworkKeyValues, string profilerKeyValue) + private static IRegistryService MockRegistryService(string[] frameworkKeyValues, string profilerKeyValue, bool wow64 = false) { var registryService = new Mock(); - registryService.Setup(r => r.GetLocalMachineValueNames(It.Is(@"SOFTWARE\Microsoft\.NETFramework", StringComparer.Ordinal))) + + var netFrameworkKey = wow64 ? @"SOFTWARE\WOW6432Node\Microsoft\.NETFramework" : @"SOFTWARE\Microsoft\.NETFramework"; + + registryService.Setup(r => r.GetLocalMachineValueNames(It.Is(netFrameworkKey, StringComparer.Ordinal))) .Returns(frameworkKeyValues); registryService.Setup(r => r.GetLocalMachineValue(It.Is(s => s == ClsidKey || s == Clsid32Key))) .Returns(profilerKeyValue);