Address review findings for thread control and process discovery
- Drop the false WOW64 claim from GetContext32/SetContext32 docs and guard them for 32-bit targets only.\n- Make FrozenThread dispose the thread handles it owns; make Freeze(predicate) dispose filtered-out threads.\n- Pass the already-validated handle through GetThreadById instead of opening a second one.\n- Add no-progress guard to MemoryBase.EnumerateRegions.\n- Dispose unmatched Process candidates in ApplicationFinder.OpenProcess.\n- Clean up RemoteThreadExecutor allocation formatting.
This commit is contained in:
@@ -7,7 +7,7 @@ namespace WhiteMagic.Thread;
|
||||
/// <summary>
|
||||
/// A disposable scope that tracks a set of threads frozen by <see cref="ThreadFactory.Freeze"/>.
|
||||
/// Disposing the scope resumes exactly those threads, in reverse order, even if the guarded
|
||||
/// body throws.
|
||||
/// body throws, and then disposes the underlying thread handles.
|
||||
/// </summary>
|
||||
public sealed class FrozenThread : IDisposable
|
||||
{
|
||||
@@ -23,8 +23,7 @@ public sealed class FrozenThread : IDisposable
|
||||
public IEnumerable<RemoteThread> Threads => _threads;
|
||||
|
||||
/// <summary>
|
||||
/// Resumes the frozen threads in reverse order. The original call is responsible for
|
||||
/// disposing the <see cref="RemoteThread"/> instances afterwards.
|
||||
/// Resumes the frozen threads in reverse order, then disposes every thread handle.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
@@ -41,9 +40,13 @@ public sealed class FrozenThread : IDisposable
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Resume-on-dispose is best-effort; callers keep the thread handles so
|
||||
// they can diagnose or recover separately.
|
||||
// Resume-on-dispose is best-effort; the handle is still disposed below.
|
||||
}
|
||||
}
|
||||
|
||||
foreach (RemoteThread thread in _threads)
|
||||
{
|
||||
thread.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user