diff options
author | Jan Kotas <jkotas@microsoft.com> | 2018-09-11 08:39:45 +0300 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2018-09-11 16:38:31 +0300 |
commit | f47c7a8697002b6f695d63cda91573ada89e79f0 (patch) | |
tree | 81c3a861c10ea9378654592f5c03d6226f490daf | |
parent | e17d570ba2836c923e1292519e27e576bee47461 (diff) |
Move registry interop to shared CoreLib partition (dotnet/coreclr#19886)
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
12 files changed, 297 insertions, 19 deletions
diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegCreateKeyEx.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegCreateKeyEx.cs new file mode 100644 index 000000000..e5219064b --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegCreateKeyEx.cs @@ -0,0 +1,27 @@ +// 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 Microsoft.Win32.SafeHandles; +using System; +using System.Runtime.InteropServices; + +internal partial class Interop +{ + internal partial class Advapi32 + { + // Note: RegCreateKeyEx won't set the last error on failure - it returns + // an error code if it fails. + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegCreateKeyExW")] + internal static extern int RegCreateKeyEx( + SafeRegistryHandle hKey, + string lpSubKey, + int Reserved, + string lpClass, + int dwOptions, + int samDesired, + ref Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs, + out SafeRegistryHandle hkResult, + out int lpdwDisposition); + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegDeleteKeyEx.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegDeleteKeyEx.cs new file mode 100644 index 000000000..4429515cd --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegDeleteKeyEx.cs @@ -0,0 +1,16 @@ +// 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 Microsoft.Win32.SafeHandles; +using System; +using System.Runtime.InteropServices; + +internal partial class Interop +{ + internal partial class Advapi32 + { + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegDeleteKeyExW")] + internal static extern int RegDeleteKeyEx(SafeRegistryHandle hKey, string lpSubKey, int samDesired, int Reserved); + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegDeleteValue.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegDeleteValue.cs new file mode 100644 index 000000000..b8044bc79 --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegDeleteValue.cs @@ -0,0 +1,16 @@ +// 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 Microsoft.Win32.SafeHandles; +using System; +using System.Runtime.InteropServices; + +internal partial class Interop +{ + internal partial class Advapi32 + { + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegDeleteValueW")] + internal static extern int RegDeleteValue(SafeRegistryHandle hKey, string lpValueName); + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs new file mode 100644 index 000000000..bedf28277 --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs @@ -0,0 +1,25 @@ +// 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 Microsoft.Win32.SafeHandles; +using System; +using System.Runtime.InteropServices; +using System.Text; + +internal partial class Interop +{ + internal partial class Advapi32 + { + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegEnumKeyExW")] + internal static extern unsafe int RegEnumKeyEx( + SafeRegistryHandle hKey, + int dwIndex, + char[] lpName, + ref int lpcbName, + int[] lpReserved, + [Out]StringBuilder lpClass, + int[] lpcbClass, + long[] lpftLastWriteTime); + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegEnumValue.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegEnumValue.cs new file mode 100644 index 000000000..e02ba98fe --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegEnumValue.cs @@ -0,0 +1,24 @@ +// 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 Microsoft.Win32.SafeHandles; +using System; +using System.Runtime.InteropServices; + +internal partial class Interop +{ + internal partial class Advapi32 + { + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegEnumValueW")] + internal static extern unsafe int RegEnumValue( + SafeRegistryHandle hKey, + int dwIndex, + char[] lpValueName, + ref int lpcbValueName, + IntPtr lpReserved_MustBeZero, + int[] lpType, + byte[] lpData, + int[] lpcbData); + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegOpenKeyEx.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegOpenKeyEx.cs new file mode 100644 index 000000000..86b6bcae2 --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegOpenKeyEx.cs @@ -0,0 +1,30 @@ +// 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 Microsoft.Win32.SafeHandles; +using System; +using System.Runtime.InteropServices; + +internal partial class Interop +{ + internal partial class Advapi32 + { + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegOpenKeyExW")] + internal static extern int RegOpenKeyEx( + SafeRegistryHandle hKey, + string lpSubKey, + int ulOptions, + int samDesired, + out SafeRegistryHandle hkResult); + + + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegOpenKeyExW")] + internal static extern int RegOpenKeyEx( + IntPtr hKey, + string lpSubKey, + int ulOptions, + int samDesired, + out SafeRegistryHandle hkResult); + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs new file mode 100644 index 000000000..2df209288 --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs @@ -0,0 +1,29 @@ +// 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 Microsoft.Win32.SafeHandles; +using System; +using System.Runtime.InteropServices; +using System.Text; + +internal partial class Interop +{ + internal partial class Advapi32 + { + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryInfoKeyW")] + internal static extern int RegQueryInfoKey( + SafeRegistryHandle hKey, + [Out]StringBuilder lpClass, + int[] lpcbClass, + IntPtr lpReserved_MustBeZero, + ref int lpcSubKeys, + int[] lpcbMaxSubKeyLen, + int[] lpcbMaxClassLen, + ref int lpcValues, + int[] lpcbMaxValueNameLen, + int[] lpcbMaxValueLen, + int[] lpcbSecurityDescriptor, + int[] lpftLastWriteTime); + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs new file mode 100644 index 000000000..c6a879817 --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs @@ -0,0 +1,59 @@ +// 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 Microsoft.Win32.SafeHandles; +using System; +using System.Runtime.InteropServices; +using System.Text; + +internal partial class Interop +{ + internal partial class Advapi32 + { + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW")] + internal static extern int RegQueryValueEx( + SafeRegistryHandle hKey, + string lpValueName, + int[] lpReserved, + ref int lpType, + [Out] byte[] lpData, + ref int lpcbData); + + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW")] + internal static extern int RegQueryValueEx( + SafeRegistryHandle hKey, + string lpValueName, + int[] lpReserved, + ref int lpType, + ref int lpData, + ref int lpcbData); + + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW")] + internal static extern int RegQueryValueEx( + SafeRegistryHandle hKey, + string lpValueName, + int[] lpReserved, + ref int lpType, + ref long lpData, + ref int lpcbData); + + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW")] + internal static extern int RegQueryValueEx( + SafeRegistryHandle hKey, + string lpValueName, + int[] lpReserved, + ref int lpType, + [Out] char[] lpData, + ref int lpcbData); + + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW")] + internal static extern int RegQueryValueEx( + SafeRegistryHandle hKey, + string lpValueName, + int[] lpReserved, + ref int lpType, + [Out]StringBuilder lpData, + ref int lpcbData); + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegSetValueEx.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegSetValueEx.cs new file mode 100644 index 000000000..d46f84809 --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegSetValueEx.cs @@ -0,0 +1,59 @@ +// 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 Microsoft.Win32; +using Microsoft.Win32.SafeHandles; +using System; +using System.Runtime.InteropServices; + +internal partial class Interop +{ + internal partial class Advapi32 + { + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW")] + internal static extern int RegSetValueEx( + SafeRegistryHandle hKey, + string lpValueName, + int Reserved, + RegistryValueKind dwType, + byte[] lpData, + int cbData); + + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW")] + internal static extern int RegSetValueEx( + SafeRegistryHandle hKey, + string lpValueName, + int Reserved, + RegistryValueKind dwType, + char[] lpData, + int cbData); + + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW")] + internal static extern int RegSetValueEx( + SafeRegistryHandle hKey, + string lpValueName, + int Reserved, + RegistryValueKind dwType, + ref int lpData, + int cbData); + + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW")] + internal static extern int RegSetValueEx( + SafeRegistryHandle hKey, + string lpValueName, + int Reserved, + RegistryValueKind dwType, + ref long lpData, + int cbData); + + [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW")] + internal static extern int RegSetValueEx( + SafeRegistryHandle hKey, + string lpValueName, + int Reserved, + RegistryValueKind dwType, + string lpData, + int cbData); + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.RegistryView.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.RegistryView.cs deleted file mode 100644 index 2e6786892..000000000 --- a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.RegistryView.cs +++ /dev/null @@ -1,15 +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. - -internal partial class Interop -{ - internal partial class Kernel32 - { - internal partial class RegistryView - { - internal const int KEY_WOW64_64KEY = 0x0100; - internal const int KEY_WOW64_32KEY = 0x0200; - } - } -} diff --git a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryView.cs b/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryView.cs index 3cc4a7878..0d6b3038e 100644 --- a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryView.cs +++ b/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryView.cs @@ -14,7 +14,7 @@ namespace Microsoft.Win32 enum RegistryView { Default = 0, // 0x0000 operate on the default registry view - Registry64 = Interop.Kernel32.RegistryView.KEY_WOW64_64KEY, // 0x0100 operate on the 64-bit registry view - Registry32 = Interop.Kernel32.RegistryView.KEY_WOW64_32KEY, // 0x0200 operate on the 32-bit registry view + Registry64 = Interop.Advapi32.RegistryView.KEY_WOW64_64KEY, // 0x0100 operate on the 64-bit registry view + Registry32 = Interop.Advapi32.RegistryView.KEY_WOW64_32KEY, // 0x0200 operate on the 32-bit registry view }; } diff --git a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems index b2db71d75..eae701602 100644 --- a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems @@ -802,8 +802,17 @@ </ItemGroup> <ItemGroup Condition="$(TargetsWindows) and '$(EnableWinRT)' != 'true'"> <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\NtDll\NtQueryInformationFile.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegCreateKeyEx.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegCloseKey.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegDeleteKeyEx.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegDeleteValue.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegEnumKeyEx.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegEnumValue.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegOpenKeyEx.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegQueryInfoKey.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegQueryValueEx.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegSetValueEx.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegistryConstants.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.RegistryView.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\IO\FileStream.Win32.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\TimeZoneInfo.Win32.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\Registry.cs" /> @@ -813,7 +822,6 @@ <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeLibraryHandle.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeRegistryHandle.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeRegistryHandle.Windows.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegCloseKey.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.LoadLibraryEx.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.FreeLibrary.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.CreateFile.cs" /> |