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
- CharEntityEncoderFallback.cs
- XmlSchemaIdentityConstraint.cs
- DecimalConstantAttribute.cs
- HashCodeCombiner.cs
- XmlEntityReference.cs
- KerberosTicketHashIdentifierClause.cs
- XmlCharacterData.cs
- Substitution.cs
- Choices.cs
- TreeNodeCollectionEditor.cs
- MediaTimeline.cs
- OdbcInfoMessageEvent.cs
- MdbDataFileEditor.cs
- DataGridViewTextBoxEditingControl.cs
- MimeTypePropertyAttribute.cs
- ArgumentOutOfRangeException.cs
- InvalidPrinterException.cs
- BitmapEffectrendercontext.cs
- GradientStopCollection.cs
- DoubleAnimationUsingKeyFrames.cs
- Size3D.cs
- JsonServiceDocumentSerializer.cs
- DataGridItem.cs
- HtmlUtf8RawTextWriter.cs
- BezierSegment.cs
- HierarchicalDataSourceControl.cs
- OptimalBreakSession.cs
- DataGridViewCellCollection.cs
- RuntimeWrappedException.cs
- XsdBuildProvider.cs
- OneToOneMappingSerializer.cs
- BitmapImage.cs
- DataContract.cs
- RefType.cs
- PeerInvitationResponse.cs
- DbDataSourceEnumerator.cs
- Rect.cs
- ClientSettingsSection.cs
- RSAProtectedConfigurationProvider.cs
- FixedPageProcessor.cs
- TypeUnloadedException.cs
- regiisutil.cs
- SqlDataSourceWizardForm.cs
- TriggerCollection.cs
- MenuAutomationPeer.cs
- FlowDocumentReaderAutomationPeer.cs
- FeatureSupport.cs
- ObjectListShowCommandsEventArgs.cs
- TdsRecordBufferSetter.cs
- UnicodeEncoding.cs
- PropertyMappingExceptionEventArgs.cs
- RowToFieldTransformer.cs
- Comparer.cs
- XmlSchemaSimpleContentRestriction.cs
- FormsAuthenticationTicket.cs
- WebPartVerbCollection.cs
- Vector3DValueSerializer.cs
- DirectionalLight.cs
- Int32Converter.cs
- IImplicitResourceProvider.cs
- FrameworkElement.cs
- TCPClient.cs
- AttachedPropertyMethodSelector.cs
- FieldToken.cs
- RewritingPass.cs
- SqlUnionizer.cs
- XmlStreamStore.cs
- ElementAction.cs
- XpsTokenContext.cs
- HtmlEncodedRawTextWriter.cs
- TextView.cs
- DiscreteKeyFrames.cs
- ActivityXRefConverter.cs
- InlineObject.cs
- SecondaryViewProvider.cs
- EmbeddedMailObject.cs
- ArgumentException.cs
- MetaTable.cs
- StreamReader.cs
- Vertex.cs
- httpapplicationstate.cs
- QuestionEventArgs.cs
- GridViewCancelEditEventArgs.cs
- FormViewPagerRow.cs
- mda.cs
- SqlNode.cs
- BigInt.cs
- CommandEventArgs.cs
- VectorCollection.cs
- InputBuffer.cs
- AlphaSortedEnumConverter.cs
- XamlVector3DCollectionSerializer.cs
- LinqDataSourceSelectEventArgs.cs
- ZipIOExtraFieldPaddingElement.cs
- WebConfigurationFileMap.cs
- NullableIntSumAggregationOperator.cs
- CryptoConfig.cs
- IndexedGlyphRun.cs
- DataColumnCollection.cs
- BrowsableAttribute.cs