mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-08 13:50:20 +00:00
sceRegMgrSetInt and sceRegMgrSetStr passed their int32_t key to the 64-bit store sign-extended, so a key with bit 31 set was stored negative and the 64-bit getters did not find it. Convert through uint32_t as sceRegMgrSetBin does. Drop the two zero-length setter throw assertions, which pin unimplemented calls, and cover a key at or above 0x80000000.
90 lines
4.4 KiB
C++
90 lines
4.4 KiB
C++
#include "prx/libSceRegMgr/include/Api.hpp"
|
|
#include "prx/libc/include/general/VabiMacros.hpp"
|
|
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
static void Require(bool value) { if (!value) std::abort(); }
|
|
|
|
template <typename TCall>
|
|
static bool ReportsNotImplemented(const char* name, TCall call) {
|
|
try {
|
|
call();
|
|
} catch (const std::runtime_error& error) {
|
|
return std::string(error.what()) == std::string(name) + " not implemented";
|
|
}
|
|
return false;
|
|
}
|
|
|
|
int main() {
|
|
std::int32_t value = 0;
|
|
Require(ReportsNotImplemented("sceRegMgrNonSysGetInt", [&] { sceRegMgrNonSysGetInt(0, 0, &value); }));
|
|
Require(ReportsNotImplemented("sceRegMgrNonSysGetInt", [&] { sceRegMgrNonSysGetInt(-1, 1, nullptr); }));
|
|
|
|
int32_t intVal = 0;
|
|
char strBuf[64] = {};
|
|
uint8_t binBuf[32] = {};
|
|
|
|
Require(sceRegMgrGetInt(0x1000, nullptr) == static_cast<int>(0x80820001));
|
|
Require(sceRegMgrGetStr(0x1001, nullptr, 10) == static_cast<int>(0x80820001));
|
|
Require(sceRegMgrGetStr(0x1001, strBuf, -1) == static_cast<int>(0x80820001));
|
|
Require(sceRegMgrGetBin(0x1002, nullptr, 10) == static_cast<int>(0x80820001));
|
|
Require(sceRegMgrGetBin(0x1002, binBuf, -1) == static_cast<int>(0x80820001));
|
|
Require(sceRegMgrGetStr(0x1001, nullptr, -1) == static_cast<int>(0x80820001));
|
|
Require(sceRegMgrGetBin(0x1002, nullptr, -1) == static_cast<int>(0x80820001));
|
|
|
|
intVal = 0x55AA;
|
|
Require(sceRegMgrGetInt(888888, &intVal) == static_cast<int>(0x80820002));
|
|
Require(intVal == 0x55AA);
|
|
std::strcpy(strBuf, "CANARY");
|
|
Require(sceRegMgrGetStr(888888, strBuf, sizeof(strBuf)) == static_cast<int>(0x80820002));
|
|
Require(std::strcmp(strBuf, "CANARY") == 0);
|
|
binBuf[0] = 0x77;
|
|
Require(sceRegMgrGetBin(888888, binBuf, sizeof(binBuf)) == static_cast<int>(0x80820002));
|
|
Require(binBuf[0] == 0x77);
|
|
Require(sceRegMgrGetInt(0, &intVal) == static_cast<int>(0x80820002));
|
|
Require(sceRegMgrGetInt(-1, &intVal) == static_cast<int>(0x80820002));
|
|
Require(intVal == 0x55AA);
|
|
Require(sceRegMgrGetStr(0, strBuf, 1) == static_cast<int>(0x80820002));
|
|
Require(sceRegMgrGetStr(-1, strBuf, 1) == static_cast<int>(0x80820002));
|
|
Require(std::strcmp(strBuf, "CANARY") == 0);
|
|
Require(sceRegMgrGetBin(0, binBuf, 1) == static_cast<int>(0x80820002));
|
|
Require(sceRegMgrGetBin(-1, binBuf, 1) == static_cast<int>(0x80820002));
|
|
Require(binBuf[0] == 0x77);
|
|
|
|
Require(sceRegMgrSetInt(0x2000, 0x12345678) == 0);
|
|
Require(sceRegMgrGetInt(0x2000, &intVal) == 0 && intVal == 0x12345678);
|
|
Require(sceRegMgrSetInt(0x2000, -7) == 0);
|
|
Require(sceRegMgrGetInt(0x2000, &intVal) == 0 && intVal == -7);
|
|
Require(sceRegMgrSetStr(0x2001, "hello", 6) == 0);
|
|
std::memset(strBuf, 0, sizeof(strBuf));
|
|
Require(sceRegMgrGetStr(0x2001, strBuf, sizeof(strBuf)) == 0 && std::strcmp(strBuf, "hello") == 0);
|
|
Require(sceRegMgrSetStr(0x2001, "world", 6) == 0);
|
|
Require(sceRegMgrGetStr(0x2001, strBuf, sizeof(strBuf)) == 0 && std::strcmp(strBuf, "world") == 0);
|
|
const std::uint8_t data[] = {1, 2, 3, 4};
|
|
Require(sceRegMgrSetBin(0x2002, data, sizeof(data)) == 0);
|
|
std::memset(binBuf, 0, sizeof(binBuf));
|
|
Require(sceRegMgrGetBin(0x2002, binBuf, sizeof(binBuf)) == 0);
|
|
Require(std::memcmp(binBuf, data, sizeof(data)) == 0);
|
|
const std::uint8_t shorter[] = {9, 8};
|
|
Require(sceRegMgrSetBin(0x2002, shorter, sizeof(shorter)) == 0);
|
|
std::memset(binBuf, 0, sizeof(binBuf));
|
|
Require(sceRegMgrGetBin(0x2002, binBuf, sizeof(binBuf)) == 0);
|
|
Require(binBuf[0] == 9 && binBuf[1] == 8 && binBuf[2] == 0);
|
|
Require(sceRegMgrSetInt(0x2001, 1) == static_cast<int>(0x80820006));
|
|
Require(sceRegMgrSetStr(0x2000, "x", 2) == static_cast<int>(0x80820006));
|
|
Require(sceRegMgrSetBin(0x2000, data, sizeof(data)) == static_cast<int>(0x80820006));
|
|
Require(sceRegMgrSetStr(0x2003, nullptr, 5) == static_cast<int>(0x80820001));
|
|
Require(sceRegMgrSetBin(0x2003, nullptr, 5) == static_cast<int>(0x80820001));
|
|
Require(sceRegMgrSetInt(static_cast<int32_t>(0xC0808000u), 5) == 0);
|
|
intVal = 0;
|
|
Require(sceRegMgrGetInt(3229646848, &intVal) == 0 && intVal == 5);
|
|
Require(sceRegMgrSetStr(static_cast<int32_t>(0xC0808001u), "hi", 3) == 0);
|
|
std::memset(strBuf, 0, sizeof(strBuf));
|
|
Require(sceRegMgrGetStr(3229646849, strBuf, sizeof(strBuf)) == 0 && std::strcmp(strBuf, "hi") == 0);
|
|
|
|
return 0;
|
|
}
|