DSInternals/Src/DSInternals.SAM/Interop/SafeHandles/SafeSamPointer.cs

29 lines
774 B
C#
Raw Permalink Normal View History

2016-11-14 23:17:45 +00:00
using DSInternals.Common.Interop;
using Microsoft.Win32.SafeHandles;
using System;
using System.Security;
namespace DSInternals.SAM.Interop
{
/// <summary>
/// Represents a wrapper class for buffers allocated by SAM RPC.
/// </summary>
[SecurityCritical]
public class SafeSamPointer : SafeHandleZeroOrMinusOneIsInvalid
2016-11-14 23:17:45 +00:00
{
private SafeSamPointer() : base(true)
{
}
public SafeSamPointer(IntPtr preexistingPointer, bool ownsPointer)
: base(ownsPointer)
{
this.SetHandle(preexistingPointer);
}
[SecurityCritical]
protected override bool ReleaseHandle()
{
return NativeMethods.SamFreeMemory(this.handle) == NtStatus.Success;
}
}
}