1
Vote

Memory leak in DetectOpenFiles

description

While playing with your DetectOpenFiles feature. I noticed a memory leak.
 
In function GetHandleTypeToken the line:
 
NativeMethods.NtQueryObject(handle, OBJECT_INFORMATION_CLASS.ObjectTypeInformation, IntPtr.Zero, 0, out length)
 
needs to be:
 
if(NativeMethods.NtQueryObject(handle, OBJECT_INFORMATION_CLASS.ObjectTypeInformation, IntPtr.Zero, 0, out length)!=NT_STATUS.STATUS_INFO_LENGTH_MISMATCH)
return null;
 
Otherwise the code runs in an OutOfMemoryException on my 64bit Win7.

comments