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
- DefaultValueAttribute.cs
- StrongNameUtility.cs
- Vector3DValueSerializer.cs
- ApplicationCommands.cs
- Rotation3DAnimationBase.cs
- UnionExpr.cs
- CryptoApi.cs
- Header.cs
- MenuTracker.cs
- ScriptReferenceEventArgs.cs
- HtmlInputImage.cs
- TemplatedWizardStep.cs
- TemplateXamlParser.cs
- BooleanConverter.cs
- RubberbandSelector.cs
- WebPartConnectionCollection.cs
- XmlAtomicValue.cs
- PointValueSerializer.cs
- XmlSchemaException.cs
- XmlSerializationReader.cs
- CultureTableRecord.cs
- ResourceProviderFactory.cs
- _ProxyRegBlob.cs
- AttributeData.cs
- BindingExpressionUncommonField.cs
- RectValueSerializer.cs
- TimelineCollection.cs
- AccessDataSourceView.cs
- CodeAttachEventStatement.cs
- DiscreteKeyFrames.cs
- PropertyGeneratedEventArgs.cs
- Typeface.cs
- LayoutDump.cs
- ReferencedAssembly.cs
- ThreadStartException.cs
- InternalTypeHelper.cs
- RegisterResponseInfo.cs
- BorderGapMaskConverter.cs
- XmlExceptionHelper.cs
- EventLogWatcher.cs
- SynchronizedInputAdaptor.cs
- ProcessModelInfo.cs
- SecurityKeyType.cs
- VisualProxy.cs
- StatusBarItemAutomationPeer.cs
- XmlObjectSerializerWriteContextComplex.cs
- SapiRecoContext.cs
- SqlUtils.cs
- WinInet.cs
- XsltQilFactory.cs
- Help.cs
- BamlStream.cs
- BamlBinaryWriter.cs
- Roles.cs
- EdmError.cs
- ExpandoClass.cs
- SessionStateContainer.cs
- SmtpCommands.cs
- CodeSubDirectory.cs
- HMACSHA1.cs
- ProtectedConfigurationSection.cs
- HttpSessionStateWrapper.cs
- SkinBuilder.cs
- BasicSecurityProfileVersion.cs
- GenerateDerivedKeyRequest.cs
- DynamicActivity.cs
- Preprocessor.cs
- ConnectionManager.cs
- BlockCollection.cs
- AxisAngleRotation3D.cs
- XmlSchemaGroupRef.cs
- GraphicsContainer.cs
- HotSpotCollection.cs
- LZCodec.cs
- AssociationSetEnd.cs
- TabRenderer.cs
- XmlSchemaSimpleContentExtension.cs
- XmlSchemaSimpleTypeRestriction.cs
- DataSet.cs
- XsltCompileContext.cs
- ResourceDefaultValueAttribute.cs
- NamespaceEmitter.cs
- StringReader.cs
- ListQueryResults.cs
- Win32SafeHandles.cs
- RemoteHelper.cs
- InheritanceContextChangedEventManager.cs
- ListBoxItemAutomationPeer.cs
- EncodingTable.cs
- ReaderOutput.cs
- AssertUtility.cs
- TreeNodeConverter.cs
- WindowsListViewGroupHelper.cs
- PortCache.cs
- SecurityTokenAuthenticator.cs
- OperationDescription.cs
- ValidatedControlConverter.cs
- LineInfo.cs
- BitmapCacheBrush.cs
- PluralizationServiceUtil.cs