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:
@@ -53,16 +53,17 @@ public sealed class InputSimulator
|
||||
|
||||
nint lParam = MakeLong(x, y);
|
||||
|
||||
(uint down, uint up) = button switch
|
||||
(uint down, uint downWParam) = button switch
|
||||
{
|
||||
MouseButton.Left => (NativeMethods.WmLButtonDown, NativeMethods.WmLButtonUp),
|
||||
MouseButton.Right => (NativeMethods.WmRButtonDown, NativeMethods.WmRButtonUp),
|
||||
MouseButton.Left => (NativeMethods.WmLButtonDown, NativeMethods.MkLButton),
|
||||
MouseButton.Right => (NativeMethods.WmRButtonDown, NativeMethods.MkRButton),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(button)),
|
||||
};
|
||||
|
||||
if (!NativeMethods.PostMessageW(hWnd, down, 0, lParam))
|
||||
if (!NativeMethods.PostMessageW(hWnd, down, downWParam, lParam))
|
||||
return false;
|
||||
|
||||
uint up = button == MouseButton.Left ? NativeMethods.WmLButtonUp : NativeMethods.WmRButtonUp;
|
||||
return NativeMethods.PostMessageW(hWnd, up, 0, lParam);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user