Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ internal static class TransactedRegistry
/// subkeys, there must be a Transaction.Current and the resulting TransactedRegistryKey from those operations ARE associated with
/// the transaction.</para>
/// </summary>
[ResourceExposure(ResourceScope.Machine)]
// The TransactedRegistryKey's members cannot be changed.
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
internal static readonly TransactedRegistryKey CurrentUser = TransactedRegistryKey.GetBaseKey(BaseRegistryKeys.HKEY_CURRENT_USER);
Expand All @@ -61,7 +60,6 @@ internal static class TransactedRegistry
/// subkeys, there must be a Transaction.Current and the resulting TransactedRegistryKey from those operations ARE associated with
/// the transaction.</para>
/// </summary>
[ResourceExposure(ResourceScope.Machine)]
// The TransactedRegistryKey's members cannot be changed.
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
internal static readonly TransactedRegistryKey LocalMachine = TransactedRegistryKey.GetBaseKey(BaseRegistryKeys.HKEY_LOCAL_MACHINE);
Expand All @@ -80,7 +78,6 @@ internal static class TransactedRegistry
/// subkeys, there must be a Transaction.Current and the resulting TransactedRegistryKey from those operations ARE associated with
/// the transaction.</para>
/// </summary>
[ResourceExposure(ResourceScope.Machine)]
// The TransactedRegistryKey's members cannot be changed.
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
internal static readonly TransactedRegistryKey ClassesRoot = TransactedRegistryKey.GetBaseKey(BaseRegistryKeys.HKEY_CLASSES_ROOT);
Expand All @@ -99,7 +96,6 @@ internal static class TransactedRegistry
/// subkeys, there must be a Transaction.Current and the resulting TransactedRegistryKey from those operations ARE associated with
/// the transaction.</para>
/// </summary>
[ResourceExposure(ResourceScope.Machine)]
// The TransactedRegistryKey's members cannot be changed.
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
internal static readonly TransactedRegistryKey Users = TransactedRegistryKey.GetBaseKey(BaseRegistryKeys.HKEY_USERS);
Expand All @@ -118,7 +114,6 @@ internal static class TransactedRegistry
/// subkeys, there must be a Transaction.Current and the resulting TransactedRegistryKey from those operations ARE associated with
/// the transaction.</para>
/// </summary>
[ResourceExposure(ResourceScope.Machine)]
// The TransactedRegistryKey's members cannot be changed.
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
internal static readonly TransactedRegistryKey CurrentConfig = TransactedRegistryKey.GetBaseKey(BaseRegistryKeys.HKEY_CURRENT_CONFIG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,6 @@ public void Dispose()
/// otherwise an ArgumentException is thrown.</param>
/// <returns>A TransactedRegistryKey object for the subkey, which is associated with Transaction.Current.
/// returns null if the operation failed.</returns>
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public TransactedRegistryKey CreateSubKey(string subkey)
Expand All @@ -366,8 +364,6 @@ public TransactedRegistryKey CreateSubKey(string subkey)
/// <param name='permissionCheck'>One of the Microsoft.Win32.RegistryKeyPermissionCheck values that
/// specifies whether the key is opened for read or read/write access.</param>
[ComVisible(false)]
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public TransactedRegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck)
Expand All @@ -387,8 +383,6 @@ public TransactedRegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCh
/// specifies whether the key is opened for read or read/write access.</param>
/// <param name='registrySecurity'>A TransactedRegistrySecurity object that specifies the access control security for the new key.</param>
[ComVisible(false)]
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public unsafe TransactedRegistryKey CreateSubKey(string subkey, RegistryKeyPermissionCheck permissionCheck, TransactedRegistrySecurity registrySecurity)
Expand All @@ -397,8 +391,6 @@ public unsafe TransactedRegistryKey CreateSubKey(string subkey, RegistryKeyPermi
}

[ComVisible(false)]
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
private unsafe TransactedRegistryKey CreateSubKeyInternal(string subkey, RegistryKeyPermissionCheck permissionCheck, object registrySecurityObj)
Expand Down Expand Up @@ -489,8 +481,6 @@ private unsafe TransactedRegistryKey CreateSubKeyInternal(string subkey, Registr
/// <exception cref="InvalidOperationException">Thrown if the subkey as child subkeys.</exception>
/// </summary>
/// <param name='subkey'>The subkey to delete.</param>
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public void DeleteSubKey(string subkey)
Expand All @@ -510,8 +500,6 @@ public void DeleteSubKey(string subkey)
/// <param name='throwOnMissingSubKey'>Specify true if an ArgumentException should be thrown if
/// the specified subkey does not exist. If false is specified, a missing subkey does not throw
/// an exception.</param>
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public void DeleteSubKey(string subkey, bool throwOnMissingSubKey)
Expand Down Expand Up @@ -569,8 +557,6 @@ public void DeleteSubKey(string subkey, bool throwOnMissingSubKey)
/// Utilizes Transaction.Current for its transaction.</para>
/// </summary>
/// <param name="subkey">The subkey to delete.</param>
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public void DeleteSubKeyTree(string subkey)
Expand Down Expand Up @@ -626,8 +612,6 @@ public void DeleteSubKeyTree(string subkey)

// An internal version which does no security checks or argument checking. Skipping the
// security checks should give us a slight perf gain on large trees.
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
private void DeleteSubKeyTreeInternal(string subkey)
Expand Down Expand Up @@ -672,8 +656,6 @@ private void DeleteSubKeyTreeInternal(string subkey)
/// Utilizes Transaction.Current for its transaction.</para>
/// </summary>
/// <param name="name">Name of the value to delete.</param>
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
public void DeleteValue(string name)
{
DeleteValue(name, true);
Expand All @@ -687,8 +669,6 @@ public void DeleteValue(string name)
/// <param name="throwOnMissingValue">Specify true if an ArgumentException should be thrown if
/// the specified value does not exist. If false is specified, a missing value does not throw
/// an exception.</param>
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
public void DeleteValue(string name, bool throwOnMissingValue)
{
EnsureWriteable();
Expand Down Expand Up @@ -758,8 +738,6 @@ internal static TransactedRegistryKey GetBaseKey(IntPtr hKey)
/// <returns>The subkey requested or null if the operation failed.</returns>
/// <param name="name">Name or path of the subkey to open.</param>
/// <param name="writable">Set to true of you only need readonly access.</param>
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public TransactedRegistryKey OpenSubKey(string name, bool writable)
Expand Down Expand Up @@ -803,8 +781,6 @@ public TransactedRegistryKey OpenSubKey(string name, bool writable)
/// <param name="permissionCheck">One of the Microsoft.Win32.RegistryKeyPermissionCheck values that specifies
/// whether the key is opened for read or read/write access.</param>
[ComVisible(false)]
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public TransactedRegistryKey OpenSubKey(string name, RegistryKeyPermissionCheck permissionCheck)
Expand All @@ -823,17 +799,13 @@ public TransactedRegistryKey OpenSubKey(string name, RegistryKeyPermissionCheck
/// whether the key is opened for read or read/write access.</param>
/// <param name="rights">A bitwise combination of Microsoft.Win32.RegistryRights values that specifies the desired security access.</param>
[ComVisible(false)]
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public TransactedRegistryKey OpenSubKey(string name, RegistryKeyPermissionCheck permissionCheck, RegistryRights rights)
{
return InternalOpenSubKey(name, permissionCheck, (int)rights);
}

[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
private TransactedRegistryKey InternalOpenSubKey(string name, RegistryKeyPermissionCheck permissionCheck, int rights)
Expand Down Expand Up @@ -874,8 +846,6 @@ private TransactedRegistryKey InternalOpenSubKey(string name, RegistryKeyPermiss

// This required no security checks. This is to get around the Deleting SubKeys which only require
// write permission. They call OpenSubKey which required read. Now instead call this function w/o security checks
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
internal TransactedRegistryKey InternalOpenSubKey(string name, bool writable)
Expand Down Expand Up @@ -906,8 +876,6 @@ internal TransactedRegistryKey InternalOpenSubKey(string name, bool writable)
/// </summary>
/// <returns>The subkey requested or null if the operation failed.</returns>
/// <param name="name">Name or path of the subkey to open.</param>
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
// Suppressed to be consistent with naming in Microsoft.Win32.RegistryKey
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public TransactedRegistryKey OpenSubKey(string name)
Expand Down
4 changes: 0 additions & 4 deletions src/System.Management.Automation/namespaces/Win32Native.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ internal struct TOKEN_USER
/// <param name="peUse"></param>
/// <returns></returns>
[DllImport(PinvokeDllNames.LookupAccountSidDllName, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
[ResourceExposure(ResourceScope.Machine)]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern unsafe bool LookupAccountSid(string lpSystemName,
Expand Down Expand Up @@ -139,7 +138,6 @@ internal static unsafe bool LookupAccountSid(string lpSystemName,
}

[DllImport(PinvokeDllNames.CloseHandleDllName, SetLastError = true)]
[ResourceExposure(ResourceScope.Machine)]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool CloseHandle(IntPtr handle);
Expand All @@ -152,7 +150,6 @@ internal static unsafe bool LookupAccountSid(string lpSystemName,
/// <param name="tokenHandle">Process token.</param>
/// <returns>The current process token.</returns>
[DllImport(PinvokeDllNames.OpenProcessTokenDllName, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
[ResourceExposure(ResourceScope.Machine)]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool OpenProcessToken(IntPtr processHandle, uint desiredAccess, out IntPtr tokenHandle);
Expand All @@ -168,7 +165,6 @@ internal static unsafe bool LookupAccountSid(string lpSystemName,
/// <param name="returnLength"></param>
/// <returns></returns>
[DllImport(PinvokeDllNames.GetTokenInformationDllName, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
[ResourceExposure(ResourceScope.Machine)]
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool GetTokenInformation(IntPtr tokenHandle,
Expand Down
Loading