unsafe bool EnumProcessModules(IntPtr[] array, out int nModules) { int nAllocModules = array.AllowNull().Select(_ => _.Length); int nAllocSpace = checked(nAllocModules * IntPtr.Size); int nSpace; IntPtr hProcess = m_handle.IntPtr; bool result; fixed (IntPtr* pArray = array) { IntPtr arrayPtr = new IntPtr(pArray); result = UnsafeNativeMethods.EnumProcessModules(hProcess, arrayPtr, nAllocSpace, out nSpace); } if (!result && Win32Error.Last != Win32Error.PartialCopy) Win32Error.EnsureNoWin32Error(false); nModules = nSpace / IntPtr.Size; return result; }