Files
HexwellandClaude Fable 5 971296f174 refactor: separate libhijacker headers from shared contracts
source/include mixed libhijacker's private implementation headers (util.hpp
with its hand-rolled UniquePtr/String/Vector, plus kernel/, elf/, dbg/,
hijacker/) with genuinely cross-module contracts, and the whole directory was
pulled in as -isystem, so any module could reach libhijacker internals and
every warning in those headers was suppressed.

Move the libhijacker-private headers to source/libhijacker/include and expose
it as a PUBLIC include directory, so the two modules that actually use it —
util for hijacker.hpp, shellui for SHA-1 — now declare that dependency.

Split sha1.hpp: the public-domain SHA-1 goes to third_party/sha1, while
NID_KEY, Sha1 and genSha1 (which needed libhijacker's StringView) move into
the nid.hpp that uses them. shellui only ever wanted the plain digest.

Drop source/include's SYSTEM marker now that it holds only first-party
contracts. That surfaced problems -isystem had been hiding:

  * 68 format-string mismatches in dbg.hpp, printing uintptr_t with %llx
  * freebsd-helper.h redefining PROT_* and TRACEBUF over the SDK's
  * ini.h's header-only helpers declared static rather than static inline

The GNU extensions that TYPE_BEGIN/TYPE_FIELD rely on are now silenced per
header instead of by the blanket -isystem.

Also drop three redundant util.hpp includes (bootstrapper, shellui) that
referenced none of its symbols, and fix backtrace.hpp being included through
relative ../include paths.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-26 20:13:50 +08:00

110 lines
4.1 KiB
C++

#pragma once
extern "C" {
#include <stdint.h>
#include <stddef.h>
}
namespace {
static constexpr size_t NID_LENGTH = 11;
}
union Nid {
char str[NID_LENGTH + 1]; // 12th character is for NULL terminator to allow constexpr constructor
struct __attribute__((packed)) data_t {
int_fast64_t low;
int_fast32_t hi;
} data;
Nid() noexcept = default;
explicit constexpr Nid(const char *nid) noexcept : str{} {
__builtin_memcpy(str, nid, NID_LENGTH);
str[NID_LENGTH] = '\0';
}
constexpr int_fast64_t operator<=>(const Nid& rhs) const {
auto i = data.low - rhs.data.low;
if (i == 0) [[unlikely]] {
return data.hi - rhs.data.hi;
}
return i;
}
constexpr bool operator==(const Nid &rhs) const {
return data.low == rhs.data.low && data.hi == rhs.data.hi;
}
constexpr void setNullTerminator() {
str[NID_LENGTH] = '\0';
}
};
namespace nid {
static inline constexpr Nid get_authinfo{"igMefp4SAv0"};
static inline constexpr Nid sceFsUmountGamePkg{"UQTSykySQ40"};
static inline constexpr Nid abort{"L1SBTkC+Cvw"};
static inline constexpr Nid strstr{"viiwFMaNamA"};
static inline constexpr Nid sceSystemServiceGetAppStatus{"t5ShV0jWEFE"};
static inline constexpr Nid sceSystemServiceAddLocalProcess{"0cl8SuwosPQ"};
static inline constexpr Nid socketpair{"MZb0GKT3mo8"};
static inline constexpr Nid usleep{"QcteRwbsnV0"};
static inline constexpr Nid _errno{"9BcDykPmo1I"};
static inline constexpr Nid sceSysmoduleLoadModuleInternal{"39iV5E1HoCk"};
static inline constexpr Nid sceSysmoduleLoadModuleByNameInternal{"CU8m+Qs+HN4"};
static inline constexpr Nid mmap{"BPE9s9vQQXo"};
static inline constexpr Nid sceSysmoduleLoadModule{"g8cM39EUZ6o"};
static inline constexpr Nid munmap{"UqDGjXA5yUM"};
static inline constexpr Nid sceKernelJitCreateSharedMemory{"avvJ3J0H0EY"};
static inline constexpr Nid sceKernelUnloadModule{"QKd0qM58Qes"};
static inline constexpr Nid socket{"TU-d9PfIHPM"};
static inline constexpr Nid pipe{"-Jp7F+pXxNg"};
static inline constexpr Nid sceKernelDlsym{"LwG8g3niqwA"};
static inline constexpr Nid setsockopt{"fFxGkxF2bVo"};
static inline constexpr Nid execve{"kdguLiAheLI"};
static inline constexpr Nid _nanosleep{"NhpspxdjEKU"};
static inline constexpr Nid close{"bY-PO6JhzhQ"};
static inline constexpr Nid connect{"XVL8So3QJUk"};
static inline constexpr Nid send{"fZOeZIOEmLw"};
static inline constexpr Nid recv{"Ez8xjo9UF4E"};
static inline constexpr Nid rfork_thread{"bSDxEpGzmUE"};
static inline constexpr Nid access{"8vE6Z6VEYyk"};
static inline constexpr Nid sceKernelOpen{"1G3lF1Gg1k8"};
static inline constexpr Nid mono_aot_get_method{"6t5G5dYpMVg"};
static inline constexpr Nid sceKernelLoadStartModule{"wzvqT4UqKX8"};
static inline constexpr Nid sceKernelDebugOutText("9JYNqN6jAKI");
static inline constexpr Nid sceKernelGetFsSandboxRandomWord("JGfTMBOdUJo");
static inline constexpr Nid open("wuCroIGjt2g");
static inline constexpr Nid ioctl("PfccT7qURYE");
static inline constexpr Nid getpid("HoLVWNanBBc");
static inline constexpr Nid gettimeofday("n88vx3C5nW8");
static inline constexpr Nid sceKernelSendNotificationRequest("zl7hupSO0C0");
static inline constexpr Nid sceGnmSubmitAndFlipCommandBuffersForWorkload("Ga6r7H6Y0RI");
static inline constexpr Nid mono_get_root_domain{"5a8b+s6HtaA"};
static inline constexpr Nid mono_property_get_get_method{"uzLsJUMjvLY"};
static inline constexpr Nid mono_property_get_set_method{"BhrEyM1kGW8"};
static inline constexpr Nid mono_class_get_property_from_name{"KK8Cr0wE81M"};
static inline constexpr Nid mono_class_from_name{"bzxTZSnnB38"};
static inline constexpr Nid mono_runtime_invoke{"pre9BjkyDhs"};
static inline constexpr Nid mono_string_new{"pXv-WCokNsY"};
static inline constexpr Nid mono_assembly_get_image{"xP4EC4Sp9GI"};
static inline constexpr Nid mono_domain_assembly_open{"dCeihPtadCM"};
static inline constexpr Nid mono_thread_attach{"qqUxjwJzc2I"};
static inline constexpr Nid mono_class_get_method_from_name{"H5IByLixeaI"};
static inline constexpr Nid scePadReadState{"YndgXqQVV7c"};
static inline constexpr Nid strlen{"j4ViWNHEgww"};
static inline constexpr Nid sceAppInstUtilInstallByPackage{"tDtjgaXYmuo"};
static inline constexpr Nid sceKernelIsDevelopmentMode{"UtO0OHMCgmI"};
}