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
- UnitySerializationHolder.cs
- XamlClipboardData.cs
- DetailsViewDeleteEventArgs.cs
- DbDataReader.cs
- XmlAttribute.cs
- AppDomainCompilerProxy.cs
- WorkflowApplicationCompletedEventArgs.cs
- DisplayMemberTemplateSelector.cs
- DataGridView.cs
- EntitySetDataBindingList.cs
- SchemaDeclBase.cs
- OrderToken.cs
- DataBinder.cs
- ToolBar.cs
- ExtenderProviderService.cs
- BitmapEditor.cs
- Timeline.cs
- ResolvePPIDRequest.cs
- ExceptionUtil.cs
- DataSourceSerializationException.cs
- Rotation3DAnimationUsingKeyFrames.cs
- HttpResponseHeader.cs
- CompiledIdentityConstraint.cs
- EntityCommandCompilationException.cs
- FrameworkRichTextComposition.cs
- TextTreeExtractElementUndoUnit.cs
- CircleHotSpot.cs
- SqlXml.cs
- SecurityElement.cs
- CertificateReferenceElement.cs
- DelegatingChannelListener.cs
- RadioButtonAutomationPeer.cs
- Freezable.cs
- AssertUtility.cs
- WebPartRestoreVerb.cs
- HttpModuleAction.cs
- SaveFileDialogDesigner.cs
- HwndProxyElementProvider.cs
- QueryOutputWriter.cs
- BordersPage.cs
- MarkupWriter.cs
- ProxyDataContractResolver.cs
- ActivityValidationServices.cs
- GridPatternIdentifiers.cs
- SocketPermission.cs
- FieldTemplateUserControl.cs
- WSHttpBindingBase.cs
- ActivationArguments.cs
- _NTAuthentication.cs
- MarginsConverter.cs
- GridViewItemAutomationPeer.cs
- ArrangedElementCollection.cs
- PcmConverter.cs
- HuffModule.cs
- ProfileGroupSettings.cs
- BuilderInfo.cs
- HttpModuleActionCollection.cs
- DynamicObjectAccessor.cs
- ComponentCollection.cs
- MailFileEditor.cs
- XsdSchemaFileEditor.cs
- DSASignatureFormatter.cs
- ParameterModifier.cs
- Configuration.cs
- DbCommandDefinition.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- TrackPoint.cs
- IHttpResponseInternal.cs
- StylusButtonCollection.cs
- System.Data_BID.cs
- VerticalAlignConverter.cs
- StringUtil.cs
- EntityAdapter.cs
- ActivityInfo.cs
- WorkflowCommandExtensionItem.cs
- TextFindEngine.cs
- Guid.cs
- DataGridViewHitTestInfo.cs
- FormViewDeleteEventArgs.cs
- ApplicationId.cs
- TraversalRequest.cs
- DBConcurrencyException.cs
- DataGridViewIntLinkedList.cs
- RegexMatchCollection.cs
- BufferedWebEventProvider.cs
- ExeConfigurationFileMap.cs
- XmlBinaryWriter.cs
- EditorZone.cs
- ContentElementCollection.cs
- UpdateExpressionVisitor.cs
- Mapping.cs
- webclient.cs
- StatusBarPanelClickEvent.cs
- Substitution.cs
- WebDisplayNameAttribute.cs
- TextEncodedRawTextWriter.cs
- PrinterUnitConvert.cs
- KeyValueConfigurationElement.cs
- TimeSpanFormat.cs
- EventEntry.cs