mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-29 12:15:39 +00:00
fix(move): restore query validation and invalid handle errors
This commit is contained in:
1 parent
7a596d28aa
commit
8a1bd363ef
3 files changed
+17
-19
No files matched your search
@@ -28,10 +28,12 @@ struct Slot {
|
||||
|
||||
std::unordered_map<int32_t, Slot> openHandles;
|
||||
|
||||
int checkHandle(int32_t handle) {
|
||||
int checkHandle(int32_t handle, bool validArguments = true) {
|
||||
std::lock_guard lock(stateMutex);
|
||||
if (!initialized) return MOVE_ERROR_NOT_INIT;
|
||||
return openHandles.contains(handle) ? MOVE_OK : MOVE_ERROR_INVALID_HANDLE;
|
||||
if (!validArguments) return MOVE_ERROR_INVALID_ARG;
|
||||
if (!openHandles.contains(handle)) return MOVE_ERROR_INVALID_HANDLE;
|
||||
return MOVE_OK;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -73,26 +75,22 @@ int APS5_VABI sceMoveClose(int32_t handle) {
|
||||
}
|
||||
|
||||
int APS5_VABI sceMoveGetDeviceInfo(int32_t handle, void* info) {
|
||||
if (const int result = checkHandle(handle); result != MOVE_OK) return result;
|
||||
if (!info) return MOVE_ERROR_INVALID_ARG;
|
||||
if (const int result = checkHandle(handle, info != nullptr); result != MOVE_OK) return result;
|
||||
return MOVE_NO_CONTROLLER_CONNECTED;
|
||||
}
|
||||
|
||||
int APS5_VABI sceMoveGetExtensionPortInfo(int32_t handle, void* data) {
|
||||
if (const int result = checkHandle(handle); result != MOVE_OK) return result;
|
||||
if (!data) return MOVE_ERROR_INVALID_ARG;
|
||||
if (const int result = checkHandle(handle, data != nullptr); result != MOVE_OK) return result;
|
||||
return MOVE_NO_CONTROLLER_CONNECTED;
|
||||
}
|
||||
|
||||
int APS5_VABI sceMoveReadStateLatest(int32_t handle, void* data) {
|
||||
if (const int result = checkHandle(handle); result != MOVE_OK) return result;
|
||||
if (!data) return MOVE_ERROR_INVALID_ARG;
|
||||
if (const int result = checkHandle(handle, data != nullptr); result != MOVE_OK) return result;
|
||||
return MOVE_NO_CONTROLLER_CONNECTED;
|
||||
}
|
||||
|
||||
int APS5_VABI sceMoveReadStateRecent(int32_t handle, int64_t timestamp, void* data, int32_t* outCount) {
|
||||
if (const int result = checkHandle(handle); result != MOVE_OK) return result;
|
||||
if (timestamp < 0 || !data || !outCount) return MOVE_ERROR_INVALID_ARG;
|
||||
if (const int result = checkHandle(handle, timestamp >= 0 && data != nullptr && outCount != nullptr); result != MOVE_OK) return result;
|
||||
return MOVE_NO_CONTROLLER_CONNECTED;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,8 +85,11 @@ void RequireUnknownHandle(std::int32_t handle) {
|
||||
Require(sceMoveSetVibration(handle, 0xFF) == kInvalidHandle);
|
||||
Require(sceMoveSetLightSphere(handle, 0xFF, 0, 0) == kInvalidHandle);
|
||||
Require(sceMoveResetLightSphere(handle) == kInvalidHandle);
|
||||
Require(sceMoveGetDeviceInfo(handle, nullptr) == kInvalidHandle);
|
||||
Require(sceMoveReadStateRecent(handle, -1, nullptr, nullptr) == kInvalidHandle);
|
||||
Require(sceMoveGetDeviceInfo(handle, nullptr) == kInvalidArg);
|
||||
Require(sceMoveGetExtensionPortInfo(handle, nullptr) == kInvalidArg);
|
||||
Require(sceMoveReadStateLatest(handle, nullptr) == kInvalidArg);
|
||||
Require(sceMoveReadStateRecent(handle, -1, buffer.bytes, &count) == kInvalidArg);
|
||||
Require(sceMoveReadStateRecent(handle, 0, buffer.bytes, nullptr) == kInvalidArg);
|
||||
Require(buffer.Untouched());
|
||||
Require(count == -7);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
# libSceMove technical debt
|
||||
|
||||
### Silent stubs
|
||||
### Functional
|
||||
|
||||
- [libSceMove](../../../core/libs/prx/libSceMove/Export.cpp) implements only the no-controller path: initialization and termination succeed, `sceMoveOpen` returns a new handle, `sceMoveClose` and `sceMoveResetLightSphere` succeed for an open handle, and the device info, state, extension port, vibration and `sceMoveSetLightSphere` calls return 1 (no controller connected) and write nothing
|
||||
|
||||
### Unknown function info
|
||||
|
||||
- [libSceMove](../../../core/libs/prx/libSceMove/Export.cpp) (libSceMove) - behaviour, error codes and the handle values (`0x30B0100`, then every `0x100`) follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/f68923fe807f657348e6719ce658bcbd0a2b1c72/src/core/libraries/move/move.cpp) (PS4), which checks no handle or open arguments; none is measured on a PS5. Signatures follow [Orbital](https://github.com/AlexAltea/orbital/blob/master/tools/ida/db_types.json), except `sceMoveGetExtensionPortInfo`, which follows shadPS4. Before `sceMoveInit` and after `sceMoveTerm` every other call returns `NOT_INIT` (`0x80EE0001`); a null output or a negative timestamp returns `INVALID_ARG` (`0x80EE0003`). Closes when: measured on a PS5
|
||||
- [libSceMove](../../../core/libs/prx/libSceMove/Export.cpp) (libSceMove) - a handle that was never opened, is closed or was opened before `sceMoveTerm` returns `INVALID_HANDLE` (`0x80EE0004`), checked before `INVALID_ARG`, and `sceMoveOpen` returns `ALREADY_OPENED` (`0x80EE0007`) for a type and index that are already open; both codes are named in [shadPS4's move_error.h](https://github.com/shadps4-emu/shadPS4/blob/a808e76/src/core/libraries/move/move_error.h), which never returns them, so the results and their order are not measured. `sceMoveOpen` throws for a user other than the initial user, whose console result is not known, and accepts any type and index. Closes when: measured on a PS5
|
||||
- [libSceMove](../../../core/libs/prx/libSceMove/Export.cpp): the host implements only disconnected controllers. The native module confirms initialization errors, disconnected return 1 without output writes, invalid-handle error 0x80EE0004, and initialization then argument then handle validation for queries. Reset-light-sphere still omits the device ioctl and its failure mapping.
|
||||
- [sceMoveOpen and sceMoveClose](../../../core/libs/prx/libSceMove/Export.cpp): protected bodies remain unchanged. Native opening resolves a user/device through the input service, rejects duplicate device handles with 0x80EE0007, limits storage to eight slots with 0x80EE0005, and obtains handles from the device ioctl. The host generates monotonically increasing handles, accepts arbitrary type/index values and returns 0x80EE0007 for duplicate slots and throws for other users. Closing an unknown handle returns the confirmed 0x80EE0004.
|
||||
- [sceMoveReadStateRecent](../../../core/libs/prx/libSceMove/Export.cpp): the native module permits a null data array for SDK versions through 0x03ffffff while still requiring a count pointer and nonnegative timestamp. The host requires the data array for every SDK version. Connected state records and device-service failures remain unimplemented.
|
||||
Reference in new issue
Block a user