mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-12-25 12:31:50 +01:00
Make sure to only access valid buffers in VPADRead and WPADRead hooks
This commit is contained in:
parent
4c1131b0bf
commit
c47c79e771
@ -80,20 +80,25 @@ DECL_FUNCTION(void, OSReleaseForeground) {
|
||||
real_OSReleaseForeground();
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int32_t, VPADRead, int32_t chan, VPADStatus *buffer, uint32_t buffer_size, int32_t *error) {
|
||||
DECL_FUNCTION(int32_t, VPADRead, int32_t chan, VPADStatus *buffer, uint32_t buffer_size, VPADReadError *error) {
|
||||
if (sConfigMenuOpened) {
|
||||
// Ignore reading vpad input only from other threads if the config menu is opened
|
||||
if (OSGetCurrentThread() != gOnlyAcceptFromThread) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
int32_t result = real_VPADRead(chan, buffer, buffer_size, error);
|
||||
VPADReadError real_error = VPAD_READ_SUCCESS;
|
||||
int32_t result = real_VPADRead(chan, buffer, buffer_size, &real_error);
|
||||
|
||||
if (result > 0 && real_error == VPAD_READ_SUCCESS && buffer && ((buffer[0].hold & 0xFFFFF) == (VPAD_BUTTON_L | VPAD_BUTTON_DOWN | VPAD_BUTTON_MINUS)) && sVpadPressCooldown == 0 && !sConfigMenuOpened) {
|
||||
|
||||
if (result > 0 && ((buffer[0].hold & 0xFFFFF) == (VPAD_BUTTON_L | VPAD_BUTTON_DOWN | VPAD_BUTTON_MINUS)) && sVpadPressCooldown == 0 && !sConfigMenuOpened) {
|
||||
sWantsToOpenConfigMenu = true;
|
||||
sVpadPressCooldown = 0x3C;
|
||||
return 0;
|
||||
}
|
||||
if (error) {
|
||||
*error = real_error;
|
||||
}
|
||||
|
||||
if (sVpadPressCooldown > 0) {
|
||||
sVpadPressCooldown--;
|
||||
@ -104,8 +109,7 @@ DECL_FUNCTION(int32_t, VPADRead, int32_t chan, VPADStatus *buffer, uint32_t buff
|
||||
DECL_FUNCTION(void, WPADRead, WPADChan chan, WPADStatusProController *data) {
|
||||
real_WPADRead(chan, data);
|
||||
|
||||
|
||||
if (!sConfigMenuOpened && data[0].err == 0) {
|
||||
if (!sConfigMenuOpened && data && data[0].err == 0) {
|
||||
if (data[0].extensionType != 0xFF) {
|
||||
if (data[0].extensionType == WPAD_EXT_CORE || data[0].extensionType == WPAD_EXT_NUNCHUK) {
|
||||
// button data is in the first 2 bytes for wiimotes
|
||||
|
Loading…
Reference in New Issue
Block a user