Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Shared / MS / Win32 / WinInet.cs / 2 / 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
- AssemblyAssociatedContentFileAttribute.cs
- ResourcesBuildProvider.cs
- EncryptedKey.cs
- VectorValueSerializer.cs
- ObjectDataSourceSelectingEventArgs.cs
- ColorIndependentAnimationStorage.cs
- Function.cs
- ExceptionRoutedEventArgs.cs
- TableLayoutPanelCellPosition.cs
- MouseCaptureWithinProperty.cs
- RowsCopiedEventArgs.cs
- TemplateBindingExpression.cs
- DeclaredTypeElement.cs
- Storyboard.cs
- KeyboardDevice.cs
- AppDomain.cs
- DependentTransaction.cs
- unitconverter.cs
- WindowsStatic.cs
- DataGridViewCellMouseEventArgs.cs
- InkCollectionBehavior.cs
- RegexCapture.cs
- ParallelQuery.cs
- ArraySet.cs
- QueryOperatorEnumerator.cs
- XmlAggregates.cs
- StateItem.cs
- XmlSchemaSimpleContentExtension.cs
- Visitor.cs
- EntityCommandDefinition.cs
- cache.cs
- FormatterServices.cs
- SmiEventStream.cs
- LookupNode.cs
- MenuScrollingVisibilityConverter.cs
- RegexMatch.cs
- Pts.cs
- DataServiceRequestException.cs
- StdRegProviderWrapper.cs
- BasePattern.cs
- CodeGeneratorOptions.cs
- BitmapFrame.cs
- SerializableAttribute.cs
- RelatedView.cs
- ThemeDirectoryCompiler.cs
- PropertyRecord.cs
- UriSectionReader.cs
- TreeView.cs
- ParameterReplacerVisitor.cs
- RefType.cs
- CachedFontFace.cs
- PropertyItem.cs
- Highlights.cs
- HandledMouseEvent.cs
- MenuAdapter.cs
- ResourceCategoryAttribute.cs
- DynamicPropertyHolder.cs
- PlainXmlSerializer.cs
- CacheChildrenQuery.cs
- SerializationUtility.cs
- ToolboxControl.cs
- TemplateColumn.cs
- NameValueSectionHandler.cs
- WorkflowViewService.cs
- HeaderedItemsControl.cs
- LicenseException.cs
- SelectionRangeConverter.cs
- TrackingLocation.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- InvalidFilterCriteriaException.cs
- UriPrefixTable.cs
- WizardStepCollectionEditor.cs
- MarshalByValueComponent.cs
- FrameworkContentElement.cs
- HitTestFilterBehavior.cs
- TrustManagerMoreInformation.cs
- UnaryNode.cs
- Overlapped.cs
- DataGridDetailsPresenterAutomationPeer.cs
- bidPrivateBase.cs
- precedingquery.cs
- DiscoveryDocumentLinksPattern.cs
- LexicalChunk.cs
- RTLAwareMessageBox.cs
- TextSelectionHighlightLayer.cs
- HttpProfileGroupBase.cs
- IsolatedStorage.cs
- Scripts.cs
- ObjectDataSourceFilteringEventArgs.cs
- InkCanvasAutomationPeer.cs
- DataProtectionSecurityStateEncoder.cs
- GridViewSortEventArgs.cs
- BrowserCapabilitiesFactoryBase.cs
- SiteMap.cs
- IriParsingElement.cs
- SessionEndedEventArgs.cs
- GregorianCalendarHelper.cs
- DrawingGroupDrawingContext.cs
- NameGenerator.cs
- SizeChangedEventArgs.cs