mirror of
https://github.com/aydencharles/onionHEN.git
synced 2026-10-23 04:12:37 -05:00
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>
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
#pragma once
|
|
|
|
extern "C" {
|
|
#include <elf.h>
|
|
#include <sys/elf64.h>
|
|
#include <ps5/payload.h>
|
|
}
|
|
|
|
#include "hijacker.hpp"
|
|
#include "util.hpp"
|
|
|
|
class ManagedResolver;
|
|
|
|
constexpr auto i = sizeof(Elf64_Dyn);
|
|
|
|
class Elf : Elf64_Ehdr {
|
|
|
|
public:
|
|
struct MappedMemory {
|
|
uintptr_t mem;
|
|
size_t len;
|
|
};
|
|
|
|
private:
|
|
dbg::Tracer tracer;
|
|
const Elf64_Phdr *__restrict phdrs;
|
|
const char *__restrict strtab;
|
|
size_t strtabLength;
|
|
const Elf64_Sym *__restrict symtab;
|
|
size_t symtabLength;
|
|
const Elf64_Rela *__restrict relatbl;
|
|
size_t relaLength;
|
|
const Elf64_Rela *__restrict plt;
|
|
size_t pltLength;
|
|
Hijacker *__restrict hijacker;
|
|
size_t textOffset;
|
|
uintptr_t imagebase;
|
|
uint8_t *data;
|
|
UniquePtr<ManagedResolver> resolver;
|
|
Array<MappedMemory> mappedMemory;
|
|
int jitFd;
|
|
|
|
bool processProgramHeaders() noexcept;
|
|
bool parseDynamicTable() noexcept;
|
|
bool processRelocations() noexcept;
|
|
bool processPltRelocations() noexcept;
|
|
bool load() noexcept;
|
|
bool start(uintptr_t args) noexcept;
|
|
uintptr_t setupKernelRW() noexcept;
|
|
uintptr_t getSymbolAddress(const Elf64_Rela *__restrict rel) const noexcept;
|
|
|
|
public:
|
|
Elf(Hijacker *hijacker, uint8_t *data) noexcept;
|
|
Elf(const Elf&) = delete;
|
|
Elf &operator=(const Elf&) = delete;
|
|
Elf(Elf&&) noexcept = default;
|
|
Elf &operator=(Elf&&) noexcept = default;
|
|
~Elf() noexcept; // external linkage to prevent undefined behavior
|
|
|
|
bool launch() noexcept;
|
|
explicit operator bool() const noexcept {
|
|
return static_cast<bool>(tracer);
|
|
}
|
|
};
|