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
- AssociationTypeEmitter.cs
- NativeCppClassAttribute.cs
- _ServiceNameStore.cs
- CapabilitiesRule.cs
- ReachPrintTicketSerializer.cs
- CalendarTable.cs
- HeaderCollection.cs
- TextPattern.cs
- BoolExpr.cs
- ChannelToken.cs
- FormatterServicesNoSerializableCheck.cs
- ComAdminInterfaces.cs
- RequestQueryParser.cs
- EventProvider.cs
- FormatConvertedBitmap.cs
- InvalidContentTypeException.cs
- Unit.cs
- _Semaphore.cs
- DocumentXmlWriter.cs
- WaitForChangedResult.cs
- XPathNodeHelper.cs
- ExecutionContext.cs
- RsaSecurityTokenAuthenticator.cs
- FormParameter.cs
- oledbmetadatacollectionnames.cs
- ThrowHelper.cs
- TaskFileService.cs
- PreProcessInputEventArgs.cs
- LinkButton.cs
- ColorAnimationUsingKeyFrames.cs
- PackagingUtilities.cs
- ConfigXmlDocument.cs
- DataTableExtensions.cs
- DllHostedComPlusServiceHost.cs
- SerializationInfoEnumerator.cs
- DocumentSequence.cs
- DocobjHost.cs
- TdsValueSetter.cs
- ApplyImportsAction.cs
- MouseOverProperty.cs
- DataTableMappingCollection.cs
- MessageHeaderDescriptionCollection.cs
- Interlocked.cs
- BitmapEffectDrawingContent.cs
- MoveSizeWinEventHandler.cs
- PeerNameRecord.cs
- AutomationElementCollection.cs
- LambdaCompiler.ControlFlow.cs
- NamespaceList.cs
- SolidColorBrush.cs
- HtmlInputHidden.cs
- ContextMarshalException.cs
- Activator.cs
- Compilation.cs
- SqlCacheDependency.cs
- RowBinding.cs
- PolicyImporterElement.cs
- BinaryObjectInfo.cs
- EventLog.cs
- RelationshipManager.cs
- XAMLParseException.cs
- MenuStrip.cs
- SettingsAttributeDictionary.cs
- MarkupObject.cs
- ExportException.cs
- Util.cs
- OdbcEnvironment.cs
- PrtTicket_Public.cs
- URLIdentityPermission.cs
- InstallerTypeAttribute.cs
- ImageButton.cs
- RequestCache.cs
- LineBreakRecord.cs
- __FastResourceComparer.cs
- CallbackBehaviorAttribute.cs
- RangeValidator.cs
- DiscoveryDocumentLinksPattern.cs
- GridViewCommandEventArgs.cs
- PageFunction.cs
- AlphabeticalEnumConverter.cs
- X509Utils.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- Int32Rect.cs
- BindingBase.cs
- ServiceTimeoutsElement.cs
- PreservationFileReader.cs
- DotNetATv1WindowsLogEntrySerializer.cs
- Converter.cs
- ConnectionPoint.cs
- MobileUserControlDesigner.cs
- Animatable.cs
- TagPrefixInfo.cs
- StructuralCache.cs
- ComplexTypeEmitter.cs
- GatewayDefinition.cs
- NamedObject.cs
- ConfigurationSettings.cs
- SecUtil.cs
- FontWeightConverter.cs
- NamespaceInfo.cs