Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / CompMod / Microsoft / Win32 / SafeHandles / SafeLocalMemHandle.cs / 1 / SafeLocalMemHandle.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SafeLocalMemHandle ** **Author: David Gutierrez ([....]) ** ** A wrapper for handle to local memory ** ** Date: July 8, 2002 ** ===========================================================*/ using System; using System.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; using System.Runtime.ConstrainedExecution; namespace Microsoft.Win32.SafeHandles { [HostProtectionAttribute(MayLeakOnAbort = true)] [SuppressUnmanagedCodeSecurityAttribute] internal sealed class SafeLocalMemHandle : SafeHandleZeroOrMinusOneIsInvalid { internal SafeLocalMemHandle() : base(true) {} [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] internal SafeLocalMemHandle(IntPtr existingHandle, bool ownsHandle) : base(ownsHandle) { SetHandle(existingHandle); } [DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError=true, BestFitMapping=false)] internal static extern unsafe bool ConvertStringSecurityDescriptorToSecurityDescriptor(string StringSecurityDescriptor, int StringSDRevision, out SafeLocalMemHandle pSecurityDescriptor, IntPtr SecurityDescriptorSize); [DllImport(ExternDll.Kernel32)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern IntPtr LocalFree(IntPtr hMem); override protected bool ReleaseHandle() { return LocalFree(handle) == IntPtr.Zero; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SafeLocalMemHandle ** **Author: David Gutierrez ([....]) ** ** A wrapper for handle to local memory ** ** Date: July 8, 2002 ** ===========================================================*/ using System; using System.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; using System.Runtime.ConstrainedExecution; namespace Microsoft.Win32.SafeHandles { [HostProtectionAttribute(MayLeakOnAbort = true)] [SuppressUnmanagedCodeSecurityAttribute] internal sealed class SafeLocalMemHandle : SafeHandleZeroOrMinusOneIsInvalid { internal SafeLocalMemHandle() : base(true) {} [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] internal SafeLocalMemHandle(IntPtr existingHandle, bool ownsHandle) : base(ownsHandle) { SetHandle(existingHandle); } [DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError=true, BestFitMapping=false)] internal static extern unsafe bool ConvertStringSecurityDescriptorToSecurityDescriptor(string StringSecurityDescriptor, int StringSDRevision, out SafeLocalMemHandle pSecurityDescriptor, IntPtr SecurityDescriptorSize); [DllImport(ExternDll.Kernel32)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern IntPtr LocalFree(IntPtr hMem); override protected bool ReleaseHandle() { return LocalFree(handle) == IntPtr.Zero; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PeerServiceMessageContracts.cs
- ConfigurationManagerHelperFactory.cs
- EditorPartCollection.cs
- TextBox.cs
- FixedSOMPageConstructor.cs
- Transform.cs
- XXXOnTypeBuilderInstantiation.cs
- UnauthorizedAccessException.cs
- GcSettings.cs
- XmlNodeChangedEventArgs.cs
- CodeThrowExceptionStatement.cs
- Property.cs
- DecimalConstantAttribute.cs
- TimeSpanOrInfiniteConverter.cs
- QuaternionAnimationUsingKeyFrames.cs
- DropSource.cs
- XpsFixedPageReaderWriter.cs
- WebServicesDescriptionAttribute.cs
- SchemaNames.cs
- SafeUserTokenHandle.cs
- ToolStripControlHost.cs
- CryptoHelper.cs
- _Rfc2616CacheValidators.cs
- KeyValuePairs.cs
- BevelBitmapEffect.cs
- DrawingImage.cs
- FormViewPageEventArgs.cs
- RectangleConverter.cs
- ExtensionFile.cs
- MenuCommand.cs
- ManagementException.cs
- LineProperties.cs
- NativeMethods.cs
- ClassicBorderDecorator.cs
- UnsafeNativeMethodsPenimc.cs
- ModuleConfigurationInfo.cs
- LinqDataSourceHelper.cs
- StructuredTypeEmitter.cs
- PrintDialogException.cs
- XsdDuration.cs
- WorkflowInstanceRecord.cs
- HitTestDrawingContextWalker.cs
- WebPart.cs
- WorkflowView.cs
- WorkerRequest.cs
- ExtendedProtectionPolicyElement.cs
- SafeSystemMetrics.cs
- UshortList2.cs
- RectKeyFrameCollection.cs
- IPGlobalProperties.cs
- Sql8ConformanceChecker.cs
- SchemaCollectionPreprocessor.cs
- ClientSettingsProvider.cs
- ItemsPanelTemplate.cs
- SqlConnectionHelper.cs
- ToolStripStatusLabel.cs
- ValidationPropertyAttribute.cs
- DBParameter.cs
- DocumentViewerBaseAutomationPeer.cs
- WebPartVerbsEventArgs.cs
- CallbackCorrelationInitializer.cs
- HtmlHead.cs
- IEnumerable.cs
- GenericUriParser.cs
- RequestNavigateEventArgs.cs
- DataGridPageChangedEventArgs.cs
- WebColorConverter.cs
- RightsManagementErrorHandler.cs
- QueryStringHandler.cs
- BlockCollection.cs
- DeviceFilterEditorDialog.cs
- ApplyTemplatesAction.cs
- bindurihelper.cs
- ZoneLinkButton.cs
- WindowsListViewGroup.cs
- SemanticBasicElement.cs
- IdentityValidationException.cs
- StyleSelector.cs
- ControlEvent.cs
- PerformanceCountersElement.cs
- XmlSchemaInferenceException.cs
- SqlDeflator.cs
- Cursor.cs
- Composition.cs
- RowSpanVector.cs
- WebPartConnectionCollection.cs
- RowBinding.cs
- ToolboxDataAttribute.cs
- PermissionAttributes.cs
- TextTreeDeleteContentUndoUnit.cs
- UserNamePasswordClientCredential.cs
- TypeForwardedToAttribute.cs
- DataGridTextBox.cs
- FreezableCollection.cs
- Mapping.cs
- NamespaceDisplay.xaml.cs
- CommonDialog.cs
- DataTableMappingCollection.cs
- ShaderRenderModeValidation.cs
- WebPartExportVerb.cs