diff options
| -rw-r--r-- | ReadMe.md | 21 | ||||
| -rw-r--r-- | src/elf_common/elf_reader.h | 3 | ||||
| -rw-r--r-- | src/wiiu/CMakeLists.txt | 73 |
3 files changed, 70 insertions, 27 deletions
@@ -9,24 +9,39 @@ You should use other repositories for the non-Wii U ELF loaders, as this one is ## Installation Copy loader plugins to IDA loaders directory. +On Linux, this is usually: + +```sh +mkdir -p "$HOME/.idapro/loaders" +cp build/wiiu.so "$HOME/.idapro/loaders/" +``` + ## Building ### Dependencies + * IDA SDK * [CMake](https://cmake.org/download/) ### Generate Projects With CMake + The IDA cmake module included will expect to find the IDA SDK in an `IDA_SDK_DIR` or `IDA_SDK` environment variable. + +On Linux, `IDADIR` must point to the IDA installation directory containing `libida.so`. + If you would like to generate 64-bit EA targeted loaders, you need to add `-D IDA_64_BIT_EA_T=YES` to cmake command line. -Navigate to the directory of the loader you would like to build in 'src/', then run the following command +Navigate to the directory of the loader you would like to build in 'src/', then run the following command: `mkdir build && cd build && cmake ../` +On Linux, for the Wii U loader, this will produce `wiiu.so`. + This should create a build directory with your generated project files. ### Building -Optionally, you can also build using cmake with the following command + +Optionally, you can also build using cmake with the following command: `cmake --build ./` @@ -35,3 +50,5 @@ Optionally, you can also build using cmake with the following command The current commit was compiled and tested to work with IDA 9.3. It also comes with improved Wii U RPX/RPL support, including compressed sections, FILE_INFO parsing, import/export metadata, and a broader set of relocations. + +On Linux, the Wii U loader links against the installed IDA runtime library `libida.so`. diff --git a/src/elf_common/elf_reader.h b/src/elf_common/elf_reader.h index 1c6a389..23ab7cd 100644 --- a/src/elf_common/elf_reader.h +++ b/src/elf_common/elf_reader.h @@ -202,9 +202,8 @@ public: void print() { this->printHeader(); - this->printSegment(); + this->printSegments(); this->printSections(); - this->printSymbols(); } bool verifyHeader() { diff --git a/src/wiiu/CMakeLists.txt b/src/wiiu/CMakeLists.txt index 0d723cc..637900c 100644 --- a/src/wiiu/CMakeLists.txt +++ b/src/wiiu/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 3.27) + project(wiiuldr LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) @@ -7,30 +8,43 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(REPO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..") set(ELF_COMMON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../elf_common") -set(IDA_SDK_ROOT "${REPO_ROOT}/third_party/ida-sdk/src") -set(IDA_INCLUDE_DIR "${IDA_SDK_ROOT}/include") -set(IDA_LOADER_DIR "${IDA_SDK_ROOT}/ldr") -set(IDA_LIBRARY "${IDA_SDK_ROOT}/lib/x64_win_64/ida.lib") -if(NOT EXISTS "${IDA_INCLUDE_DIR}/ida.hpp") - message(FATAL_ERROR - "The ida-sdk submodule was not found at ${IDA_SDK_ROOT}. " - "Initialize submodules before configuring this project.") -endif() +list(APPEND CMAKE_MODULE_PATH "${REPO_ROOT}/cmake") -if(NOT EXISTS "${IDA_LIBRARY}") - message(FATAL_ERROR - "The 64-bit Windows IDA import library was not found at ${IDA_LIBRARY}.") -endif() +find_package(IDA) -if(NOT MSVC) - message(FATAL_ERROR "The Wii U loader is configured for Visual Studio/MSVC builds.") +if(NOT IDA_SDK_FOUND) + message(FATAL_ERROR "IDA SDK not found. Set IDA_SDK_DIR or IDA_SDK.") endif() -if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) - message(FATAL_ERROR "Build the Wii U loader with a 64-bit generator (-A x64).") +set(IDA_INSTALL_DIR "$ENV{IDADIR}" CACHE PATH "IDA installation directory") + +if(UNIX AND NOT APPLE) + find_library(IDA_SHARED_LIBRARY + NAMES ida libida.so + PATHS "${IDA_INSTALL_DIR}" + NO_DEFAULT_PATH + ) + + if(NOT IDA_SHARED_LIBRARY) + message(FATAL_ERROR + "libida.so not found. Set IDADIR to your IDA installation directory.") + endif() + + set(IDA_RUNTIME_LIBS "${IDA_SHARED_LIBRARY}") + set(WIIU_LOADER_SUFFIX ".so") +elseif(WIN32) + set(IDA_RUNTIME_LIBS "${IDA_LIBRARIES}") + set(WIIU_LOADER_SUFFIX ".dll") +else() + message(FATAL_ERROR "This CMakeLists currently supports Linux and Windows only.") endif() +message(STATUS "IDA SDK: ${IDA_SDK_PATH}") +message(STATUS "IDA include dir: ${IDA_INCLUDE_DIR}") +message(STATUS "IDA runtime libs: ${IDA_RUNTIME_LIBS}") +message(STATUS "Wii U loader suffix: ${WIIU_LOADER_SUFFIX}") + set(SOURCES "${ELF_COMMON_PATH}/elf_reader.h" "${ELF_COMMON_PATH}/elf.h" @@ -44,20 +58,33 @@ add_library(wiiuldr SHARED ${SOURCES}) target_include_directories(wiiuldr PRIVATE "${IDA_INCLUDE_DIR}" - "${IDA_LOADER_DIR}" + "${IDA_SDK_PATH}/ldr" "${ELF_COMMON_PATH}" ) +set(IDA_COMPILE_DEFS "") +foreach(def ${IDA_DEFINITIONS}) + string(REGEX REPLACE "^-D" "" defname "${def}") + list(APPEND IDA_COMPILE_DEFS "${defname}") +endforeach() + target_compile_definitions(wiiuldr PRIVATE - __IDP__ - __EA64__ + ${IDA_COMPILE_DEFS} ) -target_link_libraries(wiiuldr PRIVATE "${IDA_LIBRARY}") +target_link_libraries(wiiuldr PRIVATE + ${IDA_RUNTIME_LIBS} +) + +if(UNIX AND NOT APPLE) + set_target_properties(wiiuldr PROPERTIES + BUILD_RPATH "${IDA_INSTALL_DIR}" + INSTALL_RPATH "${IDA_INSTALL_DIR}" + ) +endif() set_target_properties(wiiuldr PROPERTIES - MSVC_RUNTIME_LIBRARY "MultiThreadedDLL" OUTPUT_NAME "wiiu" PREFIX "" - SUFFIX ".dll" + SUFFIX "${WIIU_LOADER_SUFFIX}" ) |
