Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Shared / MS / Win32 / WinInet.cs / 1305600 / 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
- DbUpdateCommandTree.cs
- PackageFilter.cs
- CacheChildrenQuery.cs
- WaitHandleCannotBeOpenedException.cs
- RequestStatusBarUpdateEventArgs.cs
- ToolStripDropDownDesigner.cs
- __Filters.cs
- GridViewColumn.cs
- SettingsSavedEventArgs.cs
- SpellerStatusTable.cs
- MenuItemCollection.cs
- ScriptManagerProxy.cs
- CompletionCallbackWrapper.cs
- FontFamily.cs
- XmlDesigner.cs
- NetworkInterface.cs
- SupportingTokenBindingElement.cs
- ExpressionConverter.cs
- CatalogPartChrome.cs
- InputBuffer.cs
- Vector3DCollectionValueSerializer.cs
- UpdateProgress.cs
- ActivityXRefPropertyEditor.cs
- ExtenderControl.cs
- WebPartDisplayModeCancelEventArgs.cs
- OleDbDataReader.cs
- ContentFilePart.cs
- CheckedListBox.cs
- EventLogEntry.cs
- ScanQueryOperator.cs
- _DisconnectOverlappedAsyncResult.cs
- ProcessInfo.cs
- UIElement3DAutomationPeer.cs
- CorrelationInitializer.cs
- XmlCompatibilityReader.cs
- TreeNodeStyleCollection.cs
- WizardPanel.cs
- ObjectDataSourceStatusEventArgs.cs
- GiveFeedbackEvent.cs
- CodeValidator.cs
- _SafeNetHandles.cs
- XamlSerializerUtil.cs
- PageParser.cs
- NetworkInformationException.cs
- WhiteSpaceTrimStringConverter.cs
- VisualBrush.cs
- ReceiveActivity.cs
- IBuiltInEvidence.cs
- EntityContainerRelationshipSetEnd.cs
- ReferencedType.cs
- AlphaSortedEnumConverter.cs
- XmlHierarchicalDataSourceView.cs
- TextViewDesigner.cs
- FontStretches.cs
- HtmlInputCheckBox.cs
- ClientRuntimeConfig.cs
- DbReferenceCollection.cs
- VectorAnimationBase.cs
- NamedPermissionSet.cs
- EndpointDiscoveryMetadataCD1.cs
- DataGridTextBox.cs
- CacheDependency.cs
- BrowserCapabilitiesFactoryBase.cs
- SweepDirectionValidation.cs
- State.cs
- InvalidOperationException.cs
- StateItem.cs
- unitconverter.cs
- ConfigurationErrorsException.cs
- DbInsertCommandTree.cs
- DashStyles.cs
- XamlValidatingReader.cs
- __TransparentProxy.cs
- MetadataPropertyCollection.cs
- PageBuildProvider.cs
- NumericUpDownAccelerationCollection.cs
- FaultReason.cs
- MimeMultiPart.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- ApplicationSettingsBase.cs
- EnvironmentPermission.cs
- ListViewInsertionMark.cs
- SerializableAttribute.cs
- If.cs
- SelectionEditingBehavior.cs
- FileDialogCustomPlace.cs
- IdentityValidationException.cs
- TextRangeAdaptor.cs
- XamlSerializer.cs
- SegmentInfo.cs
- ClientRoleProvider.cs
- HierarchicalDataSourceDesigner.cs
- DebuggerAttributes.cs
- WindowsScrollBarBits.cs
- DataList.cs
- TabletDevice.cs
- OperationContext.cs
- TextAutomationPeer.cs
- MulticastDelegate.cs
- StringStorage.cs