Fix InputSimulator wParam, PeHeaderParser double-parse, and other review issues

Bug fixes:
- InputSimulator: Pass correct button state (MK_LBUTTON/MK_RBUTTON) in wParam for button-down messages instead of 0.
- PeHeaderParser: ParseOptionalHeader now reads only the optional header, not section headers (fixes double-parse waste).
- EntryPoint: Removed useless isPe32Plus branch (AddressOfEntryPoint is at offset 16 in both PE32 and PE32+).
- RemoteWindow: Handle null foreground window case in Activate to avoid calling GetWindowThreadProcessId with HWND 0.
- RemotePointer: Remove dead null-conditional operators (encoding ??) since encoding is non-nullable.

Constants added:
- SystemMethods: MkLButton (0x0001) and MkRButton (0x0002) for mouse button state flags.

Tests: 199 passing, 4 integration/interactive skipped.
This commit is contained in:
kbe
2026-07-22 01:28:42 +02:00
parent 614806f5f1
commit c40f3fd791
5 changed files with 60 additions and 23 deletions
+6 -1
View File
@@ -72,11 +72,16 @@ public sealed class RemoteWindow
{
IntPtr foreground = NativeMethods.GetForegroundWindow();
uint targetThread = NativeMethods.GetWindowThreadProcessId(Handle, out _);
uint foregroundThread = NativeMethods.GetWindowThreadProcessId(foreground, out _);
if (targetThread == 0)
return false;
// If there's no foreground window, or we're already in the foreground thread, just set it
if (foreground == IntPtr.Zero)
return NativeMethods.SetForegroundWindow(Handle);
uint foregroundThread = NativeMethods.GetWindowThreadProcessId(foreground, out _);
if (targetThread == foregroundThread)
return NativeMethods.SetForegroundWindow(Handle);