You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
@@ -26,10 +26,10 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{20A2BA2C-5517-483F-8FFE-643441A59852}.Debug|Any CPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
|
||||
{20A2BA2C-5517-483F-8FFE-643441A59852}.Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
|
||||
{20A2BA2C-5517-483F-8FFE-643441A59852}.Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
|
||||
{20A2BA2C-5517-483F-8FFE-643441A59852}.Release|Any CPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
|
||||
{20A2BA2C-5517-483F-8FFE-643441A59852}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{20A2BA2C-5517-483F-8FFE-643441A59852}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{20A2BA2C-5517-483F-8FFE-643441A59852}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{20A2BA2C-5517-483F-8FFE-643441A59852}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
|
||||
{D3F18ACC-D327-4ABB-BA6C-E9C34A041B2F}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{D3F18ACC-D327-4ABB-BA6C-E9C34A041B2F}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{D3F18ACC-D327-4ABB-BA6C-E9C34A041B2F}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\dir.props" />
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>4.1.0.0</AssemblyVersion>
|
||||
<AssemblyVersion>4.1.1.0</AssemblyVersion>
|
||||
<AssemblyKey>MSFT</AssemblyKey>
|
||||
<IsNETCoreApp>true</IsNETCoreApp>
|
||||
<IsNETCoreAppRef>false</IsNETCoreAppRef>
|
||||
<IsUAP>true</IsUAP>
|
||||
<IsUAPRef>false</IsUAPRef>
|
||||
<IsDesktopFacade>true</IsDesktopFacade>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -3,12 +3,18 @@
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ref\Microsoft.Win32.Registry.csproj">
|
||||
<SupportedFramework>net463;netcoreapp2.0</SupportedFramework>
|
||||
<SupportedFramework>net461;netcoreapp2.0;$(AllXamarinFrameworks)</SupportedFramework>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\src\Microsoft.Win32.Registry.csproj" />
|
||||
<NotSupportedOnTargetFramework Include="netcore50">
|
||||
<PackageTargetRuntime>win</PackageTargetRuntime>
|
||||
</NotSupportedOnTargetFramework>
|
||||
<HarvestIncludePaths Include="ref/net46;lib/net46;runtimes/win/lib/net46" />
|
||||
<HarvestIncludePaths Include="ref/netstandard1.3">
|
||||
<SupportedFramework>netcore50</SupportedFramework>
|
||||
</HarvestIncludePaths>
|
||||
<HarvestIncludePaths Include="runtimes/win/lib/netstandard1.3" />
|
||||
<HarvestIncludePaths Include="runtimes/unix/lib/netstandard1.3">
|
||||
<!-- package unix impl (platform not supported) as RID agnostic -->
|
||||
<TargetPath>lib/netstandard1.3</TargetPath>
|
||||
</HarvestIncludePaths>
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
@@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netstandard;
|
||||
netfx;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -3,16 +3,19 @@
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{EEC02D4E-217E-4B4D-A7DA-5038FAD44A18}</ProjectGuid>
|
||||
<!-- UAP10.1 is not yet mapped to netstandard2.0, manually duplicate this ref -->
|
||||
<PackageTargetFramework>netstandard2.0;uap10.1</PackageTargetFramework>
|
||||
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="Microsoft.Win32.Registry.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<SuppressPackageTargetFrameworkCompatibility Include="uap10.1" />
|
||||
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
|
||||
<Reference Include="mscorlib" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
|
||||
<ProjectReference Include="..\..\System.Security.AccessControl\ref\System.Security.AccessControl.csproj" />
|
||||
<ProjectReference Include="..\..\System.Security.Principal.Windows\ref\System.Security.Principal.Windows.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
uap-Windows_NT;
|
||||
netcoreapp-Windows_NT;
|
||||
netcoreapp-Unix;
|
||||
netfx;
|
||||
netstandard;
|
||||
netfx-Windows_NT;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -8,22 +8,22 @@
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DefineConstants>$(DefineConstants);REGISTRY_ASSEMBLY</DefineConstants>
|
||||
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
|
||||
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetGroup)' == 'netstandard'">SR.PlatformNotSupported_Registry</GeneratePlatformNotSupportedAssemblyMessage>
|
||||
<!--
|
||||
Temporarily necessary as this is only being built for UWP due to an unwanted dependency on it
|
||||
https://github.com/dotnet/corefx/issues/15966
|
||||
-->
|
||||
<EnablePinvokeUWPAnalyzer>false</EnablePinvokeUWPAnalyzer>
|
||||
</PropertyGroup>
|
||||
<!-- Help VS understand available configurations -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
|
||||
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' or '$(TargetGroup)' == 'uap'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
|
||||
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\advapi32\Interop.RegistryOptions.cs">
|
||||
<Link>Common\Interop\Windows\Interop.RegistryOptions.cs</Link>
|
||||
</Compile>
|
||||
@@ -40,7 +40,7 @@
|
||||
<Compile Include="System\Security\AccessControl\RegistryRights.cs" />
|
||||
<Compile Include="System\Security\AccessControl\RegistrySecurity.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="('$(TargetGroup)' == 'netcoreapp' or '$(TargetGroup)' == 'uap') AND '$(TargetsWindows)' == 'true'">
|
||||
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' AND '$(TargetsWindows)' == 'true'">
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\Interop.Libraries.cs">
|
||||
<Link>Common\Interop\Windows\Interop.Libraries.cs</Link>
|
||||
</Compile>
|
||||
@@ -105,6 +105,8 @@
|
||||
<Reference Include="mscorlib" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Buffers" />
|
||||
<Reference Include="System.Collections" />
|
||||
<Reference Include="System.Diagnostics.Debug" />
|
||||
<Reference Include="System.Diagnostics.Tools" />
|
||||
<Reference Include="System.Resources.ResourceManager" />
|
||||
|
||||
@@ -9,7 +9,6 @@ namespace Microsoft.Win32
|
||||
/**
|
||||
* Registry hive values. Useful only for GetRemoteBaseKey
|
||||
*/
|
||||
[Serializable]
|
||||
#if REGISTRY_ASSEMBLY
|
||||
public
|
||||
#else
|
||||
|
||||
@@ -16,44 +16,37 @@ namespace Microsoft.Win32
|
||||
{
|
||||
private void ClosePerfDataKey()
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private void FlushCore()
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private RegistryKey CreateSubKeyInternalCore(string subkey, RegistryKeyPermissionCheck permissionCheck, object registrySecurityObj, RegistryOptions registryOptions)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private void DeleteSubKeyCore(string subkey, bool throwOnMissingSubKey)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private void DeleteSubKeyTreeCore(string subkey)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private void DeleteValueCore(string name, bool throwOnMissingValue)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private static RegistryKey OpenBaseKeyCore(RegistryHive hKey, RegistryView view)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private static RegistryKey OpenRemoteBaseKeyCore(RegistryHive hKey, string machineName, RegistryView view)
|
||||
@@ -63,95 +56,70 @@ namespace Microsoft.Win32
|
||||
|
||||
private RegistryKey InternalOpenSubKeyCore(string name, RegistryKeyPermissionCheck permissionCheck, int rights, bool throwOnPermissionFailure)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private RegistryKey InternalOpenSubKeyCore(string name, bool writable, bool throwOnPermissionFailure)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
internal RegistryKey InternalOpenSubKeyWithoutSecurityChecksCore(string name, bool writable)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private SafeRegistryHandle SystemKeyHandle
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
}
|
||||
|
||||
private int InternalSubKeyCountCore()
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private string[] InternalGetSubKeyNamesCore(int subkeys)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private int InternalValueCountCore()
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private string[] GetValueNamesCore(int values)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private Object InternalGetValueCore(string name, Object defaultValue, bool doNotExpand)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private RegistryValueKind GetValueKindCore(string name)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private void SetValueCore(string name, Object value, RegistryValueKind valueKind)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
private bool ContainsRegistryValueCore(string name)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
private static bool IsWritable(int rights)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private static int GetRegistryKeyAccess(bool isWritable)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
|
||||
private static int GetRegistryKeyAccess(RegistryKeyPermissionCheck mode)
|
||||
{
|
||||
// TODO: Implement this
|
||||
throw new PlatformNotSupportedException();
|
||||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_Registry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Security.AccessControl;
|
||||
using System.Buffers;
|
||||
|
||||
/*
|
||||
Note on transaction support:
|
||||
@@ -393,36 +394,45 @@ 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++)
|
||||
{
|
||||
namelen = name.Length; // Don't remove this. The API's doesn't work if this is not properly initialized.
|
||||
int ret = Interop.Advapi32.RegEnumKeyEx(_hkey,
|
||||
i,
|
||||
namePtr,
|
||||
ref namelen,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
if (ret != 0)
|
||||
{
|
||||
Win32Error(ret, null);
|
||||
}
|
||||
int result;
|
||||
int nameLength = name.Length;
|
||||
|
||||
names[i] = new string(namePtr);
|
||||
while ((result = Interop.Advapi32.RegEnumKeyEx(
|
||||
_hkey,
|
||||
names.Count,
|
||||
name,
|
||||
ref nameLength,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null)) != Interop.Errors.ERROR_NO_MORE_ITEMS)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case Interop.Errors.ERROR_SUCCESS:
|
||||
names.Add(new string(name, 0, nameLength));
|
||||
nameLength = name.Length;
|
||||
break;
|
||||
default:
|
||||
// Throw the error
|
||||
Win32Error(result, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ArrayPool<char>.Shared.Return(name);
|
||||
}
|
||||
|
||||
return names;
|
||||
return names.ToArray();
|
||||
}
|
||||
|
||||
private int InternalValueCountCore()
|
||||
@@ -453,37 +463,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);
|
||||
|
||||
fixed (char* namePtr = &name[0])
|
||||
// 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);
|
||||
|
||||
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.Advapi32.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)
|
||||
@@ -505,15 +557,15 @@ namespace Microsoft.Win32
|
||||
byte[] blob = new byte[size];
|
||||
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
|
||||
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
|
||||
{
|
||||
@@ -872,14 +924,6 @@ namespace Microsoft.Win32
|
||||
}
|
||||
}
|
||||
|
||||
private bool ContainsRegistryValueCore(string name)
|
||||
{
|
||||
int type = 0;
|
||||
int datasize = 0;
|
||||
int retval = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, (byte[])null, ref datasize);
|
||||
return retval == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// After calling GetLastWin32Error(), it clears the last error field,
|
||||
/// so you must save the HResult and pass it to this method. This method
|
||||
@@ -936,15 +980,6 @@ namespace Microsoft.Win32
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsWritable(int rights)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
private static int GetRegistryKeyAccess(bool isWritable)
|
||||
{
|
||||
int winAccess;
|
||||
|
||||
@@ -124,6 +124,9 @@
|
||||
<data name="ObjectDisposed_RegKeyClosed" xml:space="preserve">
|
||||
<value>Cannot access a closed registry key.</value>
|
||||
</data>
|
||||
<data name="PlatformNotSupported_Registry" xml:space="preserve">
|
||||
<value>Registry is not supported on this platform.</value>
|
||||
</data>
|
||||
<data name="Security_RegistryPermission" xml:space="preserve">
|
||||
<value>Requested registry access is not allowed.</value>
|
||||
</data>
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netstandard-Windows_NT;
|
||||
netcoreapp-Windows_NT;
|
||||
netfx-Windows_NT;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
<ProjectGuid>{20A2BA2C-5517-483F-8FFE-643441A59852}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<!-- Default configurations to help VS understand the configurations -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\Interop.Libraries.cs">
|
||||
<Link>Common\Interop\Windows\Interop.Libraries.cs</Link>
|
||||
@@ -61,6 +63,9 @@
|
||||
<Compile Include="RegistryTestsBase.cs" />
|
||||
<Compile Include="TestData.cs" />
|
||||
<Compile Include="XunitAssemblyAttributes.cs" />
|
||||
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
|
||||
<Link>Common\System\AssertExtensions.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Microsoft.Win32.RegistryTests
|
||||
[Fact]
|
||||
public static void NullKeyName_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("keyName", () => Registry.GetValue(null, null, null));
|
||||
AssertExtensions.Throws<ArgumentNullException>("keyName", () => Registry.GetValue(null, null, null));
|
||||
}
|
||||
|
||||
public static readonly object[][] ArgumentExceptionTestData =
|
||||
|
||||
@@ -41,23 +41,6 @@ namespace Microsoft.Win32.RegistryTests
|
||||
});
|
||||
}
|
||||
|
||||
[ActiveIssue(10546)]
|
||||
[Fact]
|
||||
public void NegativeTest_DeeplyNestedKey()
|
||||
{
|
||||
// Max number of parts to the registry key path is 509 (failing once it hits 510).
|
||||
// As TestRegistryKey is already a subkey, that gives us 507 remaining parts before an
|
||||
// exception is thrown.
|
||||
const int maxNestedLevel = 507;
|
||||
string exceedsNestedSubkeyName = string.Join(@"\", Enumerable.Repeat("a", maxNestedLevel));
|
||||
using (RegistryKey k = TestRegistryKey.CreateSubKey(exceedsNestedSubkeyName))
|
||||
{
|
||||
// Verify TestRegistryKey is already nested, with 508 slashes meaning 509 parts
|
||||
Assert.Equal(maxNestedLevel + 1, k.Name.Count(c => c == '\\'));
|
||||
}
|
||||
Assert.Throws<IOException>(() => TestRegistryKey.CreateSubKey(exceedsNestedSubkeyName + @"\" + maxNestedLevel));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreateSubkeyWithEmptyName()
|
||||
{
|
||||
|
||||
@@ -111,17 +111,6 @@ namespace Microsoft.Win32.RegistryTests
|
||||
});
|
||||
}
|
||||
|
||||
[ActiveIssue(10546)]
|
||||
[Fact]
|
||||
public void NegativeTest_DeeplyNestedKey()
|
||||
{
|
||||
//According to msdn documentation max nesting level exceeds is 510 but actual is 508
|
||||
const int maxNestedLevel = 508;
|
||||
string exceedsNestedSubkeyName = string.Join(@"\", Enumerable.Repeat("a", maxNestedLevel));
|
||||
Assert.Throws<IOException>(() => TestRegistryKey.CreateSubKey(exceedsNestedSubkeyName, true));
|
||||
Assert.Throws<IOException>(() => TestRegistryKey.CreateSubKey(exceedsNestedSubkeyName, RegistryKeyPermissionCheck.ReadWriteSubTree));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreateWritableSubkeyWithEmptyName()
|
||||
{
|
||||
|
||||
@@ -62,7 +62,8 @@ namespace Microsoft.Win32.RegistryTests
|
||||
public static void TestGetValueNamesForPerformanceData()
|
||||
{
|
||||
var rk = Registry.PerformanceData;
|
||||
int iNumValue = rk.GetValueNames().Length;
|
||||
string[] names = rk.GetValueNames();
|
||||
Assert.Equal(new string[] { "Global", "Costly" }, names);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user