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
- FieldNameLookup.cs
- HttpHeaderCollection.cs
- IteratorFilter.cs
- Source.cs
- TraceSwitch.cs
- CfgRule.cs
- WorkflowApplicationCompletedEventArgs.cs
- ControllableStoryboardAction.cs
- TimeSpanValidator.cs
- TableCellAutomationPeer.cs
- AstTree.cs
- XmlCharacterData.cs
- InfiniteTimeSpanConverter.cs
- ProjectionPath.cs
- OleDbInfoMessageEvent.cs
- DefinitionBase.cs
- ArraySet.cs
- SqlParameter.cs
- FontStretch.cs
- ScriptingSectionGroup.cs
- StringUtil.cs
- RoleManagerEventArgs.cs
- basenumberconverter.cs
- UserPreferenceChangingEventArgs.cs
- ShapeTypeface.cs
- _UncName.cs
- EditorPartChrome.cs
- SortQuery.cs
- FixedTextView.cs
- MultiTrigger.cs
- FormatConvertedBitmap.cs
- BaseCollection.cs
- MenuItemBindingCollection.cs
- DynamicExpression.cs
- DrawItemEvent.cs
- DataListItemEventArgs.cs
- NullableIntAverageAggregationOperator.cs
- returneventsaver.cs
- CacheChildrenQuery.cs
- PageCodeDomTreeGenerator.cs
- SetterBase.cs
- GridViewSortEventArgs.cs
- FixedSOMElement.cs
- FixUp.cs
- EdgeModeValidation.cs
- HybridDictionary.cs
- PassportIdentity.cs
- CorrelationKey.cs
- HtmlInputFile.cs
- PluralizationService.cs
- NamedPipeTransportBindingElement.cs
- RoutedEventArgs.cs
- SchemaSetCompiler.cs
- SurrogateEncoder.cs
- Overlapped.cs
- BlobPersonalizationState.cs
- AssemblyName.cs
- followingsibling.cs
- TriState.cs
- DbConnectionPoolGroupProviderInfo.cs
- HtmlSelectionListAdapter.cs
- SafeUserTokenHandle.cs
- Utils.cs
- SessionState.cs
- AdornedElementPlaceholder.cs
- TransformValueSerializer.cs
- TrustManagerPromptUI.cs
- RSAOAEPKeyExchangeDeformatter.cs
- HostSecurityManager.cs
- PrivateFontCollection.cs
- SurrogateDataContract.cs
- FrameworkElementAutomationPeer.cs
- Mapping.cs
- User.cs
- counter.cs
- HashStream.cs
- DbConnectionFactory.cs
- DeferredSelectedIndexReference.cs
- OneOf.cs
- SiteIdentityPermission.cs
- PrePrepareMethodAttribute.cs
- ToolStripScrollButton.cs
- UserPersonalizationStateInfo.cs
- AuthenticationService.cs
- AttachedAnnotation.cs
- UrlMappingsSection.cs
- MetadataPropertyvalue.cs
- COM2ExtendedUITypeEditor.cs
- StaticExtensionConverter.cs
- RtfNavigator.cs
- DynamicMetaObject.cs
- AnimationException.cs
- SystemSounds.cs
- StreamGeometry.cs
- Transform3D.cs
- WebPartEditorOkVerb.cs
- FormsAuthenticationTicket.cs
- WebBrowsableAttribute.cs
- Monitor.cs
- QueryExtender.cs