Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #21490 System.Windows.Forms.SendKeys.Send under windows 64 bits #21491

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bmalrat
Copy link

@bmalrat bmalrat commented May 24, 2022

Fixes #21490 System.Windows.Forms.SendKeys.Send does not work on windows 64 bits

By Fixing the alignment of INPUT to support 64 bits which is 8 and not 4.

From pinvoke.net and System.Windows.Forms sources.
On 64-Bit systems, the offset of the mi, ki and hi fields is 8, because the nested struct uses the alignment of its biggest member, which is 8 (due to the 64-bit pointer in dwExtraInfo). By separating the union into its own structure, rather than placing the mi, ki and hi fields directly in the INPUT structure, we assure that the .Net structure will have the correct alignment on both 32 and 64 bit.

https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Primitives/src/Interop/User32/Interop.INPUT.cs
https://www.pinvoke.net/default.aspx/Structures/INPUT.html

Fixed alignment of INPUT to support 64 bits which is 8 and not 4.

From pinvoke.net and System.Windows.Forms sources.
On 64-Bit systems, the offset of the mi, ki and hi fields is 8, because the nested struct uses the alignment of its biggest member, which is 8 (due to the 64-bit pointer in dwExtraInfo). By separating the union into its own structure, rather than placing the mi, ki and hi fields directly in the INPUT structure, we assure that the .Net structure will have the correct alignment on both 32 and 64 bit.

https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Primitives/src/Interop/User32/Interop.INPUT.cs
https://www.pinvoke.net/default.aspx/Structures/INPUT.html
@dnfadmin
Copy link

dnfadmin commented May 24, 2022

CLA assistant check
All CLA requirements met.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System.Windows.Forms.SendKeys.Send does not work on windows 64 bits
2 participants