--- /dev/null
+// 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);
+ }
+}
--- /dev/null
+// 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);
+ }
+}
--- /dev/null
+// 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);
+ }
+}
--- /dev/null
+// 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);
+ }
+}
--- /dev/null
+// 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);
+ }
+}
--- /dev/null
+// 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);
+ }
+}
--- /dev/null
+// 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);
+ }
+}
--- /dev/null
+// 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);
+ }
+}
--- /dev/null
+// 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);
+ }
+}
+++ /dev/null
-// 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;
- }
- }
-}
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
};
}
</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" />
<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" />
public void DeleteValue(string name, bool throwOnMissingValue)
{
EnsureWriteable();
- int errorCode = Win32Native.RegDeleteValue(_hkey, name);
+ int errorCode = Interop.Advapi32.RegDeleteValue(_hkey, name);
//
// From windows 2003 server, if the name is too long we will get error code ERROR_FILENAME_EXCED_RANGE
name = FixupName(name); // Fixup multiple slashes to a single slash
SafeRegistryHandle result = null;
- int ret = Win32Native.RegOpenKeyEx(_hkey,
+ int ret = Interop.Advapi32.RegOpenKeyEx(_hkey,
name,
0,
GetRegistryKeyAccess(writable) | (int)_regView,
int result;
int nameLength = name.Length;
- while ((result = Win32Native.RegEnumKeyEx(
+ while ((result = Interop.Advapi32.RegEnumKeyEx(
_hkey,
names.Count,
name,
int result;
int nameLength = name.Length;
- while ((result = Win32Native.RegEnumValue(
+ while ((result = Interop.Advapi32.RegEnumValue(
_hkey,
names.Count,
name,
int type = 0;
int datasize = 0;
- int ret = Win32Native.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)
{
int r;
byte[] blob = new byte[size];
- while (Interop.Errors.ERROR_MORE_DATA == (r = Win32Native.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 == int.MaxValue)
{
switch (type)
{
- case Win32Native.REG_NONE:
- case Win32Native.REG_DWORD_BIG_ENDIAN:
- case Win32Native.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 = Win32Native.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 Win32Native.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 Win32Native.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 = Win32Native.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 Win32Native.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 Win32Native.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 = Win32Native.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 Win32Native.REG_SZ:
+ case Interop.Advapi32.RegistryValues.REG_SZ:
{
if (datasize % 2 == 1)
{
}
char[] blob = new char[datasize / 2];
- ret = Win32Native.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);
}
break;
- case Win32Native.REG_EXPAND_SZ:
+ case Interop.Advapi32.RegistryValues.REG_EXPAND_SZ:
{
if (datasize % 2 == 1)
{
}
char[] blob = new char[datasize / 2];
- ret = Win32Native.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 = Environment.ExpandEnvironmentVariables((string)data);
}
break;
- case Win32Native.REG_MULTI_SZ:
+ case Interop.Advapi32.RegistryValues.REG_MULTI_SZ:
{
if (datasize % 2 == 1)
{
}
char[] blob = new char[datasize / 2];
- ret = Win32Native.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)
strings.CopyTo((string[])data, 0);
}
break;
- case Win32Native.REG_LINK:
+ case Interop.Advapi32.RegistryValues.REG_LINK:
default:
break;
}
case RegistryValueKind.String:
{
string data = value.ToString();
- ret = Win32Native.RegSetValueEx(_hkey,
+ ret = Interop.Advapi32.RegSetValueEx(_hkey,
name,
0,
valueKind,
*(char*)(currentPtr.ToPointer()) = '\0';
currentPtr = new IntPtr((long)currentPtr + 2);
- ret = Win32Native.RegSetValueEx(_hkey,
+ ret = Interop.Advapi32.RegSetValueEx(_hkey,
name,
0,
RegistryValueKind.MultiString,
case RegistryValueKind.None:
case RegistryValueKind.Binary:
byte[] dataBytes = (byte[])value;
- ret = Win32Native.RegSetValueEx(_hkey,
+ ret = Interop.Advapi32.RegSetValueEx(_hkey,
name,
0,
- (valueKind == RegistryValueKind.None ? Win32Native.REG_NONE : RegistryValueKind.Binary),
+ (valueKind == RegistryValueKind.None ? Interop.Advapi32.RegistryValues.REG_NONE : RegistryValueKind.Binary),
dataBytes,
dataBytes.Length);
break;
// unboxed and cast at the same time. I.e. ((int)(object)(short) 5) will fail.
int data = Convert.ToInt32(value, System.Globalization.CultureInfo.InvariantCulture);
- ret = Win32Native.RegSetValueEx(_hkey,
+ ret = Interop.Advapi32.RegSetValueEx(_hkey,
name,
0,
RegistryValueKind.DWord,
{
long data = Convert.ToInt64(value, System.Globalization.CultureInfo.InvariantCulture);
- ret = Win32Native.RegSetValueEx(_hkey,
+ ret = Interop.Advapi32.RegSetValueEx(_hkey,
name,
0,
RegistryValueKind.QWord,
int winAccess;
if (!isWritable)
{
- winAccess = Win32Native.KEY_READ;
+ winAccess = Interop.Advapi32.RegistryOperations.KEY_READ;
}
else
{
- winAccess = Win32Native.KEY_READ | Win32Native.KEY_WRITE;
+ winAccess = Interop.Advapi32.RegistryOperations.KEY_READ | Interop.Advapi32.RegistryOperations.KEY_WRITE;
}
return winAccess;
internal static class Win32Native
{
- internal const int KEY_QUERY_VALUE = 0x0001;
- internal const int KEY_SET_VALUE = 0x0002;
- internal const int KEY_CREATE_SUB_KEY = 0x0004;
- internal const int KEY_ENUMERATE_SUB_KEYS = 0x0008;
- internal const int KEY_NOTIFY = 0x0010;
- internal const int KEY_CREATE_LINK = 0x0020;
- internal const int KEY_READ = ((STANDARD_RIGHTS_READ |
- KEY_QUERY_VALUE |
- KEY_ENUMERATE_SUB_KEYS |
- KEY_NOTIFY)
- &
- (~SYNCHRONIZE));
-
- internal const int KEY_WRITE = ((STANDARD_RIGHTS_WRITE |
- KEY_SET_VALUE |
- KEY_CREATE_SUB_KEY)
- &
- (~SYNCHRONIZE));
- internal const int REG_OPTION_NON_VOLATILE = 0x0000; // (default) keys are persisted beyond reboot/unload
- internal const int REG_OPTION_VOLATILE = 0x0001; // All keys created by the function are volatile
- internal const int REG_OPTION_CREATE_LINK = 0x0002; // They key is a symbolic link
- internal const int REG_OPTION_BACKUP_RESTORE = 0x0004; // Use SE_BACKUP_NAME process special privileges
- internal const int REG_NONE = 0; // No value type
- internal const int REG_SZ = 1; // Unicode nul terminated string
- internal const int REG_EXPAND_SZ = 2; // Unicode nul terminated string
- // (with environment variable references)
- internal const int REG_BINARY = 3; // Free form binary
- internal const int REG_DWORD = 4; // 32-bit number
- internal const int REG_DWORD_LITTLE_ENDIAN = 4; // 32-bit number (same as REG_DWORD)
- internal const int REG_DWORD_BIG_ENDIAN = 5; // 32-bit number
- internal const int REG_LINK = 6; // Symbolic Link (unicode)
- internal const int REG_MULTI_SZ = 7; // Multiple Unicode strings
- internal const int REG_RESOURCE_LIST = 8; // Resource list in the resource map
- internal const int REG_FULL_RESOURCE_DESCRIPTOR = 9; // Resource list in the hardware description
- internal const int REG_RESOURCE_REQUIREMENTS_LIST = 10;
- internal const int REG_QWORD = 11; // 64-bit number
-
- // Win32 ACL-related constants:
- internal const int READ_CONTROL = 0x00020000;
- internal const int SYNCHRONIZE = 0x00100000;
-
- internal const int STANDARD_RIGHTS_READ = READ_CONTROL;
- internal const int STANDARD_RIGHTS_WRITE = READ_CONTROL;
-
internal const int LMEM_FIXED = 0x0000;
internal const int LMEM_ZEROINIT = 0x0040;
internal const int LPTR = (LMEM_FIXED | LMEM_ZEROINIT);
}
[StructLayout(LayoutKind.Sequential)]
- internal class SECURITY_ATTRIBUTES
- {
- internal int nLength = 0;
- // don't remove null, or this field will disappear in bcl.small
- internal unsafe byte* pSecurityDescriptor = null;
- internal int bInheritHandle = 0;
- }
-
- [StructLayout(LayoutKind.Sequential)]
internal struct MEMORYSTATUSEX
{
// The length field must be set to the size of this data structure.
}
internal const string ADVAPI32 = "advapi32.dll";
- internal const string SHELL32 = "shell32.dll";
- internal const string SHIM = "mscoree.dll";
- internal const string CRYPT32 = "crypt32.dll";
- internal const string SECUR32 = "secur32.dll";
- internal const string MSCORWKS = "coreclr.dll";
[DllImport(Interop.Libraries.Kernel32, EntryPoint = "LocalAlloc")]
internal static extern IntPtr LocalAlloc_NoSafeHandle(int uFlags, UIntPtr sizetdwBytes);
[DllImport(Interop.Libraries.Ole32)]
internal static extern IntPtr CoTaskMemRealloc(IntPtr pv, UIntPtr cb);
-#if FEATURE_WIN32_REGISTRY
-
- [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern int RegDeleteValue(SafeRegistryHandle hKey, string lpValueName);
-
- [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern unsafe int RegEnumKeyEx(SafeRegistryHandle hKey, int dwIndex,
- char[] lpName, ref int lpcbName, int[] lpReserved,
- [Out]StringBuilder lpClass, int[] lpcbClass,
- long[] lpftLastWriteTime);
-
- [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern unsafe int RegEnumValue(SafeRegistryHandle hKey, int dwIndex,
- char[] lpValueName, ref int lpcbValueName,
- IntPtr lpReserved_MustBeZero, int[] lpType, byte[] lpData,
- int[] lpcbData);
-
- [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern int RegOpenKeyEx(SafeRegistryHandle hKey, string lpSubKey,
- int ulOptions, int samDesired, out SafeRegistryHandle hkResult);
-
- [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName,
- int[] lpReserved, ref int lpType, [Out] byte[] lpData,
- ref int lpcbData);
-
- [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName,
- int[] lpReserved, ref int lpType, ref int lpData,
- ref int lpcbData);
-
- [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName,
- int[] lpReserved, ref int lpType, ref long lpData,
- ref int lpcbData);
-
- [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName,
- int[] lpReserved, ref int lpType, [Out] char[] lpData,
- ref int lpcbData);
-
- [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern int RegSetValueEx(SafeRegistryHandle hKey, string lpValueName,
- int Reserved, RegistryValueKind dwType, byte[] lpData, int cbData);
-
- [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern int RegSetValueEx(SafeRegistryHandle hKey, string lpValueName,
- int Reserved, RegistryValueKind dwType, ref int lpData, int cbData);
-
- [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern int RegSetValueEx(SafeRegistryHandle hKey, string lpValueName,
- int Reserved, RegistryValueKind dwType, ref long lpData, int cbData);
-
- [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)]
- internal static extern int RegSetValueEx(SafeRegistryHandle hKey, string lpValueName,
- int Reserved, RegistryValueKind dwType, string lpData, int cbData);
-#endif // FEATURE_WIN32_REGISTRY
-
[DllImport(Interop.Libraries.Kernel32, CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false)]
internal static extern int ExpandEnvironmentStrings(string lpSrc, [Out]StringBuilder lpDst, int nSize);