Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- HMAC.cs
- DescendantBaseQuery.cs
- EncodingStreamWrapper.cs
- DataServiceException.cs
- WindowsAltTab.cs
- SignatureDescription.cs
- Properties.cs
- TextParagraph.cs
- UseLicense.cs
- ArgumentOutOfRangeException.cs
- HashCodeCombiner.cs
- ControlBuilder.cs
- BoundsDrawingContextWalker.cs
- XmlHierarchyData.cs
- RowToParametersTransformer.cs
- PeerCollaborationPermission.cs
- CompilationUnit.cs
- _ConnectOverlappedAsyncResult.cs
- WebPartManagerInternals.cs
- DataBoundLiteralControl.cs
- SimpleType.cs
- ProcessHostConfigUtils.cs
- Misc.cs
- TextInfo.cs
- ClrProviderManifest.cs
- SystemResourceHost.cs
- FileEnumerator.cs
- TypedAsyncResult.cs
- ActivityScheduledRecord.cs
- RoutedCommand.cs
- ConfigurationStrings.cs
- TemplatedAdorner.cs
- QuaternionAnimation.cs
- WizardDesigner.cs
- GroupQuery.cs
- SafeNativeMethods.cs
- EditingScope.cs
- XamlStackWriter.cs
- Symbol.cs
- CompilerHelpers.cs
- SystemColors.cs
- DataSourceConverter.cs
- DataKey.cs
- AddInActivator.cs
- VBIdentifierNameEditor.cs
- TextWriterEngine.cs
- ActiveDesignSurfaceEvent.cs
- UncommonField.cs
- DoubleLink.cs
- DetailsViewUpdateEventArgs.cs
- WebConfigurationFileMap.cs
- NetDataContractSerializer.cs
- PointAnimationUsingKeyFrames.cs
- FlowDocumentPaginator.cs
- LocalizationParserHooks.cs
- TextContainerHelper.cs
- CriticalHandle.cs
- TextTrailingWordEllipsis.cs
- GenericTypeParameterBuilder.cs
- BamlBinaryWriter.cs
- WinFormsComponentEditor.cs
- DataBoundControlHelper.cs
- BulletedList.cs
- DetailsViewRow.cs
- HostedImpersonationContext.cs
- TreeNodeMouseHoverEvent.cs
- BinaryObjectReader.cs
- PersianCalendar.cs
- TextRange.cs
- LineBreakRecord.cs
- ConstraintCollection.cs
- DataGridViewComboBoxCell.cs
- DBSchemaTable.cs
- MailMessageEventArgs.cs
- PtsCache.cs
- CompositeFontInfo.cs
- TrustSection.cs
- BamlBinaryWriter.cs
- WeakReadOnlyCollection.cs
- SortedSetDebugView.cs
- SQLConvert.cs
- Queue.cs
- TemplateBindingExpressionConverter.cs
- GregorianCalendarHelper.cs
- CatalogZone.cs
- AsnEncodedData.cs
- XmlBinaryWriterSession.cs
- Membership.cs
- CompilerResults.cs
- RealProxy.cs
- EpmAttributeNameBuilder.cs
- RemoveStoryboard.cs
- WindowsToolbar.cs
- FragmentQueryKB.cs
- BulletedListEventArgs.cs
- Decimal.cs
- UInt32Storage.cs
- CodeGenHelper.cs
- ChannelHandler.cs
- HMACMD5.cs