Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Shared / MS / Win32 / WinInet.cs / 1305600 / WinInet.cs
using System; using System.Security; using System.Runtime.InteropServices; namespace MS.Win32 { internal static class WinInet { ////// Will return the location of the internet cache folder. /// ///The location of the internet cache folder. ////// Critical: /// 1) Calls several Marshal methods which have a link demand on them. /// 2) Calls NativeMethods.GetUrlCacheConfigInfo which is SecurityCritical. /// Not Safe: /// 2) Returns a Path that may leak information about the system. /// internal static Uri InternetCacheFolder { [SecurityCritical] get { // copied value 260 from orginal implementation in BitmapDownload.cs const int maxPathSize = 260; const UInt32 fieldControl = (UInt32)maxPathSize; NativeMethods.InternetCacheConfigInfo icci = new NativeMethods.InternetCacheConfigInfo(); icci.CachePath = new string(new char[maxPathSize]); UInt32 size = (UInt32)Marshal.SizeOf(icci); icci.dwStructSize = size; bool passed = UnsafeNativeMethods.GetUrlCacheConfigInfo( ref icci, ref size, fieldControl); if (!passed) { int hr = Marshal.GetHRForLastWin32Error(); if (hr != 0) { Marshal.ThrowExceptionForHR(hr); } } return new Uri(icci.CachePath); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Security; using System.Runtime.InteropServices; namespace MS.Win32 { internal static class WinInet { ////// Will return the location of the internet cache folder. /// ///The location of the internet cache folder. ////// Critical: /// 1) Calls several Marshal methods which have a link demand on them. /// 2) Calls NativeMethods.GetUrlCacheConfigInfo which is SecurityCritical. /// Not Safe: /// 2) Returns a Path that may leak information about the system. /// internal static Uri InternetCacheFolder { [SecurityCritical] get { // copied value 260 from orginal implementation in BitmapDownload.cs const int maxPathSize = 260; const UInt32 fieldControl = (UInt32)maxPathSize; NativeMethods.InternetCacheConfigInfo icci = new NativeMethods.InternetCacheConfigInfo(); icci.CachePath = new string(new char[maxPathSize]); UInt32 size = (UInt32)Marshal.SizeOf(icci); icci.dwStructSize = size; bool passed = UnsafeNativeMethods.GetUrlCacheConfigInfo( ref icci, ref size, fieldControl); if (!passed) { int hr = Marshal.GetHRForLastWin32Error(); if (hr != 0) { Marshal.ThrowExceptionForHR(hr); } } return new Uri(icci.CachePath); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AsyncOperation.cs
- WebServiceTypeData.cs
- SourceItem.cs
- SystemIPv6InterfaceProperties.cs
- SigningDialog.cs
- WindowsTokenRoleProvider.cs
- Overlapped.cs
- EncryptedPackage.cs
- PeerUnsafeNativeCryptMethods.cs
- Button.cs
- Aggregates.cs
- BinaryObjectInfo.cs
- SplashScreen.cs
- TextSearch.cs
- CodeNamespaceImportCollection.cs
- TextContainerHelper.cs
- TopClause.cs
- DataControlPagerLinkButton.cs
- CryptoApi.cs
- AuthenticationSection.cs
- AtomServiceDocumentSerializer.cs
- UseLicense.cs
- HtmlImageAdapter.cs
- DataColumnSelectionConverter.cs
- HyperLink.cs
- SynchronizationHandlesCodeDomSerializer.cs
- SettingsPropertyNotFoundException.cs
- GenericTypeParameterBuilder.cs
- SqlConnectionPoolProviderInfo.cs
- BrowserCapabilitiesCodeGenerator.cs
- SchemaNotation.cs
- DocumentReference.cs
- DbgCompiler.cs
- DataGridCell.cs
- RequestCachePolicyConverter.cs
- InheritanceAttribute.cs
- TextEffectResolver.cs
- AuthenticationConfig.cs
- NativeCppClassAttribute.cs
- CallbackValidator.cs
- StorageScalarPropertyMapping.cs
- EntityModelBuildProvider.cs
- GridViewCellAutomationPeer.cs
- MetaModel.cs
- Timeline.cs
- DataServiceQueryOfT.cs
- VectorKeyFrameCollection.cs
- ImageFormat.cs
- ButtonFieldBase.cs
- ColumnClickEvent.cs
- UIElementPropertyUndoUnit.cs
- ServiceChannel.cs
- MouseActionConverter.cs
- LayoutEngine.cs
- CompositeClientFormatter.cs
- Compilation.cs
- Command.cs
- PackagingUtilities.cs
- CheckBox.cs
- ContentPlaceHolder.cs
- BamlResourceDeserializer.cs
- FastPropertyAccessor.cs
- SHA384.cs
- EdmError.cs
- ResourcePool.cs
- DataBindingCollectionEditor.cs
- DeclarativeCatalogPart.cs
- Baml2006KnownTypes.cs
- NotifyCollectionChangedEventArgs.cs
- RowParagraph.cs
- GlyphsSerializer.cs
- PropertyChangedEventArgs.cs
- DesignerTransactionCloseEvent.cs
- DataBindingList.cs
- DescendantQuery.cs
- TraceLevelStore.cs
- XmlSchemaSet.cs
- ReflectTypeDescriptionProvider.cs
- CmsUtils.cs
- XmlNodeChangedEventManager.cs
- ListViewEditEventArgs.cs
- hebrewshape.cs
- BamlCollectionHolder.cs
- DesignerUtils.cs
- StylusCaptureWithinProperty.cs
- ServiceDescriptions.cs
- FaultDescriptionCollection.cs
- CreateSequence.cs
- EncoderParameter.cs
- TextBreakpoint.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- basecomparevalidator.cs
- FontDifferentiator.cs
- TransportContext.cs
- SessionEndedEventArgs.cs
- DefaultProxySection.cs
- CodeStatementCollection.cs
- SqlBooleanMismatchVisitor.cs
- SqlAliasesReferenced.cs
- keycontainerpermission.cs