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
- TextDocumentView.cs
- X500Name.cs
- Roles.cs
- DetailsViewInsertedEventArgs.cs
- ThreadPool.cs
- XmlTextReaderImplHelpers.cs
- ProviderException.cs
- TextProperties.cs
- PrintController.cs
- ContentValidator.cs
- OpenTypeLayout.cs
- SpecularMaterial.cs
- RowUpdatedEventArgs.cs
- RSAPKCS1SignatureDeformatter.cs
- OdbcError.cs
- NoPersistScope.cs
- securitycriticaldata.cs
- HttpConfigurationContext.cs
- XPathExpr.cs
- CrossContextChannel.cs
- URIFormatException.cs
- BindUriHelper.cs
- AsymmetricSignatureDeformatter.cs
- PropertyMapper.cs
- EmptyEnumerator.cs
- TextAnchor.cs
- TypeElementCollection.cs
- ListItemCollection.cs
- RelatedPropertyManager.cs
- Shared.cs
- WindowsTab.cs
- ConnectionStringEditor.cs
- MethodSignatureGenerator.cs
- EncryptedReference.cs
- DtdParser.cs
- XmlStringTable.cs
- TypedDataSetSchemaImporterExtension.cs
- ButtonBaseDesigner.cs
- ObjectNavigationPropertyMapping.cs
- CacheDependency.cs
- PriorityBinding.cs
- ObjectParameterCollection.cs
- Char.cs
- HiddenFieldPageStatePersister.cs
- CodeMemberProperty.cs
- InitializationEventAttribute.cs
- EmptyQuery.cs
- PerformanceCounterLib.cs
- Int32.cs
- FileUpload.cs
- PreApplicationStartMethodAttribute.cs
- BaseCollection.cs
- PenCursorManager.cs
- AgileSafeNativeMemoryHandle.cs
- SqlNode.cs
- ImageBrush.cs
- AppDomainShutdownMonitor.cs
- ExtendedProperty.cs
- WriteableBitmap.cs
- LoginView.cs
- ListDictionaryInternal.cs
- StaticSiteMapProvider.cs
- wmiprovider.cs
- DataBindingHandlerAttribute.cs
- Control.cs
- CalculatedColumn.cs
- SudsCommon.cs
- FilterException.cs
- RadialGradientBrush.cs
- Marshal.cs
- CurrencyManager.cs
- ObjectStateEntryDbDataRecord.cs
- RectAnimationBase.cs
- SplineQuaternionKeyFrame.cs
- ResourceCategoryAttribute.cs
- BigIntegerStorage.cs
- PrintDialog.cs
- HelpKeywordAttribute.cs
- ActivityBindForm.Designer.cs
- CodeDirectiveCollection.cs
- input.cs
- UnitySerializationHolder.cs
- MemoryMappedView.cs
- NameTable.cs
- SafeRegistryHandle.cs
- DataStreams.cs
- MultipleViewPattern.cs
- DoubleKeyFrameCollection.cs
- ResourceCodeDomSerializer.cs
- CopyNodeSetAction.cs
- DelayLoadType.cs
- RolePrincipal.cs
- RemotingConfigParser.cs
- TabletDevice.cs
- ResourcePool.cs
- TextRunTypographyProperties.cs
- ClientRolePrincipal.cs
- Filter.cs
- Table.cs
- KnownBoxes.cs