From 0623d4f485c7365aa67be7e981c1ea123e30e843 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Sun, 5 Apr 2020 14:12:17 -0500 Subject: [PATCH] add SEGABOOT_EP_XOR and update GetXbeType to use named value --- src/common/AddressRanges.h | 4 ++++ src/common/xbe/Xbe.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/AddressRanges.h b/src/common/AddressRanges.h index 921524219..3e12cf767 100644 --- a/src/common/AddressRanges.h +++ b/src/common/AddressRanges.h @@ -32,6 +32,7 @@ #define KiB(x) ((x) * 1024 ) // = 0x00000400 #define MiB(x) ((x) * KiB(1024)) // = 0x00100000 +// TODO: Convert the rest of defines to constexpr or const in AddressRanges.h file in master/develop branch. #define USER_ADDRESS1_BASE 0x00010000 #define USER_ADDRESS1_SIZE (MiB(64) - KiB(64)) // = 0x03FF0000 #define USER_ADDRESS1_END (USER_ADDRESS1_BASE + USER_ADDRESS1_SIZE - 1) // 0x03FFFFFF @@ -41,6 +42,9 @@ #define USER_ADDRESS2_END (USER_ADDRESS2_BASE + USER_ADDRESS2_SIZE - 1) // 0x07FFFFFF // Base addresses of various components +// Segaboot entry point xor address +inline const uint32_t SEGABOOT_EP_XOR = 0x40000000; +// Kernel Segment Zero #define KSEG0_BASE 0x80000000 #define PHYSICAL_MAP_BASE 0x80000000 diff --git a/src/common/xbe/Xbe.cpp b/src/common/xbe/Xbe.cpp index eb93f91ee..b6788c962 100644 --- a/src/common/xbe/Xbe.cpp +++ b/src/common/xbe/Xbe.cpp @@ -815,12 +815,12 @@ XbeType Xbe::GetXbeType() { // Detect if the XBE is for Chihiro (Untested!) : // This is based on https://github.com/radare/radare2/blob/master/libr/bin/p/bin_xbe.c#L45 - if ((m_Header.dwEntryAddr & 0xf0000000) == 0x40000000) + if ((m_Header.dwEntryAddr & XBOX_WRITE_COMBINED_BASE) == SEGABOOT_EP_XOR) return XbeType::xtChihiro; // Check for Debug XBE, using high bit of the kernel thunk address : // (DO NOT test like https://github.com/radare/radare2/blob/master/libr/bin/p/bin_xbe.c#L49 !) - if ((m_Header.dwKernelImageThunkAddr & 0x80000000) > 0) + if ((m_Header.dwKernelImageThunkAddr & KSEG0_BASE) > 0) return XbeType::xtDebug; // Otherwise, the XBE is a Retail build :