Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / MS / Internal / AppModel / ProgressPage.cs / 1561345 / ProgressPage.cs
//+------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: // Deployment progress page. This is primarily a proxy to the native progress page, which supersedes // the managed one from up to v3.5. See Host\DLL\ProgressPage.hxx for details. // // History: // 2007/12/xx [....] Created // //----------------------------------------------------------------------- using System; using System.Runtime.InteropServices; using System.Windows.Interop; using System.Windows.Threading; using System.Security; // Disambiguate MS.Internal.HRESULT... using HR = MS.Internal.Interop.HRESULT; namespace MS.Internal.AppModel { ////// Critical due to SUC. /// Even if a partilar method is considered safe, applying [SecurityTreatAsSafe] to it here won't help /// much, because the transparency model still requires SUC-d methods to be called only from /// SecurityCritical ones. /// [ComImport, Guid("1f681651-1024-4798-af36-119bbe5e5665")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [SecurityCritical, SuppressUnmanagedCodeSecurity] interface INativeProgressPage { [PreserveSig] HR Show(); [PreserveSig] HR Hide(); [PreserveSig] HR ShowProgressMessage(string message); [PreserveSig] HR SetApplicationName(string appName); [PreserveSig] HR SetPublisherName(string publisherName); [PreserveSig] HR OnDownloadProgress(ulong bytesDownloaded, ulong bytesTotal); }; ////// IProgressPage is public. It was introduced for the Media Center integration, which is now considered /// deprecated, but we have to support it at least for as long as we keep doing in-place upgrades. /// interface IProgressPage2 : IProgressPage { void ShowProgressMessage(string message); }; class NativeProgressPageProxy : IProgressPage2 { internal NativeProgressPageProxy(INativeProgressPage npp) { _npp = npp; } ////// Critical: Calls a SUC'd COM interface method. /// TreatAsSafe: No concern about "spoofing" progress messages. A web site could just render an HTML /// page that looks like our progress page. /// [SecurityCritical, SecurityTreatAsSafe] public void ShowProgressMessage(string message) { // Ignore the error code. This page is transient and it's not the end of the world if this doesn't show up. HR hr = _npp.ShowProgressMessage(message); } public Uri DeploymentPath { set { } get { throw new System.NotImplementedException(); } } /// /// The native progress page sends a stop/cancel request to its host object, which then calls /// IBrowserHostServices.ExecCommand(OLECMDID_STOP). /// public DispatcherOperationCallback StopCallback { set { } get { throw new System.NotImplementedException(); } } ////// The native progress page sends a Refresh request to its host object, which then calls /// IBrowserHostServices.ExecCommand(OLECMDID_REFRESH). /// public System.Windows.Threading.DispatcherOperationCallback RefreshCallback { set { } get { return null; } } ////// Critical: Calls a SUC'd COM interface method. /// TreatAsSafe: 1) The application name is coming from the manifest, so it could be anything. /// This means the input doesn't need to be trusted. /// 2) Setting arbitrary application/publisher can be considered spoofing, but a malicious website /// could fake the whole progress page and still achieve the same. /// public string ApplicationName { [SecurityCritical, SecurityTreatAsSafe] set { // Ignore the error code. This page is transient and it's not the end of the world if this doesn't show up. HR hr = _npp.SetApplicationName(value); } get { throw new System.NotImplementedException(); } } ////// Critical: Calls a SUC'd COM interface method. /// TreatAsSafe: 1) The publisher name is coming from the manifest, so it could be anything. /// This means the input doesn't need to be trusted. /// 2) Setting arbitrary application/publisher can be considered spoofing, but a malicious website /// could fake the whole progress page and still achieve the same. /// public string PublisherName { [SecurityCritical, SecurityTreatAsSafe] set { // Ignore the error code. This page is transient and it's not the end of the world if this doesn't show up. HR hr = _npp.SetPublisherName(value); } get { throw new System.NotImplementedException(); } } /// /// Critical: Calls a SUC'd COM interface method. /// TreatAsSafe: Sending even arbitrary progress updates not considered harmful. /// [SecurityCritical, SecurityTreatAsSafe] public void UpdateProgress(long bytesDownloaded, long bytesTotal) { // Ignore the error code. This page is transient and it's not the end of the world if this doesn't show up. HR hr = _npp.OnDownloadProgress((ulong)bytesDownloaded, (ulong)bytesTotal); } INativeProgressPage _npp; }; } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //+------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: // Deployment progress page. This is primarily a proxy to the native progress page, which supersedes // the managed one from up to v3.5. See Host\DLL\ProgressPage.hxx for details. // // History: // 2007/12/xx [....] Created // //----------------------------------------------------------------------- using System; using System.Runtime.InteropServices; using System.Windows.Interop; using System.Windows.Threading; using System.Security; // Disambiguate MS.Internal.HRESULT... using HR = MS.Internal.Interop.HRESULT; namespace MS.Internal.AppModel { /// /// Critical due to SUC. /// Even if a partilar method is considered safe, applying [SecurityTreatAsSafe] to it here won't help /// much, because the transparency model still requires SUC-d methods to be called only from /// SecurityCritical ones. /// [ComImport, Guid("1f681651-1024-4798-af36-119bbe5e5665")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [SecurityCritical, SuppressUnmanagedCodeSecurity] interface INativeProgressPage { [PreserveSig] HR Show(); [PreserveSig] HR Hide(); [PreserveSig] HR ShowProgressMessage(string message); [PreserveSig] HR SetApplicationName(string appName); [PreserveSig] HR SetPublisherName(string publisherName); [PreserveSig] HR OnDownloadProgress(ulong bytesDownloaded, ulong bytesTotal); }; ////// IProgressPage is public. It was introduced for the Media Center integration, which is now considered /// deprecated, but we have to support it at least for as long as we keep doing in-place upgrades. /// interface IProgressPage2 : IProgressPage { void ShowProgressMessage(string message); }; class NativeProgressPageProxy : IProgressPage2 { internal NativeProgressPageProxy(INativeProgressPage npp) { _npp = npp; } ////// Critical: Calls a SUC'd COM interface method. /// TreatAsSafe: No concern about "spoofing" progress messages. A web site could just render an HTML /// page that looks like our progress page. /// [SecurityCritical, SecurityTreatAsSafe] public void ShowProgressMessage(string message) { // Ignore the error code. This page is transient and it's not the end of the world if this doesn't show up. HR hr = _npp.ShowProgressMessage(message); } public Uri DeploymentPath { set { } get { throw new System.NotImplementedException(); } } /// /// The native progress page sends a stop/cancel request to its host object, which then calls /// IBrowserHostServices.ExecCommand(OLECMDID_STOP). /// public DispatcherOperationCallback StopCallback { set { } get { throw new System.NotImplementedException(); } } ////// The native progress page sends a Refresh request to its host object, which then calls /// IBrowserHostServices.ExecCommand(OLECMDID_REFRESH). /// public System.Windows.Threading.DispatcherOperationCallback RefreshCallback { set { } get { return null; } } ////// Critical: Calls a SUC'd COM interface method. /// TreatAsSafe: 1) The application name is coming from the manifest, so it could be anything. /// This means the input doesn't need to be trusted. /// 2) Setting arbitrary application/publisher can be considered spoofing, but a malicious website /// could fake the whole progress page and still achieve the same. /// public string ApplicationName { [SecurityCritical, SecurityTreatAsSafe] set { // Ignore the error code. This page is transient and it's not the end of the world if this doesn't show up. HR hr = _npp.SetApplicationName(value); } get { throw new System.NotImplementedException(); } } ////// Critical: Calls a SUC'd COM interface method. /// TreatAsSafe: 1) The publisher name is coming from the manifest, so it could be anything. /// This means the input doesn't need to be trusted. /// 2) Setting arbitrary application/publisher can be considered spoofing, but a malicious website /// could fake the whole progress page and still achieve the same. /// public string PublisherName { [SecurityCritical, SecurityTreatAsSafe] set { // Ignore the error code. This page is transient and it's not the end of the world if this doesn't show up. HR hr = _npp.SetPublisherName(value); } get { throw new System.NotImplementedException(); } } /// /// Critical: Calls a SUC'd COM interface method. /// TreatAsSafe: Sending even arbitrary progress updates not considered harmful. /// [SecurityCritical, SecurityTreatAsSafe] public void UpdateProgress(long bytesDownloaded, long bytesTotal) { // Ignore the error code. This page is transient and it's not the end of the world if this doesn't show up. HR hr = _npp.OnDownloadProgress((ulong)bytesDownloaded, (ulong)bytesTotal); } INativeProgressPage _npp; }; } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TypeInfo.cs
- XPathNodeIterator.cs
- ExceptionRoutedEventArgs.cs
- wgx_sdk_version.cs
- ListViewGroupConverter.cs
- MemberCollection.cs
- SqlClientWrapperSmiStream.cs
- CanonicalFormWriter.cs
- RuntimeResourceSet.cs
- InitializationEventAttribute.cs
- SqlBulkCopyColumnMapping.cs
- RuleDefinitions.cs
- ReachFixedPageSerializer.cs
- Point3DAnimationBase.cs
- PenThread.cs
- ComponentCommands.cs
- NodeFunctions.cs
- SmtpFailedRecipientException.cs
- SystemBrushes.cs
- Literal.cs
- ToolboxControl.cs
- UnsafeNativeMethods.cs
- ListInitExpression.cs
- RolePrincipal.cs
- TransformCollection.cs
- BaseAddressPrefixFilterElementCollection.cs
- HScrollBar.cs
- objectquery_tresulttype.cs
- SqlDependencyListener.cs
- DataPager.cs
- mongolianshape.cs
- TextMetrics.cs
- BitmapFrameEncode.cs
- StylusPointProperties.cs
- Shape.cs
- DataControlLinkButton.cs
- EntityContainerRelationshipSet.cs
- Splitter.cs
- HtmlTableRowCollection.cs
- WebDescriptionAttribute.cs
- ComplexPropertyEntry.cs
- CompiledXpathExpr.cs
- ScriptIgnoreAttribute.cs
- LinkGrep.cs
- translator.cs
- SAPICategories.cs
- TagPrefixCollection.cs
- BaseAppDomainProtocolHandler.cs
- MatrixCamera.cs
- HtmlContainerControl.cs
- EmptyStringExpandableObjectConverter.cs
- Point3D.cs
- TypeElementCollection.cs
- TextDpi.cs
- IERequestCache.cs
- IgnoreFileBuildProvider.cs
- EmbossBitmapEffect.cs
- XmlSchemaSimpleType.cs
- OleDbError.cs
- NameValuePermission.cs
- DataGridViewCellStyleChangedEventArgs.cs
- Int16Animation.cs
- AssociativeAggregationOperator.cs
- Animatable.cs
- SmtpReplyReader.cs
- DataGridColumn.cs
- SeekableReadStream.cs
- HandlerMappingMemo.cs
- RegexStringValidatorAttribute.cs
- BinaryObjectWriter.cs
- TimeSpanSecondsConverter.cs
- handlecollector.cs
- ObjectParameterCollection.cs
- HtmlValidatorAdapter.cs
- UnsafeNativeMethodsMilCoreApi.cs
- ColumnWidthChangingEvent.cs
- XamlStream.cs
- OracleParameter.cs
- RichTextBoxConstants.cs
- ContentType.cs
- UnmanagedMemoryStreamWrapper.cs
- ReaderContextStackData.cs
- CalculatedColumn.cs
- HtmlShimManager.cs
- WpfXamlLoader.cs
- TagPrefixInfo.cs
- SoapSchemaExporter.cs
- Convert.cs
- SynchronizedDispatch.cs
- XmlHierarchicalEnumerable.cs
- MetabaseServerConfig.cs
- ICollection.cs
- DataSourceCacheDurationConverter.cs
- MemberPath.cs
- TCPClient.cs
- AssemblyHelper.cs
- Light.cs
- DiscoveryProxy.cs
- StaticContext.cs
- Tablet.cs