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]
|
2016-11-20 17:28:02 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|