Skip to content

Cleanup #if NETFX guarded code and remove XBAP related types #1009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 19, 2019
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
@@ -1,14 +1,15 @@
Compat issues with assembly PresentationFramework:
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.AttachedPropertyBrowsableForChildrenAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.ResourceReferenceKeyNotFoundException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.StyleTypedPropertyAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.TemplatePartAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.TemplateVisualStateAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.ThemeInfoAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Controls.PrintDialogException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Data.ValueConversionAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Data.ValueUnavailableException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Documents.TextElementEditingBehaviorAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Markup.XamlParseException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
CannotRemoveAttribute : Attribute 'System.Security.SecurityCriticalAttribute' exists on 'System.Windows.Shell.JumpList' in the contract but not the implementation.
Total Issues: 12
Compat issues with assembly PresentationFramework:
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.AttachedPropertyBrowsableForChildrenAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.ResourceReferenceKeyNotFoundException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.StyleTypedPropertyAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.TemplatePartAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.TemplateVisualStateAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.ThemeInfoAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Controls.PrintDialogException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Data.ValueConversionAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Data.ValueUnavailableException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Documents.TextElementEditingBehaviorAttribute' does not implement interface 'System.Runtime.InteropServices._Attribute' in the implementation but it does in the contract.
TypesMustExist : Type 'System.Windows.Interop.DocObjHost' does not exist in the implementation but it does exist in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Windows.Markup.XamlParseException' does not implement interface 'System.Runtime.InteropServices._Exception' in the implementation but it does in the contract.
CannotRemoveAttribute : Attribute 'System.Security.SecurityCriticalAttribute' exists on 'System.Windows.Shell.JumpList' in the contract but not the implementation.
Total Issues: 13
Original file line number Diff line number Diff line change
Expand Up @@ -11217,12 +11217,7 @@ public static partial class BrowserInteropHelper
public static bool IsBrowserHosted { get { throw null; } }
public static System.Uri Source { get { throw null; } }
}
public sealed partial class DocObjHost : System.MarshalByRefObject, System.IServiceProvider
{
public DocObjHost() { }
public override object InitializeLifetimeService() { throw null; }
object System.IServiceProvider.GetService(System.Type serviceType) { throw null; }
}

public sealed partial class DynamicScriptObject : System.Dynamic.DynamicObject
{
internal DynamicScriptObject() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,55 +47,14 @@ protected override KeyStates GetKeyStatesFromSystem(Key key)
{
KeyStates keyStates = KeyStates.None;

bool getKeyStatesFromSystem = false;
if(IsActive)
{
// Our keyboard device is only active if some WPF window in
// this AppDomain has focus. It is always safe to return
// the state of keys.
getKeyStatesFromSystem = true;
}
else if (SecurityHelper.AppDomainGrantedUnrestrictedUIPermission)
{
// This is a trusted AppDomain, so we are willing to expose
// the state of keys regardless of whether or not a WPF
// window has focus. This is important for child HWND
// hosting scenarios.
getKeyStatesFromSystem = true;
}
else
{
// Security Mitigation:
// No WPF window has focus in this AppDomain, and this is a
// partially-trusted AppDomain, so we do not generally want
// to expose the state of keys. However, we make an exception
// for modifier keys, as they are considered safe.
switch (key)
{
case Key.LeftAlt:
case Key.RightAlt:
case Key.LeftCtrl:
case Key.RightCtrl:
case Key.LeftShift:
case Key.RightShift:
getKeyStatesFromSystem = true;
break;
}
}
int virtualKeyCode = KeyInterop.VirtualKeyFromKey(key);
int nativeKeyState = UnsafeNativeMethods.GetKeyState(virtualKeyCode);

if (getKeyStatesFromSystem)
{
int virtualKeyCode = KeyInterop.VirtualKeyFromKey(key);
int nativeKeyState;
if ((nativeKeyState & 0x00008000) == 0x00008000)
keyStates |= KeyStates.Down;

nativeKeyState = UnsafeNativeMethods.GetKeyState(virtualKeyCode);

if( (nativeKeyState & 0x00008000) == 0x00008000 )
keyStates |= KeyStates.Down;

if( (nativeKeyState & 0x00000001) == 0x00000001 )
keyStates |= KeyStates.Toggled;
}
if ((nativeKeyState & 0x00000001) == 0x00000001)
keyStates |= KeyStates.Toggled;

return keyStates;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,38 +103,29 @@ bool IKeyboardInputProvider.AcquireFocus(bool checkOnly)
// In either case, the window must be enabled.
if(SafeNativeMethods.IsWindowEnabled(thisWindow))
{
if (SecurityHelper.AppDomainGrantedUnrestrictedUIPermission)
{
// In fully-trusted AppDomains, the only hard requirement
// is that Win32 keyboard focus be on some window owned
// by a thread that is attached to our Win32 queue. This
// presumes that the thread's message pump will cooperate
// by calling ComponentDispatcher.RaiseThreadMessage.
// If so, WPF will be able to route the keyboard events to the
// element with WPF keyboard focus, regardless of which
// window has Win32 keyboard focus.
//
// Menus/ComboBoxes use this feature.
//
// Dev11 is moving more towards cross-process designer
// support. They make sure to call AttachThreadInput so
// the the two threads share the same Win32 queue. In
// addition, they repost the keyboard messages to the
// main UI process/thread for handling.
//
// We rely on the behavior of GetFocus to only return a
// window handle for windows attached to the calling
// thread's queue.
//
result = focus != IntPtr.Zero;
}
else
{
// In partially-trusted AppDomains, we do not want to expose input
// intended for other native windows, or for WPF windows in other
// AppDomains.
result = IsOurWindow(focus);
}

// In fully-trusted AppDomains, the only hard requirement
// is that Win32 keyboard focus be on some window owned
// by a thread that is attached to our Win32 queue. This
// presumes that the thread's message pump will cooperate
// by calling ComponentDispatcher.RaiseThreadMessage.
// If so, WPF will be able to route the keyboard events to the
// element with WPF keyboard focus, regardless of which
// window has Win32 keyboard focus.
//
// Menus/ComboBoxes use this feature.
//
// Dev11 is moving more towards cross-process designer
// support. They make sure to call AttachThreadInput so
// the the two threads share the same Win32 queue. In
// addition, they repost the keyboard messages to the
// main UI process/thread for handling.
//
// We rely on the behavior of GetFocus to only return a
// window handle for windows attached to the calling
// thread's queue.
//
result = focus != IntPtr.Zero;
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,7 @@ private void Initialize(HwndSourceParameters parameters)
AddSource();

// Register dropable window.
// The checking CallerHasPermissionWithAppDomainOptimization will call RegisterDropTarget
// safely without the security exception in case of no unmanaged code permission.
// So RegisterDropTarget will be called safely in case of having the unmanged code permission.
// Otherwise, the security exception cause System.Printing to be instatiated which will
// load system.drawing module.
if (_hwndWrapper.Handle != IntPtr.Zero &&
SecurityHelper.CallerHasPermissionWithAppDomainOptimization(new SecurityPermission(SecurityPermissionFlag.UnmanagedCode)))
if (_hwndWrapper.Handle != IntPtr.Zero)
{
// This call is safe since DragDrop.RegisterDropTarget is checking the unmanged
// code permission.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,29 +105,7 @@ internal static LaunchResult SafeLaunchBrowserOnlyIfPossible(Uri originatingUri,
MS.Internal.PresentationFramework.SecurityHelper.CallerHasUserInitiatedNavigationPermission()) &&
((fIsTopLevel && isKnownScheme) || fIsMailTo))
{
if (isKnownScheme)
{
#if NETFX
IBrowserCallbackServices ibcs = ( Application.Current != null ) ? Application.Current.BrowserCallbackServices : null ;
if (ibcs != null)
{
launched = CanNavigateToUrlWithZoneCheck(originatingUri , destinationUri);
if ( launched == LaunchResult.Launched )
{
// resetting launched to NotLaunched here; if the assert succeeds
// and ibcs.DelegateNavigation does not throw then we will set it to Launched.
launched = LaunchResult.NotLaunched;
// Browser app.
// We need to see if this is the right behavior when clicking on a link in
// a secondary window in a multi-window browser app
ibcs.DelegateNavigation( BindUriHelper.UriToString( destinationUri ), targetName, GetHeaders(destinationUri));

launched = LaunchResult.Launched ;
}
}
#endif
}
else if (fIsMailTo) // unnecessary if - but being paranoid.
if (!isKnownScheme && fIsMailTo) // unnecessary if - but being paranoid.
{
// Shell-Exec the browser to the mailto url.
// assumed safe - because we're only allowing this for mailto urls.
Expand All @@ -150,22 +128,6 @@ internal static LaunchResult SafeLaunchBrowserOnlyIfPossible(Uri originatingUri,
// Whoever is calling this function should do the right demands.
internal static void UnsafeLaunchBrowser(Uri uri, string targetFrame = null)
{
#if NETFX
// This'll likely go into SafeLaunchBrowser() function.
if (Application.Current != null && Application.Current.CheckAccess())
{
IBrowserCallbackServices ibcs = Application.Current.BrowserCallbackServices;
if (ibcs != null)
{
// Browser app.
// TODO: See if this is the right behavior when clicking on a link in
// a secondary window in a multi-window browser app - PS # 840726
ibcs.DelegateNavigation(BindUriHelper.UriToString(uri), targetFrame, GetHeaders(uri));
return;
}
}
#endif

ShellExecuteDefaultBrowser(uri);
}

Expand Down
Loading