Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Shared / MS / Win32 / WinInet.cs / 1305600 / 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
- GroupByExpressionRewriter.cs
- ConfigurationSettings.cs
- ProcessHostServerConfig.cs
- InvalidCastException.cs
- SubMenuStyle.cs
- figurelength.cs
- HttpModuleActionCollection.cs
- Atom10FormatterFactory.cs
- VisualProxy.cs
- DrawingCollection.cs
- DocumentManager.cs
- CodeFieldReferenceExpression.cs
- MsmqIntegrationChannelFactory.cs
- MissingSatelliteAssemblyException.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- DesignTimeTemplateParser.cs
- _SafeNetHandles.cs
- XmlElement.cs
- RemotingSurrogateSelector.cs
- SrgsGrammar.cs
- DataFormat.cs
- OutputScopeManager.cs
- AxisAngleRotation3D.cs
- PixelFormat.cs
- ASCIIEncoding.cs
- IxmlLineInfo.cs
- EntitySqlQueryState.cs
- ObjectTag.cs
- DiscoveryClientChannelFactory.cs
- URLAttribute.cs
- LockCookie.cs
- QueryTaskGroupState.cs
- Ref.cs
- ZipIOLocalFileHeader.cs
- Point3D.cs
- EmptyEnumerable.cs
- XmlValidatingReaderImpl.cs
- StickyNoteContentControl.cs
- IteratorFilter.cs
- SweepDirectionValidation.cs
- StreamGeometryContext.cs
- CompatibleComparer.cs
- AppDomainAttributes.cs
- ColorTypeConverter.cs
- AccessDataSourceView.cs
- PaperSource.cs
- StringPropertyBuilder.cs
- TemplatedWizardStep.cs
- DiagnosticSection.cs
- StructuredTypeInfo.cs
- XmlDocument.cs
- RemotingException.cs
- ContentDisposition.cs
- CompiledRegexRunner.cs
- httpapplicationstate.cs
- ReachIDocumentPaginatorSerializer.cs
- DateTimeParse.cs
- StrokeNodeData.cs
- DataTableExtensions.cs
- AppLevelCompilationSectionCache.cs
- EventMappingSettingsCollection.cs
- NavigationCommands.cs
- CodeObjectCreateExpression.cs
- OleDbErrorCollection.cs
- MulticastOption.cs
- EnumBuilder.cs
- SqlClientWrapperSmiStreamChars.cs
- XmlPreloadedResolver.cs
- MachineKeyValidationConverter.cs
- CreateParams.cs
- StyleModeStack.cs
- ImageMetadata.cs
- SqlDataSourceCommandEventArgs.cs
- basevalidator.cs
- HtmlSelect.cs
- ScaleTransform3D.cs
- WebPartConnectionsConfigureVerb.cs
- SecurityKeyType.cs
- DuplexChannelFactory.cs
- TextBreakpoint.cs
- ImportContext.cs
- Number.cs
- StatusBarPanelClickEvent.cs
- StandardToolWindows.cs
- Solver.cs
- PropagatorResult.cs
- DoubleKeyFrameCollection.cs
- Control.cs
- PermissionSetTriple.cs
- DesignTimeHTMLTextWriter.cs
- WebReferencesBuildProvider.cs
- BitmapFrame.cs
- AnnotationService.cs
- ConnectionPoint.cs
- DataServiceKeyAttribute.cs
- CompilerWrapper.cs
- DispatcherExceptionFilterEventArgs.cs
- CacheEntry.cs
- FactoryMaker.cs
- DocumentApplicationJournalEntry.cs