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
- FacetChecker.cs
- RequestQueryParser.cs
- MetadataSerializer.cs
- AuthenticatedStream.cs
- ThousandthOfEmRealDoubles.cs
- UnlockInstanceAsyncResult.cs
- EllipseGeometry.cs
- ApplicationProxyInternal.cs
- SplineQuaternionKeyFrame.cs
- Polyline.cs
- HtmlEmptyTagControlBuilder.cs
- NumericUpDownAccelerationCollection.cs
- XPathBinder.cs
- _Connection.cs
- Application.cs
- CompilerResults.cs
- BatchStream.cs
- DbMetaDataFactory.cs
- Pair.cs
- RawStylusInputCustomData.cs
- DashStyles.cs
- DataContract.cs
- SchemaElement.cs
- designeractionlistschangedeventargs.cs
- HealthMonitoringSectionHelper.cs
- cookiecontainer.cs
- latinshape.cs
- ActivityExecutorOperation.cs
- TCPClient.cs
- SiteIdentityPermission.cs
- ImageUrlEditor.cs
- processwaithandle.cs
- ArcSegment.cs
- UrlMappingCollection.cs
- Stackframe.cs
- IntranetCredentialPolicy.cs
- DigitShape.cs
- HandoffBehavior.cs
- SQLDoubleStorage.cs
- CriticalFinalizerObject.cs
- Part.cs
- EventKeyword.cs
- EntitySqlQueryCacheKey.cs
- Helpers.cs
- UntrustedRecipientException.cs
- TextServicesContext.cs
- NotificationContext.cs
- TemplateContent.cs
- Visual3D.cs
- XPathAxisIterator.cs
- PeerUnsafeNativeCryptMethods.cs
- PackUriHelper.cs
- Brush.cs
- MethodBuilderInstantiation.cs
- DelegateArgumentReference.cs
- UnionCodeGroup.cs
- EventsTab.cs
- XmlIterators.cs
- SqlFlattener.cs
- FunctionParameter.cs
- HtmlControlPersistable.cs
- OSFeature.cs
- ExpressionTextBox.xaml.cs
- WhitespaceRuleReader.cs
- DataGridViewCellValidatingEventArgs.cs
- WsdlContractConversionContext.cs
- StrokeCollection.cs
- ScriptReference.cs
- Point3DCollection.cs
- WebPartTransformerAttribute.cs
- TextEditorLists.cs
- XmlDownloadManager.cs
- ExclusiveCanonicalizationTransform.cs
- XmlSerializerSection.cs
- ReliableChannelFactory.cs
- LayoutTableCell.cs
- ParenthesizePropertyNameAttribute.cs
- DockPattern.cs
- AuthorizationRule.cs
- TimelineClockCollection.cs
- NumberSubstitution.cs
- SqlParameterCollection.cs
- BulletedListEventArgs.cs
- SafeRightsManagementHandle.cs
- NativeMethodsOther.cs
- SqlProvider.cs
- PointConverter.cs
- ContextMenuStripGroupCollection.cs
- FillErrorEventArgs.cs
- PageTheme.cs
- IndexingContentUnit.cs
- KeyConverter.cs
- ComPlusContractBehavior.cs
- SingleConverter.cs
- NGCSerializationManager.cs
- UrlMappingCollection.cs
- ProfileSection.cs
- CompiledXpathExpr.cs
- ViewStateException.cs
- ServiceTimeoutsElement.cs