Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Shared / MS / Win32 / WinInet.cs / 1 / 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
- OracleParameterBinding.cs
- PackagePart.cs
- CategoryEditor.cs
- CodeEntryPointMethod.cs
- RelatedCurrencyManager.cs
- ProfileService.cs
- SoapFault.cs
- DesignBindingEditor.cs
- ResourceDefaultValueAttribute.cs
- SmiRecordBuffer.cs
- DetailsViewDeletedEventArgs.cs
- WebConfigurationManager.cs
- CopyNodeSetAction.cs
- CompensationHandlingFilter.cs
- DllNotFoundException.cs
- DescendentsWalker.cs
- ImmutableCollection.cs
- BufferedGraphicsManager.cs
- ActivityInstance.cs
- ListParagraph.cs
- NativeMethods.cs
- UpdateRecord.cs
- BaseValidatorDesigner.cs
- NativeActivityAbortContext.cs
- TypeDescriptionProviderAttribute.cs
- DataListCommandEventArgs.cs
- sqlinternaltransaction.cs
- ProfileInfo.cs
- XmlAutoDetectWriter.cs
- FormsAuthenticationUser.cs
- CommonGetThemePartSize.cs
- QilInvokeEarlyBound.cs
- GlobalEventManager.cs
- ObjectTag.cs
- AutomationPatternInfo.cs
- CodePageUtils.cs
- InputProcessorProfiles.cs
- ACE.cs
- SafeFreeMibTable.cs
- XmlILOptimizerVisitor.cs
- DataGridViewHitTestInfo.cs
- SafeSystemMetrics.cs
- ToolboxItemCollection.cs
- StreamUpgradeProvider.cs
- MemberPathMap.cs
- LayoutManager.cs
- OleServicesContext.cs
- AddInAdapter.cs
- autovalidator.cs
- QilStrConcat.cs
- RtfToken.cs
- ITextView.cs
- VBIdentifierDesigner.xaml.cs
- RightsController.cs
- TextureBrush.cs
- LoginAutoFormat.cs
- XmlIgnoreAttribute.cs
- TailPinnedEventArgs.cs
- BindingExpressionBase.cs
- XmlElementAttributes.cs
- TranslateTransform3D.cs
- BaseAddressElement.cs
- ProfileBuildProvider.cs
- Label.cs
- StreamUpdate.cs
- WebBrowserContainer.cs
- ListViewContainer.cs
- CapabilitiesAssignment.cs
- sqlinternaltransaction.cs
- SHA384Managed.cs
- DataGridViewAdvancedBorderStyle.cs
- XmlSchemaInclude.cs
- FilteredAttributeCollection.cs
- DataMember.cs
- RuntimeArgumentHandle.cs
- SqlFunctionAttribute.cs
- SystemMulticastIPAddressInformation.cs
- TypeUsageBuilder.cs
- TempFiles.cs
- XmlUTF8TextWriter.cs
- IgnorePropertiesAttribute.cs
- DbMetaDataCollectionNames.cs
- SafeNativeMethods.cs
- TextBlockAutomationPeer.cs
- ToolStripStatusLabel.cs
- ToolStripPanelCell.cs
- IsolatedStorageException.cs
- TimersDescriptionAttribute.cs
- TextServicesCompartmentContext.cs
- WorkflowTransactionOptions.cs
- ServiceModelTimeSpanValidator.cs
- InheritanceContextChangedEventManager.cs
- ArgumentException.cs
- NegatedCellConstant.cs
- CustomValidator.cs
- Constants.cs
- FormatException.cs
- MemberCollection.cs
- ToolBar.cs
- VectorAnimation.cs