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
- BookmarkEventArgs.cs
- UseAttributeSetsAction.cs
- RecordConverter.cs
- ToolStripLocationCancelEventArgs.cs
- ReferenceConverter.cs
- NamespaceInfo.cs
- TextRangeEdit.cs
- VerificationException.cs
- FrameworkTemplate.cs
- EventRoute.cs
- SettingsAttributeDictionary.cs
- AuthenticatedStream.cs
- JournalNavigationScope.cs
- CollectionViewSource.cs
- MembershipSection.cs
- DoubleConverter.cs
- Assembly.cs
- TextRenderer.cs
- MouseEventArgs.cs
- NetPipeSectionData.cs
- Operators.cs
- Contracts.cs
- ErrorFormatterPage.cs
- PriorityQueue.cs
- PersistencePipeline.cs
- DBPropSet.cs
- AnimationLayer.cs
- Pens.cs
- GroupDescription.cs
- RtfToken.cs
- DataGridViewComboBoxCell.cs
- AddInAdapter.cs
- Run.cs
- FragmentQueryProcessor.cs
- WindowsListViewItemStartMenu.cs
- HyperLinkDesigner.cs
- UserControlCodeDomTreeGenerator.cs
- DataMemberConverter.cs
- PropertyChangedEventArgs.cs
- JsonEnumDataContract.cs
- DomainUpDown.cs
- ObfuscationAttribute.cs
- SQLStringStorage.cs
- Configuration.cs
- CompiledIdentityConstraint.cs
- StringResourceManager.cs
- WeakEventTable.cs
- VerificationAttribute.cs
- OuterGlowBitmapEffect.cs
- DbExpressionVisitor_TResultType.cs
- ConfigViewGenerator.cs
- LinkDescriptor.cs
- streamingZipPartStream.cs
- StoreItemCollection.Loader.cs
- CompositeActivityTypeDescriptorProvider.cs
- SizeConverter.cs
- ContextStack.cs
- PathFigure.cs
- CqlQuery.cs
- Polygon.cs
- VisualStyleTypesAndProperties.cs
- QilIterator.cs
- ListItemDetailViewAttribute.cs
- InkCanvasAutomationPeer.cs
- CompilationLock.cs
- Rect3DValueSerializer.cs
- ListBoxItem.cs
- HebrewCalendar.cs
- CellIdBoolean.cs
- SurrogateEncoder.cs
- NavigatorOutput.cs
- DbDataSourceEnumerator.cs
- Int32CollectionConverter.cs
- StringFreezingAttribute.cs
- PreviewKeyDownEventArgs.cs
- SendMessageChannelCache.cs
- Vector3DAnimationUsingKeyFrames.cs
- XmlLangPropertyAttribute.cs
- OleTxTransactionInfo.cs
- While.cs
- ItemDragEvent.cs
- ScriptingWebServicesSectionGroup.cs
- WindowsBrush.cs
- QueueProcessor.cs
- SiteMapSection.cs
- CheckBox.cs
- FamilyTypefaceCollection.cs
- CommonXSendMessage.cs
- LogLogRecordEnumerator.cs
- LinkedResource.cs
- PersonalizablePropertyEntry.cs
- AdditionalEntityFunctions.cs
- FontNamesConverter.cs
- IsolatedStorageFile.cs
- InvalidPipelineStoreException.cs
- StringFormat.cs
- TextCollapsingProperties.cs
- Hash.cs
- DNS.cs
- LongValidator.cs