mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-23 10:39:48 +02:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7a880ec69 | ||
|
|
29adf177cb |
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
name: No Template
|
name: No Template
|
||||||
description: Create a standard issue, no template involved.
|
description: Create a standard issue, no template involved.
|
||||||
labels: [palera1n help]
|
labels: [palera1n]
|
||||||
body:
|
body:
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: description
|
id: description
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: Feature Request
|
name: Feature Request
|
||||||
description: Request a feature in palera1n!
|
description: Request a feature in palera1n!
|
||||||
labels: [enhancement]
|
labels: [enhancement, palera1n]
|
||||||
body:
|
body:
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: feature-request
|
id: feature-request
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
name: Create Issue
|
name: Create Issue
|
||||||
description: Ask help for palera1n regarding support or generally how it works!
|
description: Ask help for palera1n regarding support or generally how it works!
|
||||||
labels: [palera1n help]
|
labels: [palera1n]
|
||||||
|
assignees:
|
||||||
|
- ssalggnikool
|
||||||
|
- asdfugil
|
||||||
body:
|
body:
|
||||||
- type: input
|
- type: input
|
||||||
id: device
|
id: device
|
||||||
|
|||||||
+37
-161
@@ -72,15 +72,10 @@ jobs:
|
|||||||
gnu_triple: aarch64-apple-darwin
|
gnu_triple: aarch64-apple-darwin
|
||||||
os: iphoneos
|
os: iphoneos
|
||||||
minos: 7.0
|
minos: 7.0
|
||||||
runs-on: macos-15
|
runs-on: macos-12
|
||||||
env:
|
env:
|
||||||
MBEDTLS_VERSION: 3.5.2
|
MBEDTLS_VERSION: 3.5.2
|
||||||
READLINE_VERSION: 8.2
|
READLINE_VERSION: 8.2
|
||||||
LIBIMOBILEDEVICE_COMMIT: ed0d66d0341562731bb19928dfe48155509fa7a7
|
|
||||||
LIBIRECOVERY_COMMIT: 7ce02c347b7c26e59498e6af31c9da51018d0fa1
|
|
||||||
LIBIMOBILEDEVICE_GLUE_COMMIT: 362f7848ac89b74d9dd113b38b51ecb601f76094
|
|
||||||
LIBPLIST_COMMIT: 2117b8fdb6b4096455bd2041a63e59a028120136
|
|
||||||
LIBUSBMUXD_COMMIT: a7f0543fb1ecb20ac7121c0fd77297200e0e43fc
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -91,7 +86,7 @@ jobs:
|
|||||||
- name: Install dependencies (packages)
|
- name: Install dependencies (packages)
|
||||||
run: |
|
run: |
|
||||||
sudo /usr/local/bin/pip3 install jsonschema jinja2
|
sudo /usr/local/bin/pip3 install jsonschema jinja2
|
||||||
brew install make autoconf automake pkg-config gnu-sed gettext libtool
|
brew install make autoconf automake pkg-config gnu-sed gettext
|
||||||
sudo rm -rf /usr/local/Frameworks/Python*
|
sudo rm -rf /usr/local/Frameworks/Python*
|
||||||
curl -LO https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus7/ldid_macosx_x86_64
|
curl -LO https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus7/ldid_macosx_x86_64
|
||||||
sudo install -m755 ldid_macosx_x86_64 /usr/local/bin/ldid
|
sudo install -m755 ldid_macosx_x86_64 /usr/local/bin/ldid
|
||||||
@@ -100,9 +95,23 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "SDK=$(xcrun -sdk ${{ matrix.os }} --show-sdk-path)" >> $GITHUB_ENV
|
echo "SDK=$(xcrun -sdk ${{ matrix.os }} --show-sdk-path)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Download dependencies (source code)
|
||||||
|
run: |
|
||||||
|
curl -LOO \
|
||||||
|
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \
|
||||||
|
https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz
|
||||||
|
|
||||||
|
tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz
|
||||||
|
tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz
|
||||||
|
git clone --depth=1 https://github.com/libimobiledevice/libplist
|
||||||
|
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice-glue
|
||||||
|
git clone --depth=1 https://github.com/libimobiledevice/libirecovery
|
||||||
|
git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd
|
||||||
|
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice
|
||||||
|
|
||||||
- name: Select correct Xcode
|
- name: Select correct Xcode
|
||||||
run: |
|
run: |
|
||||||
sudo xcode-select -s /Applications/Xcode_16.2.app
|
sudo xcode-select -s /Applications/Xcode_14.2.app
|
||||||
|
|
||||||
- name: Setup environment
|
- name: Setup environment
|
||||||
run: |
|
run: |
|
||||||
@@ -114,14 +123,16 @@ jobs:
|
|||||||
echo "CC=$(xcrun --find cc)" >> $GITHUB_ENV
|
echo "CC=$(xcrun --find cc)" >> $GITHUB_ENV
|
||||||
echo "CXX=$(xcrun --find c++)" >> $GITHUB_ENV
|
echo "CXX=$(xcrun --find c++)" >> $GITHUB_ENV
|
||||||
echo "CPP=$(xcrun --find cc) -E" >> $GITHUB_ENV
|
echo "CPP=$(xcrun --find cc) -E" >> $GITHUB_ENV
|
||||||
echo "CFLAGS=-g -Os -isystem ${{ env.SDK }}/usr/include/c++/v1 -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isysroot ${{ env.SDK }} -isystem $(pwd)/sysroot/usr/local/include -Os -g -flto=full -Wl,-object_path_lto,lto.o -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64" >> $GITHUB_ENV
|
echo "CFLAGS=-g -Os -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isysroot ${{ env.SDK }} -isystem $(pwd)/sysroot/usr/local/include -Os -g -flto=full -Wl,-object_path_lto,lto.o" >> $GITHUB_ENV
|
||||||
echo "CPPFLAGS=-g -Os -isystem ${{ env.SDK }}/usr/include/c++/v1 -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isysroot ${{ env.SDK }} -isystem $(pwd)/sysroot/usr/local/include -Wno-error-implicit-function-declaration -Os -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64" >> $GITHUB_ENV
|
echo "CPPFLAGS=-g -Os -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isysroot ${{ env.SDK }} -isystem $(pwd)/sysroot/usr/local/include -Wno-error-implicit-function-declaration -Os" >> $GITHUB_ENV
|
||||||
echo "CXXFLAGS=-stdlib=libc++ -g -Os -isystem$(TARGET_SYSROOT)/usr/include/c++/v1 -isysroot ${{ env.SDK }} -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isystem $(pwd)/sysroot/usr/local/include -Os -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64" >> $GITHUB_ENV
|
echo "CXXFLAGS=-stdlib=libc++ -g -Os -isysroot ${{ env.SDK }} -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isystem $(pwd)/sysroot/usr/local/include -Os" >> $GITHUB_ENV
|
||||||
echo "LDFLAGS=-g -Wl,-dead_strip -arch ${{ matrix.arch }} -isysroot ${{ env.SDK }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -L$(pwd)/sysroot/usr/local/lib" >> $GITHUB_ENV
|
echo "LDFLAGS=-g -Wl,-dead_strip -arch ${{ matrix.arch }} -isysroot ${{ env.SDK }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -L$(pwd)/sysroot/usr/local/lib" >> $GITHUB_ENV
|
||||||
echo "CFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Os" >> $GITHUB_ENV
|
echo "CFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Os" >> $GITHUB_ENV
|
||||||
echo "CXXFLAGS_FOR_BUILD=-stdlib=libc++ -arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Os" >> $GITHUB_ENV
|
echo "CXXFLAGS_FOR_BUILD=-stdlib=libc++ -arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Os" >> $GITHUB_ENV
|
||||||
echo "CPPFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Wno-error-implicit-function-declaration -Os" >> $GITHUB_ENV
|
echo "CPPFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Wno-error-implicit-function-declaration -Os" >> $GITHUB_ENV
|
||||||
echo "LDFLAGS_FOR_BUILD=-Wl,-dead_strip" >> $GITHUB_ENV
|
echo "LDFLAGS_FOR_BUILD=-Wl,-dead_strip" >> $GITHUB_ENV
|
||||||
|
mkdir -p $(pwd)/sysroot/usr/local/lib
|
||||||
|
ln -sf $(pwd)/sysroot/usr/local/lib{,64}
|
||||||
|
|
||||||
- name: Prepare iPhoneOS environment
|
- name: Prepare iPhoneOS environment
|
||||||
if: matrix.os == 'iphoneos'
|
if: matrix.os == 'iphoneos'
|
||||||
@@ -162,59 +173,7 @@ jobs:
|
|||||||
gsed -E /'__API_UNAVAILABLE'/d < ${TARGET_SYSROOT}/usr/include/pthread.h > sysroot/usr/local/include/pthread.h
|
gsed -E /'__API_UNAVAILABLE'/d < ${TARGET_SYSROOT}/usr/include/pthread.h > sysroot/usr/local/include/pthread.h
|
||||||
gsed -i -E s/'__API_UNAVAILABLE\(.*\)'// sysroot/usr/local/include/IOKit/IOKitLib.h
|
gsed -i -E s/'__API_UNAVAILABLE\(.*\)'// sysroot/usr/local/include/IOKit/IOKitLib.h
|
||||||
|
|
||||||
- name: Check dependencies cache
|
|
||||||
run: |
|
|
||||||
echo "target: ${{ matrix.os }}-${{ matrix.arch }}" > cache.txt
|
|
||||||
echo "mbedtls ${{ env.MBEDTLS_VERSION }}" >> cache.txt
|
|
||||||
echo "readline: ${{ env.READLINE_VERSION }}" >> cache.txt
|
|
||||||
echo "libimobiledevice: ${{ env.LIBIMOBILEDEVICE_COMMIT }}" >> cache.txt
|
|
||||||
echo "libirecovery: ${{ env.LIBIRECOVERY_COMMIT }}" >> cache.txt
|
|
||||||
echo "libimobiledevice-glue: ${{ env.LIBIMOBILEDEVICE_GLUE_COMMIT }}" >> cache.txt
|
|
||||||
echo "libplist: ${{ env.LIBPLIST_COMMIT }}" >> cache.txt
|
|
||||||
echo "libusbmuxd: ${{ env.LIBUSBMUXD_COMMIT }}" >> cache.txt
|
|
||||||
echo "cc: $($(xcrun --find cc) --version)" >> cache.txt
|
|
||||||
echo "CACHE_TXT_CHECKSUM=sysroot-$(shasum -a 512 cache.txt | cut -d' ' -f1)" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Download cached sysroot
|
|
||||||
id: sysroot_cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: sysroot-${{ env.CACHE_TXT_CHECKSUM }}.txz
|
|
||||||
key: sysroot-${{ env.CACHE_TXT_CHECKSUM }}
|
|
||||||
|
|
||||||
- name: Extract cached sysroot
|
|
||||||
if: steps.sysroot_cache.outputs.cache-hit == 'true'
|
|
||||||
run: |
|
|
||||||
xz -dcT0 sysroot-${{ env.CACHE_TXT_CHECKSUM }}.txz | tar -x
|
|
||||||
|
|
||||||
- name: Setup sysroot
|
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
|
||||||
mkdir -p $(pwd)/sysroot/usr/local/lib
|
|
||||||
ln -sf $(pwd)/sysroot/usr/local/lib{,64}
|
|
||||||
|
|
||||||
- name: Download dependencies (source code)
|
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
|
||||||
curl -LOOOOOO \
|
|
||||||
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \
|
|
||||||
https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz
|
|
||||||
|
|
||||||
tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz
|
|
||||||
tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz
|
|
||||||
git clone --depth=1 https://github.com/libimobiledevice/libplist
|
|
||||||
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice-glue
|
|
||||||
git clone --depth=1 https://github.com/libimobiledevice/libirecovery
|
|
||||||
git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd
|
|
||||||
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice
|
|
||||||
cd libplist && git fetch origin ${{ env.LIBPLIST_COMMIT }} && git reset --hard ${{ env.LIBPLIST_COMMIT }} && cd ..
|
|
||||||
cd libirecovery && git fetch origin ${{ env.LIBIRECOVERY_COMMIT }} && git reset --hard ${{ env.LIBIRECOVERY_COMMIT }} && cd ..
|
|
||||||
cd libimobiledevice-glue && git fetch origin ${{ env.LIBIMOBILEDEVICE_GLUE_COMMIT }} && git reset --hard ${{ env.LIBIMOBILEDEVICE_GLUE_COMMIT }} && cd ..
|
|
||||||
cd libimobiledevice && git fetch origin ${{ env.LIBIMOBILEDEVICE_COMMIT }} && git reset --hard ${{ env.LIBIMOBILEDEVICE_COMMIT }} && cd ..
|
|
||||||
cd libusbmuxd && git fetch origin ${{ env.LIBUSBMUXD_COMMIT }} && git reset --hard ${{ env.LIBUSBMUXD_COMMIT }} && cd ..
|
|
||||||
|
|
||||||
- name: Build Mbed TLS
|
- name: Build Mbed TLS
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd mbedtls-${{ env.MBEDTLS_VERSION }}
|
cd mbedtls-${{ env.MBEDTLS_VERSION }}
|
||||||
cat ../patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
|
cat ../patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
|
||||||
@@ -239,7 +198,6 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build readline
|
- name: Build readline
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd readline-${{ env.READLINE_VERSION }}
|
cd readline-${{ env.READLINE_VERSION }}
|
||||||
CC=clang CXX=clang++ ./configure ${{ env.CONFIGURE_ARGS }} ac_cv_type_sig_atomic_t=no
|
CC=clang CXX=clang++ ./configure ${{ env.CONFIGURE_ARGS }} ac_cv_type_sig_atomic_t=no
|
||||||
@@ -248,7 +206,6 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build libplist
|
- name: Build libplist
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd libplist
|
cd libplist
|
||||||
autoreconf -fiv
|
autoreconf -fiv
|
||||||
@@ -258,7 +215,6 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build libimobiledevice-glue
|
- name: Build libimobiledevice-glue
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd libimobiledevice-glue
|
cd libimobiledevice-glue
|
||||||
autoreconf -fiv
|
autoreconf -fiv
|
||||||
@@ -268,7 +224,6 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build libirecovery
|
- name: Build libirecovery
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
sudo cp -a sysroot/usr/local/* /usr/local
|
sudo cp -a sysroot/usr/local/* /usr/local
|
||||||
cd libirecovery
|
cd libirecovery
|
||||||
@@ -284,7 +239,6 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build libusbmuxd
|
- name: Build libusbmuxd
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd libusbmuxd
|
cd libusbmuxd
|
||||||
autoreconf -fiv
|
autoreconf -fiv
|
||||||
@@ -294,11 +248,10 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build libimobiledevice
|
- name: Build libimobiledevice
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd libimobiledevice
|
cd libimobiledevice
|
||||||
autoreconf -fiv
|
autoreconf -fiv
|
||||||
./configure ${{ env.CONFIGURE_ARGS }} --with-mbedtls --disable-debug --disable-wireless-pairing
|
./configure ${{ env.CONFIGURE_ARGS }} --with-mbedtls --enable-debug
|
||||||
echo -e 'all:\ninstall:' > tools/Makefile
|
echo -e 'all:\ninstall:' > tools/Makefile
|
||||||
gmake -j$(sysctl -n hw.ncpu)
|
gmake -j$(sysctl -n hw.ncpu)
|
||||||
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
|
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
|
||||||
@@ -309,15 +262,15 @@ jobs:
|
|||||||
cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root
|
cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root
|
||||||
find dep_root -name '*.dylib' -delete
|
find dep_root -name '*.dylib' -delete
|
||||||
find dep_root -name '*.la' -delete
|
find dep_root -name '*.la' -delete
|
||||||
gmake -j$(sysctl -n hw.ncpu) ROOTFUL=1
|
gmake -j$(sysctl -n hw.ncpu) TUI=1
|
||||||
cp src/palera1n palera1n-${{ matrix.os }}-${{ matrix.arch }}
|
cp src/palera1n palera1n-${{ matrix.os }}-${{ matrix.arch }}
|
||||||
dsymutil palera1n-${{ matrix.os }}-${{ matrix.arch }}
|
dsymutil palera1n-${{ matrix.os }}-${{ matrix.arch }}
|
||||||
strip palera1n-${{ matrix.os }}-${{ matrix.arch }}
|
strip palera1n-${{ matrix.os }}-${{ matrix.arch }}
|
||||||
|
|
||||||
- name: Build palera1n (Development)
|
- name: Build palera1n (Development)
|
||||||
run: |
|
run: |
|
||||||
gmake -j$(sysctl -n hw.ncpu) clean
|
CC="${{ matrix.triple }}-gcc" gmake -j$(sysctl -n hw.ncpu) clean
|
||||||
gmake -j$(sysctl -n hw.ncpu) DEV_BUILD=1 TUI=1 ROOTFUL=1
|
CC="${{ matrix.triple }}-gcc" gmake -j$(sysctl -n hw.ncpu) DEV_BUILD=1 TUI=1 ROOTFUL=1
|
||||||
cp src/palera1n palera1n-${{ matrix.os }}-${{ matrix.arch }}.development
|
cp src/palera1n palera1n-${{ matrix.os }}-${{ matrix.arch }}.development
|
||||||
|
|
||||||
- name: Prepare artifact
|
- name: Prepare artifact
|
||||||
@@ -371,12 +324,7 @@ jobs:
|
|||||||
name: palera1n-${{ matrix.os }}-${{ matrix.arch }}.dSYM
|
name: palera1n-${{ matrix.os }}-${{ matrix.arch }}.dSYM
|
||||||
path: palera1n-${{ matrix.os }}-${{ matrix.arch }}.dSYM
|
path: palera1n-${{ matrix.os }}-${{ matrix.arch }}.dSYM
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
- name: Generate cached sysroot archive
|
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
|
||||||
tar -c sysroot | xz -zce9T 0 > sysroot-${{ env.CACHE_TXT_CHECKSUM }}.txz
|
|
||||||
|
|
||||||
darwin-dist:
|
darwin-dist:
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
@@ -530,15 +478,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
MBEDTLS_VERSION: 3.5.2
|
MBEDTLS_VERSION: 3.5.2
|
||||||
LIBUSB_VERSION: 1.0.27
|
LIBUSB_VERSION: 1.0.26
|
||||||
READLINE_VERSION: 8.2
|
READLINE_VERSION: 8.2
|
||||||
GPM_VERSION: 1.20.7
|
|
||||||
LIBIMOBILEDEVICE_COMMIT: ed0d66d0341562731bb19928dfe48155509fa7a7
|
|
||||||
LIBIRECOVERY_COMMIT: 7ce02c347b7c26e59498e6af31c9da51018d0fa1
|
|
||||||
LIBIMOBILEDEVICE_GLUE_COMMIT: 362f7848ac89b74d9dd113b38b51ecb601f76094
|
|
||||||
USBMUXD_COMMIT: bc0b91ca856811f4393318dc83db6dc3c1ac326d
|
|
||||||
LIBPLIST_COMMIT: 2117b8fdb6b4096455bd2041a63e59a028120136
|
|
||||||
LIBUSBMUXD_COMMIT: a7f0543fb1ecb20ac7121c0fd77297200e0e43fc
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -593,75 +534,35 @@ jobs:
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
echo "PKG_CONFIG_PATH=$(pwd)/sysroot/usr/local/lib/pkgconfig" >> $GITHUB_ENV
|
echo "PKG_CONFIG_PATH=$(pwd)/sysroot/usr/local/lib/pkgconfig" >> $GITHUB_ENV
|
||||||
echo "CFLAGS=-g -fdata-sections -ffunction-sections -I$(pwd)/sysroot/usr/local/include -L$(pwd)/sysroot/usr/local/lib -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64" >> $GITHUB_ENV
|
echo "CFLAGS=-g -fdata-sections -ffunction-sections -I$(pwd)/sysroot/usr/local/include -L$(pwd)/sysroot/usr/local/lib" >> $GITHUB_ENV
|
||||||
echo "CXXFLAGS=-g -fdata-sections -ffunction-sections -I$(pwd)/sysroot/usr/local/include -L$(pwd)/sysroot/usr/local/lib -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64" >> $GITHUB_ENV
|
echo "CXXFLAGS=-g -fdata-sections -ffunction-sections -I$(pwd)/sysroot/usr/local/include -L$(pwd)/sysroot/usr/local/lib" >> $GITHUB_ENV
|
||||||
echo "LDFLAGS=-g -Wl,--gc-sections -fdata-sections -ffunction-sections -I$(pwd)/sysroot/usr/local/include -L$(pwd)/sysroot/usr/local/lib" >> $GITHUB_ENV
|
echo "LDFLAGS=-g -Wl,--gc-sections -fdata-sections -ffunction-sections -I$(pwd)/sysroot/usr/local/include -L$(pwd)/sysroot/usr/local/lib" >> $GITHUB_ENV
|
||||||
echo "INSTALL=$(command -v install) --strip-program=${{ matrix.triple }}-strip" >> $GITHUB_ENV
|
echo "INSTALL=$(command -v install) --strip-program=${{ matrix.triple }}-strip" >> $GITHUB_ENV
|
||||||
echo "DESTDIR=$(pwd)/sysroot" >> $GITHUB_ENV
|
echo "DESTDIR=$(pwd)/sysroot" >> $GITHUB_ENV
|
||||||
echo "PREFIX=/usr/local" >> $GITHUB_ENV
|
echo "PREFIX=/usr/local" >> $GITHUB_ENV
|
||||||
echo "CONFIGURE_ARGS=--build=x86_64-linux-gnu --host=${{ matrix.triple }} --prefix=/usr/local --disable-shared --enable-static" >> $GITHUB_ENV
|
echo "CONFIGURE_ARGS=--build=x86_64-linux-gnu --host=${{ matrix.triple }} --prefix=/usr/local --disable-shared --enable-static" >> $GITHUB_ENV
|
||||||
echo "CROSS_COMPILE=${{ matrix.triple }}-" >> $GITHUB_ENV
|
echo "CROSS_COMPILE=${{ matrix.triple }}-" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Check dependencies cache
|
|
||||||
run: |
|
|
||||||
echo "target: ${{ matrix.triple }}" > cache.txt
|
|
||||||
echo "mbedtls ${{ env.MBEDTLS_VERSION }}" >> cache.txt
|
|
||||||
echo "readline: ${{ env.READLINE_VERSION }}" >> cache.txt
|
|
||||||
echo "libimobiledevice: ${{ env.LIBIMOBILEDEVICE_COMMIT }}" >> cache.txt
|
|
||||||
echo "libirecovery: ${{ env.LIBIRECOVERY_COMMIT }}" >> cache.txt
|
|
||||||
echo "libimobiledevice-glue: ${{ env.LIBIMOBILEDEVICE_GLUE_COMMIT }}" >> cache.txt
|
|
||||||
echo "libplist: ${{ env.LIBPLIST_COMMIT }}" >> cache.txt
|
|
||||||
echo "libusbmuxd: ${{ env.LIBUSBMUXD_COMMIT }}" >> cache.txt
|
|
||||||
echo "usbmuxd: ${{ env.USBMUXD_COMMIT }}" >> cache.txt
|
|
||||||
echo "cc: $(${{ env.CROSS_COMPILE }}gcc --version)" >> cache.txt
|
|
||||||
echo "CACHE_TXT_CHECKSUM=sysroot-$(sha512sum cache.txt | cut -d' ' -f1)" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Download cached sysroot
|
|
||||||
id: sysroot_cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: sysroot-${{ env.CACHE_TXT_CHECKSUM }}.txz
|
|
||||||
key: sysroot-${{ env.CACHE_TXT_CHECKSUM }}
|
|
||||||
|
|
||||||
- name: Extract cached sysroot
|
|
||||||
if: steps.sysroot_cache.outputs.cache-hit == 'true'
|
|
||||||
run: |
|
|
||||||
xz -dcT0 sysroot-${{ env.CACHE_TXT_CHECKSUM }}.txz | tar -x
|
|
||||||
|
|
||||||
- name: Setup sysroot
|
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
|
||||||
mkdir -p $(pwd)/sysroot/usr/local/lib
|
mkdir -p $(pwd)/sysroot/usr/local/lib
|
||||||
ln -sf $(pwd)/sysroot/usr/local/lib{,64}
|
ln -sf $(pwd)/sysroot/usr/local/lib{,64}
|
||||||
|
|
||||||
- name: Download dependencies (source code)
|
- name: Download dependencies (source code)
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
curl -LOOOOOOO \
|
curl -LOOO \
|
||||||
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \
|
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \
|
||||||
https://github.com/libusb/libusb/releases/download/v${{ env.LIBUSB_VERSION }}/libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 \
|
https://github.com/libusb/libusb/releases/download/v${{ env.LIBUSB_VERSION }}/libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 \
|
||||||
https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz \
|
https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz
|
||||||
https://github.com/telmich/gpm/archive/refs/tags/${{ env.GPM_VERSION }}.tar.gz
|
|
||||||
|
|
||||||
tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz
|
tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz
|
||||||
tar -xjf libusb-${{ env.LIBUSB_VERSION }}.tar.bz2
|
tar -xjf libusb-${{ env.LIBUSB_VERSION }}.tar.bz2
|
||||||
tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz
|
tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz
|
||||||
tar -xf ${{ env.GPM_VERSION }}.tar.gz
|
|
||||||
git clone --depth=1 https://github.com/libimobiledevice/libplist
|
git clone --depth=1 https://github.com/libimobiledevice/libplist
|
||||||
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice-glue
|
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice-glue
|
||||||
git clone --depth=1 https://github.com/libimobiledevice/libirecovery
|
git clone --depth=1 https://github.com/libimobiledevice/libirecovery
|
||||||
git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd
|
git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd
|
||||||
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice
|
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice
|
||||||
git clone --depth=1 https://github.com/libimobiledevice/usbmuxd
|
git clone --depth=1 https://github.com/libimobiledevice/usbmuxd
|
||||||
cd libplist && git fetch origin ${{ env.LIBPLIST_COMMIT }} && git reset --hard ${{ env.LIBPLIST_COMMIT }} && cd ..
|
|
||||||
cd libirecovery && git fetch origin ${{ env.LIBIRECOVERY_COMMIT }} && git reset --hard ${{ env.LIBIRECOVERY_COMMIT }} && cd ..
|
|
||||||
cd libimobiledevice-glue && git fetch origin ${{ env.LIBIMOBILEDEVICE_GLUE_COMMIT }} && git reset --hard ${{ env.LIBIMOBILEDEVICE_GLUE_COMMIT }} && cd ..
|
|
||||||
cd usbmuxd && git fetch origin ${{ env.USBMUXD_COMMIT }} && git reset --hard ${{ env.USBMUXD_COMMIT }} && cd ..
|
|
||||||
cd libimobiledevice && git fetch origin ${{ env.LIBIMOBILEDEVICE_COMMIT }} && git reset --hard ${{ env.LIBIMOBILEDEVICE_COMMIT }} && cd ..
|
|
||||||
cd libusbmuxd && git fetch origin ${{ env.LIBUSBMUXD_COMMIT }} && git reset --hard ${{ env.LIBUSBMUXD_COMMIT }} && cd ..
|
|
||||||
|
|
||||||
- name: Build Mbed TLS
|
- name: Build Mbed TLS
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd mbedtls-${{ env.MBEDTLS_VERSION }}
|
cd mbedtls-${{ env.MBEDTLS_VERSION }}
|
||||||
cat ../patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
|
cat ../patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
|
||||||
@@ -686,7 +587,6 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build libusb
|
- name: Build libusb
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd libusb-${{ env.LIBUSB_VERSION }}
|
cd libusb-${{ env.LIBUSB_VERSION }}
|
||||||
./configure ${{ env.CONFIGURE_ARGS }} --disable-udev
|
./configure ${{ env.CONFIGURE_ARGS }} --disable-udev
|
||||||
@@ -695,7 +595,6 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build readline
|
- name: Build readline
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd readline-${{ env.READLINE_VERSION }}
|
cd readline-${{ env.READLINE_VERSION }}
|
||||||
./configure ${{ env.CONFIGURE_ARGS }}
|
./configure ${{ env.CONFIGURE_ARGS }}
|
||||||
@@ -703,20 +602,7 @@ jobs:
|
|||||||
make -j$(nproc) install DESTDIR=${{ env.DESTDIR }}
|
make -j$(nproc) install DESTDIR=${{ env.DESTDIR }}
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build GPM
|
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
|
||||||
cd gpm-${{ env.GPM_VERSION }}
|
|
||||||
cat ../patches/gpm/*.patch | patch -sN -d . -p1
|
|
||||||
./autogen.sh
|
|
||||||
./configure \
|
|
||||||
${{ env.CONFIGURE_ARGS }}
|
|
||||||
gmake -j$(sysctl -n hw.ncpu)
|
|
||||||
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
- name: Build libplist
|
- name: Build libplist
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd libplist
|
cd libplist
|
||||||
autoreconf -fiv
|
autoreconf -fiv
|
||||||
@@ -726,7 +612,6 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build libimobiledevice-glue
|
- name: Build libimobiledevice-glue
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd libimobiledevice-glue
|
cd libimobiledevice-glue
|
||||||
autoreconf -fiv
|
autoreconf -fiv
|
||||||
@@ -736,7 +621,6 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build libirecovery (sorta)
|
- name: Build libirecovery (sorta)
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
sudo mv /usr/local /usr/local.bak
|
sudo mv /usr/local /usr/local.bak
|
||||||
sudo ln -s ${{ env.DESTDIR }}${{ env.PREFIX }} /usr/local
|
sudo ln -s ${{ env.DESTDIR }}${{ env.PREFIX }} /usr/local
|
||||||
@@ -750,7 +634,6 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build libusbmuxd
|
- name: Build libusbmuxd
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd libusbmuxd
|
cd libusbmuxd
|
||||||
autoreconf -fiv
|
autoreconf -fiv
|
||||||
@@ -760,11 +643,10 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build libimobiledevice
|
- name: Build libimobiledevice
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd libimobiledevice
|
cd libimobiledevice
|
||||||
autoreconf -fiv
|
autoreconf -fiv
|
||||||
./configure ${{ env.CONFIGURE_ARGS }} --with-mbedtls --disable-debug --disable-wireless-pairing
|
./configure ${{ env.CONFIGURE_ARGS }} --with-mbedtls --enable-debug
|
||||||
echo -e 'all:\ninstall:' > tools/Makefile
|
echo -e 'all:\ninstall:' > tools/Makefile
|
||||||
make -j$(nproc)
|
make -j$(nproc)
|
||||||
make -j$(nproc) install DESTDIR=${{ env.DESTDIR }}
|
make -j$(nproc) install DESTDIR=${{ env.DESTDIR }}
|
||||||
@@ -773,7 +655,6 @@ jobs:
|
|||||||
sudo mv /usr/local.bak /usr/local
|
sudo mv /usr/local.bak /usr/local
|
||||||
|
|
||||||
- name: Build usbmuxd
|
- name: Build usbmuxd
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cd usbmuxd
|
cd usbmuxd
|
||||||
autoreconf -fiv
|
autoreconf -fiv
|
||||||
@@ -794,7 +675,7 @@ jobs:
|
|||||||
cp -a ${{ env.DESTDIR }}/${{ env.PREFIX }}/{include,lib} dep_root
|
cp -a ${{ env.DESTDIR }}/${{ env.PREFIX }}/{include,lib} dep_root
|
||||||
find dep_root -name '*.so' -delete
|
find dep_root -name '*.so' -delete
|
||||||
find dep_root -name '*.la' -delete
|
find dep_root -name '*.la' -delete
|
||||||
CC="${{ matrix.triple }}-gcc" make -j$(nproc) ROOTFUL=1
|
CC="${{ matrix.triple }}-gcc" make -j$(nproc) TUI=1
|
||||||
cp src/palera1n palera1n.release
|
cp src/palera1n palera1n.release
|
||||||
|
|
||||||
- name: Seperate debug symbols
|
- name: Seperate debug symbols
|
||||||
@@ -803,11 +684,11 @@ jobs:
|
|||||||
${{ matrix.triple }}-strip --strip-debug --strip-unneeded palera1n.release
|
${{ matrix.triple }}-strip --strip-debug --strip-unneeded palera1n.release
|
||||||
${{ matrix.triple }}-objcopy --add-gnu-debuglink=palera1n.debug palera1n.release
|
${{ matrix.triple }}-objcopy --add-gnu-debuglink=palera1n.debug palera1n.release
|
||||||
chmod -x palera1n.debug
|
chmod -x palera1n.debug
|
||||||
|
|
||||||
- name: Build palera1n (Development)
|
- name: Build palera1n (Development)
|
||||||
run: |
|
run: |
|
||||||
CC="${{ matrix.triple }}-gcc" make -j$(nproc) clean
|
CC="${{ matrix.triple }}-gcc" make -j$(nproc) clean
|
||||||
CC="${{ matrix.triple }}-gcc" make -j$(nproc) DEV_BUILD=1 ROOTFUL=1
|
CC="${{ matrix.triple }}-gcc" make -j$(nproc) DEV_BUILD=1 TUI=1 ROOTFUL=1
|
||||||
cp src/palera1n palera1n.development
|
cp src/palera1n palera1n.development
|
||||||
|
|
||||||
- name: Prepare artifact
|
- name: Prepare artifact
|
||||||
@@ -832,7 +713,7 @@ jobs:
|
|||||||
|
|
||||||
sed 's|@DEB_ARCH@|${{ env.ARCH_NAME }}|g' -i stage/DEBIAN/control
|
sed 's|@DEB_ARCH@|${{ env.ARCH_NAME }}|g' -i stage/DEBIAN/control
|
||||||
sed "s|@DEB_VERSION@|$version|g" -i stage/DEBIAN/control
|
sed "s|@DEB_VERSION@|$version|g" -i stage/DEBIAN/control
|
||||||
|
|
||||||
install -Dm644 ready/binaries/palera1n-${{ env.CHECKRA1N_NAME }} stage/usr/bin/palera1n
|
install -Dm644 ready/binaries/palera1n-${{ env.CHECKRA1N_NAME }} stage/usr/bin/palera1n
|
||||||
gzip -c9 docs/palera1n.1 > stage/usr/share/man/man1/palera1n.1.gz
|
gzip -c9 docs/palera1n.1 > stage/usr/share/man/man1/palera1n.1.gz
|
||||||
chmod 755 stage/usr/bin/palera1n
|
chmod 755 stage/usr/bin/palera1n
|
||||||
@@ -872,11 +753,6 @@ jobs:
|
|||||||
localDir: 'usbmuxd-static/'
|
localDir: 'usbmuxd-static/'
|
||||||
remoteDir: "/palera1n/artifacts/usbmuxd-static"
|
remoteDir: "/palera1n/artifacts/usbmuxd-static"
|
||||||
|
|
||||||
- name: Generate cached sysroot archive
|
|
||||||
if: steps.sysroot_cache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
|
||||||
tar -c sysroot | xz -zce9T 0 > sysroot-${{ env.CACHE_TXT_CHECKSUM }}.txz
|
|
||||||
|
|
||||||
finish-build:
|
finish-build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ dep_root/**
|
|||||||
!contrib/.keep
|
!contrib/.keep
|
||||||
contrib/
|
contrib/
|
||||||
*.o
|
*.o
|
||||||
dep_root*.tgz
|
|
||||||
.vscode
|
.vscode
|
||||||
checkra1n*
|
checkra1n*
|
||||||
payload.c
|
payload.c
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ DEP = $(SRC)/dep_root
|
|||||||
STRIP = strip
|
STRIP = strip
|
||||||
CC ?= cc
|
CC ?= cc
|
||||||
CFLAGS += -isystem $(DEP)/include -I$(SRC)/include -I$(SRC) -D_XOPEN_SOURCE=500
|
CFLAGS += -isystem $(DEP)/include -I$(SRC)/include -I$(SRC) -D_XOPEN_SOURCE=500
|
||||||
CFLAGS += -Wall -Wextra -Wno-unused-parameter -DPALERAIN_VERSION=\"2.1\" -DHAVE_LIBIMOBILEDEVICE
|
CFLAGS += -Wall -Wextra -Wno-unused-parameter -DPALERAIN_VERSION=\"2.0\" -DHAVE_LIBIMOBILEDEVICE
|
||||||
CFLAGS += -Wno-unused-variable -I$(SRC)/src -std=c99 -pedantic-errors -D_C99_SOURCE -D_POSIX_C_SOURCE=200112L
|
CFLAGS += -Wno-unused-variable -I$(SRC)/src -std=c99 -pedantic-errors -D_C99_SOURCE -D_POSIX_C_SOURCE=200112L
|
||||||
LIBS += $(DEP)/lib/libimobiledevice-1.0.a $(DEP)/lib/libirecovery-1.0.a $(DEP)/lib/libusbmuxd-2.0.a
|
LIBS += $(DEP)/lib/libimobiledevice-1.0.a $(DEP)/lib/libirecovery-1.0.a $(DEP)/lib/libusbmuxd-2.0.a
|
||||||
LIBS += $(DEP)/lib/libimobiledevice-glue-1.0.a $(DEP)/lib/libplist-2.0.a -pthread -lm
|
LIBS += $(DEP)/lib/libimobiledevice-glue-1.0.a $(DEP)/lib/libplist-2.0.a -pthread -lm
|
||||||
@@ -26,12 +26,6 @@ LDFLAGS += -Wl,--gc-sections
|
|||||||
endif
|
endif
|
||||||
LIBS += $(DEP)/lib/libmbedtls.a $(DEP)/lib/libmbedcrypto.a $(DEP)/lib/libmbedx509.a $(DEP)/lib/libreadline.a
|
LIBS += $(DEP)/lib/libmbedtls.a $(DEP)/lib/libmbedcrypto.a $(DEP)/lib/libmbedx509.a $(DEP)/lib/libreadline.a
|
||||||
|
|
||||||
ifeq ($(TUI),1)
|
|
||||||
ifeq ($(TARGET_OS),Linux)
|
|
||||||
LIBS += $(DEP)/lib/libgpm.a
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(DEV_BUILD),1)
|
ifeq ($(DEV_BUILD),1)
|
||||||
CFLAGS += -O0 -g -DDEV_BUILD -fno-omit-frame-pointer
|
CFLAGS += -O0 -g -DDEV_BUILD -fno-omit-frame-pointer
|
||||||
ifeq ($(ASAN),1)
|
ifeq ($(ASAN),1)
|
||||||
@@ -59,12 +53,15 @@ ifneq ($(BAKERAIN_DEVELOPE_R),)
|
|||||||
CFLAGS += -DBAKERAIN_DEVELOPE_R="\"$(BAKERAIN_DEVELOPE_R)\""
|
CFLAGS += -DBAKERAIN_DEVELOPE_R="\"$(BAKERAIN_DEVELOPE_R)\""
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
BUILD_DATE := $(shell LANG=C date)
|
||||||
BUILD_NUMBER := $(shell git rev-list --count HEAD)
|
BUILD_NUMBER := $(shell git rev-list --count HEAD)
|
||||||
BUILD_TAG := $(shell git describe --dirty --tags --abbrev=7)
|
BUILD_TAG := $(shell git describe --dirty --tags --abbrev=7)
|
||||||
|
BUILD_WHOAMI := $(shell whoami)
|
||||||
BUILD_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
BUILD_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
||||||
BUILD_COMMIT := $(shell git rev-parse HEAD)
|
BUILD_COMMIT := $(shell git rev-parse HEAD)
|
||||||
|
|
||||||
CFLAGS += -DBUILD_STYLE="\"$(BUILD_STYLE)\"" -DBUILD_TAG="\"$(BUILD_TAG)\""
|
CFLAGS += -DBUILD_STYLE="\"$(BUILD_STYLE)\"" -DBUILD_DATE="\"$(BUILD_DATE)\""
|
||||||
|
CFLAGS += -DBUILD_WHOAMI="\"$(BUILD_WHOAMI)\"" -DBUILD_TAG="\"$(BUILD_TAG)\""
|
||||||
CFLAGS += -DBUILD_NUMBER="\"$(BUILD_NUMBER)\"" -DBUILD_BRANCH="\"$(BUILD_BRANCH)\""
|
CFLAGS += -DBUILD_NUMBER="\"$(BUILD_NUMBER)\"" -DBUILD_BRANCH="\"$(BUILD_BRANCH)\""
|
||||||
CFLAGS += -DBUILD_COMMIT="\"$(BUILD_COMMIT)\""
|
CFLAGS += -DBUILD_COMMIT="\"$(BUILD_COMMIT)\""
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ Jailbreak for A8 through A11, T2 devices, on iOS/iPadOS/tvOS 15.0, bridgeOS 5.0
|
|||||||
|
|
||||||
## Device Support
|
## Device Support
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Apple TV & iBridge support are not currently in the beta releases of palera1n, ETA s0n
|
||||||
|
|
||||||
<!--- Mobile --->
|
<!--- Mobile --->
|
||||||
|
|
||||||
| iPhone(s) | iPad(s) | iPod(s) | Apple TV(s) |
|
| iPhone(s) | iPad(s) | iPod(s) | Apple TV(s) |
|
||||||
@@ -27,8 +30,6 @@ Jailbreak for A8 through A11, T2 devices, on iOS/iPadOS/tvOS 15.0, bridgeOS 5.0
|
|||||||
| iPhone 8 | iPad Pro (12.9") (1st generation) | | |
|
| iPhone 8 | iPad Pro (12.9") (1st generation) | | |
|
||||||
| iPhone 8 Plus | iPad Pro (10.5") | | |
|
| iPhone 8 Plus | iPad Pro (10.5") | | |
|
||||||
| iPhone X | iPad Pro (12.9") (2nd generation) | | |
|
| iPhone X | iPad Pro (12.9") (2nd generation) | | |
|
||||||
| | iPad Air 2 | | |
|
|
||||||
|
|
||||||
|
|
||||||
> Note that on `A11` (iPhone X, 8, 8 Plus), **you must disable your passcode while in the jailbroken state** (on iOS 16, you need to **reset your device** before proceeding with palera1n).
|
> Note that on `A11` (iPhone X, 8, 8 Plus), **you must disable your passcode while in the jailbroken state** (on iOS 16, you need to **reset your device** before proceeding with palera1n).
|
||||||
|
|
||||||
@@ -75,59 +76,21 @@ Jailbreak for A8 through A11, T2 devices, on iOS/iPadOS/tvOS 15.0, bridgeOS 5.0
|
|||||||
|
|
||||||
> USB-C port on Apple Silicon Macs *may* require manual unplugging and replugging of the lightning cable after checkm8 exploit. This problem may be solved by connecting via USB hub, though extensions can vary.
|
> USB-C port on Apple Silicon Macs *may* require manual unplugging and replugging of the lightning cable after checkm8 exploit. This problem may be solved by connecting via USB hub, though extensions can vary.
|
||||||
|
|
||||||
## Usage
|
|
||||||
```
|
|
||||||
Usage: palera1n [-DEhpvVdsSLRnPI] [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file] [-i checkra1n file]
|
|
||||||
|
|
||||||
--version Print version
|
|
||||||
--force-revert Remove jailbreak
|
|
||||||
-d, --demote Demote
|
|
||||||
-D, --dfuhelper Exit after entering DFU
|
|
||||||
-e, --boot-args <boot arguments> XNU boot arguments
|
|
||||||
-E, --enter-recovery Enter recovery mode
|
|
||||||
-h, --help Show this help
|
|
||||||
-i, --override-checkra1n <file> Override checkra1n
|
|
||||||
-k, --override-pongo <file> Override Pongo image
|
|
||||||
-K, --override-kpf <file> Override kernel patchfinder
|
|
||||||
-L, --jbinit-log-to-file Make jbinit log to /cores/jbinit.log (can be read from sandbox while jailbroken)
|
|
||||||
-n, --exit-recovery Exit recovery mode
|
|
||||||
-I, --device-info Print info about the connected device
|
|
||||||
-o, --override-overlay <file> Override overlay
|
|
||||||
-p, --pongo-shell Boots to PongoOS shell
|
|
||||||
-P, --pongo-full Boots to a PongoOS shell with default images already uploaded
|
|
||||||
-r, --override-ramdisk <file> Override ramdisk
|
|
||||||
-R, --reboot-device Reboot connected device in normal mode
|
|
||||||
-s, --safe-mode Enter safe mode
|
|
||||||
-S, --no-colors Disable colors on the command line
|
|
||||||
-v, --debug-logging Enable debug logging
|
|
||||||
This option can be repeated for extra verbosity.
|
|
||||||
-V, --verbose-boot Verbose boot
|
|
||||||
|
|
||||||
Environmental variables:
|
|
||||||
TMPDIR temporary diretory (path the built-in checkra1n will be extracted to)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
Visit https://palera.in
|
Visit https://palera.in
|
||||||
|
|
||||||
## Disclaimers
|
## Disclaimers
|
||||||
We are **NOT** responsible for any data loss, or the result of a device being bricked. When using palera1n, the user should accept responsibility if anything happens to their device during the process.
|
We are **NOT** responsible for any data loss, or the result of a device being bricked. When using palera1n, the user should accept responsibility if anything happens to their device during the process.
|
||||||
- If your device is stuck in recovery, please run futurerestore `--exit-recovery`, or use `irecovery -n`, or `palera1n -n`.
|
- If your device is stuck in recovery, please run futurerestore `--exit-recovery`, or use `irecovery -n`.
|
||||||
- If you're unable to get out of recovery via these methods please restore with iTunes or Finder.
|
- If you're unable to get out of recovery via these methods please restore with iTunes or Finder.
|
||||||
- palera1n **will not work** in VirtualBox, VMware or any virtual machine that doesn't support PCI passthrough.
|
- palera1n **will not work** in VirtualBox, VMware or any virtual machine that doesn't support PCI passthrough.
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
Make sure you're following the guides provided [here](https://palera.in), also when asking for support make sure you provide full details on your device, such as:
|
Make sure you're following the guides provided [here](https://palera.in), also when asking for support make sure you provide full details on your device, such as:
|
||||||
- iPhone/iPad/iPod/Apple TV
|
- iPhone/iPad/iPod
|
||||||
- iOS Version
|
- iOS Version
|
||||||
- Passcode enabled?
|
- Passcode enabled?
|
||||||
- Verbose from palera1n (specifying `-Vv` within palera1n)
|
- Verbose from palera1n (specifying `-Vv` within palera1n)
|
||||||
- Panic logs, if panicked then send latest `panic-full` log from your device.
|
- Panic logs, if panicked then send latest `panic-full` log from your device.
|
||||||
|
|
||||||
Create an issue here: https://github.com/palera1n/palera1n/issues/new/choose
|
Create an issue here: https://github.com/palera1n/palera1n/issues/new/choose
|
||||||
|
|
||||||
## Credits
|
|
||||||
|
|
||||||
[All credits for palera1n can be found here](https://palera.in/)
|
|
||||||
|
|
||||||
If proper credit isn't shown please message us or create an issue.
|
|
||||||
+29
-25
@@ -2,11 +2,11 @@
|
|||||||
.\" Copyright (c) 2024 Nick Chan
|
.\" Copyright (c) 2024 Nick Chan
|
||||||
.\" SPDX-License-Identifier: MIT
|
.\" SPDX-License-Identifier: MIT
|
||||||
.\"
|
.\"
|
||||||
.Dd "23 December 2024"
|
.Dd "30 March 2024"
|
||||||
.Dt palera1n 1
|
.Dt palera1n 1
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm palera1n
|
.Nm palera1n
|
||||||
.Nd arm64 iOS/iPadOS/tvOS 15.0-18.3, bridgeOS 5.0-9.3 jailbreaking tool
|
.Nd arm64 iOS/iPadOS/tvOS 15.0-17.5, bridgeOS 5.0-8.3 jailbreaking tool
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl cCdDEfhIlLnpRsSTvV
|
.Op Fl cCdDEfhIlLnpRsSTvV
|
||||||
@@ -20,21 +20,19 @@
|
|||||||
.Op Fl -force-revert
|
.Op Fl -force-revert
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm
|
.Nm
|
||||||
jailbreaks an arm64 (arm64e excluded) iOS/iPadOS/tvOS 15.0-18.2, bridgeOS 5.0-9.2 device,
|
jailbreaks an iOS/iPadOS/tvOS 15.0-17.5, bridgeOS 6.0-8.3 device with an arm64 (arm64e excluded) on iOS 15.0-17.5,
|
||||||
utilizing the
|
utilizing the
|
||||||
.Em checkm8
|
.Em checkm8
|
||||||
bootROM exploit.
|
bootROM exploit.
|
||||||
.Pp
|
.Pp
|
||||||
.Nm
|
.Nm
|
||||||
provides rootful and rootless jailbreak modes.
|
provides rootful and rootless jailbreak modes.
|
||||||
On iOS/iPadOS 15.0 and later and on tvOS 18.2 or later,
|
On iOS/iPadOS,
|
||||||
.Nm
|
.Nm
|
||||||
is able to jailbreak the device in fakefs-rootful mode, where /
|
is able to jailbreak the device in fakefs-rootful mode, where /
|
||||||
is writable, as well as rootless mode, where / cannot be written to.
|
is writable, as well as rootless mode, where / cannot be written to.
|
||||||
On tvOS and bridgeOS,
|
On tvOS and bridgeOS,
|
||||||
only rootful is supported. On versions where fakefs-rootful is not
|
only rootful is supported, and it uses the actual filesystem instead of a fakefs.
|
||||||
applicable, palera1n modifies the actual root filesystem instead
|
|
||||||
of making a fakefs
|
|
||||||
.Pp
|
.Pp
|
||||||
Due to the nature of the
|
Due to the nature of the
|
||||||
.Em checkm8
|
.Em checkm8
|
||||||
@@ -59,7 +57,7 @@ In the remainder of this document, the term "iOS" and "iPadOS" will be used inte
|
|||||||
as the difference is negligible as far as the jailbreak is concerened.
|
as the difference is negligible as far as the jailbreak is concerened.
|
||||||
.Pp
|
.Pp
|
||||||
.Sh SUPPORTED DEVICES
|
.Sh SUPPORTED DEVICES
|
||||||
As described above, arm64 iOS 15.0-18.0 devices are supported, here is an explicit
|
As described above, arm64 iOS 15.0-17.5 devices are supported, here is an explicit
|
||||||
list of supported devicecs:
|
list of supported devicecs:
|
||||||
|
|
||||||
.Bl -tag -compact
|
.Bl -tag -compact
|
||||||
@@ -103,7 +101,9 @@ list of supported devicecs:
|
|||||||
.It Apple T2 MacBookPro15,3
|
.It Apple T2 MacBookPro15,3
|
||||||
.It Apple T2 MacBookAir8,1
|
.It Apple T2 MacBookAir8,1
|
||||||
.It Apple T2 MacBookPro15,4
|
.It Apple T2 MacBookPro15,4
|
||||||
|
.It iBridge2,11 (Unknown Mac)
|
||||||
.It Apple T2 MacBookAir8,2
|
.It Apple T2 MacBookAir8,2
|
||||||
|
.It iBridge2,13 (Unknown Mac)
|
||||||
.It Apple T2 MacBookPro16,1
|
.It Apple T2 MacBookPro16,1
|
||||||
.It Apple T2 MacBookAir9,1
|
.It Apple T2 MacBookAir9,1
|
||||||
.It Apple T2 MacBookPro16,2
|
.It Apple T2 MacBookPro16,2
|
||||||
@@ -139,14 +139,12 @@ Like
|
|||||||
but the size of the created fakefs is smaller at the expense of having unwritable
|
but the size of the created fakefs is smaller at the expense of having unwritable
|
||||||
parts in rarely-written paths. When jailbreaking 16 GB devices, this option must be used
|
parts in rarely-written paths. When jailbreaking 16 GB devices, this option must be used
|
||||||
when setting up fakefs for rootful, as they do not have enough storage for full fakefs.
|
when setting up fakefs for rootful, as they do not have enough storage for full fakefs.
|
||||||
This flag is supported on iOS/iPadOS 15.0 or later and tvOS 18.2 or later, as they
|
This flag is only supported on iOS/iPadOS.
|
||||||
require fakefs for rootful.
|
|
||||||
.It Fl c , -setup-fakefs
|
.It Fl c , -setup-fakefs
|
||||||
When used with
|
When used with
|
||||||
.Fl f , -fakefs ,
|
.Fl f , -fakefs ,
|
||||||
creates the new APFS volume required for rootful. Will fail if one already exists.
|
creates the new APFS volume required for rootful. Will fail if one already exists.
|
||||||
This flag is supported on iOS/iPadOS 15.0 or later and tvOS 18.2 or later, as they
|
This flag is only supported on iOS/iPadOS.
|
||||||
require fakefs for rootful.
|
|
||||||
.It Fl C , -clean-fakefs
|
.It Fl C , -clean-fakefs
|
||||||
This option is not currently supported and is a no-operation in this version of
|
This option is not currently supported and is a no-operation in this version of
|
||||||
.Nm
|
.Nm
|
||||||
@@ -157,13 +155,18 @@ Set the effective production fuse to 0, so as to enable hardware debugging featu
|
|||||||
Execute the DFU helper to guide the user into putting the device into DFU mode
|
Execute the DFU helper to guide the user into putting the device into DFU mode
|
||||||
then exit.
|
then exit.
|
||||||
.It Fl e , -boot-args Ar boot arguments
|
.It Fl e , -boot-args Ar boot arguments
|
||||||
Specify custom XNU kernel command line. Additionally, the
|
Specify custom XNU kernel command line. The
|
||||||
|
.Em rootdev=md0
|
||||||
|
argument is used by
|
||||||
|
.Nm
|
||||||
|
and cannot be overriden. Additionally, the
|
||||||
.Em wdt=-1
|
.Em wdt=-1
|
||||||
argument is used during fakefs setup.
|
argument is used during fakefs setup.
|
||||||
.It Fl E , -enter-recovery
|
.It Fl E , -enter-recovery
|
||||||
Exit after entering recovery mode.
|
Exit after entering recovery mode.
|
||||||
.It Fl f , -fakefs
|
.It Fl f , -fakefs
|
||||||
Proceed in rootful mode. Despite its name, this applies to both full, partial fakefs, as well as realfs, and it still applies even when trying to force revert.
|
Proceed in rootful mode. This applies to both full, partial fakefs, as well as realfs.
|
||||||
|
This option is not supported on iOS/iPadOS 17.
|
||||||
.It Fl h , -help
|
.It Fl h , -help
|
||||||
Prints help text.
|
Prints help text.
|
||||||
.It Fl i , -checkra1n-file Ar checkra1n file
|
.It Fl i , -checkra1n-file Ar checkra1n file
|
||||||
@@ -181,6 +184,10 @@ command. If in doubt, use
|
|||||||
iOS15 branch or your own fork of it.
|
iOS15 branch or your own fork of it.
|
||||||
.It Fl l , -rootless
|
.It Fl l , -rootless
|
||||||
Proceed in rootless mode. This option is only supported on iOS/iPadOS.
|
Proceed in rootless mode. This option is only supported on iOS/iPadOS.
|
||||||
|
.It Fl L , -jbinit-log-to-file
|
||||||
|
This option is not currently supported and is a no-operation in this version of
|
||||||
|
.Nm
|
||||||
|
\[char46]
|
||||||
.It Fl n , -exit-recovery
|
.It Fl n , -exit-recovery
|
||||||
Exit recovery mode and exit.
|
Exit recovery mode and exit.
|
||||||
.It Fl o , -override-overlay Ar overlay file
|
.It Fl o , -override-overlay Ar overlay file
|
||||||
@@ -235,13 +242,13 @@ is extracted and executed here. When not set, /tmp is used.
|
|||||||
.Sh EXAMPLES
|
.Sh EXAMPLES
|
||||||
To (re-)jailbreak in rootless mode:
|
To (re-)jailbreak in rootless mode:
|
||||||
.Pp
|
.Pp
|
||||||
.Dl "palera1n -l"
|
.Dl "palera1n"
|
||||||
.Pp
|
.Pp
|
||||||
To setup fakefs for rootful mode:
|
To setup fakefs for rootful mode:
|
||||||
.Pp
|
.Pp
|
||||||
.Dl "palera1n -fc"
|
.Dl "palera1n -fc"
|
||||||
.Pp
|
.Pp
|
||||||
After the device has rebooted into recovery mode, follow the following example.
|
After the device has rebooted, follow the following example.
|
||||||
.Pp
|
.Pp
|
||||||
To re-jailbreak in rootful mode:
|
To re-jailbreak in rootful mode:
|
||||||
.Pp
|
.Pp
|
||||||
@@ -298,7 +305,7 @@ option might cause some versions for tvOS to crash and not boot.
|
|||||||
Offical Apple USB-C cables as well as some other USB-C cables cannot be used to enter DFU mode.
|
Offical Apple USB-C cables as well as some other USB-C cables cannot be used to enter DFU mode.
|
||||||
USB-A cable with male USB-C to female USB-A adapter works fine.
|
USB-A cable with male USB-C to female USB-A adapter works fine.
|
||||||
.Sh POST INSTALLATION (iOS/iPadOS)
|
.Sh POST INSTALLATION (iOS/iPadOS)
|
||||||
The palera1n loader app will take up to 1 minute to appear on the homescreen after the
|
The palera1n loader app will take up to 30 seconds to appear on the homescreen after the
|
||||||
device has booted. If it does not appear, you can try using the shortcut:
|
device has booted. If it does not appear, you can try using the shortcut:
|
||||||
.Pp
|
.Pp
|
||||||
.Lk https://www.icloud.com/shortcuts/8cd5f489c8854ee0ab9ee38f2e62f87d
|
.Lk https://www.icloud.com/shortcuts/8cd5f489c8854ee0ab9ee38f2e62f87d
|
||||||
@@ -326,7 +333,7 @@ loader app to install additional jailbreak files.
|
|||||||
|
|
||||||
.Bl -tag -width "/var/jb/Library/LaunchDaemons"
|
.Bl -tag -width "/var/jb/Library/LaunchDaemons"
|
||||||
.It Pa /cores
|
.It Pa /cores
|
||||||
The location of the temporary filesystem where jailbreak files are stashed during boot.
|
The location of the temporary filesystem where jailbreak files are stash during boot.
|
||||||
.It Pa /Library/LaunchDaemons
|
.It Pa /Library/LaunchDaemons
|
||||||
The directory where jailbreak-specific
|
The directory where jailbreak-specific
|
||||||
.Xr launchd.plist 5
|
.Xr launchd.plist 5
|
||||||
@@ -346,17 +353,14 @@ has been mounted.
|
|||||||
.El
|
.El
|
||||||
.Sh BUGS
|
.Sh BUGS
|
||||||
.Nm
|
.Nm
|
||||||
may crash if the machine it is running on has non-compliant USB devices plugged in.
|
may crash if the machine it is running on:
|
||||||
.Pp
|
.Pp
|
||||||
.Nm
|
.Dl "- Has non-compliant USB devices plugged in"
|
||||||
will fail to initialize on Linux when there are no USB devices plugged in.
|
|
||||||
Usually this is not a problem on PCs since the built-in root hubs are also
|
|
||||||
USB devices. However, on platforms such as Apple Silicon Macs in Linux, since
|
|
||||||
there are no built-in USB hubs, at least one USB device needs to be manually
|
|
||||||
plugged in for palera1n to be initialized.
|
|
||||||
.Pp
|
.Pp
|
||||||
The exploit may also work less reliably on some hosts, like AMD desktops, or some MediaTek devices.
|
The exploit may also work less reliably on some hosts, like AMD desktops, or some MediaTek devices.
|
||||||
.Pp
|
.Pp
|
||||||
|
The device may randomly crash and reboot due to launchd using too much memory.
|
||||||
|
.Pp
|
||||||
The built-in SSH server might be not accessible with password after bootstrapping rootful,
|
The built-in SSH server might be not accessible with password after bootstrapping rootful,
|
||||||
since the bootstrap uses a custom crypt() function that is not supported
|
since the bootstrap uses a custom crypt() function that is not supported
|
||||||
by the built-in SSH server.
|
by the built-in SSH server.
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ typedef uint64_t palerain_option_t;
|
|||||||
#define palerain_option_ssv (UINT64_C(1) << 7) /* has signed system volume */
|
#define palerain_option_ssv (UINT64_C(1) << 7) /* has signed system volume */
|
||||||
// (UINT64_C(1) << 8) /* reserved */
|
// (UINT64_C(1) << 8) /* reserved */
|
||||||
#define palerain_option_clean_fakefs (UINT64_C(1) << 9) /* clean fakefs, but does not delete it */
|
#define palerain_option_clean_fakefs (UINT64_C(1) << 9) /* clean fakefs, but does not delete it */
|
||||||
#define palerain_option_tui (UINT64_C(1) << 10) /* terminal user interface */
|
|
||||||
// #define palerain_option_gui (UINT64_C(1) << 11) /* graphical user interface*/
|
// #define palerain_option_gui (UINT64_C(1) << 11) /* graphical user interface*/
|
||||||
#define palerain_option_dfuhelper_only (UINT64_C(1) << 12) /* dfuhelper only */
|
#define palerain_option_dfuhelper_only (UINT64_C(1) << 12) /* dfuhelper only */
|
||||||
#define palerain_option_pongo_exit (UINT64_C(1) << 13) /* boot to clean pongo shell */
|
#define palerain_option_pongo_exit (UINT64_C(1) << 13) /* boot to clean pongo shell */
|
||||||
@@ -46,7 +45,6 @@ typedef uint64_t palerain_option_t;
|
|||||||
// #define palerain_option_sf_launchdaemons (UINT64_C(1) << 28) /* safe mode with launchdaemons */
|
// #define palerain_option_sf_launchdaemons (UINT64_C(1) << 28) /* safe mode with launchdaemons */
|
||||||
// #define palerain_option_emerg_mode (UINT64_C(1) << 29) /* emergency mode (early boot usb shell) */
|
// #define palerain_option_emerg_mode (UINT64_C(1) << 29) /* emergency mode (early boot usb shell) */
|
||||||
#define palerain_option_jbinit_log_to_file (UINT64_C(1) << 30) /* deprecated (kept for compatibility) */
|
#define palerain_option_jbinit_log_to_file (UINT64_C(1) << 30) /* deprecated (kept for compatibility) */
|
||||||
#define palerain_option_cli (UINT64_C(1) << 31) /* CLI mode */
|
|
||||||
#define palerain_option_telnetd (UINT64_C(1) << 32) /* Enable TELNET daemon */
|
#define palerain_option_telnetd (UINT64_C(1) << 32) /* Enable TELNET daemon */
|
||||||
|
|
||||||
#define palerain_option_flower_chain (UINT64_C(1) << 61) /* Flower chain */
|
#define palerain_option_flower_chain (UINT64_C(1) << 61) /* Flower chain */
|
||||||
|
|||||||
+1
-1
@@ -72,7 +72,7 @@ usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, uint32_t len);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PALERAIN_VERSION
|
#ifndef PALERAIN_VERSION
|
||||||
#define PALERAIN_VERSION "2.1"
|
#define PALERAIN_VERSION "2.0"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
|||||||
-190
@@ -1,190 +0,0 @@
|
|||||||
#ifndef TUI_H
|
|
||||||
#define TUI_H
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <paleinfo.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <semaphore.h>
|
|
||||||
|
|
||||||
#define WIDTH 76
|
|
||||||
#define HEIGHT 19
|
|
||||||
|
|
||||||
#define CHECKBOX_STATE(flags, opt) (flags & opt) != 0 ? '*' : ' '
|
|
||||||
|
|
||||||
#define STR_HELPER(x) #x
|
|
||||||
#define STR(x) STR_HELPER(x)
|
|
||||||
|
|
||||||
#define CLEAR_SCREEN printf("\033[2J")
|
|
||||||
#define RESETFONT printf("\x1b[0m")
|
|
||||||
#define PRINTAT(x, y, str) printf("\x1b[%d;%dH%s", y, x, str)
|
|
||||||
#define PRINTATT(x, y, str) PRINTAT(tui_x_offset + x, tui_y_offset + y, str)
|
|
||||||
#define PRINTATLEN(x, y, str, len) printf("\x1b[%d;%dH%." STR(len) "s", y, x, str)
|
|
||||||
#define PRINTATLENT(x, y, str, len) PRINTATLEN(tui_x_offset + x, tui_y_offset + y, str, len)
|
|
||||||
#define MOVETO(x, y) printf("\x1b[%d;%dH", y, x)
|
|
||||||
#define MOVETOT(x, y) MOVETO(tui_x_offset + x, tui_y_offset + y)
|
|
||||||
#define SETCOLOR(fg, bg) printf("\x1b[%d;%dm", fg, bg)
|
|
||||||
#define SETCOLORA(fg, bg, a) printf("\x1b[" STR(fg) ";" STR(bg) ";" STR(a) "m")
|
|
||||||
#define COLOR(fg, bg) "\x1b[" STR(fg) ";" STR(bg) "m"
|
|
||||||
#define FG_BLACK 30
|
|
||||||
#define FG_YELLOW 33
|
|
||||||
#define FG_BLUE 34
|
|
||||||
#define FG_WHITE 37
|
|
||||||
#define BG_BLACK 40
|
|
||||||
#define BG_YELLOW 43
|
|
||||||
#define BG_BLUE 44
|
|
||||||
#define BG_WHITE 47
|
|
||||||
#define NONE 0
|
|
||||||
#define BOLD 1
|
|
||||||
extern bool supports_bright_colors;
|
|
||||||
#define FG_BRIGHT_BLACK 90
|
|
||||||
#define FG_BRIGHT_WHITE 97
|
|
||||||
#define BG_BRIGHT_BLACK 100
|
|
||||||
#define BG_BRIGHT_WHITE 107
|
|
||||||
#define G1D4(set) printf("\x1b\x29%c", set)
|
|
||||||
#define DSGON putchar('\x0e'); G1D4('0')
|
|
||||||
#define DSGOFF putchar('\x0f'); G1D4('B')
|
|
||||||
#define MOUSEON printf("\x1b[?1003h")
|
|
||||||
#define MOUSEOFF printf("\x1b[?1003l")
|
|
||||||
#define CIVIS printf("\x1b[?25l")
|
|
||||||
#define CNORM printf("\x1b[?25h")
|
|
||||||
#define SMCUP printf("\x1b[?1049h")
|
|
||||||
#define RMCUP printf("\x1b[?1049l")
|
|
||||||
#define DRAWLINE(x, y, len) \
|
|
||||||
MOVETO(x, y); \
|
|
||||||
DSGON; \
|
|
||||||
for (int i = 0; i < len; i++) { \
|
|
||||||
putchar(0x71); \
|
|
||||||
} \
|
|
||||||
DSGOFF;
|
|
||||||
#define DRAWLINET(x, y, len) DRAWLINE(tui_x_offset + x, tui_y_offset + y, len)
|
|
||||||
|
|
||||||
typedef enum tui_screens {
|
|
||||||
ERROR_SCREEN = -1,
|
|
||||||
EXIT_SCREEN = 0,
|
|
||||||
MAIN_SCREEN = 1,
|
|
||||||
OPTIONS_SCREEN = 2,
|
|
||||||
ENTER_DFU_SCREEN = 3,
|
|
||||||
JAILBREAK_SCREEN = 4,
|
|
||||||
ENTER_RECOVERY_SCREEN = 5
|
|
||||||
} tui_screen_t;
|
|
||||||
|
|
||||||
typedef struct bitfield_checkbox_info {
|
|
||||||
uint64_t* flags_p;
|
|
||||||
uint64_t opt;
|
|
||||||
} tui_bit_info_t;
|
|
||||||
|
|
||||||
tui_screen_t tui_screen_main(void);
|
|
||||||
void tui_screen_main_redraw(void);
|
|
||||||
tui_screen_t tui_screen_options(void);
|
|
||||||
void tui_screen_options_redraw(void);
|
|
||||||
tui_screen_t tui_screen_enter_recovery(void);
|
|
||||||
void tui_screen_enter_recovery_redraw(void);
|
|
||||||
tui_screen_t tui_screen_enter_dfu(void);
|
|
||||||
void tui_screen_enter_dfu_redraw(void);
|
|
||||||
tui_screen_t tui_screen_jailbreak(void);
|
|
||||||
void tui_screen_jailbreak_redraw(void);
|
|
||||||
|
|
||||||
int redraw_screen(void);
|
|
||||||
|
|
||||||
void tui_draw_rectangle(int x1, int y1, int x2, int y2);
|
|
||||||
|
|
||||||
#ifdef BUILD_TAG
|
|
||||||
#define TUI_VERSION BUILD_TAG
|
|
||||||
#else
|
|
||||||
#define TUI_VERSION "Unknown Version"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern int tui_state;
|
|
||||||
extern int tui_x_offset;
|
|
||||||
extern int tui_y_offset;
|
|
||||||
|
|
||||||
extern bool tui_can_start;
|
|
||||||
|
|
||||||
extern int tui_mouse_x;
|
|
||||||
extern int tui_mouse_y;
|
|
||||||
|
|
||||||
enum {
|
|
||||||
TUI_INPUT_NONE,
|
|
||||||
TUI_INPUT_LEFT,
|
|
||||||
TUI_INPUT_RIGHT,
|
|
||||||
TUI_INPUT_UP,
|
|
||||||
TUI_INPUT_DOWN,
|
|
||||||
TUI_INPUT_MOUSE_MOVE,
|
|
||||||
TUI_INPUT_MOUSE_DOWN,
|
|
||||||
TUI_INPUT_MOUSE_UP,
|
|
||||||
TUI_INPUT_SELECT,
|
|
||||||
TUI_INPUT_TAB,
|
|
||||||
TUI_INPUT_TAB_BACK,
|
|
||||||
TUI_INPUT_BACKSPACE,
|
|
||||||
TUI_INPUT_ESCAPE,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
TUI_EVENT_INPUT,
|
|
||||||
TUI_EVENT_CONNECTED_DEVICES_CHANGED,
|
|
||||||
TUI_EVENT_JAILBREAK_STATUS_CHANGED
|
|
||||||
};
|
|
||||||
|
|
||||||
int tui_get_input(void);
|
|
||||||
void *tui_input_thread(void *arg);
|
|
||||||
int tui_get_event(void);
|
|
||||||
int tui_try_get_event(void);
|
|
||||||
|
|
||||||
extern int tui_last_event;
|
|
||||||
extern int tui_last_input;
|
|
||||||
extern sem_t *tui_event_semaphore;
|
|
||||||
extern char tui_last_key;
|
|
||||||
|
|
||||||
void tui_devhelper(void);
|
|
||||||
|
|
||||||
enum tui_device_mode {
|
|
||||||
TUI_DEVICE_MODE_NORMAL,
|
|
||||||
TUI_DEVICE_MODE_RECOVERY,
|
|
||||||
TUI_DEVICE_MODE_DFU
|
|
||||||
};
|
|
||||||
|
|
||||||
struct tui_connected_device {
|
|
||||||
uint64_t ecid;
|
|
||||||
char udid[44];
|
|
||||||
char version[0x20];
|
|
||||||
bool arm64;
|
|
||||||
enum tui_device_mode mode;
|
|
||||||
char product_type[0x20];
|
|
||||||
char display_name[0x20];
|
|
||||||
unsigned int cpid;
|
|
||||||
bool requires_passcode_disabled;
|
|
||||||
bool passcode_state;
|
|
||||||
struct tui_connected_device *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern struct tui_connected_device *tui_connected_devices;
|
|
||||||
|
|
||||||
int tui_compare_versions(const char *firstVersion, const char *secondVersion);
|
|
||||||
|
|
||||||
void tui_jailbreak(void);
|
|
||||||
extern bool tui_is_jailbreaking;
|
|
||||||
extern int tui_jailbreak_stage;
|
|
||||||
extern char *tui_jailbreak_status;
|
|
||||||
|
|
||||||
void tui_jailbreak_status_changed(void);
|
|
||||||
|
|
||||||
extern bool tui_is_restarting;
|
|
||||||
void tui_terminate(int sig);
|
|
||||||
|
|
||||||
extern bool tui_options_allow_untested;
|
|
||||||
extern bool tui_options_safe_mode;
|
|
||||||
extern bool tui_options_verbose_boot;
|
|
||||||
extern bool tui_options_force_revert;
|
|
||||||
extern bool tui_options_flower_chain;
|
|
||||||
|
|
||||||
extern char tui_options_boot_args[0x1e0 + 1];
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+1
-6
@@ -63,12 +63,7 @@ CFLAGS += -DNO_CUSTOM_PONGO
|
|||||||
BUILD_OPTIONS += NO_CUSTOM_PONGO
|
BUILD_OPTIONS += NO_CUSTOM_PONGO
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TUI),1)
|
CHECKRA1N_VERSION ?= 0.1337.2
|
||||||
BUILD_OPTIONS += TUI
|
|
||||||
CFLAGS += -DTUI
|
|
||||||
endif
|
|
||||||
|
|
||||||
CHECKRA1N_VERSION ?= 0.1337.3
|
|
||||||
LIPO = lipo
|
LIPO = lipo
|
||||||
LDID = ldid
|
LDID = ldid
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -5,15 +5,13 @@
|
|||||||
#endif
|
#endif
|
||||||
#define THE_PLUSH "Ploosh"
|
#define THE_PLUSH "Ploosh"
|
||||||
|
|
||||||
#define NEKO_DEVELOPE_R "HAHALOSAH"
|
|
||||||
|
|
||||||
#define T void
|
#define T void
|
||||||
#define R print_credits(void) {
|
#define R print_credits(void) {
|
||||||
#define O fprintf(
|
#define O fprintf(
|
||||||
#define U stderr,
|
#define U stderr,
|
||||||
#define B "#\n# palera1n: " BUILD_TAG " \n#\n"
|
#define B "#\n# palera1n: " BUILD_TAG " \n#\n"
|
||||||
#define L "# ======== Made by =======\n"
|
#define L "# ======== Made by =======\n"
|
||||||
#define E "# Made by: Nick Chan, " THE_PLUSH ", Khcrysalis, Mineek, staturnz, " BAKERAIN_DEVELOPE_R ", " NEKO_DEVELOPE_R " \n"
|
#define E "# Made by: Nick Chan, " THE_PLUSH ", Samara, Mineek, staturnz, " BAKERAIN_DEVELOPE_R "\n"
|
||||||
#define M "# ======== Thanks to =======\n"
|
#define M "# ======== Thanks to =======\n"
|
||||||
#define A "# Thanks to: llsc12, Nebula, Lrdsnow, nikias (libimobiledevice),\n"
|
#define A "# Thanks to: llsc12, Nebula, Lrdsnow, nikias (libimobiledevice),\n"
|
||||||
#define K "# checkra1n team (Siguza, axi0mx, littlelailo et al.),\n"
|
#define K "# checkra1n team (Siguza, axi0mx, littlelailo et al.),\n"
|
||||||
|
|||||||
+14
-22
@@ -67,30 +67,13 @@ int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
|
|||||||
LOG(LOG_ERROR, "Unable to get device information");
|
LOG(LOG_ERROR, "Unable to get device information");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (strcmp(dev.CPUArchitecture, "arm64")) {
|
if (strncmp(dev.CPUArchitecture, "arm64", strlen("arm64"))) {
|
||||||
devinfo_free(&dev);
|
devinfo_free(&dev);
|
||||||
LOG(LOG_WARNING, "Ignoring non-arm64 device...");
|
LOG(LOG_WARNING, "Ignoring non-arm64 device...");
|
||||||
LOG(LOG_WARNING, "palera1n doesn't and never will work on A12+ (arm64e)");
|
LOG(LOG_WARNING, "palera1n doesn't and never will work on A12+ (arm64e)");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (!strncmp(dev.productType, "iPhone10,", strlen("iPhone10,"))) {
|
||||||
if ((palerain_flags & palerain_option_device_info)) {
|
|
||||||
printf("Mode: normal\n");
|
|
||||||
printf("ProductType: %s\n", dev.productType);
|
|
||||||
printf("Architecture: %s\n", dev.CPUArchitecture);
|
|
||||||
printf("Version: %s\n", dev.productVersion);
|
|
||||||
printf("DisplayName: %s\n", dev.displayName);
|
|
||||||
|
|
||||||
device_has_booted = true;
|
|
||||||
set_spin(0);
|
|
||||||
unsubscribe_cmd();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* For Booting Linux etc */
|
|
||||||
if (!getenv("PALERA1N_BYPASS_PASSCODE_CHECK") &&
|
|
||||||
!strncmp(dev.productType, "iPhone10,", strlen("iPhone10,")
|
|
||||||
)) {
|
|
||||||
if (!(palerain_flags & palerain_option_device_info))
|
if (!(palerain_flags & palerain_option_device_info))
|
||||||
LOG(LOG_VERBOSE2, "Product %s requires passcode to be disabled", dev.productType);
|
LOG(LOG_VERBOSE2, "Product %s requires passcode to be disabled", dev.productType);
|
||||||
unsigned char passcode_state = 0;
|
unsigned char passcode_state = 0;
|
||||||
@@ -108,10 +91,19 @@ int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getenv("PALERA1N_BYPASS_PASSCODE_CHECK"))
|
|
||||||
LOG(LOG_WARNING, "Bypassed passcode check");
|
|
||||||
|
|
||||||
|
if ((palerain_flags & palerain_option_device_info)) {
|
||||||
|
printf("Mode: normal\n");
|
||||||
|
printf("ProductType: %s\n", dev.productType);
|
||||||
|
printf("Architecture: %s\n", dev.CPUArchitecture);
|
||||||
|
printf("Version: %s\n", dev.productVersion);
|
||||||
|
printf("DisplayName: %s\n", dev.displayName);
|
||||||
|
|
||||||
|
device_has_booted = true;
|
||||||
|
set_spin(0);
|
||||||
|
unsubscribe_cmd();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (verbose > 1) {
|
if (verbose > 1) {
|
||||||
/* (LOG_VERBOSE - 3) or below*/
|
/* (LOG_VERBOSE - 3) or below*/
|
||||||
LOG(LOG_INFO, "Telling device with udid %s to enter recovery mode immediately", usbmuxd_device->udid);
|
LOG(LOG_INFO, "Telling device with udid %s to enter recovery mode immediately", usbmuxd_device->udid);
|
||||||
|
|||||||
+48
-49
@@ -26,9 +26,6 @@ extern char **environ;
|
|||||||
extern char* gOverrideLibcheckra1nHelper;
|
extern char* gOverrideLibcheckra1nHelper;
|
||||||
|
|
||||||
#include <palerain.h>
|
#include <palerain.h>
|
||||||
#ifdef TUI
|
|
||||||
#include <tui.h>
|
|
||||||
#endif
|
|
||||||
#include <xxd-embedded.h>
|
#include <xxd-embedded.h>
|
||||||
char* pongo_path = NULL;
|
char* pongo_path = NULL;
|
||||||
bool external_pongo = false;
|
bool external_pongo = false;
|
||||||
@@ -40,6 +37,10 @@ int exec_checkra1n(void) {
|
|||||||
LOG(LOG_INFO, "About to execute checkra1n");
|
LOG(LOG_INFO, "About to execute checkra1n");
|
||||||
int fd_checkra1n, fd_pongo, ret;
|
int fd_checkra1n, fd_pongo, ret;
|
||||||
char* checkra1n_path = NULL;
|
char* checkra1n_path = NULL;
|
||||||
|
if (ext_checkra1n != NULL) {
|
||||||
|
checkra1n_path = ext_checkra1n;
|
||||||
|
goto checkra1n_exec;
|
||||||
|
}
|
||||||
#ifndef NO_CUSTOM_PONGO
|
#ifndef NO_CUSTOM_PONGO
|
||||||
if (pongo_path == NULL) {
|
if (pongo_path == NULL) {
|
||||||
pongo_path = malloc(strlen(tmpdir) + 20);
|
pongo_path = malloc(strlen(tmpdir) + 20);
|
||||||
@@ -65,40 +66,36 @@ int exec_checkra1n(void) {
|
|||||||
}
|
}
|
||||||
} else external_pongo = true;
|
} else external_pongo = true;
|
||||||
#endif
|
#endif
|
||||||
if (ext_checkra1n != NULL) {
|
checkra1n_path = malloc(strlen(tmpdir) + 20);
|
||||||
checkra1n_path = ext_checkra1n;
|
if (checkra1n_path == NULL) {
|
||||||
} else {
|
LOG(LOG_FATAL, "memory allocation failed\n");
|
||||||
checkra1n_path = malloc(strlen(tmpdir) + 20);
|
return -1;
|
||||||
if (checkra1n_path == NULL) {
|
}
|
||||||
LOG(LOG_FATAL, "memory allocation failed\n");
|
snprintf(checkra1n_path, strlen(tmpdir) + 20, "%s/checkra1n.XXXXXX", tmpdir);
|
||||||
return -1;
|
fd_checkra1n = mkstemp(checkra1n_path);
|
||||||
}
|
if (fd_checkra1n == -1) {
|
||||||
snprintf(checkra1n_path, strlen(tmpdir) + 20, "%s/checkra1n.XXXXXX", tmpdir);
|
LOG(LOG_FATAL, "Cannot open temporary file %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
||||||
fd_checkra1n = mkstemp(checkra1n_path);
|
free(checkra1n_path);
|
||||||
if (fd_checkra1n == -1) {
|
checkra1n_path = NULL;
|
||||||
LOG(LOG_FATAL, "Cannot open temporary file %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
return -1;
|
||||||
free(checkra1n_path);
|
}
|
||||||
checkra1n_path = NULL;
|
ssize_t didWrite_checkra1n = write(fd_checkra1n, checkra1n, checkra1n_len);
|
||||||
return -1;
|
if (didWrite_checkra1n != (ssize_t)checkra1n_len) {
|
||||||
}
|
LOG(LOG_FATAL, "Size written to %s does not match expected: %zd != %" PRIu32 ": %d (%s)", checkra1n_path, didWrite_checkra1n, checkra1n_len, errno, strerror(errno));
|
||||||
ssize_t didWrite_checkra1n = write(fd_checkra1n, checkra1n, checkra1n_len);
|
|
||||||
if (didWrite_checkra1n != (ssize_t)checkra1n_len) {
|
|
||||||
LOG(LOG_FATAL, "Size written to %s does not match expected: %zd != %" PRIu32 ": %d (%s)", checkra1n_path, didWrite_checkra1n, checkra1n_len, errno, strerror(errno));
|
|
||||||
close(fd_checkra1n);
|
|
||||||
unlink(checkra1n_path);
|
|
||||||
free(checkra1n_path);
|
|
||||||
checkra1n_path = NULL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
close(fd_checkra1n);
|
close(fd_checkra1n);
|
||||||
ret = chmod(checkra1n_path, 0700);
|
unlink(checkra1n_path);
|
||||||
if (ret) {
|
free(checkra1n_path);
|
||||||
LOG(LOG_FATAL, "Cannot chmod %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
checkra1n_path = NULL;
|
||||||
unlink(checkra1n_path);
|
return -1;
|
||||||
free(checkra1n_path);
|
}
|
||||||
checkra1n_path = NULL;
|
close(fd_checkra1n);
|
||||||
return -1;
|
ret = chmod(checkra1n_path, 0700);
|
||||||
}
|
if (ret) {
|
||||||
|
LOG(LOG_FATAL, "Cannot chmod %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
||||||
|
unlink(checkra1n_path);
|
||||||
|
free(checkra1n_path);
|
||||||
|
checkra1n_path = NULL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
#if defined(__APPLE__) && defined(__arm64__) && (TARGET_OS_IPHONE || defined(FORCE_HELPER))
|
#if defined(__APPLE__) && defined(__arm64__) && (TARGET_OS_IPHONE || defined(FORCE_HELPER))
|
||||||
char* libcheckra1nhelper_dylib_path = NULL;
|
char* libcheckra1nhelper_dylib_path = NULL;
|
||||||
@@ -146,6 +143,7 @@ setenv_ra1n:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
checkra1n_exec: {};
|
||||||
char args[0x10] = "-E";
|
char args[0x10] = "-E";
|
||||||
if ((palerain_flags & palerain_option_demote)) strncat(args, "d", 0xf);
|
if ((palerain_flags & palerain_option_demote)) strncat(args, "d", 0xf);
|
||||||
if (!(palerain_flags & palerain_option_checkrain_is_clone)) {
|
if (!(palerain_flags & palerain_option_checkrain_is_clone)) {
|
||||||
@@ -160,20 +158,21 @@ setenv_ra1n:
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
posix_spawn_file_actions_t action;
|
posix_spawn_file_actions_t action;
|
||||||
posix_spawn_file_actions_init(&action);
|
posix_spawn_file_actions_init(&action);
|
||||||
#ifdef TUI
|
if (pongo_path != NULL) {
|
||||||
if (tui_is_jailbreaking) {
|
ret = posix_spawn(&pid, checkra1n_path, &action, NULL, (char* []){
|
||||||
// silence checkra1n
|
checkra1n_path,
|
||||||
posix_spawn_file_actions_addopen(&action, 1, "/dev/null", O_WRONLY, 0);
|
args,
|
||||||
posix_spawn_file_actions_addopen(&action, 2, "/dev/null", O_WRONLY, 0);
|
"-k",
|
||||||
|
pongo_path,
|
||||||
|
NULL
|
||||||
|
}, environ);
|
||||||
|
} else {
|
||||||
|
ret = posix_spawn(&pid, checkra1n_path, &action, NULL, (char* []){
|
||||||
|
checkra1n_path,
|
||||||
|
args,
|
||||||
|
NULL
|
||||||
|
}, environ);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
ret = posix_spawn(&pid, checkra1n_path, &action, NULL, (char* []){
|
|
||||||
checkra1n_path,
|
|
||||||
args,
|
|
||||||
"-k",
|
|
||||||
pongo_path,
|
|
||||||
NULL
|
|
||||||
}, environ);
|
|
||||||
posix_spawn_file_actions_destroy(&action);
|
posix_spawn_file_actions_destroy(&action);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
LOG(LOG_FATAL, "Cannot posix spawn %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
LOG(LOG_FATAL, "Cannot posix spawn %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
||||||
|
|||||||
@@ -8,20 +8,9 @@
|
|||||||
#include <ANSI-color-codes.h>
|
#include <ANSI-color-codes.h>
|
||||||
#include <palerain.h>
|
#include <palerain.h>
|
||||||
|
|
||||||
#ifdef TUI
|
|
||||||
#include <tui.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, const char *__restrict format, ...)
|
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, const char *__restrict format, ...)
|
||||||
{
|
{
|
||||||
#ifdef TUI
|
if (verbose >= 5) fprintf(stderr, "p1_log: loglevel %d from %s:%d:%s()\n", loglevel, fname, lineno, fxname);
|
||||||
if (tui_started) return 0;
|
|
||||||
#endif
|
|
||||||
if (verbose >= 5
|
|
||||||
#ifdef TUI
|
|
||||||
&& !(palerain_flags & palerain_option_tui)
|
|
||||||
#endif
|
|
||||||
) fprintf(stderr, "p1_log: loglevel %d from %s:%d:%s()\n", loglevel, fname, lineno, fxname);
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char type[0x10];
|
char type[0x10];
|
||||||
char colour[0x10];
|
char colour[0x10];
|
||||||
@@ -30,9 +19,6 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
|
|||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
if (verbose < (loglevel - 3) && loglevel > LOG_INFO) {
|
if (verbose < (loglevel - 3) && loglevel > LOG_INFO) {
|
||||||
if (verbose >= 5
|
if (verbose >= 5
|
||||||
#ifdef TUI
|
|
||||||
&& !tui_started
|
|
||||||
#endif
|
|
||||||
) fprintf(stderr, "p1_log: hid log with high log level (%d < %d)\n", verbose, loglevel - 3);
|
) fprintf(stderr, "p1_log: hid log with high log level (%d < %d)\n", verbose, loglevel - 3);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
-12
@@ -80,9 +80,6 @@ int build_checks(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TUI
|
|
||||||
bool tui_started = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_LIBUSB
|
#ifdef USE_LIBUSB
|
||||||
void log_cb(libusb_context *ctx, enum libusb_log_level level, const char *str) {
|
void log_cb(libusb_context *ctx, enum libusb_log_level level, const char *str) {
|
||||||
@@ -110,13 +107,6 @@ int palera1n(int argc, char *argv[], char *envp[]) {
|
|||||||
if ((ret = build_checks())) return ret;
|
if ((ret = build_checks())) return ret;
|
||||||
if ((ret = optparse(argc, argv))) goto cleanup;
|
if ((ret = optparse(argc, argv))) goto cleanup;
|
||||||
if (!(palerain_flags & palerain_option_device_info) && (palerain_flags & palerain_option_palerain_version)) goto normal_exit;
|
if (!(palerain_flags & palerain_option_device_info) && (palerain_flags & palerain_option_palerain_version)) goto normal_exit;
|
||||||
#ifdef TUI
|
|
||||||
if ((palerain_flags & palerain_option_tui) || (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO) && !(palerain_flags & palerain_option_cli))) {
|
|
||||||
ret = tui();
|
|
||||||
if (ret) goto cleanup;
|
|
||||||
else goto normal_exit;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef USE_LIBUSB
|
#ifdef USE_LIBUSB
|
||||||
{
|
{
|
||||||
libusb_set_log_cb(NULL, log_cb, LIBUSB_LOG_CB_GLOBAL);
|
libusb_set_log_cb(NULL, log_cb, LIBUSB_LOG_CB_GLOBAL);
|
||||||
@@ -148,8 +138,6 @@ int palera1n(int argc, char *argv[], char *envp[]) {
|
|||||||
palerain_option_device_info)
|
palerain_option_device_info)
|
||||||
) || device_has_booted)
|
) || device_has_booted)
|
||||||
goto normal_exit;
|
goto normal_exit;
|
||||||
pthread_cancel(pongo_thread);
|
|
||||||
pthread_join(pongo_thread, NULL);
|
|
||||||
if (exec_checkra1n()) goto cleanup;
|
if (exec_checkra1n()) goto cleanup;
|
||||||
|
|
||||||
if ((palerain_flags & (palerain_option_pongo_exit | palerain_option_demote)))
|
if ((palerain_flags & (palerain_option_pongo_exit | palerain_option_demote)))
|
||||||
|
|||||||
+14
-43
@@ -14,11 +14,9 @@
|
|||||||
#include <palerain.h>
|
#include <palerain.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#ifdef TUI
|
|
||||||
#include <tui.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint64_t* palerain_flags_p = &palerain_flags;
|
uint64_t* palerain_flags_p = &palerain_flags;
|
||||||
|
static bool force_use_verbose_boot = false;
|
||||||
char* gOverrideLibcheckra1nHelper = NULL;
|
char* gOverrideLibcheckra1nHelper = NULL;
|
||||||
|
|
||||||
static struct option longopts[] = {
|
static struct option longopts[] = {
|
||||||
@@ -54,10 +52,6 @@ static struct option longopts[] = {
|
|||||||
{"test1", no_argument, NULL, '1'},
|
{"test1", no_argument, NULL, '1'},
|
||||||
{"test2", no_argument, NULL, '2'},
|
{"test2", no_argument, NULL, '2'},
|
||||||
#endif
|
#endif
|
||||||
#ifdef TUI
|
|
||||||
{"tui", no_argument, NULL, 't'},
|
|
||||||
#endif
|
|
||||||
{"cli", no_argument, NULL, palerain_option_case_cli},
|
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -71,13 +65,10 @@ static int usage(int e, char* prog_name)
|
|||||||
#endif
|
#endif
|
||||||
#ifdef ROOTFUL
|
#ifdef ROOTFUL
|
||||||
"cCfB"
|
"cCfB"
|
||||||
#endif
|
|
||||||
#ifdef TUI
|
|
||||||
"t"
|
|
||||||
#endif
|
#endif
|
||||||
"] [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file] [-i checkra1n file]\n"
|
"] [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file] [-i checkra1n file]\n"
|
||||||
"Copyright (C) 2024, palera1n team, All Rights Reserved.\n\n"
|
"Copyright (C) 2024, palera1n team, All Rights Reserved.\n\n"
|
||||||
"iOS/iPadOS/tvOS 15.0-18.1, bridgeOS 5.0-9.1 arm64 jailbreaking tool\n\n"
|
"iOS/iPadOS/tvOS 15.0-17.5, bridgeOS 5.0-8.3 arm64 jailbreaking tool\n\n"
|
||||||
"\t--version\t\t\t\tPrint version\n"
|
"\t--version\t\t\t\tPrint version\n"
|
||||||
"\t--force-revert\t\t\t\tRemove jailbreak\n"
|
"\t--force-revert\t\t\t\tRemove jailbreak\n"
|
||||||
#ifdef DEV_BUILD
|
#ifdef DEV_BUILD
|
||||||
@@ -117,11 +108,6 @@ static int usage(int e, char* prog_name)
|
|||||||
"\t-v, --debug-logging\t\t\tEnable debug logging\n"
|
"\t-v, --debug-logging\t\t\tEnable debug logging\n"
|
||||||
"\t\tThis option can be repeated for extra verbosity.\n"
|
"\t\tThis option can be repeated for extra verbosity.\n"
|
||||||
"\t-V, --verbose-boot\t\t\tVerbose boot\n"
|
"\t-V, --verbose-boot\t\t\tVerbose boot\n"
|
||||||
|
|
||||||
#ifdef TUI
|
|
||||||
"\t-t, --tui\t\t\t\tForce interactive TUI\n"
|
|
||||||
"\t--cli\t\t\t\t\tForce cli mode\n"
|
|
||||||
#endif
|
|
||||||
"\nEnvironmental variables:\n"
|
"\nEnvironmental variables:\n"
|
||||||
"\tTMPDIR\t\ttemporary diretory (path the built-in checkra1n will be extracted to)\n"
|
"\tTMPDIR\t\ttemporary diretory (path the built-in checkra1n will be extracted to)\n"
|
||||||
,
|
,
|
||||||
@@ -147,9 +133,11 @@ int optparse(int argc, char* argv[]) {
|
|||||||
case 'B':
|
case 'B':
|
||||||
palerain_flags |= palerain_option_setup_partial_root;
|
palerain_flags |= palerain_option_setup_partial_root;
|
||||||
palerain_flags |= palerain_option_setup_rootful;
|
palerain_flags |= palerain_option_setup_rootful;
|
||||||
|
palerain_flags |= palerain_option_verbose_boot;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
palerain_flags |= palerain_option_setup_rootful;
|
palerain_flags |= palerain_option_setup_rootful;
|
||||||
|
palerain_flags |= palerain_option_verbose_boot;
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
palerain_flags |= palerain_option_clean_fakefs;
|
palerain_flags |= palerain_option_clean_fakefs;
|
||||||
@@ -172,19 +160,17 @@ int optparse(int argc, char* argv[]) {
|
|||||||
break;
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
palerain_flags |= palerain_option_verbose_boot;
|
palerain_flags |= palerain_option_verbose_boot;
|
||||||
#ifdef TUI
|
force_use_verbose_boot = true;
|
||||||
tui_options_verbose_boot = true;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
if (strlen(optarg) > (sizeof(xargs_cmd) - 0x20)) {
|
if (strstr(optarg, "rootdev=") != NULL) {
|
||||||
|
LOG(LOG_FATAL, "The boot arg rootdev= is already used by palera1n and cannot be overriden");
|
||||||
|
return -1;
|
||||||
|
} else if (strlen(optarg) > (sizeof(xargs_cmd) - 0x20)) {
|
||||||
LOG(LOG_FATAL, "Boot arguments too long");
|
LOG(LOG_FATAL, "Boot arguments too long");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
snprintf(xargs_cmd, sizeof(xargs_cmd), "xargs %s", optarg);
|
snprintf(xargs_cmd, sizeof(xargs_cmd), "xargs %s", optarg);
|
||||||
#ifdef TUI
|
|
||||||
snprintf(tui_options_boot_args, sizeof(tui_options_boot_args), "%s", optarg);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
#ifdef ROOTFUL
|
#ifdef ROOTFUL
|
||||||
case 'f':
|
case 'f':
|
||||||
@@ -207,9 +193,6 @@ int optparse(int argc, char* argv[]) {
|
|||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
palerain_flags |= palerain_option_safemode;
|
palerain_flags |= palerain_option_safemode;
|
||||||
#ifdef TUI
|
|
||||||
tui_options_safe_mode = true;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
palerain_flags |= palerain_option_telnetd;
|
palerain_flags |= palerain_option_telnetd;
|
||||||
@@ -302,14 +285,6 @@ int optparse(int argc, char* argv[]) {
|
|||||||
case 'S':
|
case 'S':
|
||||||
palerain_flags |= palerain_option_no_colors;
|
palerain_flags |= palerain_option_no_colors;
|
||||||
break;
|
break;
|
||||||
#ifdef TUI
|
|
||||||
case 't':
|
|
||||||
palerain_flags |= palerain_option_tui;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case palerain_option_case_cli:
|
|
||||||
palerain_flags |= palerain_option_cli;
|
|
||||||
break;
|
|
||||||
#ifdef DEV_BUILD
|
#ifdef DEV_BUILD
|
||||||
case '1':
|
case '1':
|
||||||
palerain_flags |= palerain_option_test1;
|
palerain_flags |= palerain_option_test1;
|
||||||
@@ -320,9 +295,6 @@ int optparse(int argc, char* argv[]) {
|
|||||||
#endif
|
#endif
|
||||||
case palerain_option_case_force_revert:
|
case palerain_option_case_force_revert:
|
||||||
palerain_flags |= palerain_option_force_revert;
|
palerain_flags |= palerain_option_force_revert;
|
||||||
#ifdef TUI
|
|
||||||
tui_options_force_revert = true;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case palerain_option_case_version:
|
case palerain_option_case_version:
|
||||||
palerain_flags |= palerain_option_palerain_version;
|
palerain_flags |= palerain_option_palerain_version;
|
||||||
@@ -344,8 +316,10 @@ int optparse(int argc, char* argv[]) {
|
|||||||
printf(
|
printf(
|
||||||
"palera1n " PALERAIN_VERSION "\n"
|
"palera1n " PALERAIN_VERSION "\n"
|
||||||
BUILD_COMMIT " " BUILD_NUMBER " (" BUILD_BRANCH ")\n\n"
|
BUILD_COMMIT " " BUILD_NUMBER " (" BUILD_BRANCH ")\n\n"
|
||||||
|
"Build date: " BUILD_DATE "\n"
|
||||||
"Build style: " BUILD_STYLE "\n"
|
"Build style: " BUILD_STYLE "\n"
|
||||||
"Build tag: " BUILD_TAG "\n"
|
"Build tag: " BUILD_TAG "\n"
|
||||||
|
"Built by: " BUILD_WHOAMI "\n"
|
||||||
#ifdef USE_LIBUSB
|
#ifdef USE_LIBUSB
|
||||||
"USB backend: libusb\n"
|
"USB backend: libusb\n"
|
||||||
#else
|
#else
|
||||||
@@ -360,14 +334,11 @@ int optparse(int argc, char* argv[]) {
|
|||||||
LOG(LOG_WARNING, "telnetd is enabled, this is a security hole");
|
LOG(LOG_WARNING, "telnetd is enabled, this is a security hole");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((palerain_flags & (palerain_option_tui)) && (palerain_flags & (palerain_option_cli))) {
|
if ((strstr(xargs_cmd, "serial=") != NULL) && !force_use_verbose_boot && (palerain_flags & palerain_option_setup_rootful)) {
|
||||||
LOG(LOG_FATAL, "cannot specify both --tui and --cli");
|
palerain_flags &= ~palerain_option_verbose_boot;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((palerain_flags & (palerain_option_exit_recovery | palerain_option_enter_recovery | palerain_option_reboot_device | palerain_option_device_info | palerain_option_dfuhelper_only | palerain_option_pongo_exit | palerain_option_pongo_full)) > 0) {
|
if ((palerain_flags & (palerain_option_exit_recovery | palerain_option_enter_recovery | palerain_option_reboot_device | palerain_option_device_info | palerain_option_dfuhelper_only | palerain_option_pongo_exit | palerain_option_pongo_full)) > 0) {
|
||||||
palerain_flags &= ~palerain_option_tui;
|
|
||||||
palerain_flags |= palerain_option_cli;
|
|
||||||
} else {
|
} else {
|
||||||
#ifdef ROOTFUL
|
#ifdef ROOTFUL
|
||||||
if ((palerain_flags & (palerain_option_rootless | palerain_option_rootful)) == 0) {
|
if ((palerain_flags & (palerain_option_rootless | palerain_option_rootful)) == 0) {
|
||||||
@@ -378,7 +349,7 @@ int optparse(int argc, char* argv[]) {
|
|||||||
palerain_flags |= palerain_option_rootless;
|
palerain_flags |= palerain_option_rootless;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(palerain_flags_cmd, 0x30, "palera1n_flags 0x%" PRIx64, palerain_flags);
|
snprintf(palerain_flags_cmd, 0x30, "palera1n_flags 0x%" PRIx64, palerain_flags);
|
||||||
LOG(LOG_VERBOSE3, "palerain_flags: %s", palerain_flags_cmd);
|
LOG(LOG_VERBOSE3, "palerain_flags: %s", palerain_flags_cmd);
|
||||||
if (override_kpf.magic == OVERRIDE_MAGIC) {
|
if (override_kpf.magic == OVERRIDE_MAGIC) {
|
||||||
|
|||||||
+2
-51
@@ -11,9 +11,6 @@
|
|||||||
#include <sys/stat.h> // fstst
|
#include <sys/stat.h> // fstst
|
||||||
|
|
||||||
#include <palerain.h>
|
#include <palerain.h>
|
||||||
#ifdef TUI
|
|
||||||
#include <tui.h>
|
|
||||||
#endif
|
|
||||||
#include <ANSI-color-codes.h>
|
#include <ANSI-color-codes.h>
|
||||||
|
|
||||||
bool device_has_booted = 0;
|
bool device_has_booted = 0;
|
||||||
@@ -42,27 +39,10 @@ void *pongo_usb_callback(stuff_t *arg) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
LOG(LOG_INFO, "Found PongoOS USB Device");
|
LOG(LOG_INFO, "Found PongoOS USB Device");
|
||||||
if (palerain_flags & palerain_option_pongo_exit)
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
usb_device_handle_t handle = arg->handle;
|
usb_device_handle_t handle = arg->handle;
|
||||||
#ifdef TUI
|
|
||||||
if (tui_is_jailbreaking) {
|
|
||||||
tui_jailbreak_stage = 4;
|
|
||||||
tui_jailbreak_status = "Sending PongoOS commands";
|
|
||||||
tui_jailbreak_status_changed();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
issue_pongo_command(handle, NULL);
|
issue_pongo_command(handle, NULL);
|
||||||
issue_pongo_command(handle, "fuse lock");
|
issue_pongo_command(handle, "fuse lock");
|
||||||
issue_pongo_command(handle, "sep auto");
|
issue_pongo_command(handle, "sep auto");
|
||||||
#ifdef TUI
|
|
||||||
if (tui_is_jailbreaking) {
|
|
||||||
tui_jailbreak_stage = 5;
|
|
||||||
tui_jailbreak_status = "Sending KPF";
|
|
||||||
tui_jailbreak_status_changed();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
upload_pongo_file(handle, **kpf_to_upload, checkra1n_kpf_pongo_lzma_len);
|
upload_pongo_file(handle, **kpf_to_upload, checkra1n_kpf_pongo_lzma_len);
|
||||||
if (*kpf_to_upload == &checkra1n_kpf_pongo_lzma) {
|
if (*kpf_to_upload == &checkra1n_kpf_pongo_lzma) {
|
||||||
issue_pongo_command(handle, "modload " KPF_UNCOMPRESSED_SIZE);
|
issue_pongo_command(handle, "modload " KPF_UNCOMPRESSED_SIZE);
|
||||||
@@ -74,13 +54,6 @@ void *pongo_usb_callback(stuff_t *arg) {
|
|||||||
if (ramdisk_dmg_lzma_len != 0)
|
if (ramdisk_dmg_lzma_len != 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef TUI
|
|
||||||
if (tui_is_jailbreaking) {
|
|
||||||
tui_jailbreak_stage = 6;
|
|
||||||
tui_jailbreak_status = "Sending ramdisk";
|
|
||||||
tui_jailbreak_status_changed();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
upload_pongo_file(handle, **ramdisk_to_upload, ramdisk_dmg_lzma_len);
|
upload_pongo_file(handle, **ramdisk_to_upload, ramdisk_dmg_lzma_len);
|
||||||
if ((*ramdisk_to_upload) == &ramdisk_dmg_lzma)
|
if ((*ramdisk_to_upload) == &ramdisk_dmg_lzma)
|
||||||
issue_pongo_command(handle, "ramdisk " RAMDISK_UNCOMPRESSED_SIZE);
|
issue_pongo_command(handle, "ramdisk " RAMDISK_UNCOMPRESSED_SIZE);
|
||||||
@@ -92,35 +65,21 @@ void *pongo_usb_callback(stuff_t *arg) {
|
|||||||
if (binpack_dmg_len != 0)
|
if (binpack_dmg_len != 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef TUI
|
|
||||||
if (tui_is_jailbreaking) {
|
|
||||||
tui_jailbreak_stage = 7;
|
|
||||||
tui_jailbreak_status = "Sending binpack";
|
|
||||||
tui_jailbreak_status_changed();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
upload_pongo_file(handle, **overlay_to_upload, binpack_dmg_len);
|
upload_pongo_file(handle, **overlay_to_upload, binpack_dmg_len);
|
||||||
issue_pongo_command(handle, "overlay");
|
issue_pongo_command(handle, "overlay");
|
||||||
}
|
}
|
||||||
issue_pongo_command(handle, xargs_cmd);
|
issue_pongo_command(handle, xargs_cmd);
|
||||||
if ((palerain_flags & palerain_option_pongo_full)) goto done;
|
if ((palerain_flags & palerain_option_pongo_full)) goto done;
|
||||||
|
|
||||||
#ifdef TUI
|
|
||||||
if (tui_is_jailbreaking) {
|
|
||||||
tui_jailbreak_stage = 8;
|
|
||||||
tui_jailbreak_status = "Booting";
|
|
||||||
tui_jailbreak_status_changed();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
issue_pongo_command(handle, "bootx");
|
issue_pongo_command(handle, "bootx");
|
||||||
LOG(LOG_INFO, "Booting Kernel...");
|
LOG(LOG_INFO, "Booting Kernel...");
|
||||||
#ifdef ROOTFUL
|
#ifdef ROOTFUL
|
||||||
if ((palerain_flags & palerain_option_setup_partial_root)) {
|
if ((palerain_flags & palerain_option_setup_partial_root)) {
|
||||||
LOG(LOG_INFO, "Please wait up to 5 minutes for the bindfs to be created.");
|
LOG(LOG_INFO, "Please wait up to 5 minutes for the bindfs to be created.");
|
||||||
LOG(LOG_INFO, "Once the device reboots into recovery mode, run again without the -B (Create BindFS) option to jailbreak.");
|
LOG(LOG_INFO, "Once the device boots up to iOS, run again without the -B (Create BindFS) option to jailbreak.");
|
||||||
} else if ((palerain_flags & palerain_option_setup_rootful)) {
|
} else if ((palerain_flags & palerain_option_setup_rootful)) {
|
||||||
LOG(LOG_INFO, "Please wait up to 10 minutes for the fakefs to be created.");
|
LOG(LOG_INFO, "Please wait up to 10 minutes for the fakefs to be created.");
|
||||||
LOG(LOG_INFO, "Once the device reboots into recovery mode, run again without the -c (Create FakeFS) option to jailbreak.");
|
LOG(LOG_INFO, "Once the device boots up to iOS, run again without the -c (Create FakeFS) option to jailbreak.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (dfuhelper_thr_running) {
|
if (dfuhelper_thr_running) {
|
||||||
@@ -130,14 +89,6 @@ void *pongo_usb_callback(stuff_t *arg) {
|
|||||||
done:
|
done:
|
||||||
device_has_booted = true;
|
device_has_booted = true;
|
||||||
|
|
||||||
#ifdef TUI
|
|
||||||
if (tui_is_jailbreaking) {
|
|
||||||
tui_jailbreak_stage = 9;
|
|
||||||
tui_jailbreak_status = "All Done";
|
|
||||||
tui_is_jailbreaking = false;
|
|
||||||
tui_jailbreak_status_changed();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef USE_LIBUSB
|
#ifdef USE_LIBUSB
|
||||||
libusb_unref_device(arg->dev);
|
libusb_unref_device(arg->dev);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,220 +0,0 @@
|
|||||||
#ifdef TUI
|
|
||||||
|
|
||||||
#include <palerain.h>
|
|
||||||
#include <tui.h>
|
|
||||||
|
|
||||||
irecv_device_t tui_get_recovery_device(uint64_t ecid) {
|
|
||||||
irecv_client_t client = NULL;
|
|
||||||
for (int i = 0; i <= 5; i++) {
|
|
||||||
irecv_error_t err = irecv_open_with_ecid(&client, ecid);
|
|
||||||
if (err == IRECV_E_UNSUPPORTED) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else if (err != IRECV_E_SUCCESS)
|
|
||||||
sleep(1);
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (i == 5) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
irecv_device_t device = NULL;
|
|
||||||
irecv_devices_get_device_by_client(client, &device);
|
|
||||||
irecv_close(client);
|
|
||||||
return device;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct tui_connected_device *tui_connected_devices = NULL;
|
|
||||||
|
|
||||||
void* tui_connected_recovery_mode(struct irecv_device_info* info) {
|
|
||||||
//printf("Recovery mode device %" PRIu64 " connected\n", info->ecid);
|
|
||||||
tui_last_event = TUI_EVENT_CONNECTED_DEVICES_CHANGED;
|
|
||||||
sem_post(tui_event_semaphore);
|
|
||||||
pthread_exit(NULL);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* tui_disconnected_recovery_mode(struct irecv_device_info* info) {
|
|
||||||
//printf("Recovery mode device %" PRIu64 " disconnected\n", info->ecid);
|
|
||||||
tui_last_event = TUI_EVENT_CONNECTED_DEVICES_CHANGED;
|
|
||||||
sem_post(tui_event_semaphore);
|
|
||||||
pthread_exit(NULL);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* tui_connected_dfu_mode(struct irecv_device_info* info) {
|
|
||||||
//printf("DFU mode device %" PRIu64 " connected\n", info->ecid);
|
|
||||||
tui_last_event = TUI_EVENT_CONNECTED_DEVICES_CHANGED;
|
|
||||||
sem_post(tui_event_semaphore);
|
|
||||||
pthread_exit(NULL);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* tui_disconnected_dfu_mode(struct irecv_device_info* info) {
|
|
||||||
//printf("DFU mode device %" PRIu64 " disconnected\n", info->ecid);
|
|
||||||
tui_last_event = TUI_EVENT_CONNECTED_DEVICES_CHANGED;
|
|
||||||
sem_post(tui_event_semaphore);
|
|
||||||
pthread_exit(NULL);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tui_connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
|
|
||||||
struct tui_connected_device *tui_dev = malloc(sizeof(struct tui_connected_device));
|
|
||||||
strcpy(tui_dev->udid, usbmuxd_device->udid);
|
|
||||||
tui_dev->next = tui_connected_devices;
|
|
||||||
tui_dev->mode = TUI_DEVICE_MODE_NORMAL;
|
|
||||||
tui_connected_devices = tui_dev;
|
|
||||||
devinfo_t dev;
|
|
||||||
int ret;
|
|
||||||
ret = devinfo_cmd(&dev, usbmuxd_device->udid);
|
|
||||||
if (ret != 0) {
|
|
||||||
LOG(LOG_ERROR, "Unable to get device information");
|
|
||||||
free(tui_dev);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
snprintf(tui_dev->product_type, sizeof(tui_dev->product_type), "%s", dev.productType);
|
|
||||||
snprintf(tui_dev->display_name, sizeof(tui_dev->display_name), "%s", dev.displayName);
|
|
||||||
tui_dev->ecid = dev.ecid;
|
|
||||||
if (strncmp(dev.CPUArchitecture, "arm64", strlen("arm64"))) {
|
|
||||||
tui_dev->arm64 = false;
|
|
||||||
} else {
|
|
||||||
tui_dev->arm64 = true;
|
|
||||||
}
|
|
||||||
sprintf(tui_dev->version, "%s", dev.productVersion);
|
|
||||||
if (!strncmp(dev.productType, "iPhone10,", strlen("iPhone10,"))) {
|
|
||||||
tui_dev->requires_passcode_disabled = true;
|
|
||||||
unsigned char passcode_state = 0;
|
|
||||||
ret = passstat_cmd(&passcode_state, usbmuxd_device->udid);
|
|
||||||
if (ret != 0) {
|
|
||||||
LOG(LOG_ERROR, "Failed to get passcode state");
|
|
||||||
devinfo_free(&dev);
|
|
||||||
free(tui_dev);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
tui_dev->passcode_state = passcode_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
//enter_recovery_cmd(usbmuxd_device->udid);
|
|
||||||
devinfo_free(&dev);
|
|
||||||
|
|
||||||
tui_last_event = TUI_EVENT_CONNECTED_DEVICES_CHANGED;
|
|
||||||
sem_post(tui_event_semaphore);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tui_disconnected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
|
|
||||||
struct tui_connected_device *cur = tui_connected_devices;
|
|
||||||
struct tui_connected_device *prev = NULL;
|
|
||||||
while (cur) {
|
|
||||||
if (!strcmp(cur->udid, usbmuxd_device->udid)) {
|
|
||||||
if (prev) {
|
|
||||||
prev->next = cur->next;
|
|
||||||
} else {
|
|
||||||
tui_connected_devices = cur->next;
|
|
||||||
}
|
|
||||||
free(cur);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
prev = cur;
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
tui_last_event = TUI_EVENT_CONNECTED_DEVICES_CHANGED;
|
|
||||||
sem_post(tui_event_semaphore);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tui_device_event_cb(const usbmuxd_event_t *event, void* userdata) {
|
|
||||||
if (event->device.conn_type != CONNECTION_TYPE_USB) return;
|
|
||||||
switch (event->event) {
|
|
||||||
case UE_DEVICE_ADD:
|
|
||||||
LOG(LOG_VERBOSE, "Normal mode device connected");
|
|
||||||
tui_connected_normal_mode(&event->device);
|
|
||||||
break;
|
|
||||||
case UE_DEVICE_REMOVE:
|
|
||||||
LOG(LOG_VERBOSE, "Normal mode device disconnected");
|
|
||||||
tui_disconnected_normal_mode(&event->device);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tui_irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
|
|
||||||
pthread_t recovery_thread, dfu_thread;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
switch(event->type) {
|
|
||||||
case IRECV_DEVICE_ADD: {
|
|
||||||
struct tui_connected_device *dev = malloc(sizeof(struct tui_connected_device));
|
|
||||||
dev->ecid = event->device_info->ecid;
|
|
||||||
dev->next = tui_connected_devices;
|
|
||||||
dev->arm64 = cpid_is_arm64(event->device_info->cpid);
|
|
||||||
/*recvinfo_t info;
|
|
||||||
ret = recvinfo_cmd(&info, event->device_info->ecid);
|
|
||||||
if (ret) {
|
|
||||||
LOG(LOG_WARNING, "Could not get info from device");
|
|
||||||
} else {
|
|
||||||
snprintf(dev->product_type, sizeof(dev->product_type), "%s", info.product_type);
|
|
||||||
snprintf(dev->display_name, sizeof(dev->display_name), "%s", info.display_name);
|
|
||||||
}*/
|
|
||||||
irecv_device_t device = tui_get_recovery_device(event->device_info->ecid);
|
|
||||||
if (!device) {
|
|
||||||
LOG(LOG_WARNING, "Could not get info from device");
|
|
||||||
free(dev);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
snprintf(dev->product_type, sizeof(dev->product_type), "%s", device->product_type);
|
|
||||||
snprintf(dev->display_name, sizeof(dev->display_name), "%s", device->display_name);
|
|
||||||
dev->cpid = device->chip_id;
|
|
||||||
tui_connected_devices = dev;
|
|
||||||
|
|
||||||
if (event->mode == IRECV_K_RECOVERY_MODE_1 ||
|
|
||||||
event->mode == IRECV_K_RECOVERY_MODE_2 ||
|
|
||||||
event->mode == IRECV_K_RECOVERY_MODE_3 ||
|
|
||||||
event->mode == IRECV_K_RECOVERY_MODE_4) {
|
|
||||||
|
|
||||||
dev->mode = TUI_DEVICE_MODE_RECOVERY;
|
|
||||||
pthread_create(&recovery_thread, NULL, (pthread_start_t)tui_connected_recovery_mode, event->device_info);
|
|
||||||
} else if (event->mode == IRECV_K_DFU_MODE) {
|
|
||||||
dev->mode = TUI_DEVICE_MODE_DFU;
|
|
||||||
pthread_create(&dfu_thread, NULL, (pthread_start_t)tui_connected_dfu_mode, event->device_info);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case IRECV_DEVICE_REMOVE: {
|
|
||||||
struct tui_connected_device *cur = tui_connected_devices;
|
|
||||||
struct tui_connected_device *prev = NULL;
|
|
||||||
while (cur) {
|
|
||||||
if (cur->ecid == event->device_info->ecid) {
|
|
||||||
if (prev) {
|
|
||||||
prev->next = cur->next;
|
|
||||||
} else {
|
|
||||||
tui_connected_devices = cur->next;
|
|
||||||
}
|
|
||||||
if (cur->mode == TUI_DEVICE_MODE_RECOVERY) {
|
|
||||||
LOG(LOG_VERBOSE, "Recovery mode device %" PRIu64 " disconnected", event->device_info->ecid);
|
|
||||||
pthread_create(&recovery_thread, NULL, (pthread_start_t)tui_disconnected_recovery_mode, event->device_info);
|
|
||||||
} else if (cur->mode == TUI_DEVICE_MODE_DFU) {
|
|
||||||
LOG(LOG_VERBOSE, "DFU mode device %" PRIu64 " disconnected", event->device_info->ecid);
|
|
||||||
pthread_create(&dfu_thread, NULL, (pthread_start_t)tui_disconnected_dfu_mode, event->device_info);
|
|
||||||
}
|
|
||||||
free(cur);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
prev = cur;
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tui_devhelper(void) {
|
|
||||||
subscribe_cmd(tui_device_event_cb, tui_irecv_device_event_cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* ISO C forbids an empty translation unit */
|
|
||||||
extern char** environ;
|
|
||||||
#endif
|
|
||||||
-166
@@ -1,166 +0,0 @@
|
|||||||
#ifdef TUI
|
|
||||||
|
|
||||||
#include <tui.h>
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
#include <gpm.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int tui_mouse_x = 0;
|
|
||||||
int tui_mouse_y = 0;
|
|
||||||
int tui_mouse_button = -1;
|
|
||||||
|
|
||||||
int tui_last_event = -1;
|
|
||||||
int tui_last_input = -1;
|
|
||||||
sem_t *tui_event_semaphore;
|
|
||||||
char tui_last_key = 0;
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
bool using_gpm = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int tui_get_input(void) {
|
|
||||||
char c = getc(stdin);
|
|
||||||
if (c == '\x1b' && getc(stdin) == '[') {
|
|
||||||
char c3 = getc(stdin);
|
|
||||||
switch (c3) {
|
|
||||||
case 'D':
|
|
||||||
return TUI_INPUT_LEFT;
|
|
||||||
case 'C':
|
|
||||||
return TUI_INPUT_RIGHT;
|
|
||||||
case 'A':
|
|
||||||
return TUI_INPUT_UP;
|
|
||||||
case 'B':
|
|
||||||
return TUI_INPUT_DOWN;
|
|
||||||
case 'Z':
|
|
||||||
return TUI_INPUT_TAB_BACK;
|
|
||||||
case 'M': {
|
|
||||||
char c4 = getc(stdin);
|
|
||||||
char c5 = getc(stdin);
|
|
||||||
char c6 = getc(stdin);
|
|
||||||
|
|
||||||
int new_mouse_x = c5 - 33;
|
|
||||||
if (new_mouse_x < 0) new_mouse_x += 256;
|
|
||||||
int new_mouse_y = c6 - 33;
|
|
||||||
if (new_mouse_y < 0) new_mouse_y += 256;
|
|
||||||
int mouse_button = c4 & 3;
|
|
||||||
|
|
||||||
if (tui_mouse_x != new_mouse_x || tui_mouse_y != new_mouse_y) {
|
|
||||||
tui_mouse_x = new_mouse_x;
|
|
||||||
tui_mouse_y = new_mouse_y;
|
|
||||||
return TUI_INPUT_MOUSE_MOVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tui_mouse_button != (c4 & 1)) {
|
|
||||||
tui_mouse_button = c4 & 1;
|
|
||||||
if (tui_mouse_button == 0) {
|
|
||||||
return TUI_INPUT_MOUSE_DOWN;
|
|
||||||
} else {
|
|
||||||
return TUI_INPUT_MOUSE_UP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tui_last_key = c;
|
|
||||||
|
|
||||||
if (c == '\x0d' || c == ' ') {
|
|
||||||
return TUI_INPUT_SELECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c == '\t') {
|
|
||||||
return TUI_INPUT_TAB;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c == '\x7f') {
|
|
||||||
return TUI_INPUT_BACKSPACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c == '\x1b') {
|
|
||||||
return TUI_INPUT_ESCAPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TUI_INPUT_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
void *tui_gpm_thread(void *arg) {
|
|
||||||
Gpm_Event event;
|
|
||||||
while (1) {
|
|
||||||
if (Gpm_GetEvent(&event) == -1) {
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
tui_mouse_x = event.x - 1;
|
|
||||||
tui_mouse_y = event.y - 1;
|
|
||||||
if (event.type & GPM_MOVE) {
|
|
||||||
tui_last_event = TUI_EVENT_INPUT;
|
|
||||||
tui_last_input = TUI_INPUT_MOUSE_MOVE;
|
|
||||||
sem_post(tui_event_semaphore);
|
|
||||||
}
|
|
||||||
if (event.buttons & 4) {
|
|
||||||
if (event.type & GPM_DOWN) {
|
|
||||||
tui_mouse_button = 1;
|
|
||||||
tui_last_event = TUI_EVENT_INPUT;
|
|
||||||
tui_last_input = TUI_INPUT_MOUSE_DOWN;
|
|
||||||
sem_post(tui_event_semaphore);
|
|
||||||
} else if (event.type & GPM_UP) {
|
|
||||||
tui_mouse_button = 0;
|
|
||||||
tui_last_event = TUI_EVENT_INPUT;
|
|
||||||
tui_last_input = TUI_INPUT_MOUSE_UP;
|
|
||||||
sem_post(tui_event_semaphore);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void *tui_input_thread(void *arg) {
|
|
||||||
#ifdef __linux__
|
|
||||||
if (strncmp(getenv("TERM"), "linux", 5) == 0) {
|
|
||||||
Gpm_Connect conn;
|
|
||||||
Gpm_Event event;
|
|
||||||
conn.eventMask = GPM_UP | GPM_DOWN;
|
|
||||||
conn.defaultMask = ~0;
|
|
||||||
conn.minMod = 0;
|
|
||||||
conn.maxMod = 0xffff;
|
|
||||||
if (Gpm_Open(&conn, 0) != -1) {
|
|
||||||
using_gpm = true;
|
|
||||||
pthread_t gpm_thread;
|
|
||||||
pthread_create(&gpm_thread, NULL, tui_gpm_thread, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
while (1) {
|
|
||||||
int input = tui_get_input();
|
|
||||||
tui_last_event = TUI_EVENT_INPUT;
|
|
||||||
tui_last_input = input;
|
|
||||||
sem_post(tui_event_semaphore);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tui_get_event(void) {
|
|
||||||
sem_wait(tui_event_semaphore);
|
|
||||||
int last_event = tui_last_event;
|
|
||||||
tui_last_event = -1;
|
|
||||||
return last_event;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tui_try_get_event(void) {
|
|
||||||
int ret = sem_trywait(tui_event_semaphore);
|
|
||||||
if (ret == 0) {
|
|
||||||
int last_event = tui_last_event;
|
|
||||||
tui_last_event = -1;
|
|
||||||
return last_event;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* ISO C forbids an empty translation unit */
|
|
||||||
extern char** environ;
|
|
||||||
#endif
|
|
||||||
-255
@@ -1,255 +0,0 @@
|
|||||||
#ifdef TUI
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#define _DARWIN_C_SOURCE
|
|
||||||
#else
|
|
||||||
#define _DEFAULT_SOURCE
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <palerain.h>
|
|
||||||
#include <tui.h>
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
int proc_pidpath(int pid, void * buffer, uint32_t buffersize);
|
|
||||||
char random_sem_name[sizeof("palera1n.tui_event_semaphore") + 16 + 1];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int tui_state = 0;
|
|
||||||
int tui_x_offset = 0;
|
|
||||||
int tui_y_offset = 0;
|
|
||||||
|
|
||||||
bool supports_bright_colors = true;
|
|
||||||
|
|
||||||
struct termios saved_termios;
|
|
||||||
|
|
||||||
int redraw_screen(void) {
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
CLEAR_SCREEN;
|
|
||||||
MOVETO(0, 0);
|
|
||||||
|
|
||||||
struct winsize w;
|
|
||||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
|
||||||
if (w.ws_col < 80 || w.ws_row < 24) {
|
|
||||||
LOG(LOG_FATAL, "Terminal size must be at least 80x24");
|
|
||||||
printf("\033[37;41mERROR: Terminal size must be at least 80x24!");
|
|
||||||
fflush(stdout);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
tui_y_offset = (w.ws_row - 24) / 2;
|
|
||||||
for (int i = 0; i < tui_y_offset; i++) {
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
tui_x_offset = (w.ws_col - 80) / 2;
|
|
||||||
|
|
||||||
const char* tui_version = TUI_VERSION;
|
|
||||||
if (tui_version[0] == 'v') tui_version++;
|
|
||||||
|
|
||||||
tui_draw_rectangle(0, 0, 79, 23);
|
|
||||||
MOVETOT((int)(80 - (strlen("[palera1n - Version ]") + strlen(tui_version) ) - 1), 1);
|
|
||||||
printf("[palera1n - Version %s]", tui_version);
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
switch(tui_state) {
|
|
||||||
case MAIN_SCREEN:
|
|
||||||
tui_screen_main_redraw();
|
|
||||||
break;
|
|
||||||
case OPTIONS_SCREEN:
|
|
||||||
tui_screen_options_redraw();
|
|
||||||
break;
|
|
||||||
case ENTER_RECOVERY_SCREEN:
|
|
||||||
tui_screen_enter_recovery_redraw();
|
|
||||||
break;
|
|
||||||
case ENTER_DFU_SCREEN:
|
|
||||||
tui_screen_enter_dfu_redraw();
|
|
||||||
break;
|
|
||||||
case JAILBREAK_SCREEN:
|
|
||||||
tui_screen_jailbreak_redraw();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
fflush(stdout);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int destroy_window(void) {
|
|
||||||
if (!tui_started) return 0;
|
|
||||||
tui_started = false;
|
|
||||||
tcsetattr(STDIN_FILENO, 0, &saved_termios);
|
|
||||||
MOUSEOFF;
|
|
||||||
CLEAR_SCREEN;
|
|
||||||
|
|
||||||
MOVETO(0, 0);
|
|
||||||
RMCUP;
|
|
||||||
CNORM;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int init_window(void) {
|
|
||||||
setlocale(LC_ALL, NULL);
|
|
||||||
|
|
||||||
tui_started = true;
|
|
||||||
struct winsize w;
|
|
||||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
|
||||||
if (w.ws_col < 80 || w.ws_row < 24) {
|
|
||||||
tui_started = false;
|
|
||||||
LOG(LOG_FATAL, "Terminal size must be at least 80x24");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
LOG(LOG_VERBOSE3, "cols: %d, rows: %d\n", w.ws_col, w.ws_row);
|
|
||||||
SMCUP;
|
|
||||||
CIVIS;
|
|
||||||
fflush(stdout);
|
|
||||||
struct termios term;
|
|
||||||
tcgetattr(STDIN_FILENO, &term);
|
|
||||||
tcgetattr(STDIN_FILENO, &saved_termios);
|
|
||||||
cfmakeraw(&term);
|
|
||||||
term.c_lflag |= ISIG;
|
|
||||||
tcsetattr(STDIN_FILENO, 0, &term);
|
|
||||||
|
|
||||||
MOUSEON;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool tui_is_restarting = false;
|
|
||||||
|
|
||||||
extern int saved_argc;
|
|
||||||
extern char** saved_argv;
|
|
||||||
extern char** saved_envp;
|
|
||||||
|
|
||||||
void tui_terminate(int sig) {
|
|
||||||
destroy_window();
|
|
||||||
if (tui_is_restarting) {
|
|
||||||
#ifdef __APPLE__
|
|
||||||
sem_close(tui_event_semaphore);
|
|
||||||
sem_unlink(random_sem_name);
|
|
||||||
char pathbuf[4096];
|
|
||||||
if (proc_pidpath(getpid(), pathbuf, sizeof(pathbuf)) <= 0) {
|
|
||||||
LOG(LOG_FATAL, "Failed to get path of running executable");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
execve(pathbuf, saved_argv, saved_envp);
|
|
||||||
#elif defined(__linux__)
|
|
||||||
execve("/proc/self/exe", saved_argv, saved_envp);
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void resize_handler(int sig) {
|
|
||||||
redraw_screen();
|
|
||||||
}
|
|
||||||
|
|
||||||
int tui(void) {
|
|
||||||
if (strncmp(getenv("TERM"), "xterm", 5) != 0) {
|
|
||||||
supports_bright_colors = false;
|
|
||||||
}
|
|
||||||
srand(time(NULL));
|
|
||||||
int ret = 0;
|
|
||||||
if ((ret = init_window())) return ret;
|
|
||||||
signal(SIGINT, tui_terminate);
|
|
||||||
signal(SIGTERM, tui_terminate);
|
|
||||||
signal(SIGQUIT, tui_terminate);
|
|
||||||
signal(SIGWINCH, resize_handler);
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
// generate a 16 character random hex string from urandom
|
|
||||||
int fd = open("/dev/urandom", O_RDONLY);
|
|
||||||
if (fd < 0) {
|
|
||||||
LOG(LOG_FATAL, "Failed to open /dev/urandom");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
uint8_t random[8];
|
|
||||||
if (read(fd, random, 8) != 8) {
|
|
||||||
LOG(LOG_FATAL, "Failed to read from /dev/urandom");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
for (int i = 0; i < 8; i++) {
|
|
||||||
sprintf(&random_sem_name[i * 2], "%02x", random[i]);
|
|
||||||
}
|
|
||||||
sem_unlink(random_sem_name);
|
|
||||||
tui_event_semaphore = sem_open(random_sem_name, O_CREAT, 0644, 0);
|
|
||||||
#else
|
|
||||||
tui_event_semaphore = malloc(sizeof(sem_t));
|
|
||||||
sem_init(tui_event_semaphore, 0, 0);
|
|
||||||
#endif
|
|
||||||
pthread_t input_thread;
|
|
||||||
pthread_create(&input_thread, NULL, tui_input_thread, NULL);
|
|
||||||
|
|
||||||
tui_devhelper();
|
|
||||||
|
|
||||||
tui_state = MAIN_SCREEN;
|
|
||||||
while (1) {
|
|
||||||
switch (tui_state) {
|
|
||||||
case ERROR_SCREEN:
|
|
||||||
case EXIT_SCREEN:
|
|
||||||
goto out;
|
|
||||||
break;
|
|
||||||
case MAIN_SCREEN:
|
|
||||||
tui_state = tui_screen_main();
|
|
||||||
break;
|
|
||||||
case OPTIONS_SCREEN:
|
|
||||||
tui_state = tui_screen_options();
|
|
||||||
break;
|
|
||||||
case ENTER_RECOVERY_SCREEN:
|
|
||||||
tui_state = tui_screen_enter_recovery();
|
|
||||||
break;
|
|
||||||
case ENTER_DFU_SCREEN:
|
|
||||||
tui_state = tui_screen_enter_dfu();
|
|
||||||
break;
|
|
||||||
case JAILBREAK_SCREEN:
|
|
||||||
tui_state = tui_screen_jailbreak();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
out:
|
|
||||||
destroy_window();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tui_draw_rectangle(int x1, int y1, int x2, int y2) {
|
|
||||||
if (x1 == x2 || y1 == y2) return;
|
|
||||||
DSGON;
|
|
||||||
MOVETOT(x1 + 1, y1 + 1);
|
|
||||||
printf("%c", 0x6C);
|
|
||||||
for (int x = x1 + 1; x < x2; x++) {
|
|
||||||
putchar(0x71);
|
|
||||||
}
|
|
||||||
putchar(0x6B);
|
|
||||||
MOVETOT(x1 + 1, y2 + 1);
|
|
||||||
putchar(0x6D);
|
|
||||||
for (int x = x1 + 1; x < x2; x++) {
|
|
||||||
putchar(0x71);
|
|
||||||
}
|
|
||||||
putchar(0x6A);
|
|
||||||
for (int y = y1 + 1; y < y2; y++) {
|
|
||||||
PRINTATT(x1 + 1, y + 1, "\x78");
|
|
||||||
PRINTATT(x2 + 1, y + 1, "\x78");
|
|
||||||
}
|
|
||||||
DSGOFF;
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* ISO C forbids an empty translation unit */
|
|
||||||
extern char** environ;
|
|
||||||
#endif
|
|
||||||
@@ -1,473 +0,0 @@
|
|||||||
#ifdef TUI
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <palerain.h>
|
|
||||||
#include <tui.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <palerain.h>
|
|
||||||
#include <tui.h>
|
|
||||||
|
|
||||||
int tui_enter_dfu_nav_selection = 1;
|
|
||||||
bool tui_device_is_entering_dfu = false;
|
|
||||||
int tui_enter_dfu_status = 0;
|
|
||||||
|
|
||||||
enum {
|
|
||||||
DEVICE_TYPE_IPHONE_SE,
|
|
||||||
DEVICE_TYPE_IPHONE_6S,
|
|
||||||
DEVICE_TYPE_IPHONE_7_8,
|
|
||||||
DEVICE_TYPE_IPHONE_X,
|
|
||||||
DEVICE_TYPE_IPAD,
|
|
||||||
DEVICE_TYPE_IPOD_TOUCH
|
|
||||||
} device_type;
|
|
||||||
|
|
||||||
int tui_product_type_to_device_type(char *product_type) {
|
|
||||||
if (strcmp(product_type, "iPhone8,1") == 0 || strcmp(product_type, "iPhone8,2") == 0) {
|
|
||||||
return DEVICE_TYPE_IPHONE_6S;
|
|
||||||
}
|
|
||||||
if (strcmp(product_type, "iPhone8,4") == 0) return DEVICE_TYPE_IPHONE_SE;
|
|
||||||
if (strcmp(product_type, "iPhone9,1") == 0 || strcmp(product_type, "iPhone9,2") == 0
|
|
||||||
|| strcmp(product_type, "iPhone9,3") == 0 || strcmp(product_type, "iPhone9,4") == 0) {
|
|
||||||
return DEVICE_TYPE_IPHONE_7_8;
|
|
||||||
}
|
|
||||||
if (strcmp(product_type, "iPhone10,1") == 0 || strcmp(product_type, "iPhone10,2") == 0
|
|
||||||
|| strcmp(product_type, "iPhone10,4") == 0 || strcmp(product_type, "iPhone10,5") == 0) {
|
|
||||||
return DEVICE_TYPE_IPHONE_7_8;
|
|
||||||
}
|
|
||||||
if (strcmp(product_type, "iPhone10,3") == 0 || strcmp(product_type, "iPhone10,6") == 0) {
|
|
||||||
return DEVICE_TYPE_IPHONE_X;
|
|
||||||
}
|
|
||||||
if (strncmp(product_type, "iPad", strlen("iPad")) == 0) {
|
|
||||||
return DEVICE_TYPE_IPAD;
|
|
||||||
}
|
|
||||||
if (strcmp(product_type, "iPod9,1") == 0) {
|
|
||||||
return DEVICE_TYPE_IPOD_TOUCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not found
|
|
||||||
return DEVICE_TYPE_IPHONE_SE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tui_enter_dfu_device_type = DEVICE_TYPE_IPHONE_SE;
|
|
||||||
|
|
||||||
int tui_enter_dfu_loading_progress = 1;
|
|
||||||
|
|
||||||
void tui_screen_enter_dfu_nav(void) {
|
|
||||||
MOVETOT(80 - 22, 23);
|
|
||||||
printf("%s[ Cancel ]" COLOR(FG_WHITE, BG_BLACK) " %s[ %s ]" COLOR(FG_WHITE, BG_BLACK),
|
|
||||||
tui_device_is_entering_dfu || tui_enter_dfu_status == 1 ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : tui_enter_dfu_nav_selection == 0 ? "\033[30;107m" : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 80 - 23 && tui_mouse_x <= tui_x_offset + 80 - 23 + 10
|
|
||||||
) && (tui_mouse_y == tui_y_offset + 22) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
),
|
|
||||||
tui_device_is_entering_dfu || tui_enter_dfu_status == 1 ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : tui_enter_dfu_nav_selection == 1 ? "\033[30;107m" : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 80 - 12 && tui_mouse_x <= tui_x_offset + 80 - 12 + 10
|
|
||||||
) && (tui_mouse_y == tui_y_offset + 22) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
),
|
|
||||||
tui_enter_dfu_status == 2 ? "Retry" : "Start"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tui_screen_enter_dfu_redraw(void) {
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
switch(tui_enter_dfu_status) {
|
|
||||||
case 0:
|
|
||||||
PRINTATT(3, 3, "Time to put the device into DFU mode. Locate the buttons as marked below on");
|
|
||||||
PRINTATT(3, 4, "your device and check the instructions on the right *before* clicking Start.");
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
PRINTATT(3, 3, "Device entered DFU mode successfully.");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
PRINTATT(3, 3, "Whoops, the device didn't enter DFU mode. Click Retry to try again.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
tui_screen_enter_dfu_nav();
|
|
||||||
|
|
||||||
switch(tui_enter_dfu_device_type) {
|
|
||||||
case DEVICE_TYPE_IPHONE_SE:
|
|
||||||
case DEVICE_TYPE_IPAD:
|
|
||||||
if (tui_enter_dfu_loading_progress > 0 || tui_enter_dfu_status == 2) {
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_BLACK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PRINTATT(51, 6, "1. Click Start");
|
|
||||||
if (tui_enter_dfu_loading_progress > 0) {
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tui_device_is_entering_dfu || tui_enter_dfu_loading_progress > 4 || tui_enter_dfu_status == 2) {
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_BLACK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PRINTATT(51, 7, "2. Press and hold the Top and");
|
|
||||||
MOVETOT(54, 8);
|
|
||||||
printf("Home buttons together (%d)", tui_enter_dfu_loading_progress > 4 ? 0 : tui_enter_dfu_loading_progress < 1 ? 4 : 5 - tui_enter_dfu_loading_progress);
|
|
||||||
if (!tui_device_is_entering_dfu || tui_enter_dfu_loading_progress > 4) {
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tui_enter_dfu_loading_progress < 5 || tui_enter_dfu_loading_progress > 14 || tui_enter_dfu_status == 2) {
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_BLACK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PRINTATT(51, 9, "3. Release the Top button BUT");
|
|
||||||
PRINTATT(54, 10, "KEEP HOLDING the Home");
|
|
||||||
MOVETOT(54, 11);
|
|
||||||
printf("button (%d)", tui_enter_dfu_loading_progress > 14 ? 0 : tui_enter_dfu_loading_progress < 5 ? 10 : 15 - tui_enter_dfu_loading_progress);
|
|
||||||
if (tui_enter_dfu_loading_progress < 5 || tui_enter_dfu_loading_progress > 14) {
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DEVICE_TYPE_IPHONE_6S:
|
|
||||||
if (tui_enter_dfu_loading_progress > 0 || tui_enter_dfu_status == 2) {
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_BLACK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PRINTATT(51, 6, "1. Click Start");
|
|
||||||
if (tui_enter_dfu_loading_progress > 0) {
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tui_device_is_entering_dfu || tui_enter_dfu_loading_progress > 4 || tui_enter_dfu_status == 2) {
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_BLACK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PRINTATT(51, 7, "2. Press and hold the Side");
|
|
||||||
PRINTATT(54, 8, "and Home buttons together");
|
|
||||||
MOVETOT(54, 9);
|
|
||||||
printf("(%d)", tui_enter_dfu_loading_progress > 4 ? 0 : tui_enter_dfu_loading_progress < 1 ? 4 : 5 - tui_enter_dfu_loading_progress);
|
|
||||||
if (!tui_device_is_entering_dfu || tui_enter_dfu_loading_progress > 4) {
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tui_enter_dfu_loading_progress < 5 || tui_enter_dfu_loading_progress > 14 || tui_enter_dfu_status == 2) {
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_BLACK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PRINTATT(51, 10, "3. Release the Side button");
|
|
||||||
PRINTATT(54, 11, "BUT KEEP HOLDING the Home");
|
|
||||||
MOVETOT(54, 12);
|
|
||||||
printf("button (%d)", tui_enter_dfu_loading_progress > 14 ? 0 : tui_enter_dfu_loading_progress < 5 ? 10 : 15 - tui_enter_dfu_loading_progress);
|
|
||||||
if (tui_enter_dfu_loading_progress < 5 || tui_enter_dfu_loading_progress > 14) {
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DEVICE_TYPE_IPHONE_7_8:
|
|
||||||
case DEVICE_TYPE_IPHONE_X:
|
|
||||||
tui_draw_rectangle(17, 5, 33, 21);
|
|
||||||
PRINTATT(17, 10, "|");
|
|
||||||
MOVETOT(5, 11);
|
|
||||||
printf("%sVolume down-", tui_enter_dfu_loading_progress > 14 ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : COLOR(FG_YELLOW, BG_BLACK));
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
putchar('|');
|
|
||||||
DSGON;
|
|
||||||
MOVETOT(35, 10);
|
|
||||||
putchar(0x78);
|
|
||||||
DSGOFF;
|
|
||||||
printf("%s-Side button", tui_enter_dfu_loading_progress > 4 ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : COLOR(FG_YELLOW, BG_BLACK));
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
|
|
||||||
if (tui_enter_dfu_loading_progress > 0 || tui_enter_dfu_status == 2) {
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_BLACK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PRINTATT(51, 6, "1. Click Start");
|
|
||||||
if (tui_enter_dfu_loading_progress > 0) {
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tui_device_is_entering_dfu || tui_enter_dfu_loading_progress > 4 || tui_enter_dfu_status == 2) {
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_BLACK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PRINTATT(51, 7, "2. Press and hold the Side");
|
|
||||||
PRINTATT(54, 8, "and Volume down buttons");
|
|
||||||
MOVETOT(54, 9);
|
|
||||||
printf("together (%d)", tui_enter_dfu_loading_progress > 4 ? 0 : tui_enter_dfu_loading_progress < 1 ? 4 : 5 - tui_enter_dfu_loading_progress);
|
|
||||||
if (!tui_device_is_entering_dfu || tui_enter_dfu_loading_progress > 4) {
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tui_enter_dfu_loading_progress < 5 || tui_enter_dfu_loading_progress > 14 || tui_enter_dfu_status == 2) {
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_BLACK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PRINTATT(51, 10, "3. Release the Side button");
|
|
||||||
PRINTATT(54, 11, "BUT KEEP HOLDING the");
|
|
||||||
MOVETOT(54, 12);
|
|
||||||
printf("Volume down button (%d)", tui_enter_dfu_loading_progress > 14 ? 0 : tui_enter_dfu_loading_progress < 5 ? 10 : 15 - tui_enter_dfu_loading_progress);
|
|
||||||
if (tui_enter_dfu_loading_progress < 5 || tui_enter_dfu_loading_progress > 14) {
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(tui_enter_dfu_device_type) {
|
|
||||||
case DEVICE_TYPE_IPHONE_SE:
|
|
||||||
tui_draw_rectangle(18, 6, 32, 21);
|
|
||||||
tui_draw_rectangle(24, 19, 26, 20);
|
|
||||||
for (int y = 9; y < 20; y++) {
|
|
||||||
SETCOLOR(FG_BLACK, BG_BRIGHT_BLACK);
|
|
||||||
PRINTATT(20, y, " ");
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
PRINTATT(23, 8, "o ===");
|
|
||||||
PRINTATT(18, 11, "|");
|
|
||||||
PRINTATT(18, 12, "|");
|
|
||||||
MOVETOT(30, 6);
|
|
||||||
printf("__ %s-Top button", tui_enter_dfu_loading_progress > 4 ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : COLOR(FG_YELLOW, BG_BLACK));
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
MOVETOT(31, 20);
|
|
||||||
printf("%s-Home button", tui_enter_dfu_loading_progress > 14 ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : COLOR(FG_YELLOW, BG_BLACK));
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case DEVICE_TYPE_IPHONE_6S:
|
|
||||||
tui_draw_rectangle(17, 5, 33, 21);
|
|
||||||
tui_draw_rectangle(24, 19, 26, 20);
|
|
||||||
for (int y = 8; y < 20; y++) {
|
|
||||||
SETCOLOR(FG_BLACK, BG_BRIGHT_BLACK);
|
|
||||||
PRINTATT(19, y, " ");
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
PRINTATT(23, 7, "o ===");
|
|
||||||
PRINTATT(17, 10, "|");
|
|
||||||
PRINTATT(17, 11, "|");
|
|
||||||
MOVETOT(35, 10);
|
|
||||||
printf("|%s-Side button", tui_enter_dfu_loading_progress > 4 ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : COLOR(FG_YELLOW, BG_BLACK));
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
MOVETOT(30, 20);
|
|
||||||
printf("%s-Home button", tui_enter_dfu_loading_progress > 14 ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : COLOR(FG_YELLOW, BG_BLACK));
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
break;
|
|
||||||
case DEVICE_TYPE_IPHONE_7_8:
|
|
||||||
tui_draw_rectangle(24, 19, 26, 20);
|
|
||||||
for (int y = 8; y < 20; y++) {
|
|
||||||
SETCOLOR(FG_BLACK, BG_BRIGHT_BLACK);
|
|
||||||
PRINTATT(19, y, " ");
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
PRINTATT(23, 7, "o ===");
|
|
||||||
|
|
||||||
break;
|
|
||||||
case DEVICE_TYPE_IPHONE_X:
|
|
||||||
SETCOLOR(FG_BLACK, BG_BRIGHT_BLACK);
|
|
||||||
PRINTATT(19, 7, " ");
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
printf(" ");
|
|
||||||
SETCOLOR(FG_BLACK, BG_BRIGHT_BLACK);
|
|
||||||
printf(" ");
|
|
||||||
SETCOLOR(FG_BLACK, BG_BRIGHT_BLACK);
|
|
||||||
for (int y = 8; y < 22; y++) {
|
|
||||||
PRINTATT(19, y, " ");
|
|
||||||
}
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
|
|
||||||
DSGON;
|
|
||||||
MOVETOT(35, 11);
|
|
||||||
putchar(0x78);
|
|
||||||
DSGOFF;
|
|
||||||
|
|
||||||
break;
|
|
||||||
case DEVICE_TYPE_IPAD:
|
|
||||||
tui_draw_rectangle(14, 6, 36, 21);
|
|
||||||
tui_draw_rectangle(24, 19, 26, 20);
|
|
||||||
for (int y = 9; y < 20; y++) {
|
|
||||||
SETCOLOR(FG_BLACK, BG_BRIGHT_BLACK);
|
|
||||||
PRINTATT(16, y, " ");
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
PRINTATT(23, 8, "o ===");
|
|
||||||
PRINTATT(14, 11, "|");
|
|
||||||
PRINTATT(14, 12, "|");
|
|
||||||
MOVETOT(33, 6);
|
|
||||||
printf("__ %s-Top button", tui_enter_dfu_loading_progress > 4 ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : COLOR(FG_YELLOW, BG_BLACK));
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
MOVETOT(29, 21);
|
|
||||||
printf("%s-Home button", tui_enter_dfu_loading_progress > 14 ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : COLOR(FG_YELLOW, BG_BLACK));
|
|
||||||
SETCOLOR(FG_BRIGHT_WHITE, BG_BLACK);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: IMPLEMENT REAL ENTER RECOVERY
|
|
||||||
int dfu_time = 0;
|
|
||||||
|
|
||||||
tui_screen_t tui_enter_dfu(void) {
|
|
||||||
if (tui_connected_devices && !tui_connected_devices->next) {
|
|
||||||
if (tui_connected_devices->mode == TUI_DEVICE_MODE_NORMAL) {
|
|
||||||
tui_enter_dfu_status = 0;
|
|
||||||
return ENTER_RECOVERY_SCREEN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int i = 0;
|
|
||||||
tui_enter_dfu_loading_progress = 1;
|
|
||||||
while(1) {
|
|
||||||
if (++i % 10 == 0) {
|
|
||||||
tui_enter_dfu_loading_progress++;
|
|
||||||
}
|
|
||||||
redraw_screen();
|
|
||||||
usleep(100000);
|
|
||||||
int event = tui_try_get_event();
|
|
||||||
if (event == TUI_EVENT_CONNECTED_DEVICES_CHANGED) {
|
|
||||||
if (tui_connected_devices && !tui_connected_devices->next) {
|
|
||||||
if (tui_connected_devices->mode == TUI_DEVICE_MODE_RECOVERY || tui_connected_devices->mode == TUI_DEVICE_MODE_NORMAL) {
|
|
||||||
tui_enter_dfu_status = 2;
|
|
||||||
tui_device_is_entering_dfu = false;
|
|
||||||
return ENTER_DFU_SCREEN;
|
|
||||||
} else {
|
|
||||||
tui_enter_dfu_status = 1;
|
|
||||||
tui_device_is_entering_dfu = false;
|
|
||||||
tui_enter_dfu_loading_progress = 15;
|
|
||||||
redraw_screen();
|
|
||||||
sleep(3);
|
|
||||||
tui_jailbreak();
|
|
||||||
return JAILBREAK_SCREEN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i > 10 * (60 + 15)) {
|
|
||||||
return MAIN_SCREEN;
|
|
||||||
}
|
|
||||||
if (i == 10 * 2) {
|
|
||||||
exitrecv_cmd(tui_connected_devices->ecid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
redraw_screen();
|
|
||||||
fflush(stdout);
|
|
||||||
sleep(3);
|
|
||||||
return JAILBREAK_SCREEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tui_enter_dfu_nav_mouse_select = -1;
|
|
||||||
|
|
||||||
tui_screen_t tui_screen_enter_dfu(void) {
|
|
||||||
if (tui_connected_devices && !tui_connected_devices->next) {
|
|
||||||
tui_enter_dfu_device_type = tui_product_type_to_device_type(tui_connected_devices->product_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
tui_device_is_entering_dfu = false;
|
|
||||||
tui_enter_dfu_loading_progress = 0;
|
|
||||||
tui_enter_dfu_nav_selection = 1;
|
|
||||||
redraw_screen();
|
|
||||||
|
|
||||||
tui_device_is_entering_dfu = false;
|
|
||||||
tui_enter_dfu_loading_progress = 0;
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
int event = tui_get_event();
|
|
||||||
switch (event) {
|
|
||||||
case TUI_EVENT_CONNECTED_DEVICES_CHANGED:
|
|
||||||
break;
|
|
||||||
case TUI_EVENT_INPUT: {
|
|
||||||
int input = tui_last_input;
|
|
||||||
if (input == TUI_INPUT_NONE) continue;
|
|
||||||
if (tui_device_is_entering_dfu) continue;
|
|
||||||
|
|
||||||
switch (input) {
|
|
||||||
case TUI_INPUT_LEFT:
|
|
||||||
case TUI_INPUT_RIGHT:
|
|
||||||
tui_enter_dfu_nav_selection = !tui_enter_dfu_nav_selection;
|
|
||||||
redraw_screen();
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_SELECT:
|
|
||||||
switch(tui_enter_dfu_nav_selection) {
|
|
||||||
case 0:
|
|
||||||
return MAIN_SCREEN;
|
|
||||||
case 1:
|
|
||||||
tui_device_is_entering_dfu = true;
|
|
||||||
redraw_screen();
|
|
||||||
return tui_enter_dfu();
|
|
||||||
}
|
|
||||||
case TUI_INPUT_MOUSE_MOVE:
|
|
||||||
tui_screen_enter_dfu_nav();
|
|
||||||
fflush(stdout);
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_MOUSE_DOWN:
|
|
||||||
if (tui_mouse_y == tui_y_offset + 22) {
|
|
||||||
if (tui_mouse_x >= tui_x_offset + 80 - 23 && tui_mouse_x <= tui_x_offset + 80 - 23 + 10) {
|
|
||||||
tui_enter_dfu_nav_selection = 0;
|
|
||||||
tui_enter_dfu_nav_mouse_select = 0;
|
|
||||||
redraw_screen();
|
|
||||||
} else if (tui_mouse_x >= tui_x_offset + 80 - 12 && tui_mouse_x <= tui_x_offset + 80 - 12 + 10) {
|
|
||||||
tui_enter_dfu_nav_selection = 1;
|
|
||||||
tui_enter_dfu_nav_mouse_select = 1;
|
|
||||||
redraw_screen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_MOUSE_UP:
|
|
||||||
if (tui_mouse_y == tui_y_offset + 22) {
|
|
||||||
if (tui_mouse_x >= tui_x_offset + 80 - 23 && tui_mouse_x <= tui_x_offset + 80 - 23 + 10) {
|
|
||||||
return MAIN_SCREEN;
|
|
||||||
} else if (tui_mouse_x >= tui_x_offset + 80 - 12 && tui_mouse_x <= tui_x_offset + 80 - 12 + 10) {
|
|
||||||
tui_device_is_entering_dfu = true;
|
|
||||||
redraw_screen();
|
|
||||||
return tui_enter_dfu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tui_enter_dfu_nav_mouse_select = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return MAIN_SCREEN;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/* ISO C forbids an empty translation unit */
|
|
||||||
extern char** environ;
|
|
||||||
#endif
|
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
#ifdef TUI
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <poll.h>
|
|
||||||
#include <palerain.h>
|
|
||||||
#include <tui.h>
|
|
||||||
|
|
||||||
int tui_enter_recovery_nav_selection = 1;
|
|
||||||
bool tui_device_is_entering_recovery = false;
|
|
||||||
bool tui_enter_recovery_mode_failed = false;
|
|
||||||
|
|
||||||
void tui_screen_enter_recovery_nav(void) {
|
|
||||||
MOVETOT(80 - 22, 23);
|
|
||||||
printf("%s[ Back ]" COLOR(FG_WHITE, BG_BLACK) " %s[ Next ]" COLOR(FG_WHITE, BG_BLACK),
|
|
||||||
tui_device_is_entering_recovery ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : tui_enter_recovery_nav_selection == 0 ? "\033[30;107m" : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 80 - 23 && tui_mouse_x <= tui_x_offset + 80 - 23 + 10
|
|
||||||
) && (tui_mouse_y == tui_y_offset + 22) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
),
|
|
||||||
tui_device_is_entering_recovery ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : tui_enter_recovery_nav_selection == 1 ? "\033[30;107m" : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 80 - 12 && tui_mouse_x <= tui_x_offset + 80 - 12 + 10
|
|
||||||
) && (tui_mouse_y == tui_y_offset + 22) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
char enter_recovery_loading[9][8] = {
|
|
||||||
"........",
|
|
||||||
"|.......",
|
|
||||||
".|......",
|
|
||||||
"..|.....",
|
|
||||||
"...|....",
|
|
||||||
"....|...",
|
|
||||||
".....|..",
|
|
||||||
"......|.",
|
|
||||||
".......|"
|
|
||||||
};
|
|
||||||
|
|
||||||
char enter_recovery_loading_troll[9][8] = {
|
|
||||||
".......",
|
|
||||||
"t......",
|
|
||||||
".r.....",
|
|
||||||
"..o....",
|
|
||||||
"...l...",
|
|
||||||
"....l..",
|
|
||||||
".....e.",
|
|
||||||
"......d",
|
|
||||||
};
|
|
||||||
|
|
||||||
bool is_troll;
|
|
||||||
int tui_enter_recovery_loading_progress = 0;
|
|
||||||
|
|
||||||
void tui_screen_enter_recovery_loading(void) {
|
|
||||||
SETCOLOR(FG_YELLOW, BG_BLACK);
|
|
||||||
PRINTATT(3, 8, "Entering recovery mode ");
|
|
||||||
printf("%.8s", is_troll ? enter_recovery_loading_troll[tui_enter_recovery_loading_progress] : enter_recovery_loading[tui_enter_recovery_loading_progress]);
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tui_screen_enter_recovery_redraw(void) {
|
|
||||||
PRINTATT(3, 3, "The device needs to be put into DFU mode to apply the jailbreak. This is a");
|
|
||||||
PRINTATT(3, 4, "manual process and we will guide you through it.");
|
|
||||||
PRINTATT(3, 5, "In order to prevent filesystem corruption through hard reset, the device");
|
|
||||||
PRINTATT(3, 6, "will be put into recovery mode first. Click Next when you are ready.");
|
|
||||||
|
|
||||||
if (tui_enter_recovery_mode_failed) {
|
|
||||||
SETCOLOR(FG_YELLOW, BG_BLACK);
|
|
||||||
PRINTATT(3, 8, "Hmm... device did not enter recovery mode!? Click Next to try again...");
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
tui_screen_enter_recovery_nav();
|
|
||||||
if (tui_device_is_entering_recovery) {
|
|
||||||
tui_screen_enter_recovery_loading();
|
|
||||||
}
|
|
||||||
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
int recovery_time = 0;
|
|
||||||
|
|
||||||
tui_screen_t tui_enter_recovery(void) {
|
|
||||||
enter_recovery_cmd(tui_connected_devices->udid);
|
|
||||||
is_troll = false;
|
|
||||||
if (rand() % 1000 == 0) {
|
|
||||||
is_troll = true;
|
|
||||||
}
|
|
||||||
int i = 0;
|
|
||||||
recovery_time = 0;
|
|
||||||
while(1) {
|
|
||||||
redraw_screen();
|
|
||||||
tui_enter_recovery_loading_progress++;
|
|
||||||
tui_enter_recovery_loading_progress %= 9;
|
|
||||||
// 100ms sleep
|
|
||||||
struct timespec ts;
|
|
||||||
ts.tv_sec = 0;
|
|
||||||
ts.tv_nsec = 100000000;
|
|
||||||
nanosleep(&ts, NULL);
|
|
||||||
|
|
||||||
int event = tui_try_get_event();
|
|
||||||
if (event == TUI_EVENT_CONNECTED_DEVICES_CHANGED) {
|
|
||||||
if (tui_connected_devices && !tui_connected_devices->next && tui_connected_devices->mode == TUI_DEVICE_MODE_RECOVERY) {
|
|
||||||
SETCOLOR(FG_YELLOW, BG_BLACK);
|
|
||||||
PRINTATT(3, 8, "Device is now in recovery mode.");
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
sleep(3);
|
|
||||||
|
|
||||||
return ENTER_DFU_SCREEN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i > 60 * 10) {
|
|
||||||
tui_enter_recovery_mode_failed = true;
|
|
||||||
return ENTER_RECOVERY_SCREEN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int tui_enter_recovery_nav_mouse_select = -1;
|
|
||||||
|
|
||||||
tui_screen_t tui_screen_enter_recovery(void) {
|
|
||||||
tui_device_is_entering_recovery = false;
|
|
||||||
tui_enter_recovery_loading_progress = 0;
|
|
||||||
tui_enter_recovery_nav_selection = 1;
|
|
||||||
redraw_screen();
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
int event = tui_get_event();
|
|
||||||
switch (event) {
|
|
||||||
case TUI_EVENT_CONNECTED_DEVICES_CHANGED:
|
|
||||||
tui_enter_recovery_mode_failed = false;
|
|
||||||
return MAIN_SCREEN;
|
|
||||||
case TUI_EVENT_INPUT: {
|
|
||||||
int input = tui_last_input;
|
|
||||||
if (input == TUI_INPUT_NONE) continue;
|
|
||||||
if (tui_device_is_entering_recovery) continue;
|
|
||||||
|
|
||||||
switch (input) {
|
|
||||||
case TUI_INPUT_LEFT:
|
|
||||||
case TUI_INPUT_RIGHT:
|
|
||||||
tui_enter_recovery_nav_selection = !tui_enter_recovery_nav_selection;
|
|
||||||
redraw_screen();
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_SELECT:
|
|
||||||
switch(tui_enter_recovery_nav_selection) {
|
|
||||||
case 0:
|
|
||||||
tui_enter_recovery_mode_failed = false;
|
|
||||||
return MAIN_SCREEN;
|
|
||||||
case 1:
|
|
||||||
tui_device_is_entering_recovery = true;
|
|
||||||
redraw_screen();
|
|
||||||
return tui_enter_recovery();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_MOUSE_MOVE:
|
|
||||||
tui_screen_enter_recovery_nav();
|
|
||||||
fflush(stdout);
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_MOUSE_DOWN:
|
|
||||||
if (tui_mouse_y == tui_y_offset + 22) {
|
|
||||||
if (tui_mouse_x >= tui_x_offset + 80 - 23 && tui_mouse_x <= tui_x_offset + 80 - 23 + 10) {
|
|
||||||
tui_enter_recovery_nav_selection = 0;
|
|
||||||
tui_enter_recovery_nav_mouse_select = 0;
|
|
||||||
tui_screen_enter_recovery_nav();
|
|
||||||
fflush(stdout);
|
|
||||||
} else if (tui_mouse_x >= tui_x_offset + 80 - 12 && tui_mouse_x <= tui_x_offset + 80 - 12 + 10) {
|
|
||||||
tui_enter_recovery_nav_selection = 1;
|
|
||||||
tui_enter_recovery_nav_mouse_select = 1;
|
|
||||||
tui_screen_enter_recovery_nav();
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_MOUSE_UP:
|
|
||||||
if (tui_mouse_y == tui_y_offset + 22) {
|
|
||||||
if (tui_mouse_x >= tui_x_offset + 80 - 23 && tui_mouse_x <= tui_x_offset + 80 - 23 + 10) {
|
|
||||||
return MAIN_SCREEN;
|
|
||||||
} else if (tui_mouse_x >= tui_x_offset + 80 - 12 && tui_mouse_x <= tui_x_offset + 80 - 12 + 10) {
|
|
||||||
tui_device_is_entering_recovery = true;
|
|
||||||
redraw_screen();
|
|
||||||
return tui_enter_recovery();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tui_enter_recovery_nav_mouse_select = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tui_enter_recovery_mode_failed = false;
|
|
||||||
return MAIN_SCREEN;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/* ISO C forbids an empty translation unit */
|
|
||||||
extern char** environ;
|
|
||||||
#endif
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
#ifdef TUI
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <palerain.h>
|
|
||||||
#include <tui.h>
|
|
||||||
|
|
||||||
bool tui_is_jailbreaking = false;
|
|
||||||
|
|
||||||
void tui_screen_jailbreak_nav(void) {
|
|
||||||
if (tui_is_jailbreaking) {
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_BLACK);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLACK, BG_BRIGHT_WHITE);
|
|
||||||
}
|
|
||||||
PRINTATT(80 - 11, 23, "[ Done ]");
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_t tui_jailbreak_thread_id;
|
|
||||||
int tui_jailbreak_stage = 0;
|
|
||||||
char *tui_jailbreak_status = NULL;
|
|
||||||
|
|
||||||
void tui_jailbreak_status_changed(void) {
|
|
||||||
tui_last_event = TUI_EVENT_JAILBREAK_STATUS_CHANGED;
|
|
||||||
sem_post(tui_event_semaphore);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *tui_jailbreak_thread(void *arg) {
|
|
||||||
tui_jailbreak_stage = 1;
|
|
||||||
tui_jailbreak_status = "About to execute checkra1n";
|
|
||||||
|
|
||||||
tui_jailbreak_status_changed();
|
|
||||||
|
|
||||||
if (!tui_connected_devices || tui_connected_devices->next || tui_connected_devices->mode != TUI_DEVICE_MODE_DFU) {
|
|
||||||
tui_jailbreak_status = "ERROR: No single device in DFU mode found";
|
|
||||||
tui_jailbreak_status_changed();
|
|
||||||
pthread_exit(NULL);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
tui_jailbreak_stage = 2;
|
|
||||||
tui_jailbreak_status = "Running exploit";
|
|
||||||
tui_jailbreak_status_changed();
|
|
||||||
|
|
||||||
if (exec_checkra1n() != 0) {
|
|
||||||
tui_jailbreak_status = "ERROR: Failed to run exploit";
|
|
||||||
tui_jailbreak_status_changed();
|
|
||||||
pthread_exit(NULL);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
tui_jailbreak_stage = 3;
|
|
||||||
tui_jailbreak_status = "Waiting for PongoOS";
|
|
||||||
tui_jailbreak_status_changed();
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
pthread_create(&pongo_thread, NULL, pongo_helper, NULL);
|
|
||||||
|
|
||||||
// pongo helper will take care of the rest
|
|
||||||
|
|
||||||
pthread_exit(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tui_jailbreak(void) {
|
|
||||||
tui_is_jailbreaking = true;
|
|
||||||
if (tui_options_verbose_boot) {
|
|
||||||
palerain_flags |= palerain_option_verbose_boot;
|
|
||||||
} else {
|
|
||||||
palerain_flags &= ~palerain_option_verbose_boot;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tui_options_safe_mode) {
|
|
||||||
palerain_flags |= palerain_option_safemode;
|
|
||||||
} else {
|
|
||||||
palerain_flags &= ~palerain_option_safemode;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tui_options_force_revert) {
|
|
||||||
palerain_flags |= palerain_option_force_revert;
|
|
||||||
} else {
|
|
||||||
palerain_flags &= ~palerain_option_force_revert;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(palerain_flags_cmd, 0x30, "palera1n_flags 0x%" PRIx64, palerain_flags);
|
|
||||||
snprintf(xargs_cmd, sizeof(xargs_cmd), "xargs %s", tui_options_boot_args);
|
|
||||||
|
|
||||||
pthread_create(&tui_jailbreak_thread_id, NULL, tui_jailbreak_thread, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tui_screen_jailbreak_redraw(void) {
|
|
||||||
PRINTATT(3, 3, "Installing jailbreak, this will take a moment. If the device asks for a");
|
|
||||||
PRINTATT(3, 4, "passcode please enter it. Do not disconnect the device until finished.");
|
|
||||||
|
|
||||||
if (tui_jailbreak_status) {
|
|
||||||
SETCOLOR(FG_YELLOW, BG_BLACK);
|
|
||||||
PRINTATT(3, 6, tui_jailbreak_status);
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
tui_draw_rectangle(5, 9, 80 - 6, 9 + 2);
|
|
||||||
MOVETOT(6 + 1, 10 + 1);
|
|
||||||
SETCOLOR(FG_BLACK, BG_WHITE);
|
|
||||||
for (int i = 0; i < ((80 - 12) * ((float)tui_jailbreak_stage / 9)); i++) {
|
|
||||||
putchar(' ');
|
|
||||||
}
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
|
|
||||||
tui_screen_jailbreak_nav();
|
|
||||||
}
|
|
||||||
|
|
||||||
int tui_jailbreak_nav_mouse_select = -1;
|
|
||||||
|
|
||||||
tui_screen_t tui_screen_jailbreak(void) {
|
|
||||||
redraw_screen();
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
int event = tui_get_event();
|
|
||||||
switch (event) {
|
|
||||||
case TUI_EVENT_INPUT: {
|
|
||||||
int input = tui_last_input;
|
|
||||||
if (input == TUI_INPUT_NONE) continue;
|
|
||||||
|
|
||||||
switch (input) {
|
|
||||||
case TUI_INPUT_SELECT:
|
|
||||||
if (!tui_is_jailbreaking) {
|
|
||||||
tui_is_restarting = true;
|
|
||||||
tui_terminate(0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_MOUSE_DOWN:
|
|
||||||
if (tui_mouse_y == tui_y_offset + 24 - 2 &&
|
|
||||||
tui_mouse_x >= tui_x_offset + 80 - 12 &&
|
|
||||||
tui_mouse_x <= tui_x_offset + 80 - 12 + 10) {
|
|
||||||
tui_jailbreak_nav_mouse_select = 0;
|
|
||||||
redraw_screen();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_MOUSE_UP:
|
|
||||||
if (tui_jailbreak_nav_mouse_select == 0) {
|
|
||||||
tui_jailbreak_nav_mouse_select = -1;
|
|
||||||
if (!tui_is_jailbreaking) {
|
|
||||||
tui_is_restarting = true;
|
|
||||||
tui_terminate(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TUI_EVENT_JAILBREAK_STATUS_CHANGED:
|
|
||||||
redraw_screen();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_SCREEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* ISO C forbids an empty translation unit */
|
|
||||||
extern char** environ;
|
|
||||||
#endif
|
|
||||||
@@ -1,378 +0,0 @@
|
|||||||
#ifdef TUI
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <palerain.h>
|
|
||||||
#include <tui.h>
|
|
||||||
|
|
||||||
bool showing_ecid = false;
|
|
||||||
|
|
||||||
char palera1n_logo[17][16] = {
|
|
||||||
" ++ ",
|
|
||||||
" #@@# ",
|
|
||||||
" +@@@@+ ",
|
|
||||||
" :@@@@@@: ",
|
|
||||||
" #@@@@@@# ",
|
|
||||||
" +@@@@@@@@+ ",
|
|
||||||
" :#*@@@@@@*#: ",
|
|
||||||
" %###@@@@###% ",
|
|
||||||
" .####%@@%####. ",
|
|
||||||
" @############@ ",
|
|
||||||
"=@@*########*@@=",
|
|
||||||
"+@@@@%####%@@@@+",
|
|
||||||
":@@@@%%**%%@@@@:",
|
|
||||||
" +@@%%*@@*%%@@+ ",
|
|
||||||
" ++%@@@@%++ ",
|
|
||||||
" :++: "
|
|
||||||
};
|
|
||||||
|
|
||||||
char random_quotes[][150] = {
|
|
||||||
"panic(cpu 1 caller 0xfffffff0232bd958): SEP Panic",
|
|
||||||
"Now with Apple TV support!",
|
|
||||||
"checkra1n will open source in 2020",
|
|
||||||
"Try running palera1n on a Intel 80486!",
|
|
||||||
"\"iOS 15 with SSV is unhackable\", but here we are.",
|
|
||||||
"initproc exited -- exit reason namespace 1 subcode0x7 description: none",
|
|
||||||
"totally not checkra1n",
|
|
||||||
"Because the command line wasn't easy enough",
|
|
||||||
"Checkra1n wrapper?",
|
|
||||||
""
|
|
||||||
};
|
|
||||||
|
|
||||||
#define PALERA1N_URL "https://palera.in"
|
|
||||||
|
|
||||||
int tui_main_nav_selection = 1;
|
|
||||||
bool quick_mode_enabled = false;
|
|
||||||
bool tui_can_start = false;
|
|
||||||
int random_quote;
|
|
||||||
|
|
||||||
bool easter_egg = false;
|
|
||||||
|
|
||||||
void tui_screen_main_nav(void) {
|
|
||||||
MOVETOT(80 - 52, 23);
|
|
||||||
printf("[%c] %sQuick Mode " COLOR(FG_WHITE, BG_BLACK) " %s[ Options ]" COLOR(FG_WHITE, BG_BLACK) " %s[ Start ]" COLOR(FG_WHITE, BG_BLACK) " %s[ Quit ]" COLOR(FG_WHITE, BG_BLACK), quick_mode_enabled ? 'x' : ' ',
|
|
||||||
tui_main_nav_selection == 0 ? COLOR(FG_BLACK, BG_BRIGHT_WHITE) : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 80 - 49 && tui_mouse_x <= tui_x_offset + 80 - 49 + 10
|
|
||||||
) && (tui_mouse_y == tui_y_offset + 22) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
),
|
|
||||||
tui_main_nav_selection == 1 ? COLOR(FG_BLACK, BG_BRIGHT_WHITE) : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 80 - 37 && tui_mouse_x <= tui_x_offset + 80 - 37 + 10
|
|
||||||
) && (tui_mouse_y == tui_y_offset + 22) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
),
|
|
||||||
tui_main_nav_selection == 2 ? COLOR(FG_BLACK, BG_BRIGHT_WHITE) : !tui_can_start ? (supports_bright_colors ? COLOR(FG_BRIGHT_BLACK, BG_BLACK) : COLOR(FG_BLUE, BG_BLACK)) : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 80 - 25 && tui_mouse_x <= tui_x_offset + 80 - 25 + 10
|
|
||||||
) && (tui_mouse_y == tui_y_offset + 22) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
),
|
|
||||||
tui_main_nav_selection == 3 ? COLOR(FG_BLACK, BG_BRIGHT_WHITE) : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 80 - 13 && tui_mouse_x <= tui_x_offset + 80 - 13 + 10
|
|
||||||
) && (tui_mouse_y == tui_y_offset + 22) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tui_screen_main_redraw(void) {
|
|
||||||
PRINTATT(3, 2, "Welcome to palera1n!");
|
|
||||||
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
PRINTATT(3, 9, "Made by: Nick Chan, Ploosh, Khcrysalis, Mineek");
|
|
||||||
PRINTATT(3, 10, "staturnz, kok3shidoll, ");
|
|
||||||
if ((tui_mouse_y == tui_y_offset + 9 && tui_mouse_x >= tui_x_offset + 25 && tui_mouse_x <= tui_x_offset + 25 + 8) || easter_egg) {
|
|
||||||
SETCOLORA(FG_BRIGHT_WHITE, BG_BLACK, BOLD);
|
|
||||||
}
|
|
||||||
printf("HAHALOSAH");
|
|
||||||
RESETFONT;
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
PRINTATT(3, 12, "Thanks to: llsc12, nebula,");
|
|
||||||
PRINTATT(3, 13, "nikias (libimobiledevice), checkra1n");
|
|
||||||
PRINTATT(3, 14, "(Siguza, axi0mx, littlelailo et al.), Procursus");
|
|
||||||
PRINTATT(3, 15, "Team (Hayden Seay, Cameron Katri, Keto et.al),");
|
|
||||||
PRINTATT(80 - (int)sizeof(PALERA1N_URL), 21, PALERA1N_URL);
|
|
||||||
PRINTATT(80 - (int)sizeof("@palera1n"), 20, "@palera1n");
|
|
||||||
PRINTATT(3, 20, "With <3 from HAHALOSAH");
|
|
||||||
PRINTATT(3, 21, "Note: Backup your stuff. Use at your own risk.");
|
|
||||||
DRAWLINET(2, 22, 78);
|
|
||||||
DRAWLINET(2, 3, 50);
|
|
||||||
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_BLACK);
|
|
||||||
}
|
|
||||||
DRAWLINET(2, 11, 50);
|
|
||||||
DRAWLINET(2, 16, 50);
|
|
||||||
|
|
||||||
for (int y = 0; y < 16; y++) {
|
|
||||||
PRINTATLENT(80 - 22, y + 4, palera1n_logo[y], 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
SETCOLOR(FG_YELLOW, BG_BLACK);
|
|
||||||
if (tui_connected_devices == NULL) {
|
|
||||||
PRINTATT(3, 5, "Connect your iPhone, iPad, iPod Touch, or Apple");
|
|
||||||
PRINTATT(3, 6, "TV to begin.");
|
|
||||||
tui_can_start = false;
|
|
||||||
} else if (tui_connected_devices->next != NULL) {
|
|
||||||
PRINTATT(3, 5, "Please attach only one device.");
|
|
||||||
tui_can_start = false;
|
|
||||||
} else {
|
|
||||||
if (strlen(tui_connected_devices->display_name) == 0) {
|
|
||||||
PRINTATT(3, 5, "ERROR: Failed to open device in recovery/DFU mode");
|
|
||||||
PRINTATT(3, 6, "Please reopen palera1n and try again.");
|
|
||||||
} else if (tui_connected_devices->mode == TUI_DEVICE_MODE_NORMAL) {
|
|
||||||
MOVETOT(3, 5);
|
|
||||||
int ecid_y;
|
|
||||||
if (!tui_connected_devices->arm64) {
|
|
||||||
printf("Sorry, %s (iOS %s) is not supported.", tui_connected_devices->display_name, tui_connected_devices->version);
|
|
||||||
ecid_y = 6;
|
|
||||||
tui_can_start = false;
|
|
||||||
} else if (tui_compare_versions(tui_connected_devices->version, "15.0") < 0) {
|
|
||||||
printf("Sorry, %s is supported, but iOS", tui_connected_devices->display_name);
|
|
||||||
MOVETOT(3, 6);
|
|
||||||
printf("%s is not.", tui_connected_devices->version);
|
|
||||||
PRINTATT(3, 7, "Supported versions are 15.0+");
|
|
||||||
ecid_y = 8;
|
|
||||||
tui_can_start = false;
|
|
||||||
} else if (tui_connected_devices->requires_passcode_disabled) {
|
|
||||||
printf("Sorry, this devices passcode must be disabled on %s.", tui_connected_devices->version);
|
|
||||||
MOVETOT(3, 6);
|
|
||||||
printf("On 16.0+, you must reset the phone to factory settings");
|
|
||||||
MOVETOT(3, 7);
|
|
||||||
printf("and not have a passcode enabled ever since last restore.");
|
|
||||||
ecid_y = 8;
|
|
||||||
tui_can_start = false;
|
|
||||||
} else {
|
|
||||||
printf("%s (%s) connected in Normal mode.", tui_connected_devices->display_name, tui_connected_devices->version);
|
|
||||||
ecid_y = 6;
|
|
||||||
tui_can_start = true;
|
|
||||||
}
|
|
||||||
if (showing_ecid) {
|
|
||||||
MOVETOT(3, ecid_y);
|
|
||||||
printf("ECID: 0x%" PRIx64 " ", tui_connected_devices->ecid);
|
|
||||||
} else {
|
|
||||||
PRINTATT(3, ecid_y, "Press (E) to show ECID.");
|
|
||||||
}
|
|
||||||
} else if (tui_connected_devices->mode == TUI_DEVICE_MODE_RECOVERY) {
|
|
||||||
MOVETOT(3, 5);
|
|
||||||
printf("%s connected in Recovery mode.", tui_connected_devices->display_name);
|
|
||||||
if (showing_ecid) {
|
|
||||||
MOVETOT(3, 6);
|
|
||||||
printf("ECID: 0x%" PRIx64 " ", tui_connected_devices->ecid);
|
|
||||||
} else {
|
|
||||||
PRINTATT(3, 6, "Press (E) to show ECID.");
|
|
||||||
}
|
|
||||||
PRINTATT(3, 7, "NOTE: Ensure installed iOS is in range 15.0+");
|
|
||||||
tui_can_start = true;
|
|
||||||
} else if (tui_connected_devices->mode == TUI_DEVICE_MODE_DFU) {
|
|
||||||
MOVETOT(3, 5);
|
|
||||||
printf("%s connected in DFU mode.", tui_connected_devices->display_name);
|
|
||||||
if (showing_ecid) {
|
|
||||||
MOVETOT(3, 6);
|
|
||||||
printf("ECID: 0x%" PRIx64 " ", tui_connected_devices->ecid);
|
|
||||||
} else {
|
|
||||||
PRINTATT(3, 6, "Press (E) to show ECID.");
|
|
||||||
}
|
|
||||||
#ifdef DEV_BUILD
|
|
||||||
tui_can_start = true;
|
|
||||||
#else
|
|
||||||
PRINTATT(3, 7, "Please connect device in Normal/Recovery mode");
|
|
||||||
PRINTATT(3, 8, "or run palera1n in CLI mode");
|
|
||||||
tui_can_start = false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tui_can_start && tui_main_nav_selection == 2) {
|
|
||||||
tui_main_nav_selection = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
|
|
||||||
for (int y = 0; y < 3; y++) {
|
|
||||||
PRINTATLEN(tui_x_offset + 3, tui_y_offset + 17 + y, random_quotes[random_quote] + y * 50, 50);
|
|
||||||
}
|
|
||||||
|
|
||||||
tui_screen_main_nav();
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
int tui_main_nav_mouse_select = -1;
|
|
||||||
|
|
||||||
tui_screen_t tui_screen_main(void) {
|
|
||||||
random_quote = ((unsigned int)((rand()+rand())/2)) % 8;
|
|
||||||
redraw_screen();
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
int event = tui_get_event();
|
|
||||||
switch (event) {
|
|
||||||
case TUI_EVENT_CONNECTED_DEVICES_CHANGED:
|
|
||||||
redraw_screen();
|
|
||||||
break;
|
|
||||||
case TUI_EVENT_INPUT: {
|
|
||||||
int input = tui_last_input;
|
|
||||||
|
|
||||||
switch (input) {
|
|
||||||
case TUI_INPUT_NONE:
|
|
||||||
if (tui_last_key == 'E' || tui_last_key == 'e') {
|
|
||||||
showing_ecid = !showing_ecid;
|
|
||||||
tui_screen_main_redraw();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_LEFT:
|
|
||||||
case TUI_INPUT_TAB_BACK:
|
|
||||||
if (--tui_main_nav_selection == -1) tui_main_nav_selection = 3;
|
|
||||||
if (tui_main_nav_selection == 2 && !tui_can_start) tui_main_nav_selection = 1;
|
|
||||||
tui_screen_main_nav();
|
|
||||||
fflush(stdout);
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_RIGHT:
|
|
||||||
case TUI_INPUT_TAB:
|
|
||||||
if (++tui_main_nav_selection == 4) tui_main_nav_selection = 0;
|
|
||||||
if (tui_main_nav_selection == 2 && !tui_can_start) tui_main_nav_selection = 3;
|
|
||||||
tui_screen_main_nav();
|
|
||||||
fflush(stdout);
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_SELECT:
|
|
||||||
switch(tui_main_nav_selection) {
|
|
||||||
case 0:
|
|
||||||
quick_mode_enabled = !quick_mode_enabled;
|
|
||||||
tui_screen_main_nav();
|
|
||||||
fflush(stdout);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
return OPTIONS_SCREEN;
|
|
||||||
case 2:
|
|
||||||
if (tui_can_start) {
|
|
||||||
if (tui_connected_devices->mode == TUI_DEVICE_MODE_NORMAL) {
|
|
||||||
return ENTER_RECOVERY_SCREEN;
|
|
||||||
} else if (tui_connected_devices->mode == TUI_DEVICE_MODE_RECOVERY) {
|
|
||||||
return ENTER_DFU_SCREEN;
|
|
||||||
} else if (tui_connected_devices->mode == TUI_DEVICE_MODE_DFU) {
|
|
||||||
tui_jailbreak();
|
|
||||||
return JAILBREAK_SCREEN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
return EXIT_SCREEN;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_MOUSE_MOVE:
|
|
||||||
tui_screen_main_redraw();
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_MOUSE_DOWN:
|
|
||||||
if ((tui_mouse_y == tui_y_offset + 9 && tui_mouse_x >= tui_x_offset + 25 && tui_mouse_x <= tui_x_offset + 25 + 8)) {
|
|
||||||
easter_egg = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (tui_mouse_y == tui_y_offset + 22) {
|
|
||||||
if (tui_mouse_x >= tui_x_offset + 80 - 49 && tui_mouse_x <= tui_x_offset + 80 - 49 + 10) {
|
|
||||||
tui_main_nav_selection = 0;
|
|
||||||
tui_main_nav_mouse_select = 0;
|
|
||||||
} else if (tui_mouse_x >= tui_x_offset + 80 - 37 && tui_mouse_x <= tui_x_offset + 80 - 37 + 10) {
|
|
||||||
tui_main_nav_selection = 1;
|
|
||||||
tui_main_nav_mouse_select = 1;
|
|
||||||
} else if (tui_mouse_x >= tui_x_offset + 80 - 25 && tui_mouse_x <= tui_x_offset + 80 - 25 + 10) {
|
|
||||||
if (tui_can_start) {
|
|
||||||
tui_main_nav_selection = 2;
|
|
||||||
tui_main_nav_mouse_select = 2;
|
|
||||||
}
|
|
||||||
} else if (tui_mouse_x >= tui_x_offset + 80 - 13 && tui_mouse_x <= tui_x_offset + 80 - 13 + 10) {
|
|
||||||
tui_main_nav_selection = 3;
|
|
||||||
tui_main_nav_mouse_select = 3;
|
|
||||||
}
|
|
||||||
tui_screen_main_nav();
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_MOUSE_UP:
|
|
||||||
if (tui_mouse_y == tui_y_offset + 22) {
|
|
||||||
if (tui_mouse_x >= tui_x_offset + 80 - 49 && tui_mouse_x <= tui_x_offset + 80 - 49 + 10 && tui_main_nav_mouse_select == 0) {
|
|
||||||
quick_mode_enabled = !quick_mode_enabled;
|
|
||||||
redraw_screen();
|
|
||||||
} else if (tui_mouse_x >= tui_x_offset + 80 - 37 && tui_mouse_x <= tui_x_offset + 80 - 37 + 10 && tui_main_nav_mouse_select == 1) {
|
|
||||||
return OPTIONS_SCREEN;
|
|
||||||
} else if (tui_mouse_x >= tui_x_offset + 80 - 25 && tui_mouse_x <= tui_x_offset + 80 - 25 + 10 && tui_main_nav_mouse_select == 2) {
|
|
||||||
if (tui_can_start) {
|
|
||||||
if (tui_connected_devices->mode == TUI_DEVICE_MODE_NORMAL) {
|
|
||||||
return ENTER_RECOVERY_SCREEN;
|
|
||||||
} else if (tui_connected_devices->mode == TUI_DEVICE_MODE_RECOVERY) {
|
|
||||||
return ENTER_DFU_SCREEN;
|
|
||||||
} else if (tui_connected_devices->mode == TUI_DEVICE_MODE_DFU) {
|
|
||||||
tui_jailbreak();
|
|
||||||
return JAILBREAK_SCREEN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (tui_mouse_x >= tui_x_offset + 80 - 13 && tui_mouse_x <= tui_x_offset + 80 - 13 + 10 && tui_main_nav_mouse_select == 3) {
|
|
||||||
return EXIT_SCREEN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tui_main_nav_mouse_select = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return MAIN_SCREEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tui_version_extract_component(const char *version, int index) {
|
|
||||||
int component = 0;
|
|
||||||
int componentIndex = 0;
|
|
||||||
for (int i = 0; version[i] != '\0'; i++) {
|
|
||||||
if (version[i] == '.') {
|
|
||||||
componentIndex++;
|
|
||||||
if (componentIndex > index) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (componentIndex == index) {
|
|
||||||
component *= 10;
|
|
||||||
component += version[i] - '0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return component;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tui_compare_versions(const char *firstVersion, const char *secondVersion) {
|
|
||||||
if (strcmp(firstVersion, secondVersion) == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int firstVersionMajor = tui_version_extract_component(firstVersion, 0);
|
|
||||||
int firstVersionMinor = tui_version_extract_component(firstVersion, 1);
|
|
||||||
int firstVersionPatch = tui_version_extract_component(firstVersion, 2);
|
|
||||||
|
|
||||||
int secondVersionMajor = tui_version_extract_component(secondVersion, 0);
|
|
||||||
int secondVersionMinor = tui_version_extract_component(secondVersion, 1);
|
|
||||||
int secondVersionPatch = tui_version_extract_component(secondVersion, 2);
|
|
||||||
|
|
||||||
if (firstVersionMajor != secondVersionMajor) {
|
|
||||||
return firstVersionMajor - secondVersionMajor;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (firstVersionMinor != secondVersionMinor) {
|
|
||||||
return firstVersionMinor - secondVersionMinor;
|
|
||||||
}
|
|
||||||
|
|
||||||
return firstVersionPatch - secondVersionPatch;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* ISO C forbids an empty translation unit */
|
|
||||||
extern char** environ;
|
|
||||||
#endif
|
|
||||||
@@ -1,341 +0,0 @@
|
|||||||
#ifdef TUI
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <palerain.h>
|
|
||||||
#include <tui.h>
|
|
||||||
|
|
||||||
int tui_options_nav_selection = 0;
|
|
||||||
int tui_options_nav_mouse_select = 0;
|
|
||||||
|
|
||||||
bool tui_options_allow_untested = false;
|
|
||||||
bool tui_options_safe_mode = false;
|
|
||||||
bool tui_options_verbose_boot = false;
|
|
||||||
bool tui_options_force_revert = false;
|
|
||||||
bool tui_options_flower_chain = true;
|
|
||||||
|
|
||||||
bool tui_options_is_editing_boot_args = false;
|
|
||||||
|
|
||||||
char tui_options_boot_args[0x1e0 + 1] = {0};
|
|
||||||
|
|
||||||
int tui_options_boot_args_cursor = 0;
|
|
||||||
int tui_options_boot_args_offset = 0;
|
|
||||||
|
|
||||||
void tui_screen_options_nav(void) {
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
MOVETOT(80 - 11, 23);
|
|
||||||
printf("%s[ Back ]" COLOR(FG_WHITE, BG_BLACK),
|
|
||||||
tui_options_nav_selection == 0 ? COLOR(FG_BLACK, BG_BRIGHT_WHITE) : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 80 - 12 && tui_mouse_x <= tui_x_offset + 80 - 12 + 10
|
|
||||||
) && (tui_mouse_y == tui_y_offset + 22) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
)
|
|
||||||
);
|
|
||||||
#ifdef DEV_BUILD
|
|
||||||
PRINTATT(3, 23, "DEV_BUILD");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
extern bool easter_egg;
|
|
||||||
|
|
||||||
void tui_screen_options_options(void) {
|
|
||||||
SETCOLOR( FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
MOVETOT(3, 8);
|
|
||||||
printf("[%c] %sAllow untested iOS/iPadOS versions" COLOR(FG_WHITE, BG_BLACK),
|
|
||||||
tui_options_allow_untested ? ' ' : ' ',
|
|
||||||
COLOR(FG_BLACK, FG_BRIGHT_BLACK));
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
MOVETOT(3, 9);
|
|
||||||
printf("[%c] %sSafe Mode " COLOR(FG_WHITE, BG_BLACK),
|
|
||||||
tui_options_safe_mode ? 'x' : ' ',
|
|
||||||
tui_options_nav_selection == 1 ? COLOR(FG_BLACK, BG_BRIGHT_WHITE) : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 5 && tui_mouse_x <= tui_x_offset + 5 + 34
|
|
||||||
) && (tui_mouse_y == tui_y_offset + 8) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
));
|
|
||||||
MOVETOT(3, 10);
|
|
||||||
printf("[%c] %sVerbose Boot " COLOR(FG_WHITE, BG_BLACK),
|
|
||||||
tui_options_verbose_boot ? 'x' : ' ',
|
|
||||||
tui_options_nav_selection == 2 ? COLOR(FG_BLACK, BG_BRIGHT_WHITE) : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 5 && tui_mouse_x <= tui_x_offset + 5 + 34
|
|
||||||
) && (tui_mouse_y == tui_y_offset + 9) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
));
|
|
||||||
MOVETOT(3, 11);
|
|
||||||
printf("[%c] %sForce Revert " COLOR(FG_WHITE, BG_BLACK),
|
|
||||||
tui_options_force_revert ? 'x' : ' ',
|
|
||||||
tui_options_nav_selection == 3 ? COLOR(FG_BLACK, BG_BRIGHT_WHITE) : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 5 && tui_mouse_x <= tui_x_offset + 5 + 34
|
|
||||||
) && (tui_mouse_y == tui_y_offset + 10) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
));
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_BLACK);
|
|
||||||
}
|
|
||||||
DRAWLINET(3, 13, 76);
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
MOVETOT(7, 15);
|
|
||||||
printf("%sBoot Arguments: " COLOR(FG_WHITE, BG_BLACK),
|
|
||||||
tui_options_nav_selection == 4 ? COLOR(FG_BLACK, BG_BRIGHT_WHITE) : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 5 && tui_mouse_x <= tui_x_offset + 5 + 34
|
|
||||||
) && (
|
|
||||||
tui_mouse_y == tui_y_offset + 14 || tui_mouse_y == tui_y_offset + 15
|
|
||||||
) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
));
|
|
||||||
const char* boot_args_hint = tui_options_is_editing_boot_args ? "(press ENTER when done)" : " (press ENTER to edit)";
|
|
||||||
MOVETOT((int)(80 - 5 - strlen(boot_args_hint)), 15);
|
|
||||||
printf("%s", boot_args_hint);
|
|
||||||
MOVETOT(3, 17);
|
|
||||||
printf("[%c] %s%s " COLOR(FG_WHITE, BG_BLACK),
|
|
||||||
tui_options_flower_chain ? 'x' : ' ',
|
|
||||||
tui_options_nav_selection == 5 ? COLOR(FG_BLACK, BG_BRIGHT_WHITE) : (
|
|
||||||
(
|
|
||||||
tui_mouse_x >= tui_x_offset + 5 && tui_mouse_x <= tui_x_offset + 5 + 34
|
|
||||||
) && (tui_mouse_y == tui_y_offset + 16) ? COLOR(FG_BLACK, BG_WHITE) : ""
|
|
||||||
), easter_egg ? "Neko Chain " : "Flower Chain");
|
|
||||||
|
|
||||||
MOVETOT(7, 16);
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(tui_options_is_editing_boot_args ? FG_YELLOW : FG_WHITE, BG_BRIGHT_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(tui_options_is_editing_boot_args ? FG_YELLOW : FG_WHITE, BG_BLUE);
|
|
||||||
}
|
|
||||||
int boot_args_len = strlen(tui_options_boot_args);
|
|
||||||
|
|
||||||
if ((tui_options_boot_args_cursor - tui_options_boot_args_offset) > (68 - 1)) {
|
|
||||||
tui_options_boot_args_offset += (tui_options_boot_args_cursor - tui_options_boot_args_offset) - (68 - 1);
|
|
||||||
}
|
|
||||||
if ((tui_options_boot_args_cursor - tui_options_boot_args_offset) < 0) {
|
|
||||||
tui_options_boot_args_offset = tui_options_boot_args_cursor;
|
|
||||||
}
|
|
||||||
if ((tui_options_boot_args_offset + 68 - 1) > boot_args_len && boot_args_len >= 68 - 1) {
|
|
||||||
tui_options_boot_args_offset = boot_args_len - 68 + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 68; i++) {
|
|
||||||
putchar(((i + tui_options_boot_args_offset) < boot_args_len) ? tui_options_boot_args[i + tui_options_boot_args_offset] : ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tui_options_is_editing_boot_args) {
|
|
||||||
MOVETOT((int)(7 + tui_options_boot_args_cursor - tui_options_boot_args_offset), 16);
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_YELLOW);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_YELLOW);
|
|
||||||
}
|
|
||||||
putchar(tui_options_boot_args_cursor < boot_args_len ? tui_options_boot_args[tui_options_boot_args_cursor] : ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
MOVETOT(5, 16);
|
|
||||||
printf(tui_options_boot_args_offset > 0 ? "<<" : " ");
|
|
||||||
MOVETOT(75, 16);
|
|
||||||
printf((strlen(tui_options_boot_args) - tui_options_boot_args_offset) > 68 ? ">>" : " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
void tui_screen_options_redraw(void) {
|
|
||||||
SETCOLOR(FG_WHITE, BG_BLACK);
|
|
||||||
PRINTATT(3, 3, "You may set the following options. If you don't know what they mean you'll");
|
|
||||||
PRINTATT(3, 4, "probably have no reason to set them.");
|
|
||||||
if (supports_bright_colors) {
|
|
||||||
SETCOLOR(FG_BRIGHT_BLACK, BG_BLACK);
|
|
||||||
} else {
|
|
||||||
SETCOLOR(FG_BLUE, BG_BLACK);
|
|
||||||
}
|
|
||||||
DRAWLINET(3, 6, 76);
|
|
||||||
tui_screen_options_nav();
|
|
||||||
tui_screen_options_options();
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
tui_screen_t tui_screen_options(void) {
|
|
||||||
redraw_screen();
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
int event = tui_get_event();
|
|
||||||
if (event != TUI_EVENT_INPUT) continue;
|
|
||||||
int input = tui_last_input;
|
|
||||||
|
|
||||||
switch (input) {
|
|
||||||
case TUI_INPUT_DOWN:
|
|
||||||
case TUI_INPUT_TAB:
|
|
||||||
if (tui_options_is_editing_boot_args) break;
|
|
||||||
if (++tui_options_nav_selection > 5) tui_options_nav_selection = 0;
|
|
||||||
tui_screen_options_nav();
|
|
||||||
tui_screen_options_options();
|
|
||||||
fflush(stdout);
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_UP:
|
|
||||||
case TUI_INPUT_TAB_BACK:
|
|
||||||
if (tui_options_is_editing_boot_args) break;
|
|
||||||
if (--tui_options_nav_selection < 0) tui_options_nav_selection = 5;
|
|
||||||
tui_screen_options_nav();
|
|
||||||
tui_screen_options_options();
|
|
||||||
fflush(stdout);
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_SELECT:
|
|
||||||
if (tui_options_is_editing_boot_args && tui_last_key == ' ' && tui_options_boot_args[strlen(tui_options_boot_args)] == '\x00') {
|
|
||||||
int len = strlen(tui_options_boot_args);
|
|
||||||
tui_options_boot_args[len] = ' ';
|
|
||||||
tui_options_boot_args[len + 1] = '\x00';
|
|
||||||
tui_options_boot_args_cursor++;
|
|
||||||
tui_screen_options_options();
|
|
||||||
fflush(stdout);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch(tui_options_nav_selection) {
|
|
||||||
case 0:
|
|
||||||
return MAIN_SCREEN;
|
|
||||||
// case 1:
|
|
||||||
// tui_options_allow_untested = !tui_options_allow_untested;
|
|
||||||
// break;
|
|
||||||
case 1:
|
|
||||||
tui_options_safe_mode = !tui_options_safe_mode;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
tui_options_verbose_boot = !tui_options_verbose_boot;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
tui_options_force_revert = !tui_options_force_revert;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
tui_options_is_editing_boot_args = !tui_options_is_editing_boot_args;
|
|
||||||
tui_options_boot_args_cursor = tui_options_is_editing_boot_args ? strlen(tui_options_boot_args) : 0;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
tui_options_flower_chain = !tui_options_flower_chain;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
tui_screen_options_nav();
|
|
||||||
tui_screen_options_options();
|
|
||||||
fflush(stdout);
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_MOUSE_MOVE:
|
|
||||||
tui_screen_options_nav();
|
|
||||||
tui_screen_options_options();
|
|
||||||
fflush(stdout);
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_MOUSE_DOWN:
|
|
||||||
if (tui_mouse_y == tui_y_offset + 24 - 2 &&
|
|
||||||
tui_mouse_x >= tui_x_offset + 80 - 12 &&
|
|
||||||
tui_mouse_x <= tui_x_offset + 80 - 12 + 10) {
|
|
||||||
tui_options_nav_selection = 0;
|
|
||||||
tui_options_nav_mouse_select = 0;
|
|
||||||
redraw_screen();
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MOUSEDOWN_HANDLER(y, val) \
|
|
||||||
if (tui_mouse_y == tui_y_offset + y && \
|
|
||||||
tui_mouse_x >= tui_x_offset + 5 - 4 && \
|
|
||||||
tui_mouse_x <= tui_x_offset + 5 + 34) { \
|
|
||||||
tui_options_nav_selection = val; \
|
|
||||||
tui_options_nav_mouse_select = val; \
|
|
||||||
tui_screen_options_nav(); \
|
|
||||||
tui_screen_options_options(); \
|
|
||||||
fflush(stdout); \
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tui_options_is_editing_boot_args) {
|
|
||||||
MOUSEDOWN_HANDLER(8, 1);
|
|
||||||
MOUSEDOWN_HANDLER(9, 2);
|
|
||||||
MOUSEDOWN_HANDLER(10, 3);
|
|
||||||
MOUSEDOWN_HANDLER(16, 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
MOUSEDOWN_HANDLER(14, 4);
|
|
||||||
MOUSEDOWN_HANDLER(15, 4);
|
|
||||||
|
|
||||||
#undef MOUSEDOWN_HANDLER
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_MOUSE_UP:
|
|
||||||
if (tui_mouse_y == tui_y_offset + 24 - 2 &&
|
|
||||||
tui_mouse_x >= tui_x_offset + 80 - 12 &&
|
|
||||||
tui_mouse_x <= tui_x_offset + 80 - 12 + 10 &&
|
|
||||||
tui_options_nav_mouse_select == 0) {
|
|
||||||
return MAIN_SCREEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MOUSEUP_HANDLER(y, val, option, e) \
|
|
||||||
if (tui_mouse_y == tui_y_offset + y && \
|
|
||||||
tui_mouse_x >= tui_x_offset + 5 - 4 && \
|
|
||||||
tui_mouse_x <= tui_x_offset + 5 + 34 && \
|
|
||||||
tui_options_nav_mouse_select == val) { \
|
|
||||||
tui_options_##option = !tui_options_##option; \
|
|
||||||
e \
|
|
||||||
tui_screen_options_nav(); \
|
|
||||||
tui_screen_options_options(); \
|
|
||||||
fflush(stdout); \
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tui_options_is_editing_boot_args) {
|
|
||||||
MOUSEUP_HANDLER(8, 1, safe_mode, );
|
|
||||||
MOUSEUP_HANDLER(9, 2, verbose_boot, );
|
|
||||||
MOUSEUP_HANDLER(10, 3, force_revert, );
|
|
||||||
MOUSEUP_HANDLER(16, 5, flower_chain, );
|
|
||||||
}
|
|
||||||
|
|
||||||
#define BOOTARGS_HANDLER \
|
|
||||||
tui_options_boot_args_cursor = tui_options_is_editing_boot_args ? strlen(tui_options_boot_args) : 0;
|
|
||||||
|
|
||||||
MOUSEUP_HANDLER(14, 4, is_editing_boot_args, BOOTARGS_HANDLER);
|
|
||||||
MOUSEUP_HANDLER(15, 4, is_editing_boot_args, BOOTARGS_HANDLER);
|
|
||||||
#undef MOUSEUP_HANDLER
|
|
||||||
tui_options_nav_mouse_select = -1;
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_BACKSPACE:
|
|
||||||
if (tui_options_is_editing_boot_args && tui_options_boot_args_cursor > 0) {
|
|
||||||
memmove(tui_options_boot_args + tui_options_boot_args_cursor - 1, tui_options_boot_args + tui_options_boot_args_cursor, strlen(tui_options_boot_args) - tui_options_boot_args_cursor);
|
|
||||||
tui_options_boot_args[strlen(tui_options_boot_args) - 1] = '\x00';
|
|
||||||
tui_options_boot_args_cursor--;
|
|
||||||
tui_screen_options_options();
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_NONE:
|
|
||||||
if (tui_options_is_editing_boot_args && tui_options_boot_args[strlen(tui_options_boot_args)] == '\x00') {
|
|
||||||
int len = strlen(tui_options_boot_args);
|
|
||||||
memmove(tui_options_boot_args + tui_options_boot_args_cursor + 1, tui_options_boot_args + tui_options_boot_args_cursor, strlen(tui_options_boot_args) - tui_options_boot_args_cursor);
|
|
||||||
tui_options_boot_args[tui_options_boot_args_cursor] = tui_last_key;
|
|
||||||
tui_options_boot_args[len + 1] = '\x00';
|
|
||||||
tui_options_boot_args_cursor++;
|
|
||||||
tui_screen_options_options();
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_LEFT:
|
|
||||||
if (tui_options_is_editing_boot_args) {
|
|
||||||
if (tui_options_boot_args_cursor > 0) {
|
|
||||||
tui_options_boot_args_cursor--;
|
|
||||||
tui_screen_options_options();
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TUI_INPUT_RIGHT:
|
|
||||||
if (tui_options_is_editing_boot_args) {
|
|
||||||
if (tui_options_boot_args_cursor < (int)strlen(tui_options_boot_args)) {
|
|
||||||
tui_options_boot_args_cursor++;
|
|
||||||
tui_screen_options_options();
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* ISO C forbids an empty translation unit */
|
|
||||||
extern char** environ;
|
|
||||||
#endif
|
|
||||||
Reference in new issue
Block a user