You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
I am not an expert on this but from my reading, if you need to free unmanaged resources, you can implement IDisposable. LocalGroupTasks.cs has a helper class that tries to do this, but it looks to have two bugs.
Bug 1: Failure to inherit from IDisposable.
OBJECT_ATTRIBUTES implements Dispose() but does not inherit from IDisposable. Without this, Dispose may never be called.
The documentation on implementing Dispose says that you should call it explicitly or wrap the object in a using block--as the GC is not guaranteed to call it. The easiest thing here is to call Dispose in the finally block.
finally
{
//Free memory from handles acquired during the process
if (serverHandle != IntPtr.Zero)
SamCloseHandle(serverHandle);
if (domainHandle != IntPtr.Zero)
SamCloseHandle(domainHandle);
if (aliasHandle != IntPtr.Zero)
SamCloseHandle(aliasHandle);
+ if (objectAttributes != null)+ objectAttributes.Dispose();
if (members != IntPtr.Zero)
SamFreeMemory(members);
}
I am not an expert on this but from my reading, if you need to free unmanaged resources, you can implement IDisposable.
LocalGroupTasks.cs
has a helper class that tries to do this, but it looks to have two bugs.Bug 1: Failure to inherit from IDisposable.
OBJECT_ATTRIBUTES
implementsDispose()
but does not inherit from IDisposable. Without this,Dispose
may never be called.Note the definition here: (https://www.pinvoke.net/default.aspx/Structures/OBJECT_ATTRIBUTES.html)
SharpHound3/SharpHound3/Tasks/LocalGroupTasks.cs
Line 365 in 7615860
Bug 2: Need to call Dispose() explicitly
The documentation on implementing
Dispose
says that you should call it explicitly or wrap the object in ausing
block--as the GC is not guaranteed to call it. The easiest thing here is to callDispose
in thefinally
block.SharpHound3/SharpHound3/Tasks/LocalGroupTasks.cs
Line 280 in 7615860
The text was updated successfully, but these errors were encountered: