Add in verbose error message and telemetry for SetWindowsHookEx failure #6454
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
What is this about?
In #5414 the exceptions that users reported was related to the
SetWindowsHookEx
API failing. As per the docs and after the reaching out to the respective team, the suggestion was to use theGetLastError
API to get a more detailed error code/message. In this PR I have modified the Message box that we were earlier displaying to show the error code as well as the error message as well, rather than the generic "Cannot install keyboard listener". This will allow us to get more details when users post the issue, since we do not have enough information to figure out the reason right now. The PR also adds telemetry to log this exception for KBM, FZ and SG.PR Checklist
Info on Pull Request
What does this include?
show_last_error_message
in common.h was modified to allow a different message box title, with default set to the earlier value.SetWindowsHookEx
return value is NULL,GetLastError
is called along withshow_last_error_message
.show_last_error_message
, with the method name as the parent function name followed bySetWindowsHookEx
(for example for SG it isOverlayWindow.enable.SetWindowsHookEx
).Validation Steps Performed
How does someone test & validate?
SetWindowsHookEx
checks to check non-null and validate that the message box appears.