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
- OverflowException.cs
- ChangePasswordDesigner.cs
- EventLogRecord.cs
- HierarchicalDataBoundControl.cs
- MailWriter.cs
- RemotingSurrogateSelector.cs
- CachedTypeface.cs
- CompilationUtil.cs
- SpanIndex.cs
- NavigatorInput.cs
- PrintDialog.cs
- ProfileService.cs
- ImmutableCollection.cs
- OletxVolatileEnlistment.cs
- ColorIndependentAnimationStorage.cs
- UnsafeNativeMethods.cs
- ResourceBinder.cs
- CollectionType.cs
- CalendarAutoFormat.cs
- BypassElement.cs
- SmiContextFactory.cs
- EdmToObjectNamespaceMap.cs
- ExpressionBuilderContext.cs
- SafeNativeMethods.cs
- SqlRowUpdatingEvent.cs
- AuthorizationRuleCollection.cs
- DataSourceView.cs
- UnhandledExceptionEventArgs.cs
- SchemaImporterExtensionElementCollection.cs
- Typography.cs
- TreePrinter.cs
- SafeNativeMethods.cs
- Color.cs
- ExceptionUtil.cs
- MethodAccessException.cs
- ZipFileInfoCollection.cs
- SqlDataAdapter.cs
- CatalogPartCollection.cs
- UInt64Storage.cs
- EndpointFilterProvider.cs
- PackageStore.cs
- ByteAnimationUsingKeyFrames.cs
- WorkflowItemsPresenter.cs
- LocatorPart.cs
- HMACSHA384.cs
- WebResourceUtil.cs
- KeyConstraint.cs
- DataPointer.cs
- FileDialog.cs
- BitmapMetadataBlob.cs
- KeyConstraint.cs
- DataReceivedEventArgs.cs
- Timer.cs
- SerialStream.cs
- OleDbParameter.cs
- AspCompat.cs
- OleDbCommandBuilder.cs
- StickyNote.cs
- SqlClientPermission.cs
- ListBox.cs
- CultureInfoConverter.cs
- DependencyPropertyChangedEventArgs.cs
- WindowsImpersonationContext.cs
- JulianCalendar.cs
- ValueSerializer.cs
- HashCodeCombiner.cs
- ResourceProviderFactory.cs
- SparseMemoryStream.cs
- ReadOnlyPropertyMetadata.cs
- StringValidator.cs
- ValidatedControlConverter.cs
- EventDescriptor.cs
- ListViewItem.cs
- Configuration.cs
- NotImplementedException.cs
- CapabilitiesAssignment.cs
- TreeViewCancelEvent.cs
- SafeProcessHandle.cs
- WebReferencesBuildProvider.cs
- CounterSet.cs
- VideoDrawing.cs
- Codec.cs
- ByteStorage.cs
- KeysConverter.cs
- GregorianCalendarHelper.cs
- TextRenderer.cs
- TextServicesLoader.cs
- DiffuseMaterial.cs
- AppDomainManager.cs
- DataServiceResponse.cs
- MethodToken.cs
- DataColumnSelectionConverter.cs
- Cursors.cs
- CodeTypeDelegate.cs
- MergablePropertyAttribute.cs
- StsCommunicationException.cs
- DataGrid.cs
- Stroke2.cs
- DoubleAnimationClockResource.cs
- JoinElimination.cs