Fix DirectInput data queries while GUI has focus#5038
Open
HeresHavi wants to merge 1 commit into
Open
Conversation
Prevents a potential client crash when DirectInput checks buffered keyboard or mouse events while an MTA interface has focus.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Added a null check before the DirectInput proxy clears buffered event data.
Null-output event count and flush queries now return normally while the GUI owns input. Calls that provide an event array are still cleared so GTA does not receive input intended for the GUI.
Motivation
IDirectInputDevice8::GetDeviceDataallows the output buffer to be null when checking how many events are waiting or flushing them. The proxy forwarded these valid calls, but then passed the null buffer tomemset, causing an access violation.For example, a client input integration might use a buffered keyboard and check how many events are waiting without copying them. If the player opens F8 or another MTA window at that moment, MTA owns the input and the old proxy path could crash the client.
GTA's default keyboard and mouse devices use immediate polling, so this requires a buffered DirectInput caller. The crash was reproduced inside MTA using a buffered keyboard created through the real DirectInput proxy.
Crash Stack
Test plan
Runtime
memset.0x00000000withcount=1, and the client stayed open.Builds and Tests
Debug | Win32: Client Core build passed, 304 client tests passed.Release | Win32: Client Core build passed, 304 client tests passed.clang-format.Checklist