Format Headers

Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
This commit is contained in:
Isaac Marovitz 2025-03-06 22:22:48 +00:00
parent 10b627e986
commit f9fbd822ff
No known key found for this signature in database
GPG Key ID: 97250B2B09A132E1
18 changed files with 534 additions and 507 deletions

@ -2,11 +2,12 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cstddef>
#include <charconv> #include <charconv>
#include <cstddef>
#include <disasm.h> #include <disasm.h>
#include <file.h> #include <file.h>
#include <filesystem> #include <filesystem>
#include <fmt/core.h>
#include <fstream> #include <fstream>
#include <function.h> #include <function.h>
#include <image.h> #include <image.h>
@ -14,6 +15,5 @@
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
#include <xbox.h> #include <xbox.h>
#include <xxhash.h>
#include <fmt/core.h>
#include <xmmintrin.h> #include <xmmintrin.h>
#include <xxhash.h>

@ -32,4 +32,4 @@ namespace ppc
} }
static int Disassemble(const void* code, uint64_t base, ppc_insn* out, size_t nOut); static int Disassemble(const void* code, uint64_t base, ppc_insn* out, size_t nOut);
} } // namespace ppc

@ -46,7 +46,6 @@ typedef __s64 Elf64_Sxword;
#define PT_GNU_RELRO (PT_LOOS + 0x474e552) #define PT_GNU_RELRO (PT_LOOS + 0x474e552)
#define PT_GNU_PROPERTY (PT_LOOS + 0x474e553) #define PT_GNU_PROPERTY (PT_LOOS + 0x474e553)
/* ARM MTE memory tag segment type */ /* ARM MTE memory tag segment type */
#define PT_AARCH64_MEMTAG_MTE (PT_LOPROC + 0x2) #define PT_AARCH64_MEMTAG_MTE (PT_LOPROC + 0x2)
@ -146,17 +145,21 @@ typedef __s64 Elf64_Sxword;
#define ELF64_ST_BIND(x) ELF_ST_BIND(x) #define ELF64_ST_BIND(x) ELF_ST_BIND(x)
#define ELF64_ST_TYPE(x) ELF_ST_TYPE(x) #define ELF64_ST_TYPE(x) ELF_ST_TYPE(x)
typedef struct { typedef struct
{
Elf32_Sword d_tag; Elf32_Sword d_tag;
union { union
{
Elf32_Sword d_val; Elf32_Sword d_val;
Elf32_Addr d_ptr; Elf32_Addr d_ptr;
} d_un; } d_un;
} Elf32_Dyn; } Elf32_Dyn;
typedef struct { typedef struct
{
Elf64_Sxword d_tag; /* entry tag value */ Elf64_Sxword d_tag; /* entry tag value */
union { union
{
Elf64_Xword d_val; Elf64_Xword d_val;
Elf64_Addr d_ptr; Elf64_Addr d_ptr;
} d_un; } d_un;
@ -169,29 +172,34 @@ typedef struct {
#define ELF64_R_SYM(i) ((i) >> 32) #define ELF64_R_SYM(i) ((i) >> 32)
#define ELF64_R_TYPE(i) ((i) & 0xffffffff) #define ELF64_R_TYPE(i) ((i) & 0xffffffff)
typedef struct elf32_rel { typedef struct elf32_rel
{
Elf32_Addr r_offset; Elf32_Addr r_offset;
Elf32_Word r_info; Elf32_Word r_info;
} Elf32_Rel; } Elf32_Rel;
typedef struct elf64_rel { typedef struct elf64_rel
{
Elf64_Addr r_offset; /* Location at which to apply the action */ Elf64_Addr r_offset; /* Location at which to apply the action */
Elf64_Xword r_info; /* index and type of relocation */ Elf64_Xword r_info; /* index and type of relocation */
} Elf64_Rel; } Elf64_Rel;
typedef struct elf32_rela { typedef struct elf32_rela
{
Elf32_Addr r_offset; Elf32_Addr r_offset;
Elf32_Word r_info; Elf32_Word r_info;
Elf32_Sword r_addend; Elf32_Sword r_addend;
} Elf32_Rela; } Elf32_Rela;
typedef struct elf64_rela { typedef struct elf64_rela
{
Elf64_Addr r_offset; /* Location at which to apply the action */ Elf64_Addr r_offset; /* Location at which to apply the action */
Elf64_Xword r_info; /* index and type of relocation */ Elf64_Xword r_info; /* index and type of relocation */
Elf64_Sxword r_addend; /* Constant addend used to compute value */ Elf64_Sxword r_addend; /* Constant addend used to compute value */
} Elf64_Rela; } Elf64_Rela;
typedef struct elf32_sym { typedef struct elf32_sym
{
Elf32_Word st_name; Elf32_Word st_name;
Elf32_Addr st_value; Elf32_Addr st_value;
Elf32_Word st_size; Elf32_Word st_size;
@ -200,7 +208,8 @@ typedef struct elf32_sym {
Elf32_Half st_shndx; Elf32_Half st_shndx;
} Elf32_Sym; } Elf32_Sym;
typedef struct elf64_sym { typedef struct elf64_sym
{
Elf64_Word st_name; /* Symbol name, index in string tbl */ Elf64_Word st_name; /* Symbol name, index in string tbl */
unsigned char st_info; /* Type and binding attributes */ unsigned char st_info; /* Type and binding attributes */
unsigned char st_other; /* No defined meaning, 0 */ unsigned char st_other; /* No defined meaning, 0 */
@ -209,10 +218,10 @@ typedef struct elf64_sym {
Elf64_Xword st_size; /* Associated symbol size */ Elf64_Xword st_size; /* Associated symbol size */
} Elf64_Sym; } Elf64_Sym;
#define EI_NIDENT 16 #define EI_NIDENT 16
typedef struct elf32_hdr { typedef struct elf32_hdr
{
unsigned char e_ident[EI_NIDENT]; unsigned char e_ident[EI_NIDENT];
Elf32_Half e_type; Elf32_Half e_type;
Elf32_Half e_machine; Elf32_Half e_machine;
@ -229,7 +238,8 @@ typedef struct elf32_hdr {
Elf32_Half e_shstrndx; Elf32_Half e_shstrndx;
} Elf32_Ehdr; } Elf32_Ehdr;
typedef struct elf64_hdr { typedef struct elf64_hdr
{
unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */ unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */
Elf64_Half e_type; Elf64_Half e_type;
Elf64_Half e_machine; Elf64_Half e_machine;
@ -252,7 +262,8 @@ typedef struct elf64_hdr {
#define PF_W 0x2 #define PF_W 0x2
#define PF_X 0x1 #define PF_X 0x1
typedef struct elf32_phdr { typedef struct elf32_phdr
{
Elf32_Word p_type; Elf32_Word p_type;
Elf32_Off p_offset; Elf32_Off p_offset;
Elf32_Addr p_vaddr; Elf32_Addr p_vaddr;
@ -263,7 +274,8 @@ typedef struct elf32_phdr {
Elf32_Word p_align; Elf32_Word p_align;
} Elf32_Phdr; } Elf32_Phdr;
typedef struct elf64_phdr { typedef struct elf64_phdr
{
Elf64_Word p_type; Elf64_Word p_type;
Elf64_Word p_flags; Elf64_Word p_flags;
Elf64_Off p_offset; /* Segment file offset */ Elf64_Off p_offset; /* Segment file offset */
@ -311,7 +323,8 @@ typedef struct elf64_phdr {
#define SHN_COMMON 0xfff2 #define SHN_COMMON 0xfff2
#define SHN_HIRESERVE 0xffff #define SHN_HIRESERVE 0xffff
typedef struct elf32_shdr { typedef struct elf32_shdr
{
Elf32_Word sh_name; Elf32_Word sh_name;
Elf32_Word sh_type; Elf32_Word sh_type;
Elf32_Word sh_flags; Elf32_Word sh_flags;
@ -324,7 +337,8 @@ typedef struct elf32_shdr {
Elf32_Word sh_entsize; Elf32_Word sh_entsize;
} Elf32_Shdr; } Elf32_Shdr;
typedef struct elf64_shdr { typedef struct elf64_shdr
{
Elf64_Word sh_name; /* Section name, index in string tbl */ Elf64_Word sh_name; /* Section name, index in string tbl */
Elf64_Word sh_type; /* Type of section */ Elf64_Word sh_type; /* Type of section */
Elf64_Xword sh_flags; /* Miscellaneous section attributes */ Elf64_Xword sh_flags; /* Miscellaneous section attributes */
@ -466,14 +480,16 @@ typedef struct elf64_shdr {
#define NT_GNU_PROPERTY_TYPE_0 5 #define NT_GNU_PROPERTY_TYPE_0 5
/* Note header in a PT_NOTE section */ /* Note header in a PT_NOTE section */
typedef struct elf32_note { typedef struct elf32_note
{
Elf32_Word n_namesz; /* Name size */ Elf32_Word n_namesz; /* Name size */
Elf32_Word n_descsz; /* Content size */ Elf32_Word n_descsz; /* Content size */
Elf32_Word n_type; /* Content type */ Elf32_Word n_type; /* Content type */
} Elf32_Nhdr; } Elf32_Nhdr;
/* Note header in a PT_NOTE section */ /* Note header in a PT_NOTE section */
typedef struct elf64_note { typedef struct elf64_note
{
Elf64_Word n_namesz; /* Name size */ Elf64_Word n_namesz; /* Name size */
Elf64_Word n_descsz; /* Content size */ Elf64_Word n_descsz; /* Content size */
Elf64_Word n_type; /* Content type */ Elf64_Word n_type; /* Content type */

@ -1,9 +1,9 @@
#pragma once #pragma once
#include <memory>
#include <string>
#include <set>
#include <section.h>
#include "symbol_table.h" #include "symbol_table.h"
#include <memory>
#include <section.h>
#include <set>
#include <string>
struct Image struct Image
{ {

@ -8,7 +8,8 @@
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif
struct MemoryMappedFile { struct MemoryMappedFile
{
#if defined(_WIN32) #if defined(_WIN32)
HANDLE fileHandle = nullptr; HANDLE fileHandle = nullptr;
HANDLE fileMappingHandle = nullptr; HANDLE fileMappingHandle = nullptr;

@ -17,8 +17,8 @@
#ifdef _WIN32 #ifdef _WIN32
#include <intrin.h> #include <intrin.h>
#else #else
#include <xmmintrin.h>
#include <smmintrin.h> #include <smmintrin.h>
#include <xmmintrin.h>
#endif #endif
#define PPC_JOIN(x, y) x##y #define PPC_JOIN(x, y) x##y
@ -513,6 +513,8 @@ struct PPCContext
#endif #endif
}; };
// clang-format off
inline uint8_t VectorMaskL[] = inline uint8_t VectorMaskL[] =
{ {
0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
@ -593,6 +595,8 @@ inline uint8_t VectorShiftTableR[] =
0x10, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x10, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
}; };
// clang-format on
inline __m128i _mm_adds_epu32(__m128i a, __m128i b) inline __m128i _mm_adds_epu32(__m128i a, __m128i b)
{ {
return _mm_add_epi32(a, _mm_min_epu32(_mm_xor_si128(a, _mm_cmpeq_epi32(a, a)), b)); return _mm_add_epi32(a, _mm_min_epu32(_mm_xor_si128(a, _mm_cmpeq_epi32(a, a)), b));

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <string>
#include <cstdint> #include <cstdint>
#include <string>
enum SectionFlags : uint8_t enum SectionFlags : uint8_t
{ {

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <string>
#include <cstdint> #include <cstdint>
#include <string>
enum SymbolType enum SymbolType
{ {

@ -1,9 +1,9 @@
#pragma once #pragma once
#include <cstdint>
#include <type_traits>
#include <bit>
#include <string>
#include "byteswap.h" #include "byteswap.h"
#include <bit>
#include <cstdint>
#include <string>
#include <type_traits>
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
@ -207,7 +207,8 @@ typedef struct _XRTL_CRITICAL_SECTION
uint32_t OwningThread; uint32_t OwningThread;
} XRTL_CRITICAL_SECTION; } XRTL_CRITICAL_SECTION;
typedef struct _XANSI_STRING { typedef struct _XANSI_STRING
{
be<uint16_t> Length; be<uint16_t> Length;
be<uint16_t> MaximumLength; be<uint16_t> MaximumLength;
xpointer<char> Buffer; xpointer<char> Buffer;
@ -224,14 +225,16 @@ typedef XDISPATCHER_HEADER XKEVENT;
typedef struct _XIO_STATUS_BLOCK typedef struct _XIO_STATUS_BLOCK
{ {
union { union
{
be<uint32_t> Status; be<uint32_t> Status;
be<uint32_t> Pointer; be<uint32_t> Pointer;
}; };
be<uint32_t> Information; be<uint32_t> Information;
} XIO_STATUS_BLOCK; } XIO_STATUS_BLOCK;
typedef struct _XOVERLAPPED { typedef struct _XOVERLAPPED
{
be<uint32_t> Internal; be<uint32_t> Internal;
be<uint32_t> InternalHigh; be<uint32_t> InternalHigh;
be<uint32_t> Offset; be<uint32_t> Offset;
@ -240,7 +243,8 @@ typedef struct _XOVERLAPPED {
} XOVERLAPPED; } XOVERLAPPED;
// this name is so dumb // this name is so dumb
typedef struct _XXOVERLAPPED { typedef struct _XXOVERLAPPED
{
union union
{ {
struct struct
@ -265,7 +269,8 @@ typedef struct _XXOVERLAPPED {
static_assert(sizeof(_XXOVERLAPPED) == 0x1C); static_assert(sizeof(_XXOVERLAPPED) == 0x1C);
// https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-memorystatus // https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-memorystatus
typedef struct _XMEMORYSTATUS { typedef struct _XMEMORYSTATUS
{
be<uint32_t> dwLength; be<uint32_t> dwLength;
be<uint32_t> dwMemoryLoad; be<uint32_t> dwMemoryLoad;
be<uint32_t> dwTotalPhys; be<uint32_t> dwTotalPhys;
@ -296,7 +301,8 @@ typedef struct _XKSEMAPHORE
be<uint32_t> Limit; be<uint32_t> Limit;
} XKSEMAPHORE; } XKSEMAPHORE;
typedef struct _XUSER_SIGNIN_INFO { typedef struct _XUSER_SIGNIN_INFO
{
be<uint64_t> xuid; be<uint64_t> xuid;
be<uint32_t> dwField08; be<uint32_t> dwField08;
be<uint32_t> SigninState; be<uint32_t> SigninState;
@ -343,7 +349,6 @@ typedef struct _XHOSTCONTENT_DATA : _XCONTENT_DATA
std::string szRoot {}; std::string szRoot {};
} XHOSTCONTENT_DATA, *PXHOSTCONTENT_DATA; } XHOSTCONTENT_DATA, *PXHOSTCONTENT_DATA;
#define XCONTENTDEVICETYPE_HDD 1 #define XCONTENTDEVICETYPE_HDD 1
#define XCONTENTDEVICETYPE_MU 2 #define XCONTENTDEVICETYPE_MU 2

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <vector>
#include "xdbf.h" #include "xdbf.h"
#include <vector>
struct Achievement struct Achievement
{ {

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <memory>
#include "xbox.h" #include "xbox.h"
#include <memory>
inline constexpr uint8_t Xex2RetailKey[16] = { 0x20, 0xB1, 0x85, 0xA5, 0x9D, 0x28, 0xFD, 0xC3, 0x40, 0x58, 0x3F, 0xBB, 0x08, 0x96, 0xBF, 0x91 }; inline constexpr uint8_t Xex2RetailKey[16] = { 0x20, 0xB1, 0x85, 0xA5, 0x9D, 0x28, 0xFD, 0xC3, 0x40, 0x58, 0x3F, 0xBB, 0x08, 0x96, 0xBF, 0x91 };
inline constexpr uint8_t AESBlankIV[16] = {}; inline constexpr uint8_t AESBlankIV[16] = {};

@ -18,7 +18,8 @@
struct XexPatcher struct XexPatcher
{ {
enum class Result { enum class Result
{
Success, Success,
FileOpenFailed, FileOpenFailed,
FileWriteFailed, FileWriteFailed,