mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-06-06 01:02:08 +00:00
clang-format Workflow
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
This commit is contained in:
parent
7b8e37aa37
commit
10b627e986
17
.clang-format
Normal file
17
.clang-format
Normal file
@ -0,0 +1,17 @@
|
||||
BasedOnStyle: LLVM
|
||||
UseTab: Never
|
||||
IndentWidth: 4
|
||||
Language: Cpp
|
||||
DerivePointerAlignment: false
|
||||
PointerAlignment: Left
|
||||
BreakBeforeBraces: Allman
|
||||
LineEnding: LF
|
||||
ColumnLimit: 0
|
||||
IndentCaseLabels: false
|
||||
InsertNewlineAtEOF: true
|
||||
Cpp11BracedListStyle: false
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
AlignAfterOpenBracket: DontAlign
|
||||
ContinuationIndentWidth: 4
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
SpaceAfterTemplateKeyword: false
|
25
.github/workflows/format.yml
vendored
Normal file
25
.github/workflows/format.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
name: Clang Format
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- "**/*.md"
|
||||
- '**/*.txt'
|
||||
- 'thirdparty/*'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- "**/*.md"
|
||||
- '**/*.txt'
|
||||
- 'thirdparty/*'
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Run clang-format
|
||||
uses: jidicula/clang-format-action@v4.14.0
|
||||
with:
|
||||
exclude-regex: (thirdparty)
|
||||
clang-format-version: 19
|
@ -1,10 +1,10 @@
|
||||
#include "function.h"
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
#include <byteswap.h>
|
||||
#include <cassert>
|
||||
#include <disasm.h>
|
||||
#include <vector>
|
||||
#include <bit>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <byteswap.h>
|
||||
|
||||
size_t Function::SearchBlock(size_t address) const
|
||||
{
|
||||
@ -59,7 +59,9 @@ Function Function::Analyze(const void* code, size_t size, size_t base)
|
||||
blockStack.reserve(32);
|
||||
blockStack.emplace_back();
|
||||
|
||||
#define RESTORE_DATA() if (!blockStack.empty()) data = (dataStart + ((blocks[blockStack.back()].base + blocks[blockStack.back()].size) / sizeof(*data))) - 1; // continue adds one
|
||||
#define RESTORE_DATA() \
|
||||
if (!blockStack.empty()) \
|
||||
data = (dataStart + ((blocks[blockStack.back()].base + blocks[blockStack.back()].size) / sizeof(*data))) - 1; // continue adds one
|
||||
|
||||
// TODO: Branch fallthrough
|
||||
for (; data <= dataEnd; ++data)
|
||||
@ -214,9 +216,7 @@ Function Function::Analyze(const void* code, size_t size, size_t base)
|
||||
if (blocks.size() > 1)
|
||||
{
|
||||
std::sort(blocks.begin(), blocks.end(), [](const Block& a, const Block& b)
|
||||
{
|
||||
return a.base < b.base;
|
||||
});
|
||||
{ return a.base < b.base; });
|
||||
|
||||
size_t discontinuity = -1;
|
||||
for (size_t i = 0; i < blocks.size() - 1; i++)
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <file.h>
|
||||
#include <disasm.h>
|
||||
#include <image.h>
|
||||
#include <xbox.h>
|
||||
#include <fmt/core.h>
|
||||
#include "function.h"
|
||||
#include <cassert>
|
||||
#include <disasm.h>
|
||||
#include <file.h>
|
||||
#include <fmt/core.h>
|
||||
#include <image.h>
|
||||
#include <iterator>
|
||||
#include <xbox.h>
|
||||
|
||||
#define SWITCH_ABSOLUTE 0
|
||||
#define SWITCH_COMPUTED 1
|
||||
@ -250,8 +250,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
};
|
||||
|
||||
uint32_t absoluteSwitch[] =
|
||||
{
|
||||
uint32_t absoluteSwitch[] = {
|
||||
PPC_INST_LIS,
|
||||
PPC_INST_ADDI,
|
||||
PPC_INST_RLWINM,
|
||||
@ -260,8 +259,7 @@ int main(int argc, char** argv)
|
||||
PPC_INST_BCTR,
|
||||
};
|
||||
|
||||
uint32_t computedSwitch[] =
|
||||
{
|
||||
uint32_t computedSwitch[] = {
|
||||
PPC_INST_LIS,
|
||||
PPC_INST_ADDI,
|
||||
PPC_INST_LBZX,
|
||||
@ -272,8 +270,7 @@ int main(int argc, char** argv)
|
||||
PPC_INST_MTCTR,
|
||||
};
|
||||
|
||||
uint32_t offsetSwitch[] =
|
||||
{
|
||||
uint32_t offsetSwitch[] = {
|
||||
PPC_INST_LIS,
|
||||
PPC_INST_ADDI,
|
||||
PPC_INST_LBZX,
|
||||
@ -283,8 +280,7 @@ int main(int argc, char** argv)
|
||||
PPC_INST_MTCTR,
|
||||
};
|
||||
|
||||
uint32_t wordOffsetSwitch[] =
|
||||
{
|
||||
uint32_t wordOffsetSwitch[] = {
|
||||
PPC_INST_LIS,
|
||||
PPC_INST_ADDI,
|
||||
PPC_INST_RLWINM,
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "pch.h"
|
||||
#include "recompiler.h"
|
||||
#include "pch.h"
|
||||
#include <xex_patcher.h>
|
||||
|
||||
static uint64_t ComputeMask(uint32_t mstart, uint32_t mstop)
|
||||
@ -251,7 +251,8 @@ void Recompiler::Analyse()
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(functions.begin(), functions.end(), [](auto& lhs, auto& rhs) { return lhs.base < rhs.base; });
|
||||
std::sort(functions.begin(), functions.end(), [](auto& lhs, auto& rhs)
|
||||
{ return lhs.base < rhs.base; });
|
||||
}
|
||||
|
||||
bool Recompiler::Recompile(
|
||||
@ -519,8 +520,10 @@ bool Recompiler::Recompile(
|
||||
int id = insn.opcode->id;
|
||||
|
||||
// Handling instructions that don't disassemble correctly for some reason here
|
||||
if (id == PPC_INST_VUPKHSB128 && insn.operands[2] == 0x60) id = PPC_INST_VUPKHSH128;
|
||||
else if (id == PPC_INST_VUPKLSB128 && insn.operands[2] == 0x60) id = PPC_INST_VUPKLSH128;
|
||||
if (id == PPC_INST_VUPKHSB128 && insn.operands[2] == 0x60)
|
||||
id = PPC_INST_VUPKHSH128;
|
||||
else if (id == PPC_INST_VUPKLSB128 && insn.operands[2] == 0x60)
|
||||
id = PPC_INST_VUPKLSH128;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
|
@ -38,14 +38,22 @@ void RecompilerConfig::Load(const std::string_view& configFilePath)
|
||||
longJmpAddress = main["longjmp_address"].value_or(0u);
|
||||
setJmpAddress = main["setjmp_address"].value_or(0u);
|
||||
|
||||
if (restGpr14Address == 0) fmt::println("ERROR: __restgprlr_14 address is unspecified");
|
||||
if (saveGpr14Address == 0) fmt::println("ERROR: __savegprlr_14 address is unspecified");
|
||||
if (restFpr14Address == 0) fmt::println("ERROR: __restfpr_14 address is unspecified");
|
||||
if (saveFpr14Address == 0) fmt::println("ERROR: __savefpr_14 address is unspecified");
|
||||
if (restVmx14Address == 0) fmt::println("ERROR: __restvmx_14 address is unspecified");
|
||||
if (saveVmx14Address == 0) fmt::println("ERROR: __savevmx_14 address is unspecified");
|
||||
if (restVmx64Address == 0) fmt::println("ERROR: __restvmx_64 address is unspecified");
|
||||
if (saveVmx64Address == 0) fmt::println("ERROR: __savevmx_64 address is unspecified");
|
||||
if (restGpr14Address == 0)
|
||||
fmt::println("ERROR: __restgprlr_14 address is unspecified");
|
||||
if (saveGpr14Address == 0)
|
||||
fmt::println("ERROR: __savegprlr_14 address is unspecified");
|
||||
if (restFpr14Address == 0)
|
||||
fmt::println("ERROR: __restfpr_14 address is unspecified");
|
||||
if (saveFpr14Address == 0)
|
||||
fmt::println("ERROR: __savefpr_14 address is unspecified");
|
||||
if (restVmx14Address == 0)
|
||||
fmt::println("ERROR: __restvmx_14 address is unspecified");
|
||||
if (saveVmx14Address == 0)
|
||||
fmt::println("ERROR: __savevmx_14 address is unspecified");
|
||||
if (restVmx64Address == 0)
|
||||
fmt::println("ERROR: __restvmx_64 address is unspecified");
|
||||
if (saveVmx64Address == 0)
|
||||
fmt::println("ERROR: __savevmx_64 address is unspecified");
|
||||
|
||||
if (auto functionsArray = main["functions"].as_array())
|
||||
{
|
||||
|
@ -29,7 +29,8 @@ void TestRecompiler::Analyse(const std::string_view& testName)
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(functions.begin(), functions.end(), [](auto& lhs, auto& rhs) { return lhs.base < rhs.base; });
|
||||
std::sort(functions.begin(), functions.end(), [](auto& lhs, auto& rhs)
|
||||
{ return lhs.base < rhs.base; });
|
||||
}
|
||||
|
||||
void TestRecompiler::RecompileTests(const char* srcDirectoryPath, const char* dstDirectoryPath)
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "memory_mapped_file.h"
|
||||
|
||||
#if !defined(_WIN32)
|
||||
# include <cstring>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
@ -1,17 +1,18 @@
|
||||
#include "xex.h"
|
||||
#include "image.h"
|
||||
#include <aes.hpp>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <aes.hpp>
|
||||
#include <vector>
|
||||
|
||||
#define STRINGIFY(X) #X
|
||||
#define XE_EXPORT(MODULE, ORDINAL, NAME, TYPE) { (ORDINAL), "__imp__" STRINGIFY(NAME) }
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
typedef struct _IMAGE_DOS_HEADER {
|
||||
typedef struct _IMAGE_DOS_HEADER
|
||||
{
|
||||
uint16_t e_magic;
|
||||
uint16_t e_cblp;
|
||||
uint16_t e_cp;
|
||||
@ -33,7 +34,8 @@ typedef struct _IMAGE_DOS_HEADER {
|
||||
uint32_t e_lfanew;
|
||||
} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
|
||||
|
||||
typedef struct _IMAGE_FILE_HEADER {
|
||||
typedef struct _IMAGE_FILE_HEADER
|
||||
{
|
||||
uint16_t Machine;
|
||||
uint16_t NumberOfSections;
|
||||
uint32_t TimeDateStamp;
|
||||
@ -43,14 +45,16 @@ typedef struct _IMAGE_FILE_HEADER {
|
||||
uint16_t Characteristics;
|
||||
} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
|
||||
|
||||
typedef struct _IMAGE_DATA_DIRECTORY {
|
||||
typedef struct _IMAGE_DATA_DIRECTORY
|
||||
{
|
||||
uint32_t VirtualAddress;
|
||||
uint32_t Size;
|
||||
} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
|
||||
|
||||
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
|
||||
|
||||
typedef struct _IMAGE_OPTIONAL_HEADER {
|
||||
typedef struct _IMAGE_OPTIONAL_HEADER
|
||||
{
|
||||
uint16_t Magic;
|
||||
uint8_t MajorLinkerVersion;
|
||||
uint8_t MinorLinkerVersion;
|
||||
@ -84,7 +88,8 @@ typedef struct _IMAGE_OPTIONAL_HEADER {
|
||||
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
|
||||
} IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
|
||||
|
||||
typedef struct _IMAGE_NT_HEADERS {
|
||||
typedef struct _IMAGE_NT_HEADERS
|
||||
{
|
||||
uint32_t Signature;
|
||||
IMAGE_FILE_HEADER FileHeader;
|
||||
IMAGE_OPTIONAL_HEADER32 OptionalHeader;
|
||||
@ -92,9 +97,11 @@ typedef struct _IMAGE_NT_HEADERS {
|
||||
|
||||
#define IMAGE_SIZEOF_SHORT_NAME 8
|
||||
|
||||
typedef struct _IMAGE_SECTION_HEADER {
|
||||
typedef struct _IMAGE_SECTION_HEADER
|
||||
{
|
||||
uint8_t Name[IMAGE_SIZEOF_SHORT_NAME];
|
||||
union {
|
||||
union
|
||||
{
|
||||
uint32_t PhysicalAddress;
|
||||
uint32_t VirtualSize;
|
||||
} Misc;
|
||||
@ -112,13 +119,11 @@ typedef struct _IMAGE_SECTION_HEADER {
|
||||
|
||||
#endif
|
||||
|
||||
std::unordered_map<size_t, const char*> XamExports =
|
||||
{
|
||||
std::unordered_map<size_t, const char*> XamExports = {
|
||||
#include "xbox/xam_table.inc"
|
||||
};
|
||||
|
||||
std::unordered_map<size_t, const char*> XboxKernelExports =
|
||||
{
|
||||
std::unordered_map<size_t, const char*> XboxKernelExports = {
|
||||
#include "xbox/xboxkrnl_table.inc"
|
||||
};
|
||||
|
||||
|
@ -17,10 +17,10 @@
|
||||
#include <climits>
|
||||
#include <fstream>
|
||||
|
||||
#include <TinySHA1.hpp>
|
||||
#include <aes.hpp>
|
||||
#include <lzx.h>
|
||||
#include <mspack.h>
|
||||
#include <TinySHA1.hpp>
|
||||
|
||||
#include "memory_mapped_file.h"
|
||||
|
||||
@ -145,7 +145,8 @@ static int lzxDecompress(const void *lzxData, size_t lzxLength, void *dst, size_
|
||||
{
|
||||
int resultCode = 1;
|
||||
uint32_t windowBits;
|
||||
if (!bitScanForward(windowSize, &windowBits)) {
|
||||
if (!bitScanForward(windowSize, &windowBits))
|
||||
{
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
@ -153,8 +154,10 @@ static int lzxDecompress(const void *lzxData, size_t lzxLength, void *dst, size_
|
||||
mspack_memory_file* lzxSrc = mspack_memory_open(sys, (void*)(lzxData), lzxLength);
|
||||
mspack_memory_file* lzxDst = mspack_memory_open(sys, dst, dstLength);
|
||||
lzxd_stream* lzxd = lzxd_init(sys, (mspack_file*)(lzxSrc), (mspack_file*)(lzxDst), windowBits, 0, 0x8000, dstLength, 0);
|
||||
if (lzxd != nullptr) {
|
||||
if (windowData != nullptr) {
|
||||
if (lzxd != nullptr)
|
||||
{
|
||||
if (windowData != nullptr)
|
||||
{
|
||||
size_t paddingLength = windowSize - windowDataLength;
|
||||
std::memset(&lzxd->window[0], 0, paddingLength);
|
||||
std::memcpy(&lzxd->window[paddingLength], windowData, windowDataLength);
|
||||
@ -165,15 +168,18 @@ static int lzxDecompress(const void *lzxData, size_t lzxLength, void *dst, size_
|
||||
lzxd_free(lzxd);
|
||||
}
|
||||
|
||||
if (lzxSrc) {
|
||||
if (lzxSrc)
|
||||
{
|
||||
mspack_memory_close(lzxSrc);
|
||||
}
|
||||
|
||||
if (lzxDst) {
|
||||
if (lzxDst)
|
||||
{
|
||||
mspack_memory_close(lzxDst);
|
||||
}
|
||||
|
||||
if (sys) {
|
||||
if (sys)
|
||||
{
|
||||
mspack_memory_sys_destroy(sys);
|
||||
}
|
||||
|
||||
@ -381,7 +387,8 @@ XexPatcher::Result XexPatcher::apply(const uint8_t* xexBytes, size_t xexBytesSiz
|
||||
int32_t numBlocks = (fileFormatInfo->infoSize / sizeof(Xex2FileBasicCompressionBlock)) - 1;
|
||||
int32_t baseCompressedSize = 0;
|
||||
int32_t baseImageSize = 0;
|
||||
for (int32_t i = 0; i < numBlocks; i++) {
|
||||
for (int32_t i = 0; i < numBlocks; i++)
|
||||
{
|
||||
baseCompressedSize += blocks[i].dataSize;
|
||||
baseImageSize += blocks[i].dataSize + blocks[i].zeroSize;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user