Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Shared / MS / Win32 / WinInet.cs / 1 / 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
- FieldTemplateFactory.cs
- XmlDataProvider.cs
- TextEffect.cs
- SelectionRangeConverter.cs
- StickyNoteAnnotations.cs
- InkCanvasSelection.cs
- BindValidationContext.cs
- IPPacketInformation.cs
- TableLayout.cs
- EntityModelSchemaGenerator.cs
- WindowsRichEditRange.cs
- KeyGestureValueSerializer.cs
- WebHttpBindingElement.cs
- SerializableAttribute.cs
- WindowsPrincipal.cs
- EventBindingService.cs
- DefaultTextStore.cs
- XamlStream.cs
- BitmapEffectDrawingContextState.cs
- TreeViewEvent.cs
- GridViewColumnCollectionChangedEventArgs.cs
- XmlQueryType.cs
- TextOutput.cs
- CultureInfo.cs
- ArcSegment.cs
- OutOfProcStateClientManager.cs
- ContentOperations.cs
- PerfCounters.cs
- GradientStop.cs
- HttpCookie.cs
- FontDriver.cs
- JournalEntry.cs
- BamlTreeNode.cs
- PermissionRequestEvidence.cs
- CodeDirectoryCompiler.cs
- CalendarModeChangedEventArgs.cs
- MappingItemCollection.cs
- ArcSegment.cs
- UnsafeNetInfoNativeMethods.cs
- EntityViewGenerator.cs
- SystemNetHelpers.cs
- PartialTrustVisibleAssemblyCollection.cs
- UnionCqlBlock.cs
- PieceNameHelper.cs
- EmptyImpersonationContext.cs
- CommonRemoteMemoryBlock.cs
- GeneralTransform3DCollection.cs
- XmlParserContext.cs
- HtmlWindowCollection.cs
- MultiView.cs
- AsyncContentLoadedEventArgs.cs
- Internal.cs
- FormatterServicesNoSerializableCheck.cs
- ExpandCollapsePattern.cs
- SafeLocalAllocation.cs
- TimeSpanConverter.cs
- Compiler.cs
- UpdatePanelControlTrigger.cs
- SupportsEventValidationAttribute.cs
- GridViewSortEventArgs.cs
- ChannelTerminatedException.cs
- PopupEventArgs.cs
- ChildrenQuery.cs
- PagesSection.cs
- DesignerCatalogPartChrome.cs
- EntityViewContainer.cs
- WorkflowMarkupSerializationException.cs
- MetadataItem_Static.cs
- RegistryDataKey.cs
- IdentifierService.cs
- BitmapEffectGroup.cs
- MailMessageEventArgs.cs
- SmtpNegotiateAuthenticationModule.cs
- LinkedResourceCollection.cs
- XPathNodePointer.cs
- LogReserveAndAppendState.cs
- EntityConnectionStringBuilderItem.cs
- manifestimages.cs
- Condition.cs
- InternalMappingException.cs
- AssemblyBuilderData.cs
- ExtensionWindowResizeGrip.cs
- RelatedPropertyManager.cs
- Rotation3DAnimationBase.cs
- Model3DGroup.cs
- MultiBindingExpression.cs
- ProfileProvider.cs
- Constraint.cs
- XmlSiteMapProvider.cs
- HashHelper.cs
- TextTreeTextElementNode.cs
- Point3DValueSerializer.cs
- XmlHierarchyData.cs
- InternalRelationshipCollection.cs
- StreamResourceInfo.cs
- BehaviorEditorPart.cs
- AppModelKnownContentFactory.cs
- ComponentCollection.cs
- SingleResultAttribute.cs
- CacheMemory.cs