Validate arguments on input.

This commit is contained in:
Ben Vanik 2013-10-23 22:23:52 -07:00
parent c4fe2e6926
commit 96daa6b43f
2 changed files with 19 additions and 10 deletions

View File

@ -40,14 +40,17 @@ SHIM_CALL XamInputGetCapabilities_shim(
flags,
caps_ptr);
if (!caps_ptr) {
SHIM_SET_RETURN(X_ERROR_BAD_ARGUMENTS);
return;
}
InputSystem* input_system = state->emulator()->input_system();
X_INPUT_CAPABILITIES caps;
XRESULT result = input_system->GetCapabilities(user_index, flags, caps);
if (XSUCCEEDED(result)) {
if (caps_ptr) {
caps.Write(SHIM_MEM_BASE, caps_ptr);
}
caps.Write(SHIM_MEM_BASE, caps_ptr);
}
SHIM_SET_RETURN(result);
}
@ -64,14 +67,17 @@ SHIM_CALL XamInputGetState_shim(
user_index,
state_ptr);
if (!state_ptr) {
SHIM_SET_RETURN(X_ERROR_BAD_ARGUMENTS);
return;
}
InputSystem* input_system = state->emulator()->input_system();
X_INPUT_STATE input_state;
XRESULT result = input_system->GetState(user_index, input_state);
if (XSUCCEEDED(result)) {
if (state_ptr) {
input_state.Write(SHIM_MEM_BASE, state_ptr);
}
input_state.Write(SHIM_MEM_BASE, state_ptr);
}
SHIM_SET_RETURN(result);
}
@ -88,12 +94,14 @@ SHIM_CALL XamInputSetState_shim(
user_index,
vibration_ptr);
if (!vibration_ptr) {
SHIM_SET_RETURN(X_ERROR_BAD_ARGUMENTS);
return;
}
InputSystem* input_system = state->emulator()->input_system();
X_INPUT_VIBRATION vibration;
if (vibration_ptr) {
vibration.Read(SHIM_MEM_BASE, vibration_ptr);
}
X_INPUT_VIBRATION vibration(SHIM_MEM_BASE, vibration_ptr);
XRESULT result = input_system->SetState(user_index, vibration);
SHIM_SET_RETURN(result);
}

View File

@ -55,6 +55,7 @@ typedef uint32_t X_STATUS;
typedef uint32_t XRESULT;
#define X_ERROR_SUCCESS ((uint32_t)0x00000000L)
#define X_ERROR_ACCESS_DENIED ((uint32_t)0x80070005L)
#define X_ERROR_BAD_ARGUMENTS ((uint32_t)0x800700A0L)
#define X_ERROR_BUSY ((uint32_t)0x800700AAL)
#define X_ERROR_DEVICE_NOT_CONNECTED ((uint32_t)0x8007048FL)
#define X_ERROR_CANCELLED ((uint32_t)0x800704C7L)