| | 1 | | using System; |
| | 2 | | using Microsoft.Win32.SafeHandles; |
| | 3 | | using SharpHoundRPC.SAMRPCNative; |
| | 4 | |
|
| | 5 | | namespace SharpHoundRPC.Handles |
| | 6 | | { |
| | 7 | | public class SAMHandle : SafeHandleZeroOrMinusOneIsInvalid |
| | 8 | | { |
| 0 | 9 | | public SAMHandle() : base(true) |
| 0 | 10 | | { |
| 0 | 11 | | } |
| | 12 | |
|
| 0 | 13 | | public SAMHandle(IntPtr handle) : base(true) |
| 0 | 14 | | { |
| 0 | 15 | | SetHandle(handle); |
| 0 | 16 | | } |
| | 17 | |
|
| 0 | 18 | | public SAMHandle(IntPtr handle, bool ownsHandle) : base(ownsHandle) |
| 0 | 19 | | { |
| 0 | 20 | | SetHandle(handle); |
| 0 | 21 | | } |
| | 22 | |
|
| | 23 | | protected override bool ReleaseHandle() |
| 0 | 24 | | { |
| 0 | 25 | | if (handle == IntPtr.Zero) return true; |
| 0 | 26 | | return SAMMethods.SamCloseHandle(handle) == NtStatus.StatusSuccess; |
| 0 | 27 | | } |
| | 28 | |
|
| | 29 | | ~SAMHandle() |
| 0 | 30 | | { |
| 0 | 31 | | Dispose(); |
| 0 | 32 | | } |
| | 33 | | } |
| | 34 | | } |