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
- StrongTypingException.cs
- FunctionImportMapping.cs
- ContainerParagraph.cs
- List.cs
- ColorMatrix.cs
- SqlConnectionString.cs
- AccessDataSourceWizardForm.cs
- RelOps.cs
- PageAsyncTask.cs
- EventManager.cs
- Stream.cs
- RotateTransform.cs
- MultiSelectRootGridEntry.cs
- ServicesExceptionNotHandledEventArgs.cs
- Interlocked.cs
- Crypto.cs
- ReflectPropertyDescriptor.cs
- TextServicesDisplayAttribute.cs
- RightNameExpirationInfoPair.cs
- ClientType.cs
- PackWebResponse.cs
- OleDbDataReader.cs
- CodeDirectionExpression.cs
- FixedHyperLink.cs
- MenuItem.cs
- MembershipSection.cs
- DesignerMetadata.cs
- AsymmetricSignatureFormatter.cs
- DataRelationCollection.cs
- InlineCollection.cs
- FixedElement.cs
- CodeMemberProperty.cs
- Error.cs
- ContextMarshalException.cs
- HttpRuntime.cs
- Point3D.cs
- Helper.cs
- SqlDataSource.cs
- DesigntimeLicenseContextSerializer.cs
- PageParserFilter.cs
- XamlGridLengthSerializer.cs
- ValidatedControlConverter.cs
- DLinqTableProvider.cs
- XmlSchemaAttributeGroupRef.cs
- StringResourceManager.cs
- ConsumerConnectionPointCollection.cs
- FloaterBaseParagraph.cs
- Quaternion.cs
- BaseTemplateBuildProvider.cs
- MobileUserControl.cs
- OdbcErrorCollection.cs
- XmlProcessingInstruction.cs
- LongMinMaxAggregationOperator.cs
- ContextStack.cs
- MailWriter.cs
- XmlDataSourceView.cs
- CaseInsensitiveComparer.cs
- RuntimeHelpers.cs
- DataGridViewHitTestInfo.cs
- SafeNativeMethods.cs
- ArrayList.cs
- MetadataExporter.cs
- ScriptControlDescriptor.cs
- SqlFlattener.cs
- SafeNativeMethods.cs
- TransformCollection.cs
- Parser.cs
- TypeFieldSchema.cs
- Int64KeyFrameCollection.cs
- PasswordRecoveryDesigner.cs
- HtmlElement.cs
- MemberRelationshipService.cs
- XmlSchemaObject.cs
- TypeLibConverter.cs
- SizeAnimationBase.cs
- StylusTouchDevice.cs
- EntityDesignerUtils.cs
- DataGridCell.cs
- QfeChecker.cs
- TempEnvironment.cs
- QueryableDataSourceHelper.cs
- TextEditorCharacters.cs
- PageParserFilter.cs
- TypeDelegator.cs
- RegexTypeEditor.cs
- SoapInteropTypes.cs
- SortAction.cs
- IncrementalCompileAnalyzer.cs
- MetadataItem.cs
- HtmlInputCheckBox.cs
- RawMouseInputReport.cs
- TraceUtils.cs
- NumericExpr.cs
- CodeCompiler.cs
- HostDesigntimeLicenseContext.cs
- DoubleCollectionConverter.cs
- TreeView.cs
- XpsFontSerializationService.cs
- DbFunctionCommandTree.cs
- Documentation.cs