public Toolhelp32Snapshot(Toolhelp32SnapshotFlags flags) { try { handle = CreateToolhelp32Snapshot((uint)flags, 0); if (handle.IsInvalid) { throw new Win32Exception(); } } catch (Win32Exception err) when(err.NativeErrorCode == IncompleteReadException.ErrorNumber) { throw new IncompleteReadException(err); } }
public Toolhelp32Snapshot(Toolhelp32SnapshotFlags flags, UInt32 processId) { if (processId == 0) { throw new ArgumentOutOfRangeException(nameof(processId), "The process id can't be zero!"); } if ((flags & Toolhelp32SnapshotFlags.Thread) == Toolhelp32SnapshotFlags.Thread) { throw new ArgumentException("Per process thread filtering doesn't work."); } try { handle = CreateToolhelp32Snapshot((uint)flags, processId); if (handle.IsInvalid) { throw new Win32Exception(); } } catch (Win32Exception err) when(err.NativeErrorCode == IncompleteReadException.ErrorNumber) { throw new IncompleteReadException(err); } }
internal static extern bool Thread32Next(SafeToolhelp32SnapshotHandle handle, ref ThreadEntry.Native moduleEntry);
internal static extern bool Process32NextW(SafeToolhelp32SnapshotHandle handle, ref ProcessEntry.Native moduleEntry);
internal static extern bool Module32NextW(SafeToolhelp32SnapshotHandle handle, ref ModuleEntry.Native moduleEntry);