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
- DataListDesigner.cs
- WeakReference.cs
- XmlSerializerSection.cs
- ServiceHostingEnvironment.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- BitmapInitialize.cs
- AttributeSetAction.cs
- ExpressionBuilder.cs
- CorrelationValidator.cs
- SslSecurityTokenParameters.cs
- BinaryMessageFormatter.cs
- SqlDataSourceSelectingEventArgs.cs
- DataGridRowClipboardEventArgs.cs
- SctClaimSerializer.cs
- UITypeEditors.cs
- TdsParserStateObject.cs
- CustomSignedXml.cs
- _AutoWebProxyScriptHelper.cs
- DockEditor.cs
- FontNamesConverter.cs
- Documentation.cs
- UIElementCollection.cs
- RequestSecurityTokenResponse.cs
- LicFileLicenseProvider.cs
- QueryResult.cs
- ChangeConflicts.cs
- HtmlCalendarAdapter.cs
- TakeOrSkipQueryOperator.cs
- QilReplaceVisitor.cs
- RoleGroupCollection.cs
- HiddenFieldPageStatePersister.cs
- DataGridTable.cs
- DiscoveryExceptionDictionary.cs
- DocumentCollection.cs
- CodeCommentStatement.cs
- recordstatefactory.cs
- XmlQueryContext.cs
- XmlSerializerAssemblyAttribute.cs
- ConfigurationErrorsException.cs
- ReadWriteObjectLock.cs
- SerializationSectionGroup.cs
- RegexNode.cs
- ProfileBuildProvider.cs
- DataSourceIDConverter.cs
- Int32CAMarshaler.cs
- FlowPosition.cs
- TimeIntervalCollection.cs
- QueryExpr.cs
- ValidatingReaderNodeData.cs
- CodeMemberProperty.cs
- StructuralCache.cs
- CompositeFontFamily.cs
- TextAnchor.cs
- DataRecordInternal.cs
- CharStorage.cs
- BulletedListEventArgs.cs
- ListMarkerLine.cs
- GridViewRow.cs
- Label.cs
- QueryCacheManager.cs
- X509UI.cs
- KeyTime.cs
- UserNamePasswordValidator.cs
- PingOptions.cs
- ChangeProcessor.cs
- IntegrationExceptionEventArgs.cs
- Timer.cs
- SingleTagSectionHandler.cs
- HealthMonitoringSectionHelper.cs
- TreeViewCancelEvent.cs
- ACL.cs
- DBSchemaTable.cs
- ObjectCache.cs
- ListBoxDesigner.cs
- newinstructionaction.cs
- TextEndOfLine.cs
- BufferAllocator.cs
- BrowserCapabilitiesCodeGenerator.cs
- ProjectionQueryOptionExpression.cs
- DotExpr.cs
- DesignerAutoFormatCollection.cs
- ColorContext.cs
- TypeDescriptionProviderAttribute.cs
- ShaderEffect.cs
- UInt16Converter.cs
- TypeUsageBuilder.cs
- SignedInfo.cs
- MsmqIntegrationProcessProtocolHandler.cs
- BlobPersonalizationState.cs
- SessionState.cs
- OracleRowUpdatedEventArgs.cs
- DataSourceHelper.cs
- BuiltInPermissionSets.cs
- unsafenativemethodstextservices.cs
- WebZone.cs
- AuthenticationService.cs
- ContentType.cs
- ArraySortHelper.cs
- HtmlUtf8RawTextWriter.cs
- TagPrefixAttribute.cs