Implemented SafeHandle usage for Context et al. The usage isn't actually safe yet, since I still reference the rawHandle without doing safe (CER) reference counting on the handle.
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Runtime.ConstrainedExecution;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NSspi.Contexts;
|
||||
|
||||
namespace NSspi
|
||||
{
|
||||
@@ -83,4 +84,22 @@ namespace NSspi
|
||||
return status == SecurityStatus.OK;
|
||||
}
|
||||
}
|
||||
|
||||
public class SafeContextHandle : SafeSspiHandle
|
||||
{
|
||||
public SafeContextHandle()
|
||||
: base()
|
||||
{ }
|
||||
|
||||
protected override bool ReleaseHandle()
|
||||
{
|
||||
SecurityStatus status = ContextNativeMethods.DeleteSecurityContext(
|
||||
ref base.rawHandle
|
||||
);
|
||||
|
||||
base.ReleaseHandle();
|
||||
|
||||
return status == SecurityStatus.OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user