Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/System.Private.CoreLib/src/Microsoft/Win32')
-rw-r--r--src/System.Private.CoreLib/src/Microsoft/Win32/Registry.cs34
-rw-r--r--src/System.Private.CoreLib/src/Microsoft/Win32/RegistryHive.cs24
-rw-r--r--src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.Windows.cs206
-rw-r--r--src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs11
-rw-r--r--src/System.Private.CoreLib/src/Microsoft/Win32/RegistryOptions.cs20
-rw-r--r--src/System.Private.CoreLib/src/Microsoft/Win32/RegistryValueKind.cs23
-rw-r--r--src/System.Private.CoreLib/src/Microsoft/Win32/RegistryValueOptions.cs20
-rw-r--r--src/System.Private.CoreLib/src/Microsoft/Win32/RegistryView.cs20
-rw-r--r--src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeRegistryHandle.Windows.cs19
-rw-r--r--src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs22
-rw-r--r--src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.Unix.cs17
-rw-r--r--src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs47
12 files changed, 156 insertions, 307 deletions
diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/Registry.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/Registry.cs
deleted file mode 100644
index 4afd135ac..000000000
--- a/src/System.Private.CoreLib/src/Microsoft/Win32/Registry.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-
-using System;
-
-namespace Microsoft.Win32
-{
- /**
- * Registry encapsulation. Contains members representing all top level system
- * keys.
- *
- * @security(checkClassLinking=on)
- */
- //This class contains only static members and does not need to be serializable.
- internal static class Registry
- {
- /**
- * Current User Key.
- *
- * This key should be used as the root for all user specific settings.
- */
- public static readonly RegistryKey CurrentUser = RegistryKey.GetBaseKey(RegistryKey.HKEY_CURRENT_USER);
-
- /**
- * Local Machine Key.
- *
- * This key should be used as the root for all machine specific settings.
- */
- public static readonly RegistryKey LocalMachine = RegistryKey.GetBaseKey(RegistryKey.HKEY_LOCAL_MACHINE);
- }
-}
-
diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryHive.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryHive.cs
deleted file mode 100644
index 57a5de393..000000000
--- a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryHive.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace Microsoft.Win32
-{
- /**
- * Registry hive values. Useful only for GetRemoteBaseKey
- */
-#if REGISTRY_ASSEMBLY
- public
-#else
- internal
-#endif
- enum RegistryHive
- {
- ClassesRoot = unchecked((int)0x80000000),
- CurrentUser = unchecked((int)0x80000001),
- LocalMachine = unchecked((int)0x80000002),
- Users = unchecked((int)0x80000003),
- PerformanceData = unchecked((int)0x80000004),
- CurrentConfig = unchecked((int)0x80000005),
- }
-}
diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.Windows.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.Windows.cs
index 6b0cc8962..b9221327e 100644
--- a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.Windows.cs
+++ b/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.Windows.cs
@@ -4,6 +4,7 @@
using Microsoft.Win32.SafeHandles;
using System;
+using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -75,14 +76,14 @@ namespace Microsoft.Win32
// the dispose below and usage elsewhere (other threads). This is By Design.
// This is less of an issue when OS > NT5 (i.e Vista & higher), we can close the perfkey
// (to release & refresh PERFLIB resources) and the OS will rebuild PERFLIB as necessary.
- Interop.mincore.RegCloseKey(HKEY_PERFORMANCE_DATA);
+ Interop.Advapi32.RegCloseKey(HKEY_PERFORMANCE_DATA);
}
private void FlushCore()
{
if (_hkey != null && IsDirty())
{
- Interop.mincore.RegFlushKey(_hkey);
+ Interop.Advapi32.RegFlushKey(_hkey);
}
}
@@ -93,7 +94,7 @@ namespace Microsoft.Win32
// By default, the new key will be writable.
SafeRegistryHandle result = null;
- int ret = Interop.mincore.RegCreateKeyEx(_hkey,
+ int ret = Interop.Advapi32.RegCreateKeyEx(_hkey,
subkey,
0,
null,
@@ -185,7 +186,7 @@ namespace Microsoft.Win32
private RegistryKey InternalOpenSubKeyCore(string name, RegistryRights rights, bool throwOnPermissionFailure)
{
SafeRegistryHandle result = null;
- int ret = Interop.mincore.RegOpenKeyEx(_hkey, name, 0, ((int)rights | (int)_regView), out result);
+ int ret = Interop.Advapi32.RegOpenKeyEx(_hkey, name, 0, ((int)rights | (int)_regView), out result);
if (ret == 0 && !result.IsInvalid)
{
RegistryKey key = new RegistryKey(result, IsWritable((int)rights), false, _remoteKey, false, _regView);
@@ -242,7 +243,7 @@ namespace Microsoft.Win32
// open the base key so that RegistryKey.Handle will return a valid handle
SafeRegistryHandle result;
- ret = Interop.mincore.RegOpenKeyEx(baseKey,
+ ret = Interop.Advapi32.RegOpenKeyEx(baseKey,
null,
0,
(int)GetRegistryKeyRights(IsWritable()) | (int)_regView,
@@ -264,7 +265,7 @@ namespace Microsoft.Win32
{
int subkeys = 0;
int junk = 0;
- int ret = Interop.mincore.RegQueryInfoKey(_hkey,
+ int ret = Interop.Advapi32.RegQueryInfoKey(_hkey,
null,
null,
IntPtr.Zero,
@@ -285,43 +286,52 @@ namespace Microsoft.Win32
return subkeys;
}
- private unsafe string[] InternalGetSubKeyNamesCore(int subkeys)
+ private string[] InternalGetSubKeyNamesCore(int subkeys)
{
- string[] names = new string[subkeys];
- char[] name = new char[MaxKeyLength + 1];
+ var names = new List<string>(subkeys);
+ char[] name = ArrayPool<char>.Shared.Rent(MaxKeyLength + 1);
- int namelen;
-
- fixed (char* namePtr = &name[0])
+ try
{
- for (int i = 0; i < subkeys; i++)
+ int result;
+ int nameLength = name.Length;
+
+ while ((result = Interop.Advapi32.RegEnumKeyEx(
+ _hkey,
+ names.Count,
+ name,
+ ref nameLength,
+ null,
+ null,
+ null,
+ null)) != Interop.Errors.ERROR_NO_MORE_ITEMS)
{
- namelen = name.Length; // Don't remove this. The API's doesn't work if this is not properly initialized.
- int ret = Interop.mincore.RegEnumKeyEx(_hkey,
- i,
- namePtr,
- ref namelen,
- null,
- null,
- null,
- null);
- if (ret != 0)
+ switch (result)
{
- Win32Error(ret, null);
+ case Interop.Errors.ERROR_SUCCESS:
+ names.Add(new string(name, 0, nameLength));
+ nameLength = name.Length;
+ break;
+ default:
+ // Throw the error
+ Win32Error(result, null);
+ break;
}
-
- names[i] = new string(namePtr);
}
}
+ finally
+ {
+ ArrayPool<char>.Shared.Return(name);
+ }
- return names;
+ return names.ToArray();
}
private int InternalValueCountCore()
{
int values = 0;
int junk = 0;
- int ret = Interop.mincore.RegQueryInfoKey(_hkey,
+ int ret = Interop.Advapi32.RegQueryInfoKey(_hkey,
null,
null,
IntPtr.Zero,
@@ -345,37 +355,79 @@ namespace Microsoft.Win32
/// <returns>All value names.</returns>
private unsafe string[] GetValueNamesCore(int values)
{
- string[] names = new string[values];
- char[] name = new char[MaxValueLength + 1];
- int namelen;
+ var names = new List<string>(values);
+
+ // Names in the registry aren't usually very long, although they can go to as large
+ // as 16383 characters (MaxValueLength).
+ //
+ // Every call to RegEnumValue will allocate another buffer to get the data from
+ // NtEnumerateValueKey before copying it back out to our passed in buffer. This can
+ // add up quickly- we'll try to keep the memory pressure low and grow the buffer
+ // only if needed.
+
+ char[] name = ArrayPool<char>.Shared.Rent(100);
- fixed (char* namePtr = &name[0])
+ try
{
- for (int i = 0; i < values; i++)
+ int result;
+ int nameLength = name.Length;
+
+ while ((result = Interop.Advapi32.RegEnumValue(
+ _hkey,
+ names.Count,
+ name,
+ ref nameLength,
+ IntPtr.Zero,
+ null,
+ null,
+ null)) != Interop.Errors.ERROR_NO_MORE_ITEMS)
{
- namelen = name.Length;
-
- int ret = Interop.mincore.RegEnumValue(_hkey,
- i,
- namePtr,
- ref namelen,
- IntPtr.Zero,
- null,
- null,
- null);
-
- if (ret != 0)
+ switch (result)
{
- // ignore ERROR_MORE_DATA if we're querying HKEY_PERFORMANCE_DATA
- if (!(IsPerfDataKey() && ret == Interop.Errors.ERROR_MORE_DATA))
- Win32Error(ret, null);
+ // The size is only ever reported back correctly in the case
+ // of ERROR_SUCCESS. It will almost always be changed, however.
+ case Interop.Errors.ERROR_SUCCESS:
+ names.Add(new string(name, 0, nameLength));
+ break;
+ case Interop.Errors.ERROR_MORE_DATA:
+ if (IsPerfDataKey())
+ {
+ // Enumerating the values for Perf keys always returns
+ // ERROR_MORE_DATA, but has a valid name. Buffer does need
+ // to be big enough however. 8 characters is the largest
+ // known name. The size isn't returned, but the string is
+ // null terminated.
+ fixed (char* c = &name[0])
+ {
+ names.Add(new string(c));
+ }
+ }
+ else
+ {
+ char[] oldName = name;
+ int oldLength = oldName.Length;
+ name = null;
+ ArrayPool<char>.Shared.Return(oldName);
+ name = ArrayPool<char>.Shared.Rent(checked(oldLength * 2));
+ }
+ break;
+ default:
+ // Throw the error
+ Win32Error(result, null);
+ break;
}
- names[i] = new string(namePtr);
+ // Always set the name length back to the buffer size
+ nameLength = name.Length;
}
}
+ finally
+ {
+ if (name != null)
+ ArrayPool<char>.Shared.Return(name);
+ }
- return names;
+ return names.ToArray();
}
private object InternalGetValueCore(string name, object defaultValue, bool doNotExpand)
@@ -384,7 +436,7 @@ namespace Microsoft.Win32
int type = 0;
int datasize = 0;
- int ret = Interop.mincore.RegQueryValueEx(_hkey, name, null, ref type, (byte[])null, ref datasize);
+ int ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, (byte[])null, ref datasize);
if (ret != 0)
{
@@ -395,17 +447,17 @@ namespace Microsoft.Win32
int r;
byte[] blob = new byte[size];
- while (Interop.Errors.ERROR_MORE_DATA == (r = Interop.mincore.RegQueryValueEx(_hkey, name, null, ref type, blob, ref sizeInput)))
+ while (Interop.Errors.ERROR_MORE_DATA == (r = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, blob, ref sizeInput)))
{
- if (size == Int32.MaxValue)
+ if (size == int.MaxValue)
{
- // ERROR_MORE_DATA was returned however we cannot increase the buffer size beyond Int32.MaxValue
+ // ERROR_MORE_DATA was returned however we cannot increase the buffer size beyond int.MaxValue
Win32Error(r, name);
}
- else if (size > (Int32.MaxValue / 2))
+ else if (size > (int.MaxValue / 2))
{
// at this point in the loop "size * 2" would cause an overflow
- size = Int32.MaxValue;
+ size = int.MaxValue;
}
else
{
@@ -441,47 +493,47 @@ namespace Microsoft.Win32
switch (type)
{
- case Interop.mincore.RegistryValues.REG_NONE:
- case Interop.mincore.RegistryValues.REG_DWORD_BIG_ENDIAN:
- case Interop.mincore.RegistryValues.REG_BINARY:
+ case Interop.Advapi32.RegistryValues.REG_NONE:
+ case Interop.Advapi32.RegistryValues.REG_DWORD_BIG_ENDIAN:
+ case Interop.Advapi32.RegistryValues.REG_BINARY:
{
byte[] blob = new byte[datasize];
- ret = Interop.mincore.RegQueryValueEx(_hkey, name, null, ref type, blob, ref datasize);
+ ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, blob, ref datasize);
data = blob;
}
break;
- case Interop.mincore.RegistryValues.REG_QWORD:
+ case Interop.Advapi32.RegistryValues.REG_QWORD:
{ // also REG_QWORD_LITTLE_ENDIAN
if (datasize > 8)
{
// prevent an AV in the edge case that datasize is larger than sizeof(long)
- goto case Interop.mincore.RegistryValues.REG_BINARY;
+ goto case Interop.Advapi32.RegistryValues.REG_BINARY;
}
long blob = 0;
Debug.Assert(datasize == 8, "datasize==8");
// Here, datasize must be 8 when calling this
- ret = Interop.mincore.RegQueryValueEx(_hkey, name, null, ref type, ref blob, ref datasize);
+ ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, ref blob, ref datasize);
data = blob;
}
break;
- case Interop.mincore.RegistryValues.REG_DWORD:
+ case Interop.Advapi32.RegistryValues.REG_DWORD:
{ // also REG_DWORD_LITTLE_ENDIAN
if (datasize > 4)
{
// prevent an AV in the edge case that datasize is larger than sizeof(int)
- goto case Interop.mincore.RegistryValues.REG_QWORD;
+ goto case Interop.Advapi32.RegistryValues.REG_QWORD;
}
int blob = 0;
Debug.Assert(datasize == 4, "datasize==4");
// Here, datasize must be four when calling this
- ret = Interop.mincore.RegQueryValueEx(_hkey, name, null, ref type, ref blob, ref datasize);
+ ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, ref blob, ref datasize);
data = blob;
}
break;
- case Interop.mincore.RegistryValues.REG_SZ:
+ case Interop.Advapi32.RegistryValues.REG_SZ:
{
if (datasize % 2 == 1)
{
@@ -497,7 +549,7 @@ namespace Microsoft.Win32
}
char[] blob = new char[datasize / 2];
- ret = Interop.mincore.RegQueryValueEx(_hkey, name, null, ref type, blob, ref datasize);
+ ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, blob, ref datasize);
if (blob.Length > 0 && blob[blob.Length - 1] == (char)0)
{
data = new string(blob, 0, blob.Length - 1);
@@ -511,7 +563,7 @@ namespace Microsoft.Win32
}
break;
- case Interop.mincore.RegistryValues.REG_EXPAND_SZ:
+ case Interop.Advapi32.RegistryValues.REG_EXPAND_SZ:
{
if (datasize % 2 == 1)
{
@@ -527,7 +579,7 @@ namespace Microsoft.Win32
}
char[] blob = new char[datasize / 2];
- ret = Interop.mincore.RegQueryValueEx(_hkey, name, null, ref type, blob, ref datasize);
+ ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, blob, ref datasize);
if (blob.Length > 0 && blob[blob.Length - 1] == (char)0)
{
@@ -546,7 +598,7 @@ namespace Microsoft.Win32
}
}
break;
- case Interop.mincore.RegistryValues.REG_MULTI_SZ:
+ case Interop.Advapi32.RegistryValues.REG_MULTI_SZ:
{
if (datasize % 2 == 1)
{
@@ -562,7 +614,7 @@ namespace Microsoft.Win32
}
char[] blob = new char[datasize / 2];
- ret = Interop.mincore.RegQueryValueEx(_hkey, name, null, ref type, blob, ref datasize);
+ ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, blob, ref datasize);
// make sure the string is null terminated before processing the data
if (blob.Length > 0 && blob[blob.Length - 1] != (char)0)
@@ -622,7 +674,7 @@ namespace Microsoft.Win32
data = strings;
}
break;
- case Interop.mincore.RegistryValues.REG_LINK:
+ case Interop.Advapi32.RegistryValues.REG_LINK:
default:
break;
}
@@ -634,14 +686,14 @@ namespace Microsoft.Win32
{
int type = 0;
int datasize = 0;
- int ret = Interop.mincore.RegQueryValueEx(_hkey, name, null, ref type, (byte[])null, ref datasize);
+ int ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, (byte[])null, ref datasize);
if (ret != 0)
{
Win32Error(ret, null);
}
return
- type == Interop.mincore.RegistryValues.REG_NONE ? RegistryValueKind.None :
+ type == Interop.Advapi32.RegistryValues.REG_NONE ? RegistryValueKind.None :
!Enum.IsDefined(typeof(RegistryValueKind), type) ? RegistryValueKind.Unknown :
(RegistryValueKind)type;
}
@@ -719,8 +771,8 @@ namespace Microsoft.Win32
private static bool IsWritable(int rights)
{
- return (rights & (Interop.mincore.RegistryOperations.KEY_SET_VALUE |
- Interop.mincore.RegistryOperations.KEY_CREATE_SUB_KEY |
+ return (rights & (Interop.Advapi32.RegistryOperations.KEY_SET_VALUE |
+ Interop.Advapi32.RegistryOperations.KEY_CREATE_SUB_KEY |
(int)RegistryRights.Delete |
(int)RegistryRights.TakeOwnership |
(int)RegistryRights.ChangePermissions)) != 0;
diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs
index 1fd407afa..ecf8376ed 100644
--- a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs
+++ b/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs
@@ -167,6 +167,11 @@ namespace Microsoft.Win32
DeleteValueCore(name, throwOnMissingValue);
}
+ public static RegistryKey OpenBaseKey(RegistryHive hKey)
+ {
+ return OpenBaseKey(hKey, RegistryView.Default);
+ }
+
public static RegistryKey OpenBaseKey(RegistryHive hKey, RegistryView view)
{
ValidateKeyView(view);
@@ -530,7 +535,7 @@ namespace Microsoft.Win32
// the dispose below and usage elsewhere (other threads). This is By Design.
// This is less of an issue when OS > NT5 (i.e Vista & higher), we can close the perfkey
// (to release & refresh PERFLIB resources) and the OS will rebuild PERFLIB as necessary.
- Interop.mincore.RegCloseKey(RegistryKey.HKEY_PERFORMANCE_DATA);
+ Interop.Advapi32.RegCloseKey(RegistryKey.HKEY_PERFORMANCE_DATA);
}
}
}
@@ -552,5 +557,9 @@ namespace Microsoft.Win32
key._keyName = s_hkeyNames[index];
return key;
}
+
+ // This dummy method is added to have the same implemenatation of Registry class.
+ // Its not being used anywhere.
+ public void SetValue(string name, object value, RegistryValueKind valueKind) { }
}
}
diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryOptions.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryOptions.cs
deleted file mode 100644
index 90b6a3dd7..000000000
--- a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryOptions.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-
-namespace Microsoft.Win32
-{
- [Flags]
-#if REGISTRY_ASSEMBLY
- public
-#else
- internal
-#endif
- enum RegistryOptions
- {
- None = Interop.mincore.RegistryOptions.REG_OPTION_NON_VOLATILE, // 0x0000
- Volatile = Interop.mincore.RegistryOptions.REG_OPTION_VOLATILE, // 0x0001
- };
-}
diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryValueKind.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryValueKind.cs
deleted file mode 100644
index 4cf10c8df..000000000
--- a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryValueKind.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace Microsoft.Win32
-{
-#if REGISTRY_ASSEMBLY
- public
-#else
- internal
-#endif
- enum RegistryValueKind
- {
- String = Interop.mincore.RegistryValues.REG_SZ,
- ExpandString = Interop.mincore.RegistryValues.REG_EXPAND_SZ,
- Binary = Interop.mincore.RegistryValues.REG_BINARY,
- DWord = Interop.mincore.RegistryValues.REG_DWORD,
- MultiString = Interop.mincore.RegistryValues.REG_MULTI_SZ,
- QWord = Interop.mincore.RegistryValues.REG_QWORD,
- Unknown = 0, // REG_NONE is defined as zero but BCL
- None = unchecked((int)0xFFFFFFFF), // mistakenly overrode this value.
- } // Now instead of using Interop.mincore.RegistryValues.REG_NONE we use "-1".
-}
diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryValueOptions.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryValueOptions.cs
deleted file mode 100644
index 7d9b6c403..000000000
--- a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryValueOptions.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-
-namespace Microsoft.Win32
-{
- [Flags]
-#if REGISTRY_ASSEMBLY
- public
-#else
- internal
-#endif
- enum RegistryValueOptions
- {
- None = 0,
- DoNotExpandEnvironmentNames = 1
- }
-}
diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryView.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryView.cs
deleted file mode 100644
index 2256e2d7e..000000000
--- a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryView.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-
-namespace Microsoft.Win32
-{
-#if REGISTRY_ASSEMBLY
- public
-#else
- internal
-#endif
- enum RegistryView
- {
- Default = 0, // 0x0000 operate on the default registry view
- Registry64 = Interop.mincore.RegistryView.KEY_WOW64_64KEY, // 0x0100 operate on the 64-bit registry view
- Registry32 = Interop.mincore.RegistryView.KEY_WOW64_32KEY, // 0x0200 operate on the 32-bit registry view
- };
-}
diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeRegistryHandle.Windows.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeRegistryHandle.Windows.cs
deleted file mode 100644
index 83814f6ec..000000000
--- a/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeRegistryHandle.Windows.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Runtime.InteropServices;
-
-namespace Microsoft.Win32.SafeHandles
-{
-#if REGISTRY_ASSEMBLY
- public
-#else
- internal
-#endif
- sealed partial class SafeRegistryHandle : SafeHandle
- {
- protected override bool ReleaseHandle() =>
- Interop.mincore.RegCloseKey(handle) == Interop.Errors.ERROR_SUCCESS;
- }
-}
diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs
deleted file mode 100644
index 158b28683..000000000
--- a/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace Microsoft.Win32.SafeHandles
-{
- internal
- sealed partial class SafeRegistryHandle : SafeHandle
- {
- internal SafeRegistryHandle() : base(IntPtr.Zero, true) { }
-
- public SafeRegistryHandle(IntPtr preexistingHandle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
- {
- SetHandle(preexistingHandle);
- }
-
- public override bool IsInvalid => handle == IntPtr.Zero || handle == new IntPtr(-1);
- }
-}
diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.Unix.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.Unix.cs
new file mode 100644
index 000000000..35e464b67
--- /dev/null
+++ b/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.Unix.cs
@@ -0,0 +1,17 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Threading;
+
+namespace Microsoft.Win32.SafeHandles
+{
+ public sealed partial class SafeWaitHandle : SafeHandleZeroOrMinusOneIsInvalid
+ {
+ protected override bool ReleaseHandle()
+ {
+ WaitSubsystem.DeleteHandle(handle);
+ return true;
+ }
+ }
+}
diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs
deleted file mode 100644
index 7527395fe..000000000
--- a/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================
-**
-**
-**
-** A wrapper for Win32 events (mutexes, auto reset events, and
-** manual reset events). Used by WaitHandle.
-**
-**
-===========================================================*/
-
-using System;
-using System.Security;
-using System.Runtime.InteropServices;
-using System.Runtime.CompilerServices;
-using System.Runtime.Versioning;
-using Microsoft.Win32;
-using System.Threading;
-
-namespace Microsoft.Win32.SafeHandles
-{
- public sealed class SafeWaitHandle : SafeHandleZeroOrMinusOneIsInvalid
- {
- // Called by P/Invoke marshaler
- private SafeWaitHandle() : base(true)
- {
- }
-
- public SafeWaitHandle(IntPtr existingHandle, bool ownsHandle) : base(ownsHandle)
- {
- SetHandle(existingHandle);
- }
-
- protected override bool ReleaseHandle()
- {
-#if PLATFORM_UNIX
- WaitSubsystem.DeleteHandle(handle);
-#else
- Interop.Kernel32.CloseHandle(handle);
-#endif
- return true;
- }
- }
-}