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
1 change: 0 additions & 1 deletion src/Common/src/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ namespace System.Windows.Forms {
using Accessibility;
using System.Runtime.InteropServices;
using System;
using System.Security.Permissions;
using System.Collections;
using System.Diagnostics;
using System.IO;
Expand Down
6 changes: 0 additions & 6 deletions src/Common/src/UnsafeNativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8128,16 +8128,10 @@ public interface IRawElementProviderHwndOverride : IRawElementProviderSimple {
IRawElementProviderSimple GetOverrideProviderForHwnd(IntPtr hwnd);
}

/// <SecurityNote>
/// Critical:Elevates to Unmanaged code permission
/// </SecurityNote>
[ComImport()]
[Guid("6D5140C1-7436-11CE-8034-00AA006009FA")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IServiceProvider {
///<SecurityNote>
/// Critical elevates via a SUC.
///</SecurityNote>
[PreserveSig]
int QueryService(ref Guid service, ref Guid riid, out IntPtr ppvObj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1203,10 +1203,6 @@ private bool ProcessMouseMessage(IntPtr hWnd, int msg, int x, int y)
{
return false;
}
// We could have hooked a control in a semitrust web page. This would put semitrust frames above us, which could cause this to fail.
// SECREVIEW, UNDONE. Think hard about this. Does this allow a project to have a web page that pointed to a malicious control?
// I don't think so, because the malicious control would still be on the frame.
new NamedPermissionSet("FullTrust").Assert();

foreach (AdornerWindow adornerWindow in AdornerWindow.s_adornerWindowList)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using System.Drawing.Design;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Windows.Forms.Design.Behavior;
using Microsoft.Win32;

Expand Down Expand Up @@ -539,24 +538,16 @@ public static short BitsPerPixel
{
if (s_bitsPerPixel == 0)
{
new EnvironmentPermission(PermissionState.Unrestricted).Assert();
try
foreach (Screen s in Screen.AllScreens)
{
foreach (Screen s in Screen.AllScreens)
if (s_bitsPerPixel == 0)
{
if (s_bitsPerPixel == 0)
{
s_bitsPerPixel = (short)s.BitsPerPixel;
}
else
{
s_bitsPerPixel = (short)Math.Min(s.BitsPerPixel, s_bitsPerPixel);
}
s_bitsPerPixel = (short)s.BitsPerPixel;
}
else
{
s_bitsPerPixel = (short)Math.Min(s.BitsPerPixel, s_bitsPerPixel);
}
}
finally
{
CodeAccessPermission.RevertAssert();
}
}
return s_bitsPerPixel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2703,7 +2703,7 @@ internal sealed class InternalAccessibleObject : StandardOleMarshalObject,
private UnsafeNativeMethods.IRawElementProviderHwndOverride publicIRawElementProviderHwndOverride; // AccessibleObject as IRawElementProviderHwndOverride

/// <summary>
/// Create a new wrapper. Protect this with UnmanagedCode Permission
/// Create a new wrapper.
/// </summary>
internal InternalAccessibleObject(AccessibleObject accessibleImplemention)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2501,8 +2501,6 @@ internal ParkingWindow GetParkingWindow(DpiAwarenessContext context) {
var parkingWindow = GetParkingWindowForContext(context);
if (parkingWindow == null) {
#if DEBUG
// if we use Debug.WriteLine instead of "if", we need extra security permissions
// to get the stack trace!
if (CoreSwitches.PerfTrack.Enabled) {
Debug.WriteLine("Creating parking form!");
Debug.WriteLine(CoreSwitches.PerfTrack.Enabled, Environment.StackTrace);
Expand Down Expand Up @@ -2578,8 +2576,6 @@ internal Control MarshalingControl {
lock (this) {
if (marshalingControl == null) {
#if DEBUG
// if we use Debug.WriteLine instead of "if", we need extra security permissions
// to get the stack trace!
if (CoreSwitches.PerfTrack.Enabled) {
Debug.WriteLine("Creating marshalling control!");
Debug.WriteLine(CoreSwitches.PerfTrack.Enabled, Environment.StackTrace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace System.Windows.Forms {
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Collections;
using System.Security.Permissions;
using System.ComponentModel;

/// <include file='doc\AutoCompleteStringCollection.uex' path='docs/doc[@for="AutoCompleteStringCollection"]/*' />
Expand Down Expand Up @@ -210,7 +209,6 @@ public void RemoveAt(int index) {
/// <para>Gets an object that can be used to synchronize access to the <see cref='System.Collections.Specialized.AutoCompleteStringCollection'/>.</para>
/// </devdoc>
public object SyncRoot {
[HostProtection(Synchronization=true)]
[SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
get {
return this;
Expand Down
18 changes: 2 additions & 16 deletions src/System.Windows.Forms/src/System/Windows/Forms/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6262,16 +6262,6 @@ public Control GetChildAtPoint(Point pt, GetChildAtPointSkip skipValue) {

IntPtr hwnd = UnsafeNativeMethods.ChildWindowFromPointEx(new HandleRef(null, Handle), pt.X, pt.Y, value);

// Security Reviewed
// While doing a security review it was noticed that GetChildAtPoint
// does work to ensure that you can only gain access to children of your own control,
// but the methods it uses to determine the children demand all window permission first,
// negating the extra check.
// It is OK to return child windows for children within your own control for semitrust.

// Hence calling the Internal methods to ByPass the Security Demand...
// for IntSecurity.ControlFromHandleOrLocation == ALLWindows.

Control ctl = FromChildHandleInternal(hwnd);

return(ctl == this) ? null : ctl;
Expand Down Expand Up @@ -6804,7 +6794,7 @@ public Control GetNextControl(Control ctl, bool forward) {

/// <devdoc>
/// Return ((Control) window).Handle if window is a Control.
/// Otherwise, demands permission for AllWindows and returns window.Handle
/// Otherwise, returns window.Handle
/// </devdoc>
internal static IntPtr GetSafeHandle(IWin32Window window)
{
Expand Down Expand Up @@ -16435,9 +16425,7 @@ internal void InPlaceActivate(int verb)
this.hwndParent = hwndParent;
UnsafeNativeMethods.SetParent(new HandleRef(control, control.Handle), new HandleRef(null, hwndParent));

// Now create our handle if it hasn't already been done. Note that because
// this raises events to the user that it CANNOT be done with a security assertion
// in place!
// Now create our handle if it hasn't already been done.
//
control.CreateControl();

Expand Down Expand Up @@ -18601,8 +18589,6 @@ public ControlAccessibleObject(Control ownerControl) {

this.ownerControl = ownerControl;

// call get_Handle outside the UnmanagedCode permission because if the handle is not created yet,
// we will invoke 3rd party HandleCreated event handlers
IntPtr handle = ownerControl.Handle;

this.Handle = handle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace System.Windows.Forms
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using Security.Permissions;

/// <include file='doc\DataGridViewComboBoxEditingControl.uex' path='docs/doc[@for="DataGridViewComboBoxEditingControl"]/*' />
[
Expand Down Expand Up @@ -207,7 +206,6 @@ public DataGridViewComboBoxEditingControlAccessibleObject(DataGridViewComboBoxEd

public override AccessibleObject Parent
{
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
get
{
return _parentAccessibleObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
namespace System.Windows.Forms {
using Microsoft.Win32;
using System.Security;
using System.Security.Permissions;

internal class DisplayInformation {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace System.Windows.Forms
{
using System;
using System.Diagnostics;
using System.Security.Permissions;
using System.Security;
using System.ComponentModel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,7 @@ public string InitialDirectory {
/// Gets the Win32 instance handle for the application.
/// </para>
/// </devdoc>
/* SECURITYUNDONE : should require EventQueue permission */
protected virtual IntPtr Instance {


get { return UnsafeNativeMethods.GetModuleHandle(null); }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System;
using System.IO;
using System.Security;
using System.Security.Permissions;
using System.Text;

namespace System.Windows.Forms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace System.Windows.Forms
using System.Drawing.Design;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Win32.SafeHandles;

Expand Down
2 changes: 0 additions & 2 deletions src/System.Windows.Forms/src/System/Windows/Forms/Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4153,8 +4153,6 @@ protected override void OnEnabledChanged(EventArgs e) {
// Make sure we activate the active control.
Control activeControl = ActiveControl;

// Seems safe to call this here without demanding permissions, since we only
// get here if this form is enabled and active.
if( activeControl == null ){
SelectNextControlInternal(this, true, true, true, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,15 +480,6 @@
// InProc SxS Supperssions: Methods wich consume but not expose resources
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Resources.AssemblyNamesTypeResolutionService.#GetType(System.String,System.Boolean,System.Boolean)")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Resources.ResXResourceReader.#EnsureResData()")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Security.Policy.TrustManager.#GetZonePromptingLevel(System.String)")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Security.Policy.TrustManager.#get_DefaultBrowserExePath()")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Security.Policy.TrustManagerMoreInformation.#.ctor(System.Security.Policy.TrustManagerPromptOptions,System.String)")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Security.Policy.TrustManagerMoreInformation.#LoadWarningBitmap(System.Security.Policy.TrustManagerWarningLevel,System.Windows.Forms.PictureBox)")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Security.Policy.TrustManagerMoreInformation.#OnUserPreferenceChanged(System.Object,Microsoft.Win32.UserPreferenceChangedEventArgs)")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Security.Policy.TrustManagerPromptUI.#LoadGlobeBitmap()")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Security.Policy.TrustManagerPromptUI.#LoadWarningBitmap(System.Security.Policy.TrustManagerWarningLevel)")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Security.Policy.TrustManagerPromptUI.#TrustManagerPromptUI_ShowSupportPage(System.Object,System.Windows.Forms.LinkLabelLinkClickedEventArgs)")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Security.Policy.TrustManagerPromptUI.#UpdateFonts()")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Windows.Forms.Application+ComponentManager.#System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(System.Int32,System.Int32,System.Int32)")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Windows.Forms.Application+ModalApplicationContext.#DisableThreadWindows(System.Boolean,System.Boolean)")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Windows.Forms.Application+ParkingWindow.#CheckDestroy()")]
Expand Down Expand Up @@ -951,7 +942,6 @@
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Windows.Forms.Internal.WindowsGraphics.#GetTextExtent(System.String,System.Windows.Forms.Internal.WindowsFont)")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Windows.Forms.Internal.WindowsGraphics.#GetTextMetrics()")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Windows.Forms.Internal.WindowsGraphics.#MeasureText(System.String,System.Windows.Forms.Internal.WindowsFont,System.Drawing.Size,System.Windows.Forms.Internal.IntTextFormatFlags)")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Windows.Forms.IntSecurity.#DemandFileIO(System.Security.Permissions.FileIOPermissionAccess,System.String)")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Windows.Forms.Label.#Dispose(System.Boolean)")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Windows.Forms.Label.#GetLeadingTextPaddingFromTextFormatFlags()")]
[module: SuppressMessage("Microsoft.SideBySide", "CA710:ExposedResourcesMustBeConsumed", Scope = "member", Target = "System.Windows.Forms.Label.#GetPreferredSizeCore(System.Drawing.Size)")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;
using System.Security.Permissions;
using System.Security;
using System.Runtime.InteropServices;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;
using System.Security.Permissions;
using System.Security;
using System.Runtime.InteropServices;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;
using System.Security.Permissions;
using System.Security;
using System.Runtime.InteropServices;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace System.Windows.Forms.Layout {

using System.Collections;
using System.Security.Permissions;

/// <include file='doc\Layout.uex' path='docs/doc[@for="Layout.ArrangedElementCollection"]/*' />
public class ArrangedElementCollection : IList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2771,8 +2771,6 @@ unsafe void CustomDraw(ref Message m) {

private void DeleteFileName(string fileName) {
if (!string.IsNullOrEmpty(fileName)) {
// the list view needs the FileIOPermission when the app runs on an UNC share
// and the list view creates / destroys temporary files for its background image

System.IO.FileInfo fi = new System.IO.FileInfo(fileName);
if (fi.Exists) {
Expand Down Expand Up @@ -2865,9 +2863,7 @@ protected override void Dispose(bool disposing) {
}

if (!string.IsNullOrEmpty(this.backgroundImageFileName) || this.bkImgFileNames != null) {
// we need the fileIoPermission when the app runs on an UNC share and
// the list view creates/deletes temporary files for its background image


System.IO.FileInfo fi;
if (!string.IsNullOrEmpty(this.backgroundImageFileName)) {
fi = new System.IO.FileInfo(this.backgroundImageFileName);
Expand Down Expand Up @@ -4638,9 +4634,6 @@ private void SetBackgroundImage() {

if (this.BackgroundImage != null) {

// the list view needs these permissions when the app runs on an UNC share
// and the list view creates / destroys temporary files for its background image

// save the image to a temporary file name
string tempDirName = System.IO.Path.GetTempPath();
System.Text.StringBuilder sb = new System.Text.StringBuilder(1024);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.ComponentModel;
using System.Diagnostics;
using System;
using System.Security.Permissions;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel.Design;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1263,10 +1263,6 @@ private char SystemPasswordChar
throw;
}
}
finally
{
CodeAccessPermission.RevertAssert();
}

MaskedTextBox.systemPwdChar = foundRsc ? (char) int.Parse(charVal.ToString()) : MaskedTextProvider.DefaultPasswordChar;
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace System.Windows.Forms {
using System.Windows.Forms.Internal;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Windows.Forms.Layout;

/// <include file='doc\NumericUpDown.uex' path='docs/doc[@for="NumericUpDown"]/*' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ private bool ShouldSerializeMinMargins() {

private static void UpdateSettings(NativeMethods.PAGESETUPDLG data, PageSettings pageSettings,
PrinterSettings printerSettings) {
// SetHDevMode demands AllPrintingAndUnmanagedCode Permission : Since we are calling that function we should Assert the permision,
pageSettings.SetHdevmode(data.hDevMode);
if (printerSettings != null) {
printerSettings.SetHdevmode(data.hDevMode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ private void ComputePreview() {
document.PrintController = new PrintControllerWithStatusDialog(previewController,
string.Format(SR.PrintControllerWithStatusDialog_DialogTitlePreview));

// Want to make sure we've reverted any security asserts before we call Print -- that calls into user code
document.Print();
pageInfo = previewController.GetPreviewPageInfo();
Debug.Assert(pageInfo != null, "ReviewPrintController did not give us preview info");
Expand Down
Loading