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
- JsonFormatGeneratorStatics.cs
- TabPanel.cs
- DbInsertCommandTree.cs
- CodeSubDirectoriesCollection.cs
- _UncName.cs
- MissingSatelliteAssemblyException.cs
- MailMessageEventArgs.cs
- SizeKeyFrameCollection.cs
- X509IssuerSerialKeyIdentifierClause.cs
- OdbcErrorCollection.cs
- externdll.cs
- Int16Converter.cs
- Base64Decoder.cs
- WorkflowPersistenceContext.cs
- CoreSwitches.cs
- UpdateException.cs
- BufferedGenericXmlSecurityToken.cs
- CalloutQueueItem.cs
- AudioFileOut.cs
- Utils.cs
- BaseCAMarshaler.cs
- HttpModuleCollection.cs
- UrlParameterWriter.cs
- SynchronizedDispatch.cs
- RuleSettingsCollection.cs
- SplitterPanel.cs
- WorkItem.cs
- CDSsyncETWBCLProvider.cs
- Decoder.cs
- ComponentChangedEvent.cs
- CustomSignedXml.cs
- XmlUtf8RawTextWriter.cs
- ClaimTypeElementCollection.cs
- SizeAnimation.cs
- ObfuscationAttribute.cs
- RSAOAEPKeyExchangeFormatter.cs
- Geometry.cs
- MSG.cs
- DispatchChannelSink.cs
- XslVisitor.cs
- WebPartDescription.cs
- IsolatedStorageFileStream.cs
- XmlMapping.cs
- PhysicalOps.cs
- HttpConfigurationSystem.cs
- Point3DValueSerializer.cs
- TextDecorations.cs
- ConfigurationSectionCollection.cs
- ItemCheckEvent.cs
- HexParser.cs
- String.cs
- ContainerControl.cs
- EventItfInfo.cs
- ServiceOperationViewControl.cs
- ConfigurationStrings.cs
- OracleFactory.cs
- Rectangle.cs
- StoreItemCollection.cs
- WebPartDisplayModeCollection.cs
- HttpFormatExtensions.cs
- TaiwanLunisolarCalendar.cs
- HebrewCalendar.cs
- TextViewDesigner.cs
- LinkDescriptor.cs
- HTTPNotFoundHandler.cs
- AppDomainProtocolHandler.cs
- InvalidCastException.cs
- COM2ColorConverter.cs
- VersionedStream.cs
- CodeAccessSecurityEngine.cs
- LineServicesCallbacks.cs
- RuntimeCompatibilityAttribute.cs
- StoreItemCollection.cs
- MarkedHighlightComponent.cs
- MenuItem.cs
- GeometryConverter.cs
- InputScope.cs
- FlowDocumentFormatter.cs
- ImpersonationContext.cs
- HtmlMeta.cs
- CodeRegionDirective.cs
- FunctionUpdateCommand.cs
- WebPartTransformer.cs
- FrameworkReadOnlyPropertyMetadata.cs
- TableColumn.cs
- SerializationSectionGroup.cs
- SoapElementAttribute.cs
- IdentitySection.cs
- DefaultWorkflowTransactionService.cs
- PermissionRequestEvidence.cs
- UriExt.cs
- MarshalDirectiveException.cs
- CachedRequestParams.cs
- ControlIdConverter.cs
- ClientSettings.cs
- RoutedEventHandlerInfo.cs
- Brushes.cs
- ResourcePool.cs
- MetadataExporter.cs
- ControlBuilderAttribute.cs