clean up runtime helpers

This commit is contained in:
nmzik
2026-09-17 19:50:21 +04:00
parent 218e7200bb
commit 1211958b4e
12 changed files with 74 additions and 143 deletions
+26 -29
View File
@@ -7,6 +7,7 @@
#include <algorithm>
#include <atomic>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <deque>
#include <mutex>
@@ -18,35 +19,31 @@
namespace Libs::Ime {
namespace {
constexpr int Error(uint32_t value) {
return static_cast<int32_t>(value);
}
constexpr int ERROR_BUSY = Error(0x80bc0001);
constexpr int ERROR_NOT_OPENED = Error(0x80bc0002);
constexpr int ERROR_CONNECTION_FAILED = Error(0x80bc0004);
constexpr int ERROR_EVENT_OVERFLOW = Error(0x80bc0007);
constexpr int ERROR_INVALID_TEXT = Error(0x80bc0006);
constexpr int ERROR_INVALID_USER_ID = Error(0x80bc0010);
constexpr int ERROR_INVALID_TYPE = Error(0x80bc0011);
constexpr int ERROR_INVALID_LANGUAGES = Error(0x80bc0012);
constexpr int ERROR_INVALID_ENTER_LABEL = Error(0x80bc0013);
constexpr int ERROR_INVALID_INPUT_METHOD = Error(0x80bc0014);
constexpr int ERROR_INVALID_OPTION = Error(0x80bc0015);
constexpr int ERROR_INVALID_MAX_TEXT_LENGTH = Error(0x80bc0016);
constexpr int ERROR_INVALID_TEXT_BUFFER = Error(0x80bc0017);
constexpr int ERROR_INVALID_POSX = Error(0x80bc0018);
constexpr int ERROR_INVALID_POSY = Error(0x80bc0019);
constexpr int ERROR_INVALID_HALIGN = Error(0x80bc001a);
constexpr int ERROR_INVALID_VALIGN = Error(0x80bc001b);
constexpr int ERROR_INVALID_EXTENDED = Error(0x80bc001c);
constexpr int ERROR_INVALID_WORK = Error(0x80bc0020);
constexpr int ERROR_INVALID_HANDLER = Error(0x80bc0022);
constexpr int ERROR_NO_RESOURCE_ID = Error(0x80bc0023);
constexpr int ERROR_INVALID_MODE = Error(0x80bc0024);
constexpr int ERROR_INVALID_PARAM = Error(0x80bc0030);
constexpr int ERROR_INVALID_ADDRESS = Error(0x80bc0031);
constexpr int ERROR_INVALID_RESERVED = Error(0x80bc0032);
constexpr int ERROR_BUSY = static_cast<int32_t>(0x80bc0001);
constexpr int ERROR_NOT_OPENED = static_cast<int32_t>(0x80bc0002);
constexpr int ERROR_CONNECTION_FAILED = static_cast<int32_t>(0x80bc0004);
constexpr int ERROR_EVENT_OVERFLOW = static_cast<int32_t>(0x80bc0007);
constexpr int ERROR_INVALID_TEXT = static_cast<int32_t>(0x80bc0006);
constexpr int ERROR_INVALID_USER_ID = static_cast<int32_t>(0x80bc0010);
constexpr int ERROR_INVALID_TYPE = static_cast<int32_t>(0x80bc0011);
constexpr int ERROR_INVALID_LANGUAGES = static_cast<int32_t>(0x80bc0012);
constexpr int ERROR_INVALID_ENTER_LABEL = static_cast<int32_t>(0x80bc0013);
constexpr int ERROR_INVALID_INPUT_METHOD = static_cast<int32_t>(0x80bc0014);
constexpr int ERROR_INVALID_OPTION = static_cast<int32_t>(0x80bc0015);
constexpr int ERROR_INVALID_MAX_TEXT_LENGTH = static_cast<int32_t>(0x80bc0016);
constexpr int ERROR_INVALID_TEXT_BUFFER = static_cast<int32_t>(0x80bc0017);
constexpr int ERROR_INVALID_POSX = static_cast<int32_t>(0x80bc0018);
constexpr int ERROR_INVALID_POSY = static_cast<int32_t>(0x80bc0019);
constexpr int ERROR_INVALID_HALIGN = static_cast<int32_t>(0x80bc001a);
constexpr int ERROR_INVALID_VALIGN = static_cast<int32_t>(0x80bc001b);
constexpr int ERROR_INVALID_EXTENDED = static_cast<int32_t>(0x80bc001c);
constexpr int ERROR_INVALID_WORK = static_cast<int32_t>(0x80bc0020);
constexpr int ERROR_INVALID_HANDLER = static_cast<int32_t>(0x80bc0022);
constexpr int ERROR_NO_RESOURCE_ID = static_cast<int32_t>(0x80bc0023);
constexpr int ERROR_INVALID_MODE = static_cast<int32_t>(0x80bc0024);
constexpr int ERROR_INVALID_PARAM = static_cast<int32_t>(0x80bc0030);
constexpr int ERROR_INVALID_ADDRESS = static_cast<int32_t>(0x80bc0031);
constexpr int ERROR_INVALID_RESERVED = static_cast<int32_t>(0x80bc0032);
constexpr uint32_t VALID_OPTIONS = 0x00007bff;
constexpr uint32_t VALID_EXTENDED_OPTIONS = 0x00004fde;
+22 -25
View File
@@ -5,6 +5,7 @@
#include <algorithm>
#include <atomic>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <mutex>
#include <vector>
@@ -13,31 +14,27 @@ namespace Libs::Dialog::ImeDialog {
namespace {
constexpr int Error(uint32_t value) {
return static_cast<int32_t>(value);
}
constexpr int ERROR_BUSY = Error(0x80bc0001);
constexpr int ERROR_INVALID_USER_ID = Error(0x80bc0010);
constexpr int ERROR_INVALID_TYPE = Error(0x80bc0011);
constexpr int ERROR_INVALID_LANGUAGES = Error(0x80bc0012);
constexpr int ERROR_INVALID_ENTER_LABEL = Error(0x80bc0013);
constexpr int ERROR_INVALID_INPUT_METHOD = Error(0x80bc0014);
constexpr int ERROR_INVALID_OPTION = Error(0x80bc0015);
constexpr int ERROR_INVALID_MAX_TEXT_LENGTH = Error(0x80bc0016);
constexpr int ERROR_INVALID_TEXT_BUFFER = Error(0x80bc0017);
constexpr int ERROR_INVALID_POSX = Error(0x80bc0018);
constexpr int ERROR_INVALID_POSY = Error(0x80bc0019);
constexpr int ERROR_INVALID_HALIGN = Error(0x80bc001a);
constexpr int ERROR_INVALID_VALIGN = Error(0x80bc001b);
constexpr int ERROR_INVALID_EXTENDED = Error(0x80bc001c);
constexpr int ERROR_INVALID_PARAM = Error(0x80bc0030);
constexpr int ERROR_INVALID_ADDRESS = Error(0x80bc0031);
constexpr int ERROR_INVALID_RESERVED = Error(0x80bc0032);
constexpr int ERROR_INVALID_TITLE = Error(0x80bc0101);
constexpr int ERROR_NOT_RUNNING = Error(0x80bc0105);
constexpr int ERROR_NOT_FINISHED = Error(0x80bc0106);
constexpr int ERROR_NOT_IN_USE = Error(0x80bc0107);
constexpr int ERROR_BUSY = static_cast<int32_t>(0x80bc0001);
constexpr int ERROR_INVALID_USER_ID = static_cast<int32_t>(0x80bc0010);
constexpr int ERROR_INVALID_TYPE = static_cast<int32_t>(0x80bc0011);
constexpr int ERROR_INVALID_LANGUAGES = static_cast<int32_t>(0x80bc0012);
constexpr int ERROR_INVALID_ENTER_LABEL = static_cast<int32_t>(0x80bc0013);
constexpr int ERROR_INVALID_INPUT_METHOD = static_cast<int32_t>(0x80bc0014);
constexpr int ERROR_INVALID_OPTION = static_cast<int32_t>(0x80bc0015);
constexpr int ERROR_INVALID_MAX_TEXT_LENGTH = static_cast<int32_t>(0x80bc0016);
constexpr int ERROR_INVALID_TEXT_BUFFER = static_cast<int32_t>(0x80bc0017);
constexpr int ERROR_INVALID_POSX = static_cast<int32_t>(0x80bc0018);
constexpr int ERROR_INVALID_POSY = static_cast<int32_t>(0x80bc0019);
constexpr int ERROR_INVALID_HALIGN = static_cast<int32_t>(0x80bc001a);
constexpr int ERROR_INVALID_VALIGN = static_cast<int32_t>(0x80bc001b);
constexpr int ERROR_INVALID_EXTENDED = static_cast<int32_t>(0x80bc001c);
constexpr int ERROR_INVALID_PARAM = static_cast<int32_t>(0x80bc0030);
constexpr int ERROR_INVALID_ADDRESS = static_cast<int32_t>(0x80bc0031);
constexpr int ERROR_INVALID_RESERVED = static_cast<int32_t>(0x80bc0032);
constexpr int ERROR_INVALID_TITLE = static_cast<int32_t>(0x80bc0101);
constexpr int ERROR_NOT_RUNNING = static_cast<int32_t>(0x80bc0105);
constexpr int ERROR_NOT_FINISHED = static_cast<int32_t>(0x80bc0106);
constexpr int ERROR_NOT_IN_USE = static_cast<int32_t>(0x80bc0107);
constexpr uint32_t VALID_OPTIONS = 0x00007bff;
constexpr uint32_t VALID_EXTENDED_OPTIONS = 0x00005fde;
+4 -7
View File
@@ -24,6 +24,7 @@
#include <algorithm>
#include <array>
#include <atomic>
#include <bit>
#include <chrono>
#include <cstddef>
#include <cstdio>
@@ -68,10 +69,6 @@ using KernelModule = int32_t;
using get_thread_atexit_count_func_t = KYTY_SYSV_ABI int (*)(KernelModule);
using thread_atexit_report_func_t = KYTY_SYSV_ABI void (*)(KernelModule);
static uint32_t sha1_rol(uint32_t value, uint32_t bits) {
return (value << bits) | (value >> (32u - bits));
}
static std::array<uint8_t, 20> sha1_digest(const uint8_t* data, size_t size) {
uint32_t h0 = 0x67452301u;
uint32_t h1 = 0xefcdab89u;
@@ -99,7 +96,7 @@ static std::array<uint8_t, 20> sha1_digest(const uint8_t* data, size_t size) {
(static_cast<uint32_t>(msg[j + 2]) << 8u) | static_cast<uint32_t>(msg[j + 3]);
}
for (int i = 16; i < 80; i++) {
w[i] = sha1_rol(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
w[i] = std::rotl(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
}
uint32_t a = h0;
@@ -125,10 +122,10 @@ static std::array<uint8_t, 20> sha1_digest(const uint8_t* data, size_t size) {
k = 0xca62c1d6u;
}
const auto temp = sha1_rol(a, 5) + f + e + k + w[i];
const auto temp = std::rotl(a, 5) + f + e + k + w[i];
e = d;
d = c;
c = sha1_rol(b, 30);
c = std::rotl(b, 30);
b = a;
a = temp;
}
-13
View File
@@ -3118,16 +3118,6 @@ static std::map<int64_t, NpWebApi2Request>& NpWebApi2Requests() {
return requests;
}
[[maybe_unused]] static std::string NpWebApi2MakeResponse(const NpWebApi2Request& request) {
if (request.api_group.find("sessionManager") != std::string::npos ||
request.path.find("sessions") != std::string::npos ||
request.path.find("Sessions") != std::string::npos) {
return R"({"gameSessions":[],"playerSessions":[]})";
}
return "{}";
}
static int KYTY_SYSV_ABI NpWebApi2Initialize(int lib_http_ctx_id, size_t pool_size) {
PRINT_NAME();
@@ -3224,12 +3214,10 @@ NpWebApi2SendRequest(int64_t request_id, const void* data, size_t data_size,
return NP_WEBAPI2_ERROR_REQUEST_NOT_FOUND;
}
// request->second.response = NpWebApi2MakeResponse(request->second);
request->second.response.clear();
request->second.read_offset = 0;
if (response_info_option != nullptr) {
// response_info_option->http_status = 200;
response_info_option->http_status = 0;
response_info_option->response_data_size = request->second.response.size();
if (response_info_option->error_object != nullptr &&
@@ -3238,7 +3226,6 @@ NpWebApi2SendRequest(int64_t request_id, const void* data, size_t data_size,
}
}
// return 0;
return NP_WEBAPI2_ERROR_NOT_SIGNED_IN;
}
+5 -9
View File
@@ -13,15 +13,11 @@ LIB_VERSION("Psml", 1, "Psml", 1, 1);
namespace Psml {
constexpr int Error(uint32_t value) {
return static_cast<int>(value);
}
constexpr int PSML_ERROR_NOT_INITIALIZED = Error(0x8a810001u);
constexpr int PSML_ERROR_INVALID_OBJECT = Error(0x8a810005u);
constexpr int PSML_ERROR_INVALID_POINTER = Error(0x8a810009u);
constexpr int PSML_ERROR_INVALID_VALUE = Error(0x8a81000du);
constexpr int PSML_ERROR_NULL_OBJECT = Error(0x8a810014u);
constexpr int PSML_ERROR_NOT_INITIALIZED = static_cast<int>(0x8a810001u);
constexpr int PSML_ERROR_INVALID_OBJECT = static_cast<int>(0x8a810005u);
constexpr int PSML_ERROR_INVALID_POINTER = static_cast<int>(0x8a810009u);
constexpr int PSML_ERROR_INVALID_VALUE = static_cast<int>(0x8a81000du);
constexpr int PSML_ERROR_NULL_OBJECT = static_cast<int>(0x8a810014u);
constexpr uint32_t SHARED_RESOURCES_MAGIC = 0xa9c4;
constexpr uint32_t CONTEXT_MAGIC = 0x9231;
-9
View File
@@ -3103,17 +3103,10 @@ static HostNetworkInfo QueryHostNetworkInfo() {
#endif
}
[[maybe_unused]] static bool HostNetworkConnected() {
return QueryHostNetworkInfo().connected;
}
static bool NetCtlConnected() {
if (!g_net_ctl_status_initialized.load()) {
// g_net_ctl_connected = HostNetworkConnected();
g_net_ctl_connected = false;
g_net_ctl_status_initialized = true;
// LOGF("\t host network connected = %s\n", (g_net_ctl_connected.load() ? "true" :
// "false"));
LOGF("\t host network connected = false (forced offline)\n");
}
@@ -3123,10 +3116,8 @@ static bool NetCtlConnected() {
int KYTY_SYSV_ABI NetCtlInit() {
PRINT_NAME();
// g_net_ctl_connected = HostNetworkConnected();
g_net_ctl_connected = false;
g_net_ctl_status_initialized = true;
// LOGF("\t host network connected = %s\n", (g_net_ctl_connected.load() ? "true" : "false"));
LOGF("\t host network connected = false (forced offline)\n");
return OK;