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

View File

@ -13,10 +13,10 @@ struct Function
{ {
struct Block struct Block
{ {
size_t base{}; size_t base {};
size_t size{}; size_t size {};
size_t projectedSize{ static_cast<size_t>(-1) }; // scratch size_t projectedSize { static_cast<size_t>(-1) }; // scratch
DEBUG(size_t parent{}); DEBUG(size_t parent {});
Block() Block()
{ {
@ -33,9 +33,9 @@ struct Function
} }
}; };
size_t base{}; size_t base {};
size_t size{}; size_t size {};
std::vector<Block> blocks{}; std::vector<Block> blocks {};
Function() Function()
{ {

View File

@ -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>

View File

@ -5,17 +5,17 @@
struct RecompilerLocalVariables struct RecompilerLocalVariables
{ {
bool ctr{}; bool ctr {};
bool xer{}; bool xer {};
bool reserved{}; bool reserved {};
bool cr[8]{}; bool cr[8] {};
bool r[32]{}; bool r[32] {};
bool f[32]{}; bool f[32] {};
bool v[128]{}; bool v[128] {};
bool env{}; bool env {};
bool temp{}; bool temp {};
bool vTemp{}; bool vTemp {};
bool ea{}; bool ea {};
}; };
enum class CSRState enum class CSRState

View File

@ -4,9 +4,9 @@
namespace ppc namespace ppc
{ {
struct DisassemblerEngine struct DisassemblerEngine
{ {
disassemble_info info{}; disassemble_info info {};
DisassemblerEngine(const DisassemblerEngine&) = default; DisassemblerEngine(const DisassemblerEngine&) = default;
DisassemblerEngine& operator=(const DisassemblerEngine&) = delete; DisassemblerEngine& operator=(const DisassemblerEngine&) = delete;
@ -17,19 +17,19 @@ namespace ppc
* \return Numbers of bytes decoded * \return Numbers of bytes decoded
*/ */
int Disassemble(const void* code, size_t size, uint64_t base, ppc_insn& out); int Disassemble(const void* code, size_t size, uint64_t base, ppc_insn& out);
}; };
thread_local extern DisassemblerEngine gBigEndianDisassembler; thread_local extern DisassemblerEngine gBigEndianDisassembler;
static int Disassemble(const void* code, size_t size, uint64_t base, ppc_insn& out) static int Disassemble(const void* code, size_t size, uint64_t base, ppc_insn& out)
{ {
return gBigEndianDisassembler.Disassemble(code, size, base, out); return gBigEndianDisassembler.Disassemble(code, size, base, out);
}
static int Disassemble(const void* code, uint64_t base, ppc_insn& out)
{
return Disassemble(code, 4, base, out);
}
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)
{
return Disassemble(code, 4, base, out);
}
static int Disassemble(const void* code, uint64_t base, ppc_insn* out, size_t nOut);
} // namespace ppc

View File

@ -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)
@ -72,7 +71,7 @@ typedef __s64 Elf64_Sxword;
*/ */
#define PN_XNUM 0xffff #define PN_XNUM 0xffff
/* These constants define the different elf file types */ /* These constants define the different elf file types */
#define ET_NONE 0 #define ET_NONE 0
#define ET_REL 1 #define ET_REL 1
#define ET_EXEC 2 #define ET_EXEC 2
@ -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 */
@ -386,7 +400,7 @@ typedef struct elf64_shdr {
#define NT_PRPSINFO 3 #define NT_PRPSINFO 3
#define NT_TASKSTRUCT 4 #define NT_TASKSTRUCT 4
#define NT_AUXV 6 #define NT_AUXV 6
/* /*
* Note to userspace developers: size of NT_SIGINFO note may increase * Note to userspace developers: size of NT_SIGINFO note may increase
* in the future to accomodate more fields, don't assume it is fixed! * in the future to accomodate more fields, don't assume it is fixed!
*/ */
@ -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 */

View File

@ -18,7 +18,7 @@ inline std::vector<uint8_t> LoadFile(const std::filesystem::path& path)
std::vector<uint8_t> data; std::vector<uint8_t> data;
data.resize(size); data.resize(size);
stream.read((char *)(data.data()), size); stream.read((char*)(data.data()), size);
if (stream.bad()) if (stream.bad())
{ {
return {}; return {};

View File

@ -1,19 +1,19 @@
#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
{ {
std::unique_ptr<uint8_t[]> data{}; std::unique_ptr<uint8_t[]> data {};
size_t base{}; size_t base {};
uint32_t size{}; uint32_t size {};
size_t entry_point{}; size_t entry_point {};
std::set<Section, SectionComparer> sections{}; std::set<Section, SectionComparer> sections {};
SymbolTable symbols{}; SymbolTable symbols {};
/** /**
* \brief Map data to image by RVA * \brief Map data to image by RVA

View File

@ -3,12 +3,13 @@
#include <filesystem> #include <filesystem>
#if defined(_WIN32) #if defined(_WIN32)
# include <Windows.h> #include <Windows.h>
#else #else
# 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;
@ -16,17 +17,17 @@ struct MemoryMappedFile {
LARGE_INTEGER fileSize = {}; LARGE_INTEGER fileSize = {};
#else #else
int fileHandle = -1; int fileHandle = -1;
void *fileView = MAP_FAILED; void* fileView = MAP_FAILED;
off_t fileSize = 0; off_t fileSize = 0;
#endif #endif
MemoryMappedFile(); MemoryMappedFile();
MemoryMappedFile(const std::filesystem::path &path); MemoryMappedFile(const std::filesystem::path& path);
MemoryMappedFile(MemoryMappedFile &&other); MemoryMappedFile(MemoryMappedFile&& other);
~MemoryMappedFile(); ~MemoryMappedFile();
bool open(const std::filesystem::path &path); bool open(const std::filesystem::path& path);
void close(); void close();
bool isOpen() const; bool isOpen() const;
uint8_t *data() const; uint8_t* data() const;
size_t size() const; size_t size() const;
}; };

View File

@ -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
@ -27,7 +27,7 @@
#define PPC_FUNC(x) void x(PPCContext& __restrict ctx, uint8_t* base) #define PPC_FUNC(x) void x(PPCContext& __restrict ctx, uint8_t* base)
#define PPC_FUNC_IMPL(x) extern "C" PPC_FUNC(x) #define PPC_FUNC_IMPL(x) extern "C" PPC_FUNC(x)
#define PPC_EXTERN_FUNC(x) extern PPC_FUNC(x) #define PPC_EXTERN_FUNC(x) extern PPC_FUNC(x)
#define PPC_WEAK_FUNC(x) __attribute__((weak,noinline)) PPC_FUNC(x) #define PPC_WEAK_FUNC(x) __attribute__((weak, noinline)) PPC_FUNC(x)
#define PPC_FUNC_PROLOGUE() __builtin_assume(((size_t)base & 0x1F) == 0) #define PPC_FUNC_PROLOGUE() __builtin_assume(((size_t)base & 0x1F) == 0)
@ -52,7 +52,7 @@
// The fallback would be a runtime exception handler which will intercept reads from MMIO regions // The fallback would be a runtime exception handler which will intercept reads from MMIO regions
// and log the PC for compiling to static code later. // and log the PC for compiling to static code later.
#ifndef PPC_MM_LOAD_U8 #ifndef PPC_MM_LOAD_U8
#define PPC_MM_LOAD_U8(x) PPC_LOAD_U8 (x) #define PPC_MM_LOAD_U8(x) PPC_LOAD_U8(x)
#endif #endif
#ifndef PPC_MM_LOAD_U16 #ifndef PPC_MM_LOAD_U16
@ -86,7 +86,7 @@
// MMIO Store handling is completely reliant on being preeceded by eieio. // MMIO Store handling is completely reliant on being preeceded by eieio.
// TODO: Verify if that's always the case. // TODO: Verify if that's always the case.
#ifndef PPC_MM_STORE_U8 #ifndef PPC_MM_STORE_U8
#define PPC_MM_STORE_U8(x, y) PPC_STORE_U8 (x, y) #define PPC_MM_STORE_U8(x, y) PPC_STORE_U8(x, y)
#endif #endif
#ifndef PPC_MM_STORE_U16 #ifndef PPC_MM_STORE_U16
@ -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));

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <string>
#include <cstdint> #include <cstdint>
#include <string>
enum SectionFlags : uint8_t enum SectionFlags : uint8_t
{ {
@ -11,11 +11,11 @@ enum SectionFlags : uint8_t
struct Section struct Section
{ {
std::string name{}; std::string name {};
size_t base{}; size_t base {};
uint32_t size{}; uint32_t size {};
SectionFlags flags{}; SectionFlags flags {};
uint8_t* data{}; uint8_t* data {};
bool operator<(size_t address) const bool operator<(size_t address) const
{ {

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <string>
#include <cstdint> #include <cstdint>
#include <string>
enum SymbolType enum SymbolType
{ {
@ -12,10 +12,10 @@ enum SymbolType
struct Symbol struct Symbol
{ {
mutable std::string name{}; mutable std::string name {};
size_t address{}; size_t address {};
size_t size{}; size_t size {};
mutable SymbolType type{}; mutable SymbolType type {};
Symbol() Symbol()
{ {

View File

@ -4,7 +4,7 @@
class SymbolTable : public std::multiset<Symbol, SymbolComparer> class SymbolTable : public std::multiset<Symbol, SymbolComparer>
{ {
public: public:
const_iterator find(size_t address) const const_iterator find(size_t address) const
{ {
auto [beginIt, endIt] = equal_range(address); auto [beginIt, endIt] = equal_range(address);
@ -13,7 +13,7 @@ public:
return end(); return end();
} }
size_t closest{ address - beginIt->address }; size_t closest { address - beginIt->address };
auto match = end(); auto match = end();
for (auto it = beginIt; it != endIt; ++it) for (auto it = beginIt; it != endIt; ++it)
{ {
@ -41,7 +41,7 @@ public:
return end(); return end();
} }
size_t closest{ address - beginIt->address }; size_t closest { address - beginIt->address };
auto match = end(); auto match = end();
for (auto it = beginIt; it != endIt; ++it) for (auto it = beginIt; it != endIt; ++it)
{ {

View File

@ -1,12 +1,12 @@
#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>
#endif #endif
// real win32 handles will never use the upper bits unless something goes really wrong // real win32 handles will never use the upper bits unless something goes really wrong
@ -15,7 +15,7 @@
#define HOST_HANDLE(HANDLE) ((HANDLE) & ~0x80000000) #define HOST_HANDLE(HANDLE) ((HANDLE) & ~0x80000000)
// Return true to free the associated memory // Return true to free the associated memory
typedef bool(*TypeDestructor_t)(void*); typedef bool (*TypeDestructor_t)(void*);
template<typename T> template<typename T>
bool DestroyObject(void* obj) bool DestroyObject(void* obj)
@ -71,13 +71,13 @@ struct be
return byteswap(value); return byteswap(value);
} }
be& operator| (T value) be& operator|(T value)
{ {
set(get() | value); set(get() | value);
return *this; return *this;
} }
be& operator& (T value) be& operator&(T value)
{ {
set(get() & value); set(get() & value);
return *this; return *this;
@ -119,7 +119,7 @@ struct xpointer
return reinterpret_cast<T*>(MmGetHostAddress(ptr)); return reinterpret_cast<T*>(MmGetHostAddress(ptr));
} }
operator T* () const operator T*() const
{ {
return get(); return get();
} }
@ -196,7 +196,7 @@ typedef struct _XDISPATCHER_HEADER
be<uint32_t> SignalState; be<uint32_t> SignalState;
XLIST_ENTRY WaitListHead; XLIST_ENTRY WaitListHead;
} XDISPATCHER_HEADER, * XPDISPATCHER_HEADER; } XDISPATCHER_HEADER, *XPDISPATCHER_HEADER;
// These variables are never accessed in guest code, we can safely use them in little endian // These variables are never accessed in guest code, we can safely use them in little endian
typedef struct _XRTL_CRITICAL_SECTION typedef struct _XRTL_CRITICAL_SECTION
@ -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;
@ -274,7 +279,7 @@ typedef struct _XMEMORYSTATUS {
be<uint32_t> dwAvailPageFile; be<uint32_t> dwAvailPageFile;
be<uint32_t> dwTotalVirtual; be<uint32_t> dwTotalVirtual;
be<uint32_t> dwAvailVirtual; be<uint32_t> dwAvailVirtual;
} XMEMORYSTATUS, * XLPMEMORYSTATUS; } XMEMORYSTATUS, *XLPMEMORYSTATUS;
typedef struct _XVIDEO_MODE typedef struct _XVIDEO_MODE
{ {
@ -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;
@ -315,7 +321,7 @@ typedef struct _XTIME_FIELDS
be<uint16_t> Second; be<uint16_t> Second;
be<uint16_t> Milliseconds; be<uint16_t> Milliseconds;
be<uint16_t> Weekday; be<uint16_t> Weekday;
} XTIME_FIELDS, * PXTIME_FIELDS; } XTIME_FIELDS, *PXTIME_FIELDS;
// Content types // Content types
#define XCONTENTTYPE_SAVEDATA 1 #define XCONTENTTYPE_SAVEDATA 1
@ -335,15 +341,14 @@ typedef struct _XCONTENT_DATA
be<uint32_t> dwContentType; be<uint32_t> dwContentType;
be<uint16_t> szDisplayName[XCONTENT_MAX_DISPLAYNAME]; be<uint16_t> szDisplayName[XCONTENT_MAX_DISPLAYNAME];
char szFileName[XCONTENT_MAX_FILENAME]; char szFileName[XCONTENT_MAX_FILENAME];
} XCONTENT_DATA, * PXCONTENT_DATA; } XCONTENT_DATA, *PXCONTENT_DATA;
typedef struct _XHOSTCONTENT_DATA : _XCONTENT_DATA typedef struct _XHOSTCONTENT_DATA : _XCONTENT_DATA
{ {
// This is a host exclusive type so we don't care what goes on // This is a host exclusive type so we don't care what goes on
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
@ -391,7 +396,7 @@ typedef struct _XAMINPUT_VIBRATION
{ {
uint16_t wLeftMotorSpeed; uint16_t wLeftMotorSpeed;
uint16_t wRightMotorSpeed; uint16_t wRightMotorSpeed;
} XAMINPUT_VIBRATION, * PXAMINPUT_VIBRATION; } XAMINPUT_VIBRATION, *PXAMINPUT_VIBRATION;
typedef struct _XAMINPUT_CAPABILITIES typedef struct _XAMINPUT_CAPABILITIES
{ {
@ -400,10 +405,10 @@ typedef struct _XAMINPUT_CAPABILITIES
uint16_t Flags; uint16_t Flags;
XAMINPUT_GAMEPAD Gamepad; XAMINPUT_GAMEPAD Gamepad;
XAMINPUT_VIBRATION Vibration; XAMINPUT_VIBRATION Vibration;
} XAMINPUT_CAPABILITIES, * PXAMINPUT_CAPABILITIES; } XAMINPUT_CAPABILITIES, *PXAMINPUT_CAPABILITIES;
typedef struct _XAMINPUT_STATE typedef struct _XAMINPUT_STATE
{ {
uint32_t dwPacketNumber; uint32_t dwPacketNumber;
XAMINPUT_GAMEPAD Gamepad; XAMINPUT_GAMEPAD Gamepad;
} XAMINPUT_STATE, * PXAMINPUT_STATE; } XAMINPUT_STATE, *PXAMINPUT_STATE;

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <vector>
#include "xdbf.h" #include "xdbf.h"
#include <vector>
struct Achievement struct Achievement
{ {
@ -27,7 +27,7 @@ struct XDBFBlock
class XDBFWrapper class XDBFWrapper
{ {
public: public:
const uint8_t* pBuffer; const uint8_t* pBuffer;
size_t BufferSize; size_t BufferSize;

View File

@ -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] = {};

View File

@ -18,7 +18,8 @@
struct XexPatcher struct XexPatcher
{ {
enum class Result { enum class Result
{
Success, Success,
FileOpenFailed, FileOpenFailed,
FileWriteFailed, FileWriteFailed,
@ -30,6 +31,6 @@ struct XexPatcher
PatchUnsupported PatchUnsupported
}; };
static Result apply(const uint8_t* xexBytes, size_t xexBytesSize, const uint8_t* patchBytes, size_t patchBytesSize, std::vector<uint8_t> &outBytes, bool skipData); static Result apply(const uint8_t* xexBytes, size_t xexBytesSize, const uint8_t* patchBytes, size_t patchBytesSize, std::vector<uint8_t>& outBytes, bool skipData);
static Result apply(const std::filesystem::path &baseXexPath, const std::filesystem::path &patchXexPath, const std::filesystem::path &newXexPath); static Result apply(const std::filesystem::path& baseXexPath, const std::filesystem::path& patchXexPath, const std::filesystem::path& newXexPath);
}; };