diff --git a/PowerRecomp/recompiler.cpp b/PowerRecomp/recompiler.cpp index 365662f..63e2ffb 100644 --- a/PowerRecomp/recompiler.cpp +++ b/PowerRecomp/recompiler.cpp @@ -1765,7 +1765,7 @@ bool Recompiler::Recompile(const Function& fn) if (insn.opcode == nullptr) { println("\t// {}", insn.op_str); -#if 0 +#if 1 if (*(data - 1) != 0) std::println("Unable to decode instruction {:X} at {:X}", *(data - 1), base - 4); #endif diff --git a/PowerRecomp/swa_recompiler.cpp b/PowerRecomp/swa_recompiler.cpp index 7d35d1b..a4dd6bf 100644 --- a/PowerRecomp/swa_recompiler.cpp +++ b/PowerRecomp/swa_recompiler.cpp @@ -163,6 +163,11 @@ void SWARecompiler::Analyse() continue; } + if (*(uint32_t*)data == 0x45564800) + { + break; + } + auto fnSymbol = image.symbols.find(base); if (fnSymbol != image.symbols.end() && fnSymbol->address == base && fnSymbol->type == Symbol_Function) { diff --git a/PowerUtils/image.cpp b/PowerUtils/image.cpp index 5be2475..39136bc 100644 --- a/PowerUtils/image.cpp +++ b/PowerUtils/image.cpp @@ -11,7 +11,7 @@ void Image::Map(const std::string_view& name, size_t base, uint32_t size, uint8_ const void* Image::Find(size_t address) const { - const auto section = sections.find(address); + const auto section = sections.lower_bound(address); if (section == sections.end()) { return nullptr; diff --git a/PowerUtils/section.h b/PowerUtils/section.h index b93cdc8..f245cd6 100644 --- a/PowerUtils/section.h +++ b/PowerUtils/section.h @@ -39,7 +39,7 @@ struct SectionComparer bool operator()(const Section& lhs, size_t rhs) const { - return rhs > lhs.base + lhs.size; + return lhs.base < rhs; } bool operator()(size_t lhs, const Section& rhs) const @@ -49,6 +49,6 @@ struct SectionComparer bool operator()(const Section& lhs, const Section& rhs) const { - return (lhs.base + lhs.size) < rhs.base; + return lhs.base < rhs.base; } }; diff --git a/PowerUtils/xex.cpp b/PowerUtils/xex.cpp index 721c1a4..0083565 100644 --- a/PowerUtils/xex.cpp +++ b/PowerUtils/xex.cpp @@ -101,12 +101,13 @@ Image Xex2LoadImage(const uint8_t* data) auto originalThunk = (XEX_THUNK_DATA*)image.Find(descriptors[im].FirstThunk); auto thunkType = originalThunk->Function >> 24; - if (thunkType == 1) + if (thunkType != 0) { uint32_t thunk[4] = { 0x00000060, 0x00000060, 0x00000060, 0x2000804E }; memcpy(originalThunk, thunk, sizeof(thunk)); } } + library = (XEX_IMPORT_LIBRARY*)((char*)(library + 1) + library->NumberOfImports * sizeof(XEX_IMPORT_DESCRIPTOR)); } }