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
- AsyncResult.cs
- FederatedMessageSecurityOverHttpElement.cs
- BitmapSourceSafeMILHandle.cs
- ValidatedControlConverter.cs
- AsnEncodedData.cs
- CollectionExtensions.cs
- WebPartAddingEventArgs.cs
- Tracer.cs
- WebPartZoneBase.cs
- TextDecoration.cs
- ZoomPercentageConverter.cs
- WebConvert.cs
- ToolTipAutomationPeer.cs
- PointLightBase.cs
- TagMapInfo.cs
- BinarySerializer.cs
- ImageInfo.cs
- webclient.cs
- ExpressionBindingCollection.cs
- XPathMultyIterator.cs
- TextBox.cs
- RegexRunnerFactory.cs
- RootBrowserWindowAutomationPeer.cs
- ComPlusServiceHost.cs
- Paragraph.cs
- DecoratedNameAttribute.cs
- TypeSystem.cs
- PageParserFilter.cs
- NotCondition.cs
- DoubleUtil.cs
- ELinqQueryState.cs
- ConfigErrorGlyph.cs
- SpellerHighlightLayer.cs
- SimpleHandlerBuildProvider.cs
- DataGridViewCellCancelEventArgs.cs
- UnknownWrapper.cs
- mactripleDES.cs
- ExeConfigurationFileMap.cs
- X509WindowsSecurityToken.cs
- FixUpCollection.cs
- XmlBaseReader.cs
- SubordinateTransaction.cs
- AlignmentXValidation.cs
- ColorBlend.cs
- FullTextState.cs
- KeysConverter.cs
- PointCollectionValueSerializer.cs
- InkCanvasInnerCanvas.cs
- CompilationAssemblyInstallComponent.cs
- ClonableStack.cs
- DesignerAttributeInfo.cs
- MasterPageParser.cs
- AppSettingsExpressionBuilder.cs
- DesignerTransactionCloseEvent.cs
- DataServiceQueryProvider.cs
- InstanceDataCollection.cs
- VectorAnimationUsingKeyFrames.cs
- ListViewInsertedEventArgs.cs
- MarkupCompiler.cs
- COAUTHINFO.cs
- ToolStripHighContrastRenderer.cs
- InfoCardConstants.cs
- FixedTextPointer.cs
- hresults.cs
- ParameterCollection.cs
- UnsafeNetInfoNativeMethods.cs
- MulticastIPAddressInformationCollection.cs
- CaseInsensitiveHashCodeProvider.cs
- CalendarAutoFormat.cs
- DataServiceHost.cs
- QuaternionRotation3D.cs
- Effect.cs
- MobileSysDescriptionAttribute.cs
- ProfilePropertyMetadata.cs
- FacetValueContainer.cs
- _NegoStream.cs
- StateDesigner.LayoutSelectionGlyph.cs
- SpecialFolderEnumConverter.cs
- ChildDocumentBlock.cs
- AddInController.cs
- ActivityTypeResolver.xaml.cs
- Util.cs
- OracleConnectionFactory.cs
- InstanceDataCollectionCollection.cs
- AppLevelCompilationSectionCache.cs
- ScriptingJsonSerializationSection.cs
- SqlMethodAttribute.cs
- BasicViewGenerator.cs
- ResponseStream.cs
- TemplateColumn.cs
- WmlValidatorAdapter.cs
- SimpleType.cs
- AuthorizationRuleCollection.cs
- TextServicesPropertyRanges.cs
- MessageBox.cs
- CompletedAsyncResult.cs
- AssemblyInfo.cs
- HashHelper.cs
- CalendarAutoFormat.cs
- AssemblyName.cs