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
- TextCompositionEventArgs.cs
- HttpCachePolicy.cs
- ListDictionaryInternal.cs
- HttpHandlersSection.cs
- BinHexDecoder.cs
- SafeNativeMethods.cs
- CodeObject.cs
- PrintingPermissionAttribute.cs
- MailMessageEventArgs.cs
- ContractMapping.cs
- NegatedConstant.cs
- MenuStrip.cs
- ListViewTableCell.cs
- Filter.cs
- Container.cs
- FlowDocumentFormatter.cs
- MimeTextImporter.cs
- RuleElement.cs
- AttributeAction.cs
- Filter.cs
- CodeDomSerializationProvider.cs
- DesignerExtenders.cs
- StringBuilder.cs
- RoleServiceManager.cs
- BitVector32.cs
- SymDocumentType.cs
- _ConnectionGroup.cs
- VirtualDirectoryMappingCollection.cs
- TableLayout.cs
- DataSourceXmlSubItemAttribute.cs
- RemoteWebConfigurationHostStream.cs
- SkinBuilder.cs
- WindowsRegion.cs
- ComponentConverter.cs
- SiteMapDesignerDataSourceView.cs
- WinEventTracker.cs
- Drawing.cs
- InstanceHandleReference.cs
- SqlClientMetaDataCollectionNames.cs
- ResourceDefaultValueAttribute.cs
- TreeViewImageIndexConverter.cs
- DuplicateWaitObjectException.cs
- RewritingPass.cs
- ConsoleKeyInfo.cs
- DecimalSumAggregationOperator.cs
- DataListItem.cs
- DependencyPropertyValueSerializer.cs
- WebPartConnectionsEventArgs.cs
- XmlCountingReader.cs
- FormsAuthenticationUserCollection.cs
- WebAdminConfigurationHelper.cs
- ViewGenResults.cs
- FrameworkContentElement.cs
- DrawingCollection.cs
- StandardCommands.cs
- InvalidFilterCriteriaException.cs
- SafePipeHandle.cs
- ColorConvertedBitmap.cs
- PropertyEntry.cs
- TimeoutValidationAttribute.cs
- TextAdaptor.cs
- SqlBooleanMismatchVisitor.cs
- AbstractDataSvcMapFileLoader.cs
- SigningCredentials.cs
- DecoderBestFitFallback.cs
- ByteAnimationUsingKeyFrames.cs
- ClientSettingsSection.cs
- TextTreePropertyUndoUnit.cs
- CodeTypeMember.cs
- MissingFieldException.cs
- ProviderException.cs
- SymbolDocumentGenerator.cs
- MaskedTextBoxTextEditorDropDown.cs
- DataContractSerializer.cs
- SelectorAutomationPeer.cs
- DockAndAnchorLayout.cs
- CharacterBufferReference.cs
- SqlAliasesReferenced.cs
- XmlName.cs
- OdbcConnection.cs
- ResourcesChangeInfo.cs
- InputLanguage.cs
- IncrementalHitTester.cs
- PathData.cs
- XPathNodePointer.cs
- TimeIntervalCollection.cs
- SudsParser.cs
- XmlAnyAttributeAttribute.cs
- BindingGroup.cs
- UserNameSecurityTokenAuthenticator.cs
- Soap12ProtocolImporter.cs
- ConvertEvent.cs
- NetworkInformationException.cs
- WizardStepBase.cs
- GridLength.cs
- HostnameComparisonMode.cs
- ListViewItem.cs
- MenuEventArgs.cs
- WeakRefEnumerator.cs
- _SslStream.cs