Fix 32-bit host context APIs and ExternalReader bitness detection
- Add GetThreadContext/SetThreadContext overloads accepting Context32 so a 32-bit process on a native 32-bit OS can capture x86 thread context. - DllInjector.InjectWithThreadHijack now selects the context API based on both process bitness and OS bitness: * 64-bit process -> native 64-bit context * 32-bit process on 64-bit OS -> WOW64 context * 32-bit process on 32-bit OS -> native x86 context - ExternalReader now validates that the caller supplied ProcessAccess.QueryInformation, and surfaces any IsWow64Process failure instead of silently falling back to host bitness. Tests: 207 passing, 4 skipped.
This commit is contained in:
@@ -138,6 +138,20 @@ internal static partial class NativeMethods
|
||||
SafeMemoryHandle thread,
|
||||
ref Context64 context);
|
||||
|
||||
/// <summary>Sets a 32-bit thread context (x86 or WOW64).</summary>
|
||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static partial bool SetThreadContext(
|
||||
SafeMemoryHandle thread,
|
||||
ref Context32 context);
|
||||
|
||||
/// <summary>Gets a 32-bit thread context (x86 or WOW64).</summary>
|
||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static partial bool GetThreadContext(
|
||||
SafeMemoryHandle thread,
|
||||
ref Context32 context);
|
||||
|
||||
/// <summary>Sets a 32-bit (WOW64) thread context.</summary>
|
||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
|
||||
Reference in New Issue
Block a user