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
- LineMetrics.cs
- StrokeNodeData.cs
- VirtualPathExtension.cs
- BaseParser.cs
- DrawingGroup.cs
- MarginCollapsingState.cs
- TransformerInfoCollection.cs
- StringConcat.cs
- ResourceKey.cs
- ReachNamespaceInfo.cs
- SpecularMaterial.cs
- SafeNativeMethods.cs
- Models.cs
- SpeechSynthesizer.cs
- DbFunctionCommandTree.cs
- MappingItemCollection.cs
- OdbcPermission.cs
- StatusBarDrawItemEvent.cs
- XmlException.cs
- ChannelDispatcherBase.cs
- XmlAnyElementAttributes.cs
- ScrollPattern.cs
- Fonts.cs
- HttpContext.cs
- WebPartConnection.cs
- BindingOperations.cs
- RemoteWebConfigurationHost.cs
- XsltQilFactory.cs
- MarkupProperty.cs
- AffineTransform3D.cs
- ArrangedElementCollection.cs
- BuildProviderUtils.cs
- CqlParserHelpers.cs
- InputProcessorProfilesLoader.cs
- PngBitmapEncoder.cs
- XmlName.cs
- InheritanceRules.cs
- CollectionBase.cs
- SessionEndedEventArgs.cs
- InheritablePropertyChangeInfo.cs
- ActivationWorker.cs
- WorkflowWebService.cs
- Registry.cs
- StreamGeometry.cs
- SendActivityValidator.cs
- SQLInt16Storage.cs
- XmlUtilWriter.cs
- CommandBinding.cs
- Size3D.cs
- OpacityConverter.cs
- RawStylusInputCustomDataList.cs
- ApplicationSettingsBase.cs
- LoadedOrUnloadedOperation.cs
- SchemaObjectWriter.cs
- LocalsItemDescription.cs
- TablePattern.cs
- RequestCachingSection.cs
- DoubleUtil.cs
- OleDbTransaction.cs
- WorkerRequest.cs
- RuleSettingsCollection.cs
- CollectionViewGroup.cs
- CatalogPartCollection.cs
- GeneralTransformGroup.cs
- DataObjectSettingDataEventArgs.cs
- DataGridViewRowPostPaintEventArgs.cs
- ZipIOCentralDirectoryBlock.cs
- ProviderCommandInfoUtils.cs
- EntityProxyTypeInfo.cs
- WindowsServiceElement.cs
- HtmlTableCellCollection.cs
- LineServices.cs
- AuthorizationSection.cs
- HostedElements.cs
- SQLInt32Storage.cs
- CommandTreeTypeHelper.cs
- EmbeddedObject.cs
- ToolboxBitmapAttribute.cs
- FlowLayoutSettings.cs
- TemplatePropertyEntry.cs
- AssemblyBuilder.cs
- Nullable.cs
- OleDbPropertySetGuid.cs
- CodeMemberField.cs
- ParserHooks.cs
- NegatedCellConstant.cs
- WinOEToolBoxItem.cs
- SplashScreenNativeMethods.cs
- HistoryEventArgs.cs
- _BufferOffsetSize.cs
- NotFiniteNumberException.cs
- AndAlso.cs
- ByteAnimation.cs
- TargetParameterCountException.cs
- Exceptions.cs
- MetadataHelper.cs
- UmAlQuraCalendar.cs
- CompiledRegexRunnerFactory.cs
- ComponentConverter.cs
- XmlSequenceWriter.cs