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
- MatrixKeyFrameCollection.cs
- CommandField.cs
- TPLETWProvider.cs
- ComboBox.cs
- InvalidDataException.cs
- CommandField.cs
- XmlSchemaAny.cs
- StringExpressionSet.cs
- XmlSchema.cs
- IdnMapping.cs
- MembershipSection.cs
- UITypeEditor.cs
- FixedSOMPageConstructor.cs
- LocalizationParserHooks.cs
- TextSchema.cs
- DispatcherBuilder.cs
- BuildResultCache.cs
- URLString.cs
- AspNetSynchronizationContext.cs
- CounterSetInstanceCounterDataSet.cs
- FamilyMapCollection.cs
- TransformCollection.cs
- WebPartCatalogCloseVerb.cs
- ChannelManager.cs
- DesignerCategoryAttribute.cs
- SchemaImporterExtensionsSection.cs
- DataKeyCollection.cs
- ItemsPresenter.cs
- DesignDataSource.cs
- CalendarTable.cs
- Propagator.Evaluator.cs
- SuppressIldasmAttribute.cs
- ProcessModuleCollection.cs
- XmlDataSourceView.cs
- SqlDataReaderSmi.cs
- DesignerCapabilities.cs
- BatchParser.cs
- DataPagerFieldCommandEventArgs.cs
- cache.cs
- AttributeEmitter.cs
- _ServiceNameStore.cs
- RSAOAEPKeyExchangeFormatter.cs
- HtmlDocument.cs
- ZoneButton.cs
- ActiveXHelper.cs
- Command.cs
- StrokeFIndices.cs
- DBSchemaTable.cs
- MethodImplAttribute.cs
- ClientSettingsStore.cs
- SelectionRange.cs
- TimeoutHelper.cs
- FrugalList.cs
- TypeToken.cs
- HostedTransportConfigurationBase.cs
- ColumnHeader.cs
- StringBlob.cs
- RegexMatchCollection.cs
- KeysConverter.cs
- DateTimeFormatInfo.cs
- ExtractorMetadata.cs
- TrueReadOnlyCollection.cs
- HuffModule.cs
- MetadataUtil.cs
- PageThemeCodeDomTreeGenerator.cs
- WinInetCache.cs
- HtmlShimManager.cs
- ServiceManager.cs
- BamlLocalizer.cs
- Stackframe.cs
- MenuRenderer.cs
- ButtonBase.cs
- CodeTypeParameter.cs
- PermissionSet.cs
- LoginDesignerUtil.cs
- TeredoHelper.cs
- QilParameter.cs
- PointLightBase.cs
- BaseProcessor.cs
- LocalizabilityAttribute.cs
- EventSinkHelperWriter.cs
- SecurityUtils.cs
- CodeAttributeArgumentCollection.cs
- UnsafeNetInfoNativeMethods.cs
- CqlParserHelpers.cs
- TripleDESCryptoServiceProvider.cs
- Attributes.cs
- EditBehavior.cs
- ProtocolsConfigurationHandler.cs
- ProfilePropertyNameValidator.cs
- MediaContextNotificationWindow.cs
- ReferenceTypeElement.cs
- TextFormatterImp.cs
- LocalBuilder.cs
- SystemShuttingDownException.cs
- ModelProperty.cs
- designeractionlistschangedeventargs.cs
- DecimalConverter.cs
- ReliableSessionBindingElement.cs
- SiteMembershipCondition.cs