Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit abda906

Browse files
JeremyKuhnesafern
authored andcommitted
Strip out unused reg code. (dotnet/coreclr#10741)
* Strip out unused reg code. Removing the unused code to better be able to audit our CoreLib usage and to prepare for targeted code sharing with CoreFX. Wraps key usages in using statements. * Fix static init and remove Contract Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
1 parent bde4bd5 commit abda906

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Common/src/CoreLib/System/Diagnostics/Tracing/EventProvider.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -555,21 +555,21 @@ private unsafe bool GetDataFromController(int etwSessionId,
555555
{
556556
#if (!ES_BUILD_PCL && !ES_BUILD_PN && !FEATURE_PAL)
557557
string regKey = @"\Microsoft\Windows\CurrentVersion\Winevt\Publishers\{" + m_providerId + "}";
558-
if (System.Runtime.InteropServices.Marshal.SizeOf(typeof(IntPtr)) == 8)
559-
regKey = @"HKEY_LOCAL_MACHINE\Software" + @"\Wow6432Node" + regKey;
558+
if (Marshal.SizeOf(typeof(IntPtr)) == 8)
559+
regKey = @"Software" + @"\Wow6432Node" + regKey;
560560
else
561-
regKey = @"HKEY_LOCAL_MACHINE\Software" + regKey;
561+
regKey = @"Software" + regKey;
562562

563563
string valueName = "ControllerData_Session_" + etwSessionId.ToString(CultureInfo.InvariantCulture);
564564

565-
// we need to assert this permission for partial trust scenarios
566-
#if !CORECLR
567-
(new RegistryPermission(RegistryPermissionAccess.Read, regKey)).Assert();
568-
#endif
569-
data = Microsoft.Win32.Registry.GetValue(regKey, valueName, null) as byte[];
565+
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(regKey, writable: false))
566+
{
567+
data = key.GetValue(valueName) as byte[];
568+
}
569+
570570
if (data != null)
571571
{
572-
// We only used the persisted data from the registry for updates.
572+
// We only used the persisted data from the registry for updates.
573573
command = ControllerCommand.Update;
574574
return true;
575575
}

0 commit comments

Comments
 (0)