├── .version ├── dep_root ├── .keep ├── lib │ └── .keep └── include │ └── .keep ├── README.md ├── .github └── workflows │ ├── linux-post.sh │ ├── mac-post.sh │ ├── linux-build.sh │ ├── linux-bootstrap.sh │ ├── mac-bootstrap.sh │ ├── mac-build.sh │ └── ci.yml ├── .gitignore ├── CMakeLists.txt └── src └── main.cpp /.version: -------------------------------------------------------------------------------- 1 | 27 2 | -------------------------------------------------------------------------------- /dep_root/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dep_root/lib/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dep_root/include/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iBoot64Patcher 2 | [![CI Building](https://img.shields.io/github/actions/workflow/status/Cryptiiiic/iBoot64Patcher/ci.yml?branch=main&style=for-the-badge)](https://github.com/Cryptiiiic/iBoot64Patcher/actions) 3 | ## Fork of [tihmstar/iBoot64Patcher](https://github.com/tihmstar/iBoot64Patcher) 4 | -------------------------------------------------------------------------------- /.github/workflows/linux-post.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | export TMPDIR=/tmp 5 | export WORKFLOW_ROOT=${TMPDIR}/Builder/repos/iBoot64Patcher/.github/workflows 6 | export DEP_ROOT=${TMPDIR}/Builder/repos/iBoot64Patcher/dep_root 7 | export BASE=${TMPDIR}/Builder/repos/iBoot64Patcher/ 8 | 9 | cd ${BASE} 10 | export iBoot64Patcher_VERSION=$(git rev-list --count HEAD | tr -d '\n') 11 | cd ${WORKFLOW_ROOT} 12 | echo "iBoot64Patcher-Linux-x86_64-Build_${iBoot64Patcher_VERSION}-RELEASE.tar.xz" > name1.txt 13 | echo "iBoot64Patcher-Linux-x86_64-Build_${iBoot64Patcher_VERSION}-DEBUG.tar.xz" > name2.txt 14 | cp -RpP "${BASE}/cmake-build-release-x86_64/iBoot64Patcher" iBoot64Patcher 15 | tar cpPJvf "iBoot64Patcher1.tar.xz" iBoot64Patcher 16 | cp -RpP "${BASE}/cmake-build-debug-x86_64/iBoot64Patcher" iBoot64Patcher 17 | tar cpPJvf "iBoot64Patcher2.tar.xz" iBoot64Patcher 18 | -------------------------------------------------------------------------------- /.github/workflows/mac-post.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | set -e 4 | export WORKFLOW_ROOT=/Users/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows 5 | export DEP_ROOT=/Users/runner/work/iBoot64Patcher/iBoot64Patcher/dep_root 6 | export BASE=/Users/runner/work/iBoot64Patcher/iBoot64Patcher/ 7 | 8 | cd ${BASE} 9 | export iBoot64Patcher_VERSION=$(git rev-list --count HEAD | tr -d '\n') 10 | export iBoot64Patcher_VERSION_SHA=$(git rev-parse HEAD | tr -d '\n') 11 | echo -n $iBoot64Patcher_VERSION_SHA > latest_build_sha.txt 12 | echo -n $iBoot64Patcher_VERSION > latest_build_num.txt 13 | tar cpPJf "iBoot64Patcher-macOS-x86_64-Build_${iBoot64Patcher_VERSION}-RELEASE.tar.xz" -C cmake-build-release-x86_64 iBoot64Patcher 14 | tar cpPJf "iBoot64Patcher-macOS-x86_64-Build_${iBoot64Patcher_VERSION}-DEBUG.tar.xz" -C cmake-build-debug-x86_64 iBoot64Patcher 15 | tar cpPJf "iBoot64Patcher-macOS-arm64-Build_${iBoot64Patcher_VERSION}-RELEASE.tar.xz" -C cmake-build-release-arm64 iBoot64Patcher 16 | tar cpPJf "iBoot64Patcher-macOS-arm64-Build_${iBoot64Patcher_VERSION}-DEBUG.tar.xz" -C cmake-build-debug-arm64 iBoot64Patcher 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | !dep_root/include 2 | !dep_root/include/.keep 3 | !dep_root/lib 4 | !dep_root/lib/.keep 5 | *.DS_Store 6 | *.[oa] 7 | *.a 8 | *.diff 9 | *.in 10 | *.la 11 | *.lo 12 | *.o 13 | *.patch 14 | *.pc 15 | *.po 16 | *.so 17 | *.swp 18 | *.xcworkspace 19 | */.deps 20 | */.deps/* 21 | */.libs 22 | */all.h* 23 | */futurerestore* 24 | */tsschecker* 25 | *Makefile 26 | *Makefile.in 27 | *~ 28 | .DS_Store 29 | .build_complete 30 | .deps 31 | .idea 32 | .libs 33 | .vscode 34 | Build 35 | CMakeCache.txt 36 | CMakeFiles 37 | Index 38 | Makefile 39 | Makefile.in 40 | aclocal.m4 41 | autom4te.cache 42 | autom4te.cache/ 43 | autom4te.cache/* 44 | build 45 | cmake-build-debug 46 | cmake-build-debug* 47 | cmake-build-release 48 | cmake-build-release* 49 | cmake_install.cmake 50 | compile 51 | config.* 52 | config.guess 53 | config.h 54 | config.h.in 55 | config.log 56 | config.status 57 | config.sub 58 | configure 59 | configure~ 60 | dep_root/* 61 | dep_root/include/* 62 | dep_root/lib/* 63 | depcomp 64 | install-sh 65 | liboffsetfinder64.pc 66 | libtool 67 | ltmain.sh 68 | m4 69 | m4/ 70 | m4/* 71 | main 72 | missing 73 | mkinstalldirs 74 | py-compile 75 | src/.libs 76 | src/iBoot64Patcher 77 | src/idevicerestore 78 | stamp-h1 79 | stamp-h2 80 | swig/* 81 | test-driver 82 | xcuserdata 83 | *.zst 84 | -------------------------------------------------------------------------------- /.github/workflows/linux-build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | export TMPDIR=/tmp 5 | export WORKFLOW_ROOT=${TMPDIR}/Builder/repos/iBoot64Patcher/.github/workflows 6 | export DEP_ROOT=${TMPDIR}/Builder/repos/iBoot64Patcher/dep_root 7 | export BASE=${TMPDIR}/Builder/repos/iBoot64Patcher/ 8 | 9 | cd ${BASE} 10 | rm -rf ${DEP_ROOT}/{lib,include} || true 11 | ln -sf ${DEP_ROOT}/Linux_x86_64_Release/{lib/,include/} ${DEP_ROOT}/ 12 | cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -DCMAKE_CXX_COMPILER=$(which clang++) -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-release-x86_64 -DARCH=x86_64 -DCMAKE_C_COMPILER=clang-13 -DCMAKE_CXX_COMPILER=clang++-13 -DCMAKE_LINKER=ld.lld-13 -DNO_PKGCFG=1 13 | make -j4 -l4 -C cmake-build-release-x86_64 14 | 15 | cd ${BASE} 16 | ln -sf ${DEP_ROOT}/Linux_x86_64_Debug/{lib/,include/} ${DEP_ROOT}/ 17 | cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=$(which make) -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-debug-x86_64 -DARCH=x86_64 -DCMAKE_C_COMPILER=clang-13 -DCMAKE_CXX_COMPILER=clang++-13 -DCMAKE_LINKER=ld.lld-13 -DNO_PKGCFG=1 18 | make -j4 -l4 -C cmake-build-debug-x86_64 19 | llvm-strip-13 -s cmake-build-release-x86_64/iBoot64Patcher 20 | -------------------------------------------------------------------------------- /.github/workflows/linux-bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | export TMPDIR=/tmp 5 | export WORKFLOW_ROOT=${TMPDIR}/Builder/repos/iBoot64Patcher/.github/workflows 6 | export DEP_ROOT=${TMPDIR}/Builder/repos/iBoot64Patcher/dep_root 7 | export BASE=${TMPDIR}/Builder/repos/iBoot64Patcher/ 8 | 9 | #sed -i 's/deb\.debian\.org/ftp.de.debian.org/g' /etc/apt/sources.list 10 | apt-get -qq update 11 | apt-get -yqq dist-upgrade 12 | apt-get install --no-install-recommends -yqq zstd curl gnupg2 lsb-release wget software-properties-common build-essential git autoconf automake libtool-bin pkg-config cmake zlib1g-dev libminizip-dev libpng-dev libreadline-dev libbz2-dev libudev-dev libudev1 13 | cp -RpP /usr/bin/ld / 14 | rm -rf /usr/bin/ld /usr/lib/x86_64-linux-gnu/lib{usb-1.0,png*,readline}.so* 15 | cd ${WORKFLOW_ROOT} 16 | curl -sO https://apt.llvm.org/llvm.sh 17 | chmod +x llvm.sh 18 | ./llvm.sh 13 all 19 | ln -sf /usr/bin/ld.lld-13 /usr/bin/ld 20 | curl -sO https://cdn.cryptiiiic.com/deps/static/Linux/x86_64/Linux_x86_64_Release_Latest.tar.zst & 21 | curl -sO https://cdn.cryptiiiic.com/deps/static/Linux/x86_64/Linux_x86_64_Debug_Latest.tar.zst & 22 | curl -sLO https://github.com/Kitware/CMake/releases/download/v3.23.2/cmake-3.23.2-linux-x86_64.tar.gz & 23 | wait 24 | mkdir -p ${DEP_ROOT}/Linux_x86_64_{Release,Debug} 25 | tar xf Linux_x86_64_Release_Latest.tar.zst -C ${DEP_ROOT}/Linux_x86_64_Release & 26 | tar xf Linux_x86_64_Debug_Latest.tar.zst -C ${DEP_ROOT}/Linux_x86_64_Debug & 27 | tar xf cmake-3.23.2-linux-x86_64.tar.gz 28 | cp -RpP cmake-3.23.2-linux-x86_64/* /usr/local/ || true 29 | wait 30 | rm -rf "*.zst" 31 | cd ${WORKFLOW_ROOT} 32 | -------------------------------------------------------------------------------- /.github/workflows/mac-bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | set -e 4 | export WORKFLOW_ROOT=/Users/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows 5 | export DEP_ROOT=/Users/runner/work/iBoot64Patcher/iBoot64Patcher/dep_root 6 | export BASE=/Users/runner/work/iBoot64Patcher/iBoot64Patcher/ 7 | 8 | cd ${WORKFLOW_ROOT} 9 | curl -sO https://cdn.cryptiiiic.com/bootstrap/bootstrap_x86_64.tar.zst & 10 | # curl -sO https://cdn.cryptiiiic.com/bootstrap/Builder_macOS.tar.zst & 11 | curl -sO https://cdn.cryptiiiic.com/deps/static/macOS/x86_64/macOS_x86_64_Release_Latest.tar.zst & 12 | curl -sO https://cdn.cryptiiiic.com/deps/static/macOS/arm64/macOS_arm64_Release_Latest.tar.zst & 13 | curl -sO https://cdn.cryptiiiic.com/deps/static/macOS/x86_64/macOS_x86_64_Debug_Latest.tar.zst & 14 | curl -sO https://cdn.cryptiiiic.com/deps/static/macOS/arm64/macOS_arm64_Debug_Latest.tar.zst & 15 | wait 16 | sudo gtar xf ${WORKFLOW_ROOT}/bootstrap_x86_64.tar.zst -C / --warning=none || true || true & 17 | echo "${PROCURSUS}/bin" | sudo tee /etc/paths1 18 | echo "${PROCURSUS}/libexec/gnubin" | sudo tee /etc/paths1 19 | cat /etc/paths | sudo tee -a /etc/paths1 20 | sudo mv /etc/paths{1,} 21 | wait 22 | mkdir -p ${DEP_ROOT}/macOS_x86_64_Release ${DEP_ROOT}/macOS_x86_64_Debug ${DEP_ROOT}/macOS_arm64_Release ${DEP_ROOT}/macOS_arm64_Debug 23 | gtar xf macOS_x86_64_Release_Latest.tar.zst -C ${DEP_ROOT}/macOS_x86_64_Release & 24 | gtar xf macOS_x86_64_Debug_Latest.tar.zst -C ${DEP_ROOT}/macOS_x86_64_Debug & 25 | gtar xf macOS_arm64_Release_Latest.tar.zst -C ${DEP_ROOT}/macOS_arm64_Release & 26 | gtar xf macOS_arm64_Debug_Latest.tar.zst -C ${DEP_ROOT}/macOS_arm64_Debug & 27 | wait 28 | # gtar xf ${BASE}/Builder_macOS.tar.zst & 29 | sudo ${PROCURSUS}/bin/apt-get update -qq 30 | sudo ${PROCURSUS}/bin/apt-get install llvm-utils -yqq 31 | sudo mv /usr/local/bin{,1} 32 | -------------------------------------------------------------------------------- /.github/workflows/mac-build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | set -e 4 | export WORKFLOW_ROOT=/Users/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows 5 | export DEP_ROOT=/Users/runner/work/iBoot64Patcher/iBoot64Patcher/dep_root 6 | export BASE=/Users/runner/work/iBoot64Patcher/iBoot64Patcher/ 7 | export CC="$(xcrun --find clang)" 8 | export CXX="$(xcrun --find clang++)" 9 | 10 | cd /Users/runner/work/iBoot64Patcher/iBoot64Patcher/ 11 | rm -rf ${DEP_ROOT}/{lib,include} 12 | ln -sf ${DEP_ROOT}/macOS_x86_64_Release/{lib/,include/} ${DEP_ROOT}/ 13 | cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM="$(which make)" -DCMAKE_C_COMPILER="${CC}" -DCMAKE_CXX_COMPILER="${CXX}" -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-release-x86_64 -DARCH=x86_64 -DNO_PKGCFG=1 14 | make -j4 -l4 -C cmake-build-release-x86_64 15 | 16 | ln -sf ${DEP_ROOT}/macOS_x86_64_Debug/{lib/,include/} ${DEP_ROOT}/ 17 | cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM="$(which make)" -DCMAKE_C_COMPILER="${CC}" -DCMAKE_CXX_COMPILER="${CXX}" -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-debug-x86_64 -DARCH=x86_64 -DNO_PKGCFG=1 18 | make -j4 -l4 -C cmake-build-debug-x86_64 19 | 20 | ln -sf ${DEP_ROOT}/macOS_arm64_Release/{lib/,include/} ${DEP_ROOT}/ 21 | cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM="$(which make)" -DCMAKE_C_COMPILER="${CC}" -DCMAKE_CXX_COMPILER="${CXX}" -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-release-arm64 -DARCH=arm64 -DNO_PKGCFG=1 22 | make -j4 -l4 -C cmake-build-release-arm64 23 | 24 | ln -sf ${DEP_ROOT}/macOS_arm64_Debug/{lib/,include/} ${DEP_ROOT}/ 25 | cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM="$(which make)" -DCMAKE_C_COMPILER="${CC}" -DCMAKE_CXX_COMPILER="${CXX}" -DCMAKE_MESSAGE_LOG_LEVEL="WARNING" -G "CodeBlocks - Unix Makefiles" -S ./ -B cmake-build-debug-arm64 -DARCH=arm64 -DNO_PKGCFG=1 26 | make -j4 -l4 -C cmake-build-debug-arm64 27 | llvm-strip -s cmake-build-release-x86_64/iBoot64Patcher 28 | llvm-strip -s cmake-build-release-arm64/iBoot64Patcher 29 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22) 2 | set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG") 3 | set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG") 4 | set(CMAKE_C_FLAGS_DEBUG "-g -O0 -DDEBUG") 5 | set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -DDEBUG") 6 | set(CMAKE_C_STANDARD 17) 7 | set(CMAKE_CXX_STANDARD 20) 8 | set(ignoreMe "${NO_PKGCFG}") 9 | project(iBoot64Patcher) 10 | if("${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Darwin") 11 | if(NOT DEFINED NO_XCODE AND NOT DEFINED ENV{NO_XCODE}) 12 | execute_process(COMMAND xcrun --find clang WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE CC OUTPUT_STRIP_TRAILING_WHITESPACE) 13 | execute_process(COMMAND xcrun --find clang++ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE CXX OUTPUT_STRIP_TRAILING_WHITESPACE) 14 | execute_process(COMMAND xcrun --find ar WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE AR OUTPUT_STRIP_TRAILING_WHITESPACE) 15 | execute_process(COMMAND xcrun --find ld WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE LD OUTPUT_STRIP_TRAILING_WHITESPACE) 16 | execute_process(COMMAND xcrun --show-sdk-path WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE SYSROOT OUTPUT_STRIP_TRAILING_WHITESPACE) 17 | set(CMAKE_C_COMPILER "${CC}") 18 | set(CMAKE_CXX_COMPILER "${CXX}") 19 | endif() 20 | if(NOT DEFINED ARCH) 21 | set(ARCH "$ENV{ARCH}") 22 | if(ARCH STREQUAL "") 23 | set(ARCH "${CMAKE_SYSTEM_PROCESSOR}") 24 | endif() 25 | endif() 26 | if(NOT DEFINED MINVER OR NOT DEFINED "$ENV{MINVER}" AND DEFINED NO_PKGCFG OR "$ENV{NO_PKGCFG}" MATCHES "1") 27 | if("${ARCH}" STREQUAL "x86_64" OR "$ENV{ARCH}" STREQUAL "x86_64") 28 | set(MINVER -mmacosx-version-min=10.12) 29 | set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12) 30 | else() 31 | set(MINVER -mmacosx-version-min=11.0) 32 | set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0) 33 | endif() 34 | endif() 35 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch ${ARCH} -isysroot ${SYSROOT} ${MINVER} -fembed-bitcode=off -flto=thin -pthread -mrelax-all -std=gnu++20") 36 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch ${ARCH} -isysroot ${SYSROOT} ${MINVER} -fembed-bitcode=off -flto=thin -pthread -mrelax-all -std=gnu17") 37 | elseif("${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Linux") 38 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-multiple-definition -pthread") 39 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-multiple-definition -pthread") 40 | endif() 41 | add_executable(iBoot64Patcher 42 | src/main.cpp) 43 | target_include_directories(iBoot64Patcher PRIVATE 44 | "${CMAKE_SOURCE_DIR}/dep_root/include" 45 | src) 46 | target_link_directories(iBoot64Patcher PRIVATE 47 | "${CMAKE_SOURCE_DIR}/dep_root/lib") 48 | if(NOT DEFINED NO_PKGCFG AND NOT "$ENV{NO_PKGCFG}" MATCHES "1") 49 | find_package(PkgConfig REQUIRED) 50 | pkg_check_modules(DEPS REQUIRED 51 | libgeneral 52 | libinsn 53 | libplist-2.0 54 | libimg3tool 55 | libimg4tool 56 | libpatchfinder) 57 | target_include_directories(iBoot64Patcher PRIVATE "${DEPS_INCLUDE_DIRS}") 58 | target_link_directories(iBoot64Patcher PRIVATE "${DEPS_LIBRARY_DIRS}") 59 | target_link_libraries(futurerestore PRIVATE "${DEPS_LIBRARIES}" 60 | "-lgeneral" 61 | insn 62 | plist-2.0 63 | img3tool 64 | img4tool 65 | patchfinder) 66 | else() 67 | target_include_directories(iBoot64Patcher PRIVATE "${CMAKE_SOURCE_DIR}/dep_root/include") 68 | target_link_directories(iBoot64Patcher PRIVATE "${CMAKE_SOURCE_DIR}/dep_root/lib") 69 | if("${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Darwin") 70 | set(compression_lib compression) 71 | else() 72 | set(compression_lib 73 | dl 74 | lzfse) 75 | endif() 76 | target_link_libraries(iBoot64Patcher PRIVATE 77 | ${compression_lib} 78 | "-lgeneral" 79 | insn 80 | crypto 81 | plist-2.0 82 | img3tool 83 | img4tool 84 | patchfinder) 85 | endif() 86 | 87 | execute_process(COMMAND git rev-list --count HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE VERSION_COMMIT_COUNT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) 88 | execute_process(COMMAND git rev-parse HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE VERSION_COMMIT_SHA ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) 89 | add_definitions( 90 | -DVERSION_COMMIT_COUNT="${VERSION_COMMIT_COUNT}" 91 | -DVERSION_COMMIT_SHA="${VERSION_COMMIT_SHA}") 92 | install(TARGETS iBoot64Patcher 93 | DESTINATION ${CMAKE_INSTALL_PREFIX}) 94 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: iBoot64Patcher 2 | 3 | on: 4 | push: 5 | pull_request: 6 | workflow_dispatch: 7 | schedule: 8 | - cron: '0 0 1 1 *' 9 | - cron: '0 0 1 4 *' 10 | - cron: '0 0 30 6 *' 11 | - cron: '0 0 28 9 *' 12 | - cron: '0 0 27 12 *' 13 | 14 | jobs: 15 | macOS: 16 | env: 17 | PROCURSUS: /opt/procursus 18 | PATH: /opt/procursus/bin:/opt/procursus/libexec/gnubin:/usr/local/lib/ruby/gems/2.7.0/bin:/usr/local/opt/ruby@2.7/bin:/usr/local/opt/pipx_bin:/Users/runner/.cargo/bin:/usr/local/opt/curl/bin:/usr/local/bin:/usr/local/sbin:/Users/runner/bin:/Users/runner/.yarn/bin:/Users/runner/Library/Android/sdk/tools:/Users/runner/Library/Android/sdk/platform-tools:/Users/runner/Library/Android/sdk/ndk-bundle:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/bin:/bin:/usr/sbin:/sbin:/Users/runner/.dotnet/tools:/Users/runner/.ghcup/bin:/Users/runner/hostedtoolcache/stack/2.7.3/x64 19 | runs-on: macos-12 20 | steps: 21 | - name: Checkout 22 | uses: actions/checkout@v2 23 | with: 24 | submodules: 'true' 25 | fetch-depth: 0 26 | - name: Update Xcode 27 | id: Update-Xcode 28 | uses: maxim-lobanov/setup-xcode@v1 29 | with: 30 | xcode-version: '14.1.0' 31 | - name: macOS Build 32 | id: macOS-Build 33 | run: | 34 | /Users/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/mac-bootstrap.sh 35 | /Users/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/mac-build.sh 36 | /Users/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/mac-post.sh 37 | - name: Versioning 38 | id: Versioning 39 | uses: actions/upload-artifact@v2 40 | with: 41 | name: Versioning 42 | path: | 43 | /Users/runner/work/iBoot64Patcher/iBoot64Patcher/latest_build_sha.txt 44 | /Users/runner/work/iBoot64Patcher/iBoot64Patcher/latest_build_num.txt 45 | - name: macOS x86_64 RELEASE Archive 46 | id: macOS-x86_64-RELEASE-Archive 47 | uses: actions/upload-artifact@v2 48 | with: 49 | name: iBoot64Patcher-macOS-x86_64-RELEASE 50 | path: | 51 | /Users/runner/work/iBoot64Patcher/iBoot64Patcher/iBoot64Patcher-macOS-x86_64-*-RELEASE.tar.xz 52 | - name: macOS x86_64 DEBUG Archive 53 | id: macOS-x86_64-DEBUG-Archive 54 | uses: actions/upload-artifact@v2 55 | with: 56 | name: iBoot64Patcher-macOS-x86_64-DEBUG 57 | path: | 58 | /Users/runner/work/iBoot64Patcher/iBoot64Patcher/iBoot64Patcher-macOS-x86_64-*-DEBUG.tar.xz 59 | - name: macOS arm64 RELEASE Archive 60 | id: macOS-arm64-RELEASE-Archive 61 | uses: actions/upload-artifact@v2 62 | with: 63 | name: iBoot64Patcher-macOS-arm64-RELEASE 64 | path: | 65 | /Users/runner/work/iBoot64Patcher/iBoot64Patcher/iBoot64Patcher-macOS-arm64-*-RELEASE.tar.xz 66 | - name: macOS arm64 DEBUG Archive 67 | id: macOS-arm64-DEBUG-Archive 68 | uses: actions/upload-artifact@v2 69 | with: 70 | name: iBoot64Patcher-macOS-arm64-DEBUG 71 | path: | 72 | /Users/runner/work/iBoot64Patcher/iBoot64Patcher/iBoot64Patcher-macOS-arm64-*-DEBUG.tar.xz 73 | Linux: 74 | runs-on: ubuntu-latest 75 | steps: 76 | - name: Checkout 77 | uses: actions/checkout@v2 78 | with: 79 | submodules: 'true' 80 | fetch-depth: 0 81 | - name: Linux Build 82 | id: Linux 83 | uses: addnab/docker-run-action@v3 84 | with: 85 | image: debian:buster-slim 86 | options: -v ${{ github.workspace }}/..:/tmp/Builder/repos/ 87 | run: | 88 | /tmp/Builder/repos/iBoot64Patcher/.github/workflows/linux-bootstrap.sh 89 | /tmp/Builder/repos/iBoot64Patcher/.github/workflows/linux-build.sh 90 | /tmp/Builder/repos/iBoot64Patcher/.github/workflows/linux-post.sh 91 | - name: Linux x86_64 RELEASE Build 92 | run: | 93 | mkdir -p /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/ 94 | docker cp $(docker ps -ql):/tmp/Builder/repos/iBoot64Patcher/.github/workflows/name1.txt /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/ 95 | docker cp $(docker ps -ql):/tmp/Builder/repos/iBoot64Patcher/.github/workflows/iBoot64Patcher1.tar.xz /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/ 96 | mv /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/iBoot64Patcher1.tar.xz /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/$(cat /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/name1.txt) 97 | - name: Linux x86_64 DEBUG Build 98 | run: | 99 | mkdir -p /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/ 100 | docker cp $(docker ps -ql):/tmp/Builder/repos/iBoot64Patcher/.github/workflows/name2.txt /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/ 101 | docker cp $(docker ps -ql):/tmp/Builder/repos/iBoot64Patcher/.github/workflows/iBoot64Patcher2.tar.xz /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/ 102 | mv /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/iBoot64Patcher2.tar.xz /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/$(cat /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/name2.txt) 103 | - name: iBoot64Patcher Linux x86_64 RELEASE Archive 104 | id: iBoot64Patcher-Linux-x86_64-RELEASE-Archive 105 | uses: actions/upload-artifact@v2 106 | with: 107 | name: iBoot64Patcher-Linux-x86_64-RELEASE 108 | path: | 109 | /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/iBoot64Patcher-Linux-x86_64*-RELEASE.tar.xz 110 | - name: iBoot64Patcher Linux x86_64 DEBUG Archive 111 | id: iBoot64Patcher-Linux-x86_64-DEBUG-Archive 112 | uses: actions/upload-artifact@v2 113 | with: 114 | name: iBoot64Patcher-Linux-x86_64-DEBUG 115 | path: | 116 | /home/runner/work/iBoot64Patcher/iBoot64Patcher/.github/workflows/iBoot64Patcher-Linux-x86_64*-DEBUG.tar.xz 117 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // main.cpp 3 | // src 4 | // 5 | // Created by tihmstar on 27.09.19. 6 | // Copyright © 2019 tihmstar. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #define HAS_ARG(x,y) (!strcmp(argv[i], x) && (i + y) < argc) 22 | 23 | #define addpatch(pp) do {\ 24 | auto p = pp; \ 25 | patches.insert(patches.end(), p.begin(), p.end()); \ 26 | } while (0) 27 | 28 | #define addloc(pp) do {\ 29 | patches.push_back({pp,NULL,0}); \ 30 | } while (0) 31 | 32 | using namespace tihmstar::patchfinder; 33 | 34 | #define FLAG_UNLOCK_NVRAM (1 << 0) 35 | 36 | int main(int argc, const char * argv[]) { 37 | FILE* fp = nullptr; 38 | FILE* fp2 = nullptr; 39 | char* cmd_handler_str = nullptr; 40 | char* custom_boot_args = nullptr; 41 | uint64_t cmd_handler_ptr = 0; 42 | int flags = 0; 43 | 44 | printf("Version: " VERSION_COMMIT_SHA "-" VERSION_COMMIT_COUNT "\n"); 45 | 46 | if(argc < 3) { 47 | printf("Usage: %s [args]\n", argv[0]); 48 | printf("\t-b \tApply custom boot args.\n"); 49 | printf("\t-c \tChange a command handler's pointer (hex).\n"); 50 | printf("\t-n \t\tApply unlock nvram patch.\n"); 51 | return -1; 52 | } 53 | 54 | printf("%s: Starting...\n", __FUNCTION__); 55 | 56 | for(int i = 0; i < argc; i++) { 57 | if(HAS_ARG("-b", 1)) { 58 | custom_boot_args = (char*) argv[i+1]; 59 | } else if(HAS_ARG("-n", 0)) { 60 | flags |= FLAG_UNLOCK_NVRAM; 61 | }else if(HAS_ARG("-c", 2)) { 62 | cmd_handler_str = (char*) argv[i+1]; 63 | sscanf((char*) argv[i+2], "0x%016llX", &cmd_handler_ptr); 64 | } 65 | } 66 | 67 | std::vector patches; 68 | 69 | ibootpatchfinder *ibpf = nullptr; 70 | kernelpatchfinder *kpf = nullptr; 71 | cleanup([&]{ 72 | safeDelete(ibpf); 73 | safeDelete(kpf); 74 | }); 75 | const char *iboot_path = argv[1]; 76 | const char *iboot_patched_path = argv[2]; 77 | struct stat st{0}; 78 | if(stat(iboot_path, &st) < 0) { 79 | printf("%s: Error getting iBoot size for %s!\n", __FUNCTION__, iboot_path); 80 | return -1; 81 | } 82 | size_t iboot_size = st.st_size; 83 | try { 84 | kpf = kernelpatchfinder64::make_kernelpatchfinder64(iboot_path); 85 | } catch (...) { 86 | try { 87 | kpf = kernelpatchfinder32::make_kernelpatchfinder32(iboot_path); 88 | } catch (...) { 89 | try { 90 | ibpf = ibootpatchfinder64::make_ibootpatchfinder64(iboot_path); 91 | } catch (...) { 92 | ibpf = ibootpatchfinder32::make_ibootpatchfinder32(iboot_path); 93 | } 94 | } 95 | } 96 | /* Check to see if the loader has a kernel load routine before trying to apply custom boot args + debug-enabled override. */ 97 | if(ibpf->has_kernel_load()) { 98 | if(custom_boot_args) { 99 | try { 100 | printf("getting get_boot_arg_patch(%s) patch\n",custom_boot_args); 101 | addpatch(ibpf->get_boot_arg_patch(custom_boot_args)); 102 | } catch (tihmstar::exception &e) { 103 | printf("%s: Error doing patch_boot_args()! (%s)\n", __FUNCTION__, e.what()); 104 | return -1; 105 | } 106 | } 107 | 108 | 109 | /* Only bootloaders with the kernel load routines pass the DeviceTree. */ 110 | try { 111 | printf("getting get_debug_enabled_patch() patch\n"); 112 | addpatch(ibpf->get_debug_enabled_patch()); 113 | } catch (tihmstar::exception &e) { 114 | printf("%s: Error doing patch_debug_enabled()! (%s)\n", __FUNCTION__, e.what()); 115 | return -1; 116 | } 117 | } 118 | 119 | /* Ensure that the loader has a shell. */ 120 | if(ibpf->has_recovery_console()) { 121 | if (cmd_handler_str && cmd_handler_ptr) { 122 | try { 123 | printf("getting get_cmd_handler_patch(%s,0x%016llx) patch\n",cmd_handler_str,cmd_handler_ptr); 124 | addpatch(ibpf->get_cmd_handler_patch(cmd_handler_str, cmd_handler_ptr)); 125 | } catch (tihmstar::exception &e) { 126 | printf("%s: Error doing patch_cmd_handler()! (%s)\n", __FUNCTION__, e.what()); 127 | return -1; 128 | } 129 | } 130 | 131 | if (flags & FLAG_UNLOCK_NVRAM) { 132 | try { 133 | printf("getting get_unlock_nvram_patch() patch\n"); 134 | addpatch(ibpf->get_unlock_nvram_patch()); 135 | } catch (tihmstar::exception &e) { 136 | printf("%s: Error doing get_unlock_nvram_patch()! (%s)\n", __FUNCTION__, e.what()); 137 | return -1; 138 | } 139 | try { 140 | printf("getting get_freshnonce_patch() patch\n"); 141 | addpatch(ibpf->get_freshnonce_patch()); 142 | } catch (tihmstar::exception &e) { 143 | printf("%s: Error doing get_freshnonce_patch()! (%s)\n", __FUNCTION__, e.what()); 144 | return -1; 145 | } 146 | } 147 | } 148 | 149 | /* All loaders have the RSA check. */ 150 | try { 151 | printf("getting get_sigcheck_patch() patch\n"); 152 | addpatch(ibpf->get_sigcheck_patch()); 153 | } catch (tihmstar::exception &e) { 154 | printf("%s: Error doing patch_rsa_check()! (%s)\n", __FUNCTION__, e.what()); 155 | return -1; 156 | } 157 | 158 | 159 | /* Write out the patched file... */ 160 | fp = fopen(iboot_patched_path, "wb+"); 161 | if(!fp) { 162 | printf("%s: Unable to open %s!\n", __FUNCTION__, iboot_patched_path); 163 | return -1; 164 | } 165 | fp2 = fopen(iboot_path, "rb+"); 166 | if(!fp2) { 167 | printf("%s: Unable to open %s!\n", __FUNCTION__, iboot_path); 168 | fflush(fp); 169 | fclose(fp); 170 | return -1; 171 | } 172 | char *deciboot = (char *)calloc(1, iboot_size); 173 | size_t ret = fread(deciboot, 1, iboot_size, fp2); 174 | if(ret != iboot_size) { 175 | printf("%s: Unable to read iBoot, read size %zu/%zu!\n", __FUNCTION__, ret, iboot_size); 176 | fflush(fp); 177 | fclose(fp); 178 | fflush(fp2); 179 | fclose(fp2); 180 | free(deciboot); 181 | return -1; 182 | } 183 | fflush(fp2); 184 | fclose(fp2); 185 | 186 | for (const auto& p2 : patches) { 187 | printf("%s: Applying patch=0x%016llx: ", __FUNCTION__, p2._location); 188 | for (int i=0; ifind_base()); 198 | memcpy(&deciboot[off], p2._patch, p2._patchSize); 199 | } 200 | printf("%s: Writing out patched file to %s...\n", __FUNCTION__, iboot_patched_path); 201 | ret = fwrite(deciboot,1, iboot_size, fp); 202 | if(ret != iboot_size) { 203 | printf("%s: Unable to write patched iBoot, wrote size %zu/%zu!\n", __FUNCTION__, ret, iboot_size); 204 | fflush(fp); 205 | fclose(fp); 206 | fflush(fp2); 207 | fclose(fp2); 208 | free(deciboot); 209 | return -1; 210 | } 211 | 212 | fflush(fp); 213 | fclose(fp); 214 | free(deciboot); 215 | 216 | printf("%s: Quitting...\n", __FUNCTION__); 217 | 218 | return 0; 219 | } 220 | --------------------------------------------------------------------------------