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:
@@ -139,11 +139,17 @@ public sealed class RemoteThread : IDisposable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the 32-bit native context of the thread. Valid for 32-bit targets or
|
||||
/// WOW64 threads selected by a 64-bit caller.
|
||||
/// Reads the 32-bit native context of the thread. Valid only for 32-bit targets.
|
||||
/// </summary>
|
||||
public void GetContext32(out Context32 context)
|
||||
{
|
||||
if (_memory.Is64Bit)
|
||||
{
|
||||
context = default;
|
||||
throw new InvalidOperationException(
|
||||
"Use GetContext64 for 64-bit targets; GetContext32 is valid for 32-bit targets only.");
|
||||
}
|
||||
|
||||
context = new Context32 { ContextFlags = ContextFlags.X86Full };
|
||||
if (!NativeMethods.GetThreadContext(_handle, ref context))
|
||||
{
|
||||
@@ -153,10 +159,14 @@ public sealed class RemoteThread : IDisposable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the 32-bit native context of the thread.
|
||||
/// Writes the 32-bit native context of the thread. Valid only for 32-bit targets.
|
||||
/// </summary>
|
||||
public void SetContext32(ref Context32 context)
|
||||
{
|
||||
if (_memory.Is64Bit)
|
||||
throw new InvalidOperationException(
|
||||
"Use SetContext64 for 64-bit targets; SetContext32 is valid for 32-bit targets only.");
|
||||
|
||||
if (!NativeMethods.SetThreadContext(_handle, ref context))
|
||||
{
|
||||
int error = Marshal.GetLastPInvokeError();
|
||||
|
||||
Reference in New Issue
Block a user