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
- DataMember.cs
- OleDbDataAdapter.cs
- CultureInfo.cs
- AppSettingsExpressionBuilder.cs
- ViewStateChangedEventArgs.cs
- WebPartDeleteVerb.cs
- XmlAttributes.cs
- DeclarativeCatalogPart.cs
- Floater.cs
- SQLString.cs
- Root.cs
- EntityContainer.cs
- SystemNetHelpers.cs
- InfoCardAsymmetricCrypto.cs
- ServiceErrorHandler.cs
- CheckBox.cs
- OrderByExpression.cs
- IndexedString.cs
- PeerHelpers.cs
- DataSourceHelper.cs
- HttpHandlerAction.cs
- CodeActivityContext.cs
- SimpleHandlerBuildProvider.cs
- Workspace.cs
- LayoutDump.cs
- DataTableClearEvent.cs
- RootProfilePropertySettingsCollection.cs
- DataGridCheckBoxColumn.cs
- ApplicationServiceManager.cs
- References.cs
- PathStreamGeometryContext.cs
- EventPropertyMap.cs
- PackageFilter.cs
- ToolBar.cs
- HandlerElement.cs
- XmlnsCache.cs
- WebPartConnectionCollection.cs
- SocketStream.cs
- FactoryGenerator.cs
- NameScopePropertyAttribute.cs
- LazyLoadBehavior.cs
- XmlQueryType.cs
- DiagnosticTrace.cs
- Int32CAMarshaler.cs
- updatecommandorderer.cs
- PropertyDescriptor.cs
- DataKey.cs
- ChannelSinkStacks.cs
- XmlDownloadManager.cs
- CompilerTypeWithParams.cs
- MDIControlStrip.cs
- SignedXml.cs
- NativeMethods.cs
- ContextConfiguration.cs
- CorrelationManager.cs
- TableLayoutColumnStyleCollection.cs
- QueryInterceptorAttribute.cs
- ApplicationId.cs
- OleDbStruct.cs
- ComponentEvent.cs
- ClientFormsIdentity.cs
- Tokenizer.cs
- SchemaImporterExtension.cs
- SystemTcpStatistics.cs
- FrameworkElement.cs
- DataGridViewTopLeftHeaderCell.cs
- XmlILConstructAnalyzer.cs
- ArgumentValidation.cs
- ToolStripItemGlyph.cs
- WebAdminConfigurationHelper.cs
- GiveFeedbackEventArgs.cs
- WriteFileContext.cs
- SignedXml.cs
- TextReturnReader.cs
- Decimal.cs
- KeyFrames.cs
- XmlUrlResolver.cs
- Header.cs
- HeaderedContentControl.cs
- WaitForChangedResult.cs
- DefaultHttpHandler.cs
- X509Utils.cs
- Buffer.cs
- RoleGroup.cs
- ConfigurationSettings.cs
- InputLanguageEventArgs.cs
- MetadataPropertyvalue.cs
- ComponentDispatcher.cs
- AlphabeticalEnumConverter.cs
- ContainerCodeDomSerializer.cs
- ProcessModelInfo.cs
- sqlser.cs
- DataGridView.cs
- EntityDataSource.cs
- LedgerEntry.cs
- ChtmlTextWriter.cs
- TagElement.cs
- NullableFloatMinMaxAggregationOperator.cs
- XmlJsonWriter.cs
- HostVisual.cs