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

Callbacks AtCommentHandler and AtApplicationDataHandler fail in x86 mode on Windows #45

Closed
vbaderks opened this issue Apr 14, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@vbaderks
Copy link
Contributor

Using the events ApplicationData or Comment will fail in x86 due to stack corruption.

Root cause
The callback functions are marked _stdcall. This is the default calling convention .NET uses to interact with native code.
In .NET the user_context argument is not used as .NET has its own mechanism to forward the callback to a class member method.
The delegate definitions in C# are missing the user_context parameter, which means a mismatch between the C++ and the C# definition.
The _stdcall calling convention defines that the callee cleans up the stack. In x64 mode the arguments are passed in registers and the stack is correctly cleaned up. In x86 mode some parameters are passed on the stack and the clean-up will fail due to the mismatch in function pointer definitions.

@vbaderks vbaderks self-assigned this Apr 14, 2023
@vbaderks vbaderks added the bug Something isn't working label Apr 14, 2023
@vbaderks
Copy link
Contributor Author

Resolved with #46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant