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
- ScriptingSectionGroup.cs
- CompilerScopeManager.cs
- PackageFilter.cs
- HtmlTextArea.cs
- PrefixQName.cs
- SQLCharsStorage.cs
- TreeNodeBindingCollection.cs
- DrawingImage.cs
- tooltip.cs
- SystemFonts.cs
- GradientStopCollection.cs
- DynamicValidatorEventArgs.cs
- TextEditorTables.cs
- IntranetCredentialPolicy.cs
- InvalidDocumentContentsException.cs
- XmlSchemaAny.cs
- HttpCookiesSection.cs
- TraceProvider.cs
- SpinLock.cs
- DependencyPropertyDescriptor.cs
- MeshGeometry3D.cs
- DesignSurfaceEvent.cs
- CrossAppDomainChannel.cs
- Util.cs
- XPathNodeInfoAtom.cs
- DeclarationUpdate.cs
- CaseStatementSlot.cs
- GuidelineSet.cs
- XhtmlConformanceSection.cs
- StringUtil.cs
- UrlUtility.cs
- ExpandSegment.cs
- ListItemConverter.cs
- MimeBasePart.cs
- BitmapCodecInfoInternal.cs
- BackgroundWorker.cs
- DataColumnChangeEvent.cs
- DataBindingList.cs
- BezierSegment.cs
- TypeExtensionConverter.cs
- XslTransform.cs
- CancelAsyncOperationRequest.cs
- ConnectionInterfaceCollection.cs
- FindCriteriaElement.cs
- NamespaceCollection.cs
- SafeEventLogWriteHandle.cs
- AsyncInvokeContext.cs
- CodeExporter.cs
- ToolBar.cs
- TextTreeTextElementNode.cs
- EditorPartDesigner.cs
- TypefaceCollection.cs
- SchemaName.cs
- SafeBuffer.cs
- EventMetadata.cs
- XmlSchemaAny.cs
- WpfKnownMemberInvoker.cs
- Monitor.cs
- XmlSecureResolver.cs
- EdmTypeAttribute.cs
- Duration.cs
- WebPartsPersonalizationAuthorization.cs
- RoleManagerModule.cs
- TransformedBitmap.cs
- BasePattern.cs
- HttpModulesSection.cs
- SafeHGlobalHandleCritical.cs
- RetrieveVirtualItemEventArgs.cs
- Page.cs
- FontDialog.cs
- SystemIcmpV4Statistics.cs
- RelOps.cs
- _ChunkParse.cs
- ICspAsymmetricAlgorithm.cs
- TextDecorations.cs
- OuterGlowBitmapEffect.cs
- HttpStaticObjectsCollectionWrapper.cs
- ToolTipService.cs
- Encoder.cs
- MenuCommand.cs
- Walker.cs
- ImageInfo.cs
- FontSourceCollection.cs
- FormsIdentity.cs
- PrimitiveRenderer.cs
- UrlParameterReader.cs
- XmlReflectionImporter.cs
- HitTestWithGeometryDrawingContextWalker.cs
- SortDescription.cs
- ObjectDisposedException.cs
- MatrixUtil.cs
- XmlSchemaSimpleContentExtension.cs
- VectorAnimation.cs
- QueryMath.cs
- FontStyleConverter.cs
- HtmlTableCell.cs
- ThaiBuddhistCalendar.cs
- MenuItem.cs
- Tablet.cs
- MimeImporter.cs