mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-21 17:57:01 +02:00
Compare commits
71
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93a0ac8802 | ||
|
|
238c96befe | ||
|
|
5c41f37b39 | ||
|
|
045d11d956 | ||
|
|
0df72933a8 | ||
|
|
f20b5386dd | ||
|
|
3d5600aef4 | ||
|
|
40f50cfc25 | ||
|
|
2d9b3684e5 | ||
|
|
85bda57ef7 | ||
|
|
f0de1ef328 | ||
|
|
7a20bc0ad9 | ||
|
|
0194d5296a | ||
|
|
ef55859eb0 | ||
|
|
b5db51c1ac | ||
|
|
5106372a4b | ||
|
|
6686fdd1a4 | ||
|
|
48eb11ada0 | ||
|
|
f72ad75db2 | ||
|
|
4a8fb113ae | ||
|
|
03a0a5db6b | ||
|
|
8b56b01cee | ||
|
|
52d20c8e5b | ||
|
|
b0ac19e4d1 | ||
|
|
e8d4e857dd | ||
|
|
bf549b8f86 | ||
|
|
b79ac3176f | ||
|
|
e12216dc5e | ||
|
|
f7603371f6 | ||
|
|
f80e2a8849 | ||
|
|
a30e2ef32a | ||
|
|
2825ccaf17 | ||
|
|
e1e0304b98 | ||
|
|
5f4ef51da9 | ||
|
|
98f7d032eb | ||
|
|
5b32d61a1e | ||
|
|
fd80f9e63f | ||
|
|
52ff0b2e62 | ||
|
|
aa0c3a77b3 | ||
|
|
a5fbf1b18b | ||
|
|
7d3bf14ea6 | ||
|
|
a8325474cf | ||
|
|
8a09d2670a | ||
|
|
30d8241e2d | ||
|
|
e33d50860b | ||
|
|
3b4340525d | ||
|
|
e6033f31cc | ||
|
|
c14d93b008 | ||
|
|
ed48d4fcb4 | ||
|
|
2541330a07 | ||
|
|
58aaf508fc | ||
|
|
e6644c0601 | ||
|
|
194f568363 | ||
|
|
963fbb6ed8 | ||
|
|
88185b7a88 | ||
|
|
3c6213774b | ||
|
|
c35d199809 | ||
|
|
67ca5a9d24 | ||
|
|
8edc991786 | ||
|
|
f59ef6dcee | ||
|
|
1ca25ceca8 | ||
|
|
0a0410d506 | ||
|
|
5f8b503ae3 | ||
|
|
9e253f98f4 | ||
|
|
d17af1fbc7 | ||
|
|
f3920b883d | ||
|
|
1abfdf5441 | ||
|
|
1c3613c669 | ||
|
|
627f9b3363 | ||
|
|
388ae6f296 | ||
|
|
24a09bc44d |
No files matched your search
+71
-23
@@ -12,19 +12,19 @@ on:
|
||||
- '.github/workflows/build.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'docs/**'
|
||||
- 'patches/**'
|
||||
- 'include/**'
|
||||
- 'Makefile'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/build.yml'
|
||||
- 'src/**'
|
||||
- 'docs/**'
|
||||
- 'patches/**'
|
||||
- 'include/**'
|
||||
- 'Makefile'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/build.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-docs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
@@ -39,6 +39,10 @@ jobs:
|
||||
mkdir ready
|
||||
cp docs/*.html docs/mandoc.css docs/palera1n.1 ready
|
||||
|
||||
- name: Get branch name
|
||||
id: branch-name
|
||||
uses: tj-actions/branch-names@v7
|
||||
|
||||
- name: Upload artifact
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
uses: wangyucode/[email protected]
|
||||
@@ -46,11 +50,11 @@ jobs:
|
||||
host: ${{ secrets.NICKCHAN_FTP_HOST }}
|
||||
port: ${{ secrets.NICKCHAN_FTP_PORT }}
|
||||
username: palera1n
|
||||
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
|
||||
password: ${{ secrets.NICKCHAN_FTP_PASS }}
|
||||
forceUpload: true
|
||||
dryRun: false
|
||||
localDir: 'ready/'
|
||||
remoteDir: '/palera1n/artifacts/c-rewrite'
|
||||
remoteDir: "/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch || github.ref_name }}/${{ github.run_number }}"
|
||||
|
||||
build-darwin:
|
||||
strategy:
|
||||
@@ -70,7 +74,7 @@ jobs:
|
||||
minos: 7.0
|
||||
runs-on: macos-12
|
||||
env:
|
||||
MBEDTLS_VERSION: 3.3.0
|
||||
MBEDTLS_VERSION: 3.4.0
|
||||
READLINE_VERSION: 8.2
|
||||
SLANG_VERSION: 2.3.3
|
||||
NEWT_VERSION: 0.52.23
|
||||
@@ -325,6 +329,10 @@ jobs:
|
||||
mkdir -p ready
|
||||
tar -zcf ready/dep_root-${{ matrix.os }}-${{ matrix.arch }}.tgz dep_root
|
||||
|
||||
- name: Get branch name
|
||||
id: branch-name
|
||||
uses: tj-actions/branch-names@v7
|
||||
|
||||
- name: Upload artifact
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
uses: wangyucode/[email protected]
|
||||
@@ -332,11 +340,11 @@ jobs:
|
||||
host: ${{ secrets.NICKCHAN_FTP_HOST }}
|
||||
port: ${{ secrets.NICKCHAN_FTP_PORT }}
|
||||
username: palera1n
|
||||
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
|
||||
password: ${{ secrets.NICKCHAN_FTP_PASS }}
|
||||
forceUpload: true
|
||||
dryRun: false
|
||||
localDir: 'ready/'
|
||||
remoteDir: '/palera1n/artifacts/c-rewrite'
|
||||
remoteDir: "/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch || github.ref }}/${{ github.run_number }}"
|
||||
|
||||
- name: Upload ${{ matrix.os }} thin ${{ matrix.arch }} build
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
@@ -353,7 +361,7 @@ jobs:
|
||||
name: palera1n-${{ matrix.os }}-${{ matrix.arch }}.dSYM
|
||||
path: palera1n-${{ matrix.os }}-${{ matrix.arch }}.dSYM
|
||||
retention-days: 1
|
||||
|
||||
|
||||
darwin-dist:
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
runs-on: macos-latest
|
||||
@@ -385,8 +393,8 @@ jobs:
|
||||
cp palera1n-macos ready/palera1n-macos-universal
|
||||
cp ./palera1n-macosx-x86_64/palera1n-macosx-x86_64 ready/palera1n-macos-x86_64
|
||||
cp ./palera1n-macosx-arm64/palera1n-macosx-arm64 ready/palera1n-macos-arm64
|
||||
cp ./palera1n-iphoneos-arm64/palera1n-iphoneos-arm64 ready/palera1n-ios
|
||||
zip -r9 ready/palera1n-ios.dSYM.zip palera1n-iphoneos-arm64.dSYM
|
||||
cp ./palera1n-iphoneos-arm64/palera1n-iphoneos-arm64 ready/palera1n-iphoneos-arm64
|
||||
zip -r9 ready/palera1n-iphoneos-arm64.dSYM.zip palera1n-iphoneos-arm64.dSYM
|
||||
zip -r9 ready/palera1n-macos.dSYM.zip palera1n-macos.dSYM
|
||||
|
||||
- name: Build debs
|
||||
@@ -437,7 +445,7 @@ jobs:
|
||||
gsed 's|@DEB_ARCH@|iphoneos-arm|g' -i stage/DEBIAN/control
|
||||
gsed "s|@DEB_VERSION@|$version|g" -i stage/DEBIAN/control
|
||||
|
||||
ginstall -Dm644 ready/palera1n-ios stage/usr/bin/palera1n
|
||||
ginstall -Dm644 ready/palera1n-iphoneos-arm64 stage/usr/bin/palera1n
|
||||
ginstall -Dm644 docs/palera1n.1 stage/usr/share/man/man1/palera1n.1
|
||||
chmod +x stage/usr/bin/palera1n
|
||||
|
||||
@@ -454,13 +462,26 @@ jobs:
|
||||
gsed 's|@DEB_ARCH@|iphoneos-arm64|g' -i stage/DEBIAN/control
|
||||
gsed "s|@DEB_VERSION@|$version|g" -i stage/DEBIAN/control
|
||||
|
||||
ginstall -Dm644 ready/palera1n-ios stage/var/jb/usr/bin/palera1n
|
||||
ginstall -Dm644 ready/palera1n-iphoneos-arm64 stage/var/jb/usr/bin/palera1n
|
||||
ginstall -Dm644 docs/palera1n.1 stage/var/jb/usr/share/man/man1/palera1n.1
|
||||
chmod +x stage/var/jb/usr/bin/palera1n
|
||||
|
||||
dpkg-deb -Zzstd -b stage palera1n_iphoneos-arm64.deb
|
||||
mv palera1n*.deb ready/
|
||||
rm -rf stage
|
||||
|
||||
- name: Save build tag
|
||||
run: echo "$(git describe --dirty --tags --abbrev=7 | sed 's|-dirty||')" > build-tag.txt
|
||||
|
||||
- name: Upload build tag
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: build-tag
|
||||
path: build-tag.txt
|
||||
|
||||
- name: Get branch name
|
||||
id: branch-name
|
||||
uses: tj-actions/branch-names@v7
|
||||
|
||||
- name: Upload artifact
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
@@ -469,11 +490,11 @@ jobs:
|
||||
host: ${{ secrets.NICKCHAN_FTP_HOST }}
|
||||
port: ${{ secrets.NICKCHAN_FTP_PORT }}
|
||||
username: palera1n
|
||||
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
|
||||
password: ${{ secrets.NICKCHAN_FTP_PASS }}
|
||||
forceUpload: true
|
||||
dryRun: false
|
||||
localDir: 'ready/'
|
||||
remoteDir: '/palera1n/artifacts/c-rewrite'
|
||||
remoteDir: "/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch || github.ref }}/${{ github.run_number }}"
|
||||
|
||||
build-Linux:
|
||||
strategy:
|
||||
@@ -485,7 +506,7 @@ jobs:
|
||||
- aarch64-linux-musl
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
MBEDTLS_VERSION: 3.3.0
|
||||
MBEDTLS_VERSION: 3.4.0
|
||||
LIBUSB_VERSION: 1.0.26
|
||||
READLINE_VERSION: 8.2
|
||||
SLANG_VERSION: 2.3.3
|
||||
@@ -771,6 +792,10 @@ jobs:
|
||||
mv palera1n*.deb ready/
|
||||
rm -rf stage
|
||||
|
||||
- name: Get branch name
|
||||
id: branch-name
|
||||
uses: tj-actions/branch-names@v7
|
||||
|
||||
- name: Upload artifact
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
uses: wangyucode/[email protected]
|
||||
@@ -778,8 +803,31 @@ jobs:
|
||||
host: ${{ secrets.NICKCHAN_FTP_HOST }}
|
||||
port: ${{ secrets.NICKCHAN_FTP_PORT }}
|
||||
username: palera1n
|
||||
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
|
||||
password: ${{ secrets.NICKCHAN_FTP_PASS }}
|
||||
forceUpload: true
|
||||
dryRun: false
|
||||
localDir: 'ready/'
|
||||
remoteDir: '/palera1n/artifacts/c-rewrite'
|
||||
remoteDir: "/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch || github.ref }}/${{ github.run_number }}"
|
||||
|
||||
finish-build:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
needs: [build-docs, build-darwin, darwin-dist, build-Linux]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Get branch name
|
||||
id: branch-name
|
||||
uses: tj-actions/branch-names@v7
|
||||
|
||||
- name: Download build tag
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: build-tag
|
||||
|
||||
- name: Send Discord build message
|
||||
run: |
|
||||
COMMITMESSAGE=`git log --pretty=format:'- \`%h\` %s' -1 --reverse` &&
|
||||
(curl "${{ secrets.DISCORD_WEBHOOK }}" -sS -H "Content-Type:application/json" -X POST -d "{\"content\":null,\"embeds\":[{\"title\":\"[palera1n:${{ steps.branch-name.outputs.ref_branch }}] Nightly Build ${{ github.run_number }}\",\"url\":\"https://github.com/palera1n/palera1n/actions/runs/${GITHUB_RUN_ID}\",\"color\":2829617,\"fields\":[{\"name\":\"Build tag\",\"value\":\"- \`$(cat build-tag.txt | sed 's|\n||')\`\"},{\"name\":\"Destination\",\"value\":\"- https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}\"},{\"name\":\"Documentation\",\"value\":\"- [palera1n.1.html](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n.1.html)\"},{\"name\":\"Main Artifacts\",\"value\":\"- [palera1n-iphoneos-arm64](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n-iphoneos-arm64)\n- [palera1n-linux-arm64](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n-linux-arm64)\n- [palera1n-linux-armel](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n-linux-armel)\n- [palera1n-linux-x86](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/$${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n-linux-x86)\n- [palera1n-linux-x86_64](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n-linux-x86_64)\n- [palera1n-macos-universal](https://cdn.nickchan.lol/palera1n/artifacts/c-rewrite/${{ steps.branch-name.outputs.ref_branch }}/${{ github.run_number }}/palera1n-macos-universal)\"}],\"footer\":{\"text\":\"${{ github.actor }}\", \"icon_url\": \"https://github.com/${{ github.actor }}.png\",\"timestamp\":\"$(date -u +"%FT%TZ")\"}}],\"username\":\"GitHub Actions\",\"avatar_url\":\"https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png\"}")
|
||||
|
||||
+4
-1
@@ -8,6 +8,7 @@ contrib/
|
||||
checkra1n*
|
||||
payload.c
|
||||
src/palera1n
|
||||
src/palera1n.exe
|
||||
!xxd-embedded.h
|
||||
src/binpack.dmg
|
||||
src/ramdisk.dmg
|
||||
@@ -22,4 +23,6 @@ src/*.dmg.c
|
||||
.idea
|
||||
src/stage2/
|
||||
src/libcheckra1nhelper.dylib*
|
||||
src/Pongo.bin
|
||||
payloads/Pongo.bin
|
||||
src/*.dSYM
|
||||
include/payloads
|
||||
@@ -1,17 +1,25 @@
|
||||
NAME = bakepale
|
||||
NAME = Dusk
|
||||
|
||||
SRC = $(shell pwd)
|
||||
DEP = $(SRC)/dep_root
|
||||
STRIP = strip
|
||||
CC ?= cc
|
||||
CFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC)
|
||||
CFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC) -D_XOPEN_SOURCE=500
|
||||
CFLAGS += -Wall -Wextra -Wno-unused-parameter -DPALERAIN_VERSION=\"2.0.0\"
|
||||
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-glue-1.0.a $(DEP)/lib/libplist-2.0.a -pthread
|
||||
ifeq ($(TARGET_OS),)
|
||||
TARGET_OS = $(shell uname -s)
|
||||
endif
|
||||
ifeq ($(findstring MINGW64,$(TARGET_OS)),MINGW64)
|
||||
TARGET_OS = Windows
|
||||
CFLAGS += -DWIN
|
||||
LIBS = -limobiledevice-1.0 -lirecovery-1.0 -lusbmuxd-2.0 -limobiledevice-glue-1.0 -lplist-2.0 -lssl -lcrypto -lusb-1.0 -lreadline -pthread -lm
|
||||
LIBS += -lws2_32 -liphlpapi -lsetupapi -lwinusb
|
||||
else
|
||||
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/libmbedtls.a $(DEP)/lib/libmbedcrypto.a $(DEP)/lib/libmbedx509.a $(DEP)/lib/libreadline.a
|
||||
endif
|
||||
ifeq ($(TARGET_OS),Darwin)
|
||||
CFLAGS += -Wno-nullability-extension
|
||||
ifeq (,$(findstring version-min=, $(CFLAGS)))
|
||||
@@ -21,9 +29,11 @@ LDFLAGS += -Wl,-dead_strip
|
||||
LIBS += -framework CoreFoundation -framework IOKit
|
||||
else
|
||||
CFLAGS += -fdata-sections -ffunction-sections
|
||||
LDFLAGS += -static -no-pie -Wl,--gc-sections
|
||||
LDFLAGS += -no-pie -Wl,--gc-sections
|
||||
ifneq ($(TARGET_OS),Windows)
|
||||
LDFLAGS += -static
|
||||
endif
|
||||
endif
|
||||
LIBS += $(DEP)/lib/libmbedtls.a $(DEP)/lib/libmbedcrypto.a $(DEP)/lib/libmbedx509.a $(DEP)/lib/libreadline.a
|
||||
|
||||
ifeq ($(TUI),1)
|
||||
LIBS += $(DEP)/lib/libnewt.a $(DEP)/lib/libpopt.a $(DEP)/lib/libslang.a
|
||||
@@ -46,7 +56,9 @@ else
|
||||
CFLAGS += -Os -g
|
||||
BUILD_STYLE = RELEASE
|
||||
endif
|
||||
ifneq ($(TARGET_OS),Windows)
|
||||
LIBS += -lc
|
||||
endif
|
||||
|
||||
ifneq ($(BAKERAIN_DEVELOPE_R),)
|
||||
CFLAGS += -DBAKERAIN_DEVELOPE_R="\"$(BAKERAIN_DEVELOPE_R)\""
|
||||
@@ -68,21 +80,31 @@ export SRC DEP CC CFLAGS LDFLAGS LIBS TARGET_OS DEV_BUILD BUILD_DATE BUILD_TAG B
|
||||
|
||||
all: palera1n
|
||||
|
||||
palera1n: download-deps
|
||||
xxd-payloads: download-deps
|
||||
mkdir -p include/payloads
|
||||
for file in payloads/*; do \
|
||||
xxd -i $$file > include/$$file.h; \
|
||||
done
|
||||
|
||||
palera1n: download-deps xxd-payloads
|
||||
$(MAKE) -C src
|
||||
|
||||
clean:
|
||||
$(MAKE) -C src clean
|
||||
$(MAKE) -C docs clean
|
||||
|
||||
download-deps:
|
||||
$(MAKE) -C src checkra1n-macos checkra1n-linux-arm64 checkra1n-linux-armel checkra1n-linux-x86 checkra1n-linux-x86_64 checkra1n-kpf-pongo ramdisk.dmg binpack.dmg Pongo.bin
|
||||
download-deps: Pongo.bin
|
||||
$(MAKE) -C src checkra1n-kpf-pongo ramdisk.dmg binpack.dmg
|
||||
|
||||
docs:
|
||||
$(MAKE) -C docs
|
||||
|
||||
Pongo.bin:
|
||||
rm -f payloads/Pongo.bin
|
||||
curl -Lo payloads/Pongo.bin https://cdn.nickchan.lol/palera1n/artifacts/kpf/Pongo.bin
|
||||
|
||||
distclean: clean
|
||||
rm -rf palera1n-* palera1n*.dSYM src/checkra1n-* src/checkra1n-kpf-pongo src/ramdisk.dmg src/binpack.dmg src/Pongo.bin
|
||||
rm -rf palera1n-* palera1n*.dSYM src/checkra1n-* src/checkra1n-kpf-pongo src/ramdisk.dmg src/binpack.dmg payloads/Pongo.bin include/payloads
|
||||
|
||||
.PHONY: all palera1n clean docs distclean
|
||||
.PHONY: all xxd-payloads palera1n clean docs distclean
|
||||
|
||||
@@ -1,39 +1,34 @@
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://cdn.discordapp.com/attachments/1028398976640229380/1088049124441604136/IMG_0033.png">
|
||||
<img align="left" height="120" src="https://cdn.discordapp.com/attachments/1017854329887129611/1073858292159352862/thing.png" alt="palera1n logo" style="float: left;"/>
|
||||
</picture>
|
||||
<h3 align="right">An iOS 15.0-16.4.1 work-in-progress, <br>semi-tethered checkm8 jailbreak</h3>
|
||||
<center>
|
||||
<a href="#"><img src="https://cdn.discordapp.com/attachments/1103485261196832779/1126450758523572285/pxd.png" alt="Logo"></a>
|
||||
</center>
|
||||
|
||||
<p align="right" >
|
||||
<strong><a href="https://cdn.nickchan.lol/palera1n/c-rewrite/releases/v2.0.0-beta.4/palera1n.1.html">Usage</a></strong>
|
||||
•
|
||||
<strong><a href="https://github.com/palera1n/palera1n/graphs/contributors">Contributors</a></strong>
|
||||
•
|
||||
<strong><a href="https://dsc.gg/palera1n">Discord</a></strong>
|
||||
•
|
||||
<strong><a href="https://twitter.com/palera1n">Twitter</a></strong>
|
||||
<p align="center">
|
||||
<a href="https://cdn.nickchan.lol/palera1n/c-rewrite/releases/v2.0.0-beta.7/palera1n.1.html">Documentation</a> •
|
||||
<a href="https://ios.cfw.guide/installing-palera1n">Installation Guide</a> •
|
||||
<a href="#requirements">Requirements</a> •
|
||||
<a href="https://discord.gg/palera1n">Support Discord</a> •
|
||||
<a href="https://palera.in">Website</a>
|
||||
</p>
|
||||
<div class="clear"></div>
|
||||
|
||||
## If you want a jailbreak, you should read the [guide](https://palera.in).
|
||||
## Information
|
||||
This is the official repo for the palera1n project, a jailbreak for arm64 devices on iOS 15.0+
|
||||
|
||||
### You can obtain v2.0.0 beta [here](https://github.com/palera1n/palera1n/releases).
|
||||
If you need an older v2.0.0 beta, please get it [here](https://github.com/palera1n/palera1n-c/releases/tag/v2.0.0-beta.4).
|
||||
- Loader application used in palera1n can be found [here](https://github.com/palera1n/loader).
|
||||
- palera1ns jbinit can be found [here](https://github.com/palera1n/jbinit).
|
||||
- palera1ns custom PongoOS can be found [here](https://github.com/palera1n/pongoos).
|
||||
|
||||
# Warnings
|
||||
- This palera1n rewrite has noticeably different arguments compared to the shell version of palera1n.
|
||||
- Highly recommended that you take a look at how to use palera1n-c [here](https://cdn.nickchan.lol/palera1n/c-rewrite/releases/v2.0.0-beta.1/palera1n.1.html).
|
||||
Website & credits can be found at https://palera.in (scroll down for credits).
|
||||
|
||||
- This does **NOT** support tethered creation or booting. You must use the older [shell version of palera1n](https://github.com/palera1n/palera1n/tree/legacy) (clone with `-b legacy`).
|
||||
## Warnings
|
||||
We are **NOT** responsible for any data loss, or the result of a device being bricked. The user of this program accepts responsibility should something happen to their device. While nothing should happen, jailbreaking has risks in itself.
|
||||
- If your device is stuck in recovery, please run futurerestore `--exit-recovery`, or use `irecovery -n`.
|
||||
|
||||
- We are **NOT** responsible for any data loss, or the result of a device being bricked. The user of this program accepts responsibility should something happen to their device. While nothing should happen, jailbreaking has risks in itself.
|
||||
- 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.
|
||||
|
||||
- palera1n will never work in VirtualBox, VMware or any virtual machine that doesn't support PCI passthrough.
|
||||
|
||||
# Requirements
|
||||
- A checkm8 vulnerable iOS device on iOS 15.x or 16.x (`A8` - `A11`)
|
||||
- If using rootful, you will need **5-10GB of space** for the fakefs. This means 16GB devices cannot use the full fakefs creation. However, you can change the arguments to `-Bf` to create a fakefs with bind mounts, so it uses a smaller size, at the expense having unwritable parts in rarely-written paths, and then boot it
|
||||
## Requirements
|
||||
- A checkm8 vulnerable iOS device on iOS 15+ (`A8` - `A11`)
|
||||
- On `A11`, **you must disable your passcode while in the jailbroken state** (on iOS 16, you need to **reset your device** before proceeding with palera1n).
|
||||
|
||||
- **USB-A** cables are recommended to use, USB-C may have issues with palera1n and getting into DFU mode.<details><summary>Technical explanation</summary>The BootROM will only enter DFU if it detects USB voltage, which boils down to checking whether a certain pin is asserted from the Tristar chip. The Tristar does this based on the cable's accessory ID, and apparently USB-A and USB-C cables have different accessory IDs, and the one of the USB-C cables makes the Tristar not assert the USB voltage pin.</details>
|
||||
@@ -41,8 +36,12 @@ If you need an older v2.0.0 beta, please get it [here](https://github.com/palera
|
||||
- A Linux or macOS computer
|
||||
- AMD CPUs (not AMD Mobile) have an issue [with (likely) their USB controllers] that causes them to have a very low success rate with checkm8. It is not recommended that you use them with palera1n.
|
||||
- If your device does not successfully jailbreak, try a computer with an Intel or other CPU
|
||||
|
||||
- Apple Silicon Macs with USB-C
|
||||
- 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.
|
||||
|
||||
# Need help?
|
||||
## Need help?
|
||||
|
||||
Make sure you provide full details on your device, such as:
|
||||
- iDevice
|
||||
@@ -50,42 +49,6 @@ Make sure you provide full details on your device, such as:
|
||||
- Passcode enabled?
|
||||
- Logs, if panicked then send latest `panic-full` log from your iDevice.
|
||||
|
||||
Using `-V` and `-v` would help with debugging.
|
||||
Using `-VvL` would help with debugging.
|
||||
|
||||
Join the [Support Discord](https://dsc.gg/palera1n), and create a thread in [#support](https://discord.com/channels/1028398973452570725/1028730487700738130) or ask in [#general](https://discord.com/channels/1028398973452570725/1028398976640229380).
|
||||
|
||||
# Credits
|
||||
<details><summary>palera1n-c Contributors and Credits</summary>
|
||||
<p>
|
||||
|
||||
- [Nick Chan](https://github.com/asdfugil) for the rewrite
|
||||
- [Nebula](https://github.com/itsnebulalol) - palera1n owner and manager
|
||||
- [Mineek](https://github.com/mineek)
|
||||
- [Tom](https://github.com/plooshi) for updated ploosh kpf and universal loader
|
||||
- [Lakhan Lothiyi](https://github.com/llsc12) for palera1n loader app
|
||||
- [checkra1n](https://github.com/checkra1n) for the base of the kpf
|
||||
- [the Procursus Team](https://github.com/ProcursusTeam) for the amazing [bootstrap](https://github.com/ProcursusTeam/Procursus)
|
||||
- [Évelyne](https://github.com/evelyneee) for [ElleKit](https://github.com/evelyneee/ellekit), rootless tweak injection
|
||||
- [Sam Bingner](https://github.com/sbingner) for [Substitute](https://github.com/sbingner/substitute), rootful tweak injection
|
||||
|
||||
</details>
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<p align="center">
|
||||
Thank you so much to our Patreons that make the future development possible! You may sub <a href="https://patreon.com/palera1n">here</a>, if you'd like to.</br>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://github.com/samh06"><img width=64 style="border-radius: 25%;" src="https://user-images.githubusercontent.com/18669106/206333607-881d7ca1-f3bf-4e18-b620-25de0c527315.png"></img></a>
|
||||
<a href="https://havoc.app"><img width=64 style="border-radius: 25%;" src="https://docs.havoc.app/img/standard_icon.png"></img></a>
|
||||
<a href="https://twitter.com/yyyyyy_public"><img width=64 style="border-radius: 25%;" src="https://cdn.discordapp.com/attachments/1054239098006683688/1072587455779328040/image.png?size=400"></img></a>
|
||||
<a href="https://twitter.com/0xSp00kyb0t"><img width=64 style="border-radius: 25%;" src="https://pbs.twimg.com/profile_images/1603601553226620935/1t4yD1bD_400x400.jpg"></img></a>
|
||||
<a href="https://chariz.com"><img width=64 src="https://chariz.com/img/favicon.png"></img></a>
|
||||
<a href="https://twitter.com/stars6220"><img width=64 style="border-radius: 25%;" src="https://pbs.twimg.com/profile_images/1621062976982728706/pWVZQ-NO_400x400.jpg"></img></a>
|
||||
<a href="https://github.com/TheFunnyMan16"><img width=64 style="border-radius: 25%;" src="https://cdn.discordapp.com/attachments/1050068822473842778/1082867264807772281/IMG_3942.jpg">
|
||||
<a href="https://github.com/beast9265"><img width=64 style="border-radius: 25%;" src="https://avatars.githubusercontent.com/u/79794946?v=4"></img></a>
|
||||
<a href="https://twitter.com/0x7FF7"><img width=64 style="border-radius: 25%;" src="https://pbs.twimg.com/profile_images/1630818481191919618/8MWaJ1F7_400x400.jpg"></img></a>
|
||||
<a href="https://sideloadly.io/"><img width=64 style="border-radius: 25%;" src="https://sideloadly.io/icon.png"></img></a>
|
||||
<a href="https://blog.stevesec.com/"><img width=64 style="border-radius: 25%;" src="https://blog.stevesec.com/img/avatar.jpg"></img>
|
||||
<a href="https://github.com/0xilis/"><img width=64 style="border-radius: 25%;" src="https://github.com/0xilis.png"></img></a>
|
||||
</p>
|
||||
+16
-91
@@ -2,33 +2,27 @@
|
||||
.\" Copyright (c) 2023 Nick Chan
|
||||
.\" SPDX-License-Identifier: MIT
|
||||
.\"
|
||||
.Dd "20 March 2023"
|
||||
.Dd "2 July 2023"
|
||||
.Dt palera1n 1
|
||||
.Sh NAME
|
||||
.Nm palera1n
|
||||
.Nd iOS 15.0-16.4.1 arm64 iOS/iPadOS jailbreaking tool
|
||||
.Nd iOS 15.0-16.5.1 arm64 iOS/iPadOS jailbreaking tool
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl cCdDEfhIlLnpRsSvV
|
||||
.Op Fl dDEhILnpRsSvV
|
||||
.Op Fl e Ar Boot arguments
|
||||
.Op Fl k Ar Pongo image
|
||||
.Op Fl o Ar overlay file
|
||||
.Op Fl r Ar ramdisk file
|
||||
.Op Fl K Ar KPF file
|
||||
.Op Fl i Ar checkra1n file
|
||||
.Op Fl -version
|
||||
.Op Fl -force-revert
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
jailbreaks any iOS/iPadOS device with an arm64 (arm64e excluded) on iOS 15.0-16.4.1,
|
||||
jailbreaks any iOS/iPadOS device with an arm64 (arm64e excluded) on iOS 15.0-16.5.1,
|
||||
utilizing the
|
||||
.Em checkm8
|
||||
bootROM exploit.
|
||||
.Pp
|
||||
.Nm
|
||||
is able to jailbreak the device in fakefs-rootful mode, where /
|
||||
is writable, as well as rootless mode, where / cannot be written to.
|
||||
.Pp
|
||||
Due to the nature of the
|
||||
.Em checkm8
|
||||
exploit,
|
||||
@@ -52,7 +46,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.
|
||||
.Pp
|
||||
.Sh SUPPORTED DEVICES
|
||||
As described above, arm64 iOS 15.0-16.4.1 devices are supported, here is an explicit
|
||||
As described above, arm64 iOS 15.0-16.5.1 devices are supported, here is an explicit
|
||||
list of supported devicecs:
|
||||
|
||||
.Bl -tag -compact
|
||||
@@ -95,24 +89,7 @@ Prints the program version and exit.
|
||||
Remove the jailbreak while keeping user data. Some jailbreak files may remain
|
||||
after running this command. Additionally, jailbreak apps will remain on the
|
||||
home screen on for a while even when the files are deleted as the icon cache
|
||||
still has their icons. When used with
|
||||
.Fl f , -fakefs ,
|
||||
this will actually boot the device in rootless mode then delete the jailbreak
|
||||
files. As a result, using the loader app to install the jailbreak environment
|
||||
is not supported when this option is used together with
|
||||
.Fl f , -fakefs
|
||||
\[char46]
|
||||
.It Fl B , -setup-fakefs-partial
|
||||
Like
|
||||
.Fl c , -setup-fakefs
|
||||
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
|
||||
when setting up fakefs for rootful, as they do not have enough storage for full fakefs.
|
||||
This option currently does not work on iOS 16.
|
||||
.It Fl c , -setup-fakefs
|
||||
When used with
|
||||
.Fl f , -fakefs ,
|
||||
creates the new APFS volume required for rootful. Will fail if one already exists.
|
||||
still has their icons.
|
||||
.It Fl d , -demote
|
||||
Set the effective production fuse to 0, so as to enable hardware debugging features.
|
||||
.It Fl D , -dfuhelper
|
||||
@@ -123,38 +100,29 @@ Specify custom XNU kernel command line. The
|
||||
.Em rootdev=md0
|
||||
argument is used by
|
||||
.Nm
|
||||
and cannot be overriden. Additionally, the
|
||||
.Em wdt=-1
|
||||
argument is used during fakefs setup.
|
||||
and cannot be overriden.
|
||||
.It Fl E , -enter-recovery
|
||||
Exit after entering recovery mode.
|
||||
.It Fl f , -fakefs
|
||||
Proceed in rootful mode. This applies to both full fakefs and partial fakefs.
|
||||
.It Fl h , -help
|
||||
Prints help text.
|
||||
.It Fl i , -checkra1n-file Ar checkra1n file
|
||||
Specify the path to a custom checkra1n file.
|
||||
.It Fl k , -override-pongo Ar pongo file
|
||||
Override PongoOS image. The raw image, named
|
||||
.Em Pongo.bin
|
||||
when built, should be used. PongoOS 2.6.0 or later is required.
|
||||
.It Fl K , -override-kpf Ar KPF file
|
||||
Override the kernel patchfinder PongoOS module. The module is required to support setting
|
||||
root filesystem in paleinfo with
|
||||
.Em rootfs
|
||||
command. If in doubt, use
|
||||
.Sy https://github.com/guacaplushy/PongoOS
|
||||
.Sy https://github.com/palera1n/PongoOS
|
||||
iOS15 branch or your own fork of it.
|
||||
.Fl L , -jbinit-log-to-file
|
||||
Makes jbinit log to
|
||||
.Em /cores/jbinit.log
|
||||
This file may be viewed from sandboxed applications while jailbroken.
|
||||
.It Fl l , -rootless
|
||||
Proceed in rootless mode, this is the default when neither
|
||||
.Fl l , -rootless
|
||||
and
|
||||
.Fl f , -fakefs
|
||||
is specified.
|
||||
.Fl L , -jbinit-log-to-file
|
||||
Makes jbinit log to
|
||||
.Em /cores/jbinit.log
|
||||
This file may be viewed from sandboxed applications while jailbroken.
|
||||
>>>>>>> a8e6075 (paleinfo v2)
|
||||
.It Fl n , -exit-recovery
|
||||
Exit recovery mode and exit.
|
||||
.It Fl o , -override-overlay Ar overlay file
|
||||
@@ -209,32 +177,10 @@ To (re-)jailbreak in rootless mode:
|
||||
.Pp
|
||||
.Dl "palera1n"
|
||||
.Pp
|
||||
To setup fakefs for rootful mode:
|
||||
.Pp
|
||||
.Dl "palera1n -fc"
|
||||
.Pp
|
||||
After the device has rebooted, follow the following example.
|
||||
.Pp
|
||||
To re-jailbreak in rootful mode:
|
||||
.Pp
|
||||
.Dl "palera1n -f"
|
||||
.Pp
|
||||
To remove the jailbreak in rootful mode:
|
||||
.Pp
|
||||
.Dl "palera1n --force-revert -f"
|
||||
.Pp
|
||||
To remove the jailbreak in rootless mode:
|
||||
.Pp
|
||||
.Dl "palera1n --force-revert"
|
||||
.Pp
|
||||
To verbose boot in rootful mode:
|
||||
.Pp
|
||||
.Dl "palera1n -Vf"
|
||||
.Pp
|
||||
To create a partial fakefs with bind mounts:
|
||||
.Pp
|
||||
.Dl "palera1n -Bf"
|
||||
.Pp
|
||||
To exit recovery mode:
|
||||
.Pp
|
||||
.Dl "palera1n -n"
|
||||
@@ -248,8 +194,6 @@ To verbose boot, use the
|
||||
.Fl V , -verbose-boot
|
||||
option when jailbreaking.
|
||||
.Pp
|
||||
Fakefs takes up around 5-10 GB of storage, and take up to 10 minutes to setup.
|
||||
.Pp
|
||||
iOS 15.0 requires DER entitlements, and iOS 15.1 requires hash agility in code signatures.
|
||||
As a result, binaries with the old code signature format need to be resigned with a recent
|
||||
version of the Procursus fork of
|
||||
@@ -257,11 +201,6 @@ version of the Procursus fork of
|
||||
before they can be ran on a device jailbroken with
|
||||
.Nm
|
||||
\[char46]
|
||||
.Pp
|
||||
When using rootful mode, the
|
||||
.Fl f , -fakefs
|
||||
flag must be specified at all times. It does not matter whether you want to create fakefs,
|
||||
create partial fakefs, rejailbreak or remove jailbreak.
|
||||
.Sh POST INSTALLATION
|
||||
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:
|
||||
@@ -286,18 +225,11 @@ The location of the temporary filesystem where jailbreak files are stash during
|
||||
When
|
||||
.Fl L
|
||||
is used, the log file of jbinit.
|
||||
.It Pa /Library/LaunchDaemons
|
||||
The directory where jailbreak-specific
|
||||
.Xr launchd.plist 5
|
||||
property list files should be placed on rootful.
|
||||
The log file of jbinit.
|
||||
.It Pa /var/jb/Library/LaunchDaemons
|
||||
The directory where jailbreak-specific
|
||||
.Xr launchd.plist 5
|
||||
property list files should be placed on rootless.
|
||||
.It Pa /etc/rc.d
|
||||
The directory where executable filse that needs to be executed during boot, before
|
||||
daemons are launched, are placed rootful. They are executed after all filesystems
|
||||
has been mounted.
|
||||
.It Pa /var/jb/etc/rc.d
|
||||
The directory where executable files that needs to be executed during boot, before
|
||||
daemons are launched, are placed on rootless. They are executed after all filesystems
|
||||
@@ -318,15 +250,8 @@ injects a dylib into launchd to allow the
|
||||
.Sy launchctl runstats
|
||||
command to be used on the device.
|
||||
.Sh DEPRECATED AND REMOVED FUNCTIONALITY
|
||||
There was an option in
|
||||
.Nm
|
||||
to force create the fakefs even when one already exists (which would overwrite
|
||||
the existing fakefs), by setting the palerain_option_setup_rootful_forced flag
|
||||
in palera1n flags. This option was removed because using
|
||||
.Fl -force-revert
|
||||
and
|
||||
.Fl c
|
||||
at the same time has exactly the same effect.
|
||||
.Pp
|
||||
The fakefs functionality was removed.
|
||||
.Sh SEE ALSO
|
||||
.Xr launchd 8
|
||||
.Xr launchd.plist 5
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
curl -LOOOOOO \
|
||||
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v3.3.0.tar.gz \
|
||||
https://github.com/libusb/libusb/releases/download/v1.0.26/libusb-1.0.26.tar.bz2 \
|
||||
https://mirror-hk.koddos.net/gnu/readline/readline-8.2.tar.gz \
|
||||
https://www.jedsoft.org/releases/slang/slang-2.3.3.tar.bz2 \
|
||||
https://releases.pagure.org/newt/newt-0.52.23.tar.gz \
|
||||
https://github.com/rpm-software-management/popt/archive/master-release.tar.gz
|
||||
|
||||
tar xf v3.3.0.tar.gz
|
||||
tar xf libusb-1.0.26.tar.bz2
|
||||
tar xf readline-8.2.tar.gz
|
||||
tar xf slang-2.3.3.tar.bz2
|
||||
tar xf newt-0.52.23.tar.gz
|
||||
tar xf master-release.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
|
||||
@@ -78,7 +78,6 @@
|
||||
#define BHWHT "\033[1;97m"
|
||||
|
||||
//Reset
|
||||
#define reset "\033[0m"
|
||||
#define CRESET "\033[0m"
|
||||
#define COLOR_RESET "\033[0m"
|
||||
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* pongoOS - https://checkra.in
|
||||
*
|
||||
* Copyright (C) 2019-2022 checkra1n team
|
||||
*
|
||||
* This file is part of pongoOS.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef _KERNINFO_H
|
||||
#define _KERNINFO_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define MAX_BOOTARGS_LEN 256
|
||||
|
||||
#define checkrain_option_none 0x00000000
|
||||
#define checkrain_option_all 0x7fffffff
|
||||
#define checkrain_option_failure 0x80000000
|
||||
|
||||
// Host options
|
||||
#define checkrain_option_verbose_logging (1 << 0)
|
||||
#define checkrain_option_demote (1 << 1)
|
||||
#define checkrain_option_early_exit (1 << 2)
|
||||
#define checkrain_option_quick_mode (1 << 3)
|
||||
#define checkrain_option_pongo_shell (1 << 4)
|
||||
#define checkrain_option_pongo_full (1 << 5)
|
||||
|
||||
// KPF options
|
||||
#define checkrain_option_verbose_boot (1 << 0)
|
||||
|
||||
// Global options
|
||||
#define checkrain_option_safemode (1 << 0)
|
||||
#define checkrain_option_bind_mount (1 << 1)
|
||||
#define checkrain_option_overlay (1 << 2)
|
||||
#define checkrain_option_force_revert (1 << 7) /* keep this at 7 */
|
||||
|
||||
// palera1n option
|
||||
#define palerain_option_rootful (1 << 0) /* rootful jailbreak */
|
||||
#define palerain_option_jbinit_log_to_file (1 << 1) /* log to /cores/jbinit.log */
|
||||
#define palerain_option_setup_rootful (1 << 2) /* create fakefs */
|
||||
#define palerain_option_setup_rootful_forced (1 << 3) /* create fakefs over an existing one */
|
||||
#define palerain_option_setup_partial_root (1 << 4) /* fakefs creating should be partial */
|
||||
#define palerain_option_checkrain_is_clone (1 << 5) /* supplied checkra1n is checkra1n clone */
|
||||
#define palerain_option_rootless_livefs (1 << 6) /* mount root livefs on rootless */
|
||||
|
||||
#ifdef DEV_BUILD
|
||||
#define palerain_option_test1 (1 << 29)
|
||||
#define palerain_option_test2 (1 << 30)
|
||||
#endif
|
||||
|
||||
// palerain host options
|
||||
#define host_option_dfuhelper_only (1 << 0) /* dfuhelper only */
|
||||
#define host_option_pongo_exit (1 << 1) /* boot to clean pongo shell */
|
||||
#ifdef TUI
|
||||
#define host_option_tui (1 << 2) /* use terminal user interface */
|
||||
#else
|
||||
#define host_option_res1 (1 << 2) /* reserved */
|
||||
#endif
|
||||
#define host_option_demote (1 << 3) /* Demote effective production fuse status */
|
||||
// (1 << 4) is removed
|
||||
#define host_option_pongo_full (1 << 5) /* Boot to pongo with default images and options */
|
||||
#define host_option_palerain_version (1 << 6) /* Print version */
|
||||
#define host_option_exit_recovery (1 << 7) /* Exit recovery mode */
|
||||
#define host_option_reboot_device (1 << 8) /* Reboot device in normal mode */
|
||||
#define host_option_enter_recovery (1 << 9) /* Enter recovery mode */
|
||||
#define host_option_device_info (1 << 10) /* Print device info */
|
||||
#define host_option_no_colors (1 << 11) /* no colors */
|
||||
|
||||
#define PALEINFO_MAGIC 'PLSH'
|
||||
#define PALEINFO_CIGAM 'HSLP'
|
||||
|
||||
typedef uint32_t checkrain_option_t, *checkrain_option_p;
|
||||
|
||||
typedef enum {
|
||||
jailbreak_capability_tfp0 = 1 << 0,
|
||||
jailbreak_capability_userspace_reboot = 1 << 1,
|
||||
jailbreak_capability_dyld_ignore_os = 1 << 2, // TODO: This needs a better name
|
||||
} jailbreak_capability_t, *jailbreak_capability_p;
|
||||
|
||||
#define DEFAULT_CAPABILITIES (jailbreak_capability_tfp0|jailbreak_capability_userspace_reboot)
|
||||
struct kerninfo {
|
||||
uint64_t size;
|
||||
uint64_t base;
|
||||
uint64_t slide;
|
||||
checkrain_option_t flags;
|
||||
};
|
||||
struct paleinfo {
|
||||
uint32_t magic; // 'PLSH' / 0x504c5348
|
||||
uint32_t version; // 1
|
||||
checkrain_option_t flags;
|
||||
char rootdev[0x10];
|
||||
};
|
||||
struct kpfinfo {
|
||||
struct kerninfo k;
|
||||
checkrain_option_t kpf_flags;
|
||||
char bootargs[MAX_BOOTARGS_LEN];
|
||||
};
|
||||
|
||||
#define checkrain_set_option(options, option, enabled) do { \
|
||||
if (enabled) \
|
||||
options = (checkrain_option_t)(options | option); \
|
||||
else \
|
||||
options = (checkrain_option_t)(options & ~option); \
|
||||
} while (0);
|
||||
|
||||
static inline bool checkrain_options_enabled(checkrain_option_t flags, checkrain_option_t opt)
|
||||
{
|
||||
return (flags & opt) != 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,860 @@
|
||||
/*
|
||||
* LZ4 - Fast LZ compression algorithm
|
||||
* Header File
|
||||
* Copyright (C) 2011-2020, Yann Collet.
|
||||
|
||||
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
You can contact the author at :
|
||||
- LZ4 homepage : http://www.lz4.org
|
||||
- LZ4 source repository : https://github.com/lz4/lz4
|
||||
*/
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef LZ4_H_2983827168210
|
||||
#define LZ4_H_2983827168210
|
||||
|
||||
/* --- Dependency --- */
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
|
||||
/**
|
||||
Introduction
|
||||
|
||||
LZ4 is lossless compression algorithm, providing compression speed >500 MB/s per core,
|
||||
scalable with multi-cores CPU. It features an extremely fast decoder, with speed in
|
||||
multiple GB/s per core, typically reaching RAM speed limits on multi-core systems.
|
||||
|
||||
The LZ4 compression library provides in-memory compression and decompression functions.
|
||||
It gives full buffer control to user.
|
||||
Compression can be done in:
|
||||
- a single step (described as Simple Functions)
|
||||
- a single step, reusing a context (described in Advanced Functions)
|
||||
- unbounded multiple steps (described as Streaming compression)
|
||||
|
||||
lz4.h generates and decodes LZ4-compressed blocks (doc/lz4_Block_format.md).
|
||||
Decompressing such a compressed block requires additional metadata.
|
||||
Exact metadata depends on exact decompression function.
|
||||
For the typical case of LZ4_decompress_safe(),
|
||||
metadata includes block's compressed size, and maximum bound of decompressed size.
|
||||
Each application is free to encode and pass such metadata in whichever way it wants.
|
||||
|
||||
lz4.h only handle blocks, it can not generate Frames.
|
||||
|
||||
Blocks are different from Frames (doc/lz4_Frame_format.md).
|
||||
Frames bundle both blocks and metadata in a specified manner.
|
||||
Embedding metadata is required for compressed data to be self-contained and portable.
|
||||
Frame format is delivered through a companion API, declared in lz4frame.h.
|
||||
The `lz4` CLI can only manage frames.
|
||||
*/
|
||||
|
||||
/*^***************************************************************
|
||||
* Export parameters
|
||||
*****************************************************************/
|
||||
/*
|
||||
* LZ4_DLL_EXPORT :
|
||||
* Enable exporting of functions when building a Windows DLL
|
||||
* LZ4LIB_VISIBILITY :
|
||||
* Control library symbols visibility.
|
||||
*/
|
||||
#ifndef LZ4LIB_VISIBILITY
|
||||
# if defined(__GNUC__) && (__GNUC__ >= 4)
|
||||
# define LZ4LIB_VISIBILITY __attribute__ ((visibility ("default")))
|
||||
# else
|
||||
# define LZ4LIB_VISIBILITY
|
||||
# endif
|
||||
#endif
|
||||
#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1)
|
||||
# define LZ4LIB_API __declspec(dllexport) LZ4LIB_VISIBILITY
|
||||
#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)
|
||||
# define LZ4LIB_API __declspec(dllimport) LZ4LIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
|
||||
#else
|
||||
# define LZ4LIB_API LZ4LIB_VISIBILITY
|
||||
#endif
|
||||
|
||||
/*! LZ4_FREESTANDING :
|
||||
* When this macro is set to 1, it enables "freestanding mode" that is
|
||||
* suitable for typical freestanding environment which doesn't support
|
||||
* standard C library.
|
||||
*
|
||||
* - LZ4_FREESTANDING is a compile-time switch.
|
||||
* - It requires the following macros to be defined:
|
||||
* LZ4_memcpy, LZ4_memmove, LZ4_memset.
|
||||
* - It only enables LZ4/HC functions which don't use heap.
|
||||
* All LZ4F_* functions are not supported.
|
||||
* - See tests/freestanding.c to check its basic setup.
|
||||
*/
|
||||
#if defined(LZ4_FREESTANDING) && (LZ4_FREESTANDING == 1)
|
||||
# define LZ4_HEAPMODE 0
|
||||
# define LZ4HC_HEAPMODE 0
|
||||
# define LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION 1
|
||||
# if !defined(LZ4_memcpy)
|
||||
# error "LZ4_FREESTANDING requires macro 'LZ4_memcpy'."
|
||||
# endif
|
||||
# if !defined(LZ4_memset)
|
||||
# error "LZ4_FREESTANDING requires macro 'LZ4_memset'."
|
||||
# endif
|
||||
# if !defined(LZ4_memmove)
|
||||
# error "LZ4_FREESTANDING requires macro 'LZ4_memmove'."
|
||||
# endif
|
||||
#elif ! defined(LZ4_FREESTANDING)
|
||||
# define LZ4_FREESTANDING 0
|
||||
#endif
|
||||
|
||||
|
||||
/*------ Version ------*/
|
||||
#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
|
||||
#define LZ4_VERSION_MINOR 9 /* for new (non-breaking) interface capabilities */
|
||||
#define LZ4_VERSION_RELEASE 4 /* for tweaks, bug-fixes, or development */
|
||||
|
||||
#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
|
||||
|
||||
#define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE
|
||||
#define LZ4_QUOTE(str) #str
|
||||
#define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str)
|
||||
#define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION) /* requires v1.7.3+ */
|
||||
|
||||
LZ4LIB_API int LZ4_versionNumber (void); /**< library version number; useful to check dll version; requires v1.3.0+ */
|
||||
LZ4LIB_API const char* LZ4_versionString (void); /**< library version string; useful to check dll version; requires v1.7.5+ */
|
||||
|
||||
|
||||
/*-************************************
|
||||
* Tuning parameter
|
||||
**************************************/
|
||||
#define LZ4_MEMORY_USAGE_MIN 10
|
||||
#define LZ4_MEMORY_USAGE_DEFAULT 14
|
||||
#define LZ4_MEMORY_USAGE_MAX 20
|
||||
|
||||
/*!
|
||||
* LZ4_MEMORY_USAGE :
|
||||
* Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; )
|
||||
* Increasing memory usage improves compression ratio, at the cost of speed.
|
||||
* Reduced memory usage may improve speed at the cost of ratio, thanks to better cache locality.
|
||||
* Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache
|
||||
*/
|
||||
#ifndef LZ4_MEMORY_USAGE
|
||||
# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
|
||||
#endif
|
||||
|
||||
#if (LZ4_MEMORY_USAGE < LZ4_MEMORY_USAGE_MIN)
|
||||
# error "LZ4_MEMORY_USAGE is too small !"
|
||||
#endif
|
||||
|
||||
#if (LZ4_MEMORY_USAGE > LZ4_MEMORY_USAGE_MAX)
|
||||
# error "LZ4_MEMORY_USAGE is too large !"
|
||||
#endif
|
||||
|
||||
/*-************************************
|
||||
* Simple Functions
|
||||
**************************************/
|
||||
/*! LZ4_compress_default() :
|
||||
* Compresses 'srcSize' bytes from buffer 'src'
|
||||
* into already allocated 'dst' buffer of size 'dstCapacity'.
|
||||
* Compression is guaranteed to succeed if 'dstCapacity' >= LZ4_compressBound(srcSize).
|
||||
* It also runs faster, so it's a recommended setting.
|
||||
* If the function cannot compress 'src' into a more limited 'dst' budget,
|
||||
* compression stops *immediately*, and the function result is zero.
|
||||
* In which case, 'dst' content is undefined (invalid).
|
||||
* srcSize : max supported value is LZ4_MAX_INPUT_SIZE.
|
||||
* dstCapacity : size of buffer 'dst' (which must be already allocated)
|
||||
* @return : the number of bytes written into buffer 'dst' (necessarily <= dstCapacity)
|
||||
* or 0 if compression fails
|
||||
* Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer).
|
||||
*/
|
||||
LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity);
|
||||
|
||||
/*! LZ4_decompress_safe() :
|
||||
* @compressedSize : is the exact complete size of the compressed block.
|
||||
* @dstCapacity : is the size of destination buffer (which must be already allocated),
|
||||
* is an upper bound of decompressed size.
|
||||
* @return : the number of bytes decompressed into destination buffer (necessarily <= dstCapacity)
|
||||
* If destination buffer is not large enough, decoding will stop and output an error code (negative value).
|
||||
* If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||
* Note 1 : This function is protected against malicious data packets :
|
||||
* it will never writes outside 'dst' buffer, nor read outside 'source' buffer,
|
||||
* even if the compressed block is maliciously modified to order the decoder to do these actions.
|
||||
* In such case, the decoder stops immediately, and considers the compressed block malformed.
|
||||
* Note 2 : compressedSize and dstCapacity must be provided to the function, the compressed block does not contain them.
|
||||
* The implementation is free to send / store / derive this information in whichever way is most beneficial.
|
||||
* If there is a need for a different format which bundles together both compressed data and its metadata, consider looking at lz4frame.h instead.
|
||||
*/
|
||||
LZ4LIB_API int LZ4_decompress_safe (const char* src, char* dst, int compressedSize, int dstCapacity);
|
||||
|
||||
|
||||
/*-************************************
|
||||
* Advanced Functions
|
||||
**************************************/
|
||||
#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
|
||||
#define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
|
||||
|
||||
/*! LZ4_compressBound() :
|
||||
Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible)
|
||||
This function is primarily useful for memory allocation purposes (destination buffer size).
|
||||
Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example).
|
||||
Note that LZ4_compress_default() compresses faster when dstCapacity is >= LZ4_compressBound(srcSize)
|
||||
inputSize : max supported value is LZ4_MAX_INPUT_SIZE
|
||||
return : maximum output size in a "worst case" scenario
|
||||
or 0, if input size is incorrect (too large or negative)
|
||||
*/
|
||||
LZ4LIB_API int LZ4_compressBound(int inputSize);
|
||||
|
||||
/*! LZ4_compress_fast() :
|
||||
Same as LZ4_compress_default(), but allows selection of "acceleration" factor.
|
||||
The larger the acceleration value, the faster the algorithm, but also the lesser the compression.
|
||||
It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed.
|
||||
An acceleration value of "1" is the same as regular LZ4_compress_default()
|
||||
Values <= 0 will be replaced by LZ4_ACCELERATION_DEFAULT (currently == 1, see lz4.c).
|
||||
Values > LZ4_ACCELERATION_MAX will be replaced by LZ4_ACCELERATION_MAX (currently == 65537, see lz4.c).
|
||||
*/
|
||||
LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
||||
|
||||
/*! LZ4_compress_fast_extState() :
|
||||
* Same as LZ4_compress_fast(), using an externally allocated memory space for its state.
|
||||
* Use LZ4_sizeofState() to know how much memory must be allocated,
|
||||
* and allocate it on 8-bytes boundaries (using `malloc()` typically).
|
||||
* Then, provide this buffer as `void* state` to compression function.
|
||||
*/
|
||||
LZ4LIB_API int LZ4_sizeofState(void);
|
||||
LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
||||
|
||||
|
||||
/*! LZ4_compress_destSize() :
|
||||
* Reverse the logic : compresses as much data as possible from 'src' buffer
|
||||
* into already allocated buffer 'dst', of size >= 'targetDestSize'.
|
||||
* This function either compresses the entire 'src' content into 'dst' if it's large enough,
|
||||
* or fill 'dst' buffer completely with as much data as possible from 'src'.
|
||||
* note: acceleration parameter is fixed to "default".
|
||||
*
|
||||
* *srcSizePtr : will be modified to indicate how many bytes where read from 'src' to fill 'dst'.
|
||||
* New value is necessarily <= input value.
|
||||
* @return : Nb bytes written into 'dst' (necessarily <= targetDestSize)
|
||||
* or 0 if compression fails.
|
||||
*
|
||||
* Note : from v1.8.2 to v1.9.1, this function had a bug (fixed un v1.9.2+):
|
||||
* the produced compressed content could, in specific circumstances,
|
||||
* require to be decompressed into a destination buffer larger
|
||||
* by at least 1 byte than the content to decompress.
|
||||
* If an application uses `LZ4_compress_destSize()`,
|
||||
* it's highly recommended to update liblz4 to v1.9.2 or better.
|
||||
* If this can't be done or ensured,
|
||||
* the receiving decompression function should provide
|
||||
* a dstCapacity which is > decompressedSize, by at least 1 byte.
|
||||
* See https://github.com/lz4/lz4/issues/859 for details
|
||||
*/
|
||||
LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize);
|
||||
|
||||
/*! LZ4_decompress_safe_partial() :
|
||||
* Decompress an LZ4 compressed block, of size 'srcSize' at position 'src',
|
||||
* into destination buffer 'dst' of size 'dstCapacity'.
|
||||
* Up to 'targetOutputSize' bytes will be decoded.
|
||||
* The function stops decoding on reaching this objective.
|
||||
* This can be useful to boost performance
|
||||
* whenever only the beginning of a block is required.
|
||||
*
|
||||
* @return : the number of bytes decoded in `dst` (necessarily <= targetOutputSize)
|
||||
* If source stream is detected malformed, function returns a negative result.
|
||||
*
|
||||
* Note 1 : @return can be < targetOutputSize, if compressed block contains less data.
|
||||
*
|
||||
* Note 2 : targetOutputSize must be <= dstCapacity
|
||||
*
|
||||
* Note 3 : this function effectively stops decoding on reaching targetOutputSize,
|
||||
* so dstCapacity is kind of redundant.
|
||||
* This is because in older versions of this function,
|
||||
* decoding operation would still write complete sequences.
|
||||
* Therefore, there was no guarantee that it would stop writing at exactly targetOutputSize,
|
||||
* it could write more bytes, though only up to dstCapacity.
|
||||
* Some "margin" used to be required for this operation to work properly.
|
||||
* Thankfully, this is no longer necessary.
|
||||
* The function nonetheless keeps the same signature, in an effort to preserve API compatibility.
|
||||
*
|
||||
* Note 4 : If srcSize is the exact size of the block,
|
||||
* then targetOutputSize can be any value,
|
||||
* including larger than the block's decompressed size.
|
||||
* The function will, at most, generate block's decompressed size.
|
||||
*
|
||||
* Note 5 : If srcSize is _larger_ than block's compressed size,
|
||||
* then targetOutputSize **MUST** be <= block's decompressed size.
|
||||
* Otherwise, *silent corruption will occur*.
|
||||
*/
|
||||
LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcSize, int targetOutputSize, int dstCapacity);
|
||||
|
||||
|
||||
/*-*********************************************
|
||||
* Streaming Compression Functions
|
||||
***********************************************/
|
||||
typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
|
||||
|
||||
/**
|
||||
Note about RC_INVOKED
|
||||
|
||||
- RC_INVOKED is predefined symbol of rc.exe (the resource compiler which is part of MSVC/Visual Studio).
|
||||
https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros
|
||||
|
||||
- Since rc.exe is a legacy compiler, it truncates long symbol (> 30 chars)
|
||||
and reports warning "RC4011: identifier truncated".
|
||||
|
||||
- To eliminate the warning, we surround long preprocessor symbol with
|
||||
"#if !defined(RC_INVOKED) ... #endif" block that means
|
||||
"skip this block when rc.exe is trying to read it".
|
||||
*/
|
||||
#if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */
|
||||
#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
|
||||
LZ4LIB_API LZ4_stream_t* LZ4_createStream(void);
|
||||
LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr);
|
||||
#endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
|
||||
#endif
|
||||
|
||||
/*! LZ4_resetStream_fast() : v1.9.0+
|
||||
* Use this to prepare an LZ4_stream_t for a new chain of dependent blocks
|
||||
* (e.g., LZ4_compress_fast_continue()).
|
||||
*
|
||||
* An LZ4_stream_t must be initialized once before usage.
|
||||
* This is automatically done when created by LZ4_createStream().
|
||||
* However, should the LZ4_stream_t be simply declared on stack (for example),
|
||||
* it's necessary to initialize it first, using LZ4_initStream().
|
||||
*
|
||||
* After init, start any new stream with LZ4_resetStream_fast().
|
||||
* A same LZ4_stream_t can be re-used multiple times consecutively
|
||||
* and compress multiple streams,
|
||||
* provided that it starts each new stream with LZ4_resetStream_fast().
|
||||
*
|
||||
* LZ4_resetStream_fast() is much faster than LZ4_initStream(),
|
||||
* but is not compatible with memory regions containing garbage data.
|
||||
*
|
||||
* Note: it's only useful to call LZ4_resetStream_fast()
|
||||
* in the context of streaming compression.
|
||||
* The *extState* functions perform their own resets.
|
||||
* Invoking LZ4_resetStream_fast() before is redundant, and even counterproductive.
|
||||
*/
|
||||
LZ4LIB_API void LZ4_resetStream_fast (LZ4_stream_t* streamPtr);
|
||||
|
||||
/*! LZ4_loadDict() :
|
||||
* Use this function to reference a static dictionary into LZ4_stream_t.
|
||||
* The dictionary must remain available during compression.
|
||||
* LZ4_loadDict() triggers a reset, so any previous data will be forgotten.
|
||||
* The same dictionary will have to be loaded on decompression side for successful decoding.
|
||||
* Dictionary are useful for better compression of small data (KB range).
|
||||
* While LZ4 accept any input as dictionary,
|
||||
* results are generally better when using Zstandard's Dictionary Builder.
|
||||
* Loading a size of 0 is allowed, and is the same as reset.
|
||||
* @return : loaded dictionary size, in bytes (necessarily <= 64 KB)
|
||||
*/
|
||||
LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
|
||||
|
||||
/*! LZ4_compress_fast_continue() :
|
||||
* Compress 'src' content using data from previously compressed blocks, for better compression ratio.
|
||||
* 'dst' buffer must be already allocated.
|
||||
* If dstCapacity >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster.
|
||||
*
|
||||
* @return : size of compressed block
|
||||
* or 0 if there is an error (typically, cannot fit into 'dst').
|
||||
*
|
||||
* Note 1 : Each invocation to LZ4_compress_fast_continue() generates a new block.
|
||||
* Each block has precise boundaries.
|
||||
* Each block must be decompressed separately, calling LZ4_decompress_*() with relevant metadata.
|
||||
* It's not possible to append blocks together and expect a single invocation of LZ4_decompress_*() to decompress them together.
|
||||
*
|
||||
* Note 2 : The previous 64KB of source data is __assumed__ to remain present, unmodified, at same address in memory !
|
||||
*
|
||||
* Note 3 : When input is structured as a double-buffer, each buffer can have any size, including < 64 KB.
|
||||
* Make sure that buffers are separated, by at least one byte.
|
||||
* This construction ensures that each block only depends on previous block.
|
||||
*
|
||||
* Note 4 : If input buffer is a ring-buffer, it can have any size, including < 64 KB.
|
||||
*
|
||||
* Note 5 : After an error, the stream status is undefined (invalid), it can only be reset or freed.
|
||||
*/
|
||||
LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
||||
|
||||
/*! LZ4_saveDict() :
|
||||
* If last 64KB data cannot be guaranteed to remain available at its current memory location,
|
||||
* save it into a safer place (char* safeBuffer).
|
||||
* This is schematically equivalent to a memcpy() followed by LZ4_loadDict(),
|
||||
* but is much faster, because LZ4_saveDict() doesn't need to rebuild tables.
|
||||
* @return : saved dictionary size in bytes (necessarily <= maxDictSize), or 0 if error.
|
||||
*/
|
||||
LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int maxDictSize);
|
||||
|
||||
|
||||
/*-**********************************************
|
||||
* Streaming Decompression Functions
|
||||
* Bufferless synchronous API
|
||||
************************************************/
|
||||
typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* tracking context */
|
||||
|
||||
/*! LZ4_createStreamDecode() and LZ4_freeStreamDecode() :
|
||||
* creation / destruction of streaming decompression tracking context.
|
||||
* A tracking context can be re-used multiple times.
|
||||
*/
|
||||
#if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */
|
||||
#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
|
||||
LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void);
|
||||
LZ4LIB_API int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
|
||||
#endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
|
||||
#endif
|
||||
|
||||
/*! LZ4_setStreamDecode() :
|
||||
* An LZ4_streamDecode_t context can be allocated once and re-used multiple times.
|
||||
* Use this function to start decompression of a new stream of blocks.
|
||||
* A dictionary can optionally be set. Use NULL or size 0 for a reset order.
|
||||
* Dictionary is presumed stable : it must remain accessible and unmodified during next decompression.
|
||||
* @return : 1 if OK, 0 if error
|
||||
*/
|
||||
LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
|
||||
|
||||
/*! LZ4_decoderRingBufferSize() : v1.8.2+
|
||||
* Note : in a ring buffer scenario (optional),
|
||||
* blocks are presumed decompressed next to each other
|
||||
* up to the moment there is not enough remaining space for next block (remainingSize < maxBlockSize),
|
||||
* at which stage it resumes from beginning of ring buffer.
|
||||
* When setting such a ring buffer for streaming decompression,
|
||||
* provides the minimum size of this ring buffer
|
||||
* to be compatible with any source respecting maxBlockSize condition.
|
||||
* @return : minimum ring buffer size,
|
||||
* or 0 if there is an error (invalid maxBlockSize).
|
||||
*/
|
||||
LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize);
|
||||
#define LZ4_DECODER_RING_BUFFER_SIZE(maxBlockSize) (65536 + 14 + (maxBlockSize)) /* for static allocation; maxBlockSize presumed valid */
|
||||
|
||||
/*! LZ4_decompress_safe_continue() :
|
||||
* This decoding function allows decompression of consecutive blocks in "streaming" mode.
|
||||
* The difference with the usual independent blocks is that
|
||||
* new blocks are allowed to find references into former blocks.
|
||||
* A block is an unsplittable entity, and must be presented entirely to the decompression function.
|
||||
* LZ4_decompress_safe_continue() only accepts one block at a time.
|
||||
* It's modeled after `LZ4_decompress_safe()` and behaves similarly.
|
||||
*
|
||||
* @LZ4_streamDecode : decompression state, tracking the position in memory of past data
|
||||
* @compressedSize : exact complete size of one compressed block.
|
||||
* @dstCapacity : size of destination buffer (which must be already allocated),
|
||||
* must be an upper bound of decompressed size.
|
||||
* @return : number of bytes decompressed into destination buffer (necessarily <= dstCapacity)
|
||||
* If destination buffer is not large enough, decoding will stop and output an error code (negative value).
|
||||
* If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||
*
|
||||
* The last 64KB of previously decoded data *must* remain available and unmodified
|
||||
* at the memory position where they were previously decoded.
|
||||
* If less than 64KB of data has been decoded, all the data must be present.
|
||||
*
|
||||
* Special : if decompression side sets a ring buffer, it must respect one of the following conditions :
|
||||
* - Decompression buffer size is _at least_ LZ4_decoderRingBufferSize(maxBlockSize).
|
||||
* maxBlockSize is the maximum size of any single block. It can have any value > 16 bytes.
|
||||
* In which case, encoding and decoding buffers do not need to be synchronized.
|
||||
* Actually, data can be produced by any source compliant with LZ4 format specification, and respecting maxBlockSize.
|
||||
* - Synchronized mode :
|
||||
* Decompression buffer size is _exactly_ the same as compression buffer size,
|
||||
* and follows exactly same update rule (block boundaries at same positions),
|
||||
* and decoding function is provided with exact decompressed size of each block (exception for last block of the stream),
|
||||
* _then_ decoding & encoding ring buffer can have any size, including small ones ( < 64 KB).
|
||||
* - Decompression buffer is larger than encoding buffer, by a minimum of maxBlockSize more bytes.
|
||||
* In which case, encoding and decoding buffers do not need to be synchronized,
|
||||
* and encoding ring buffer can have any size, including small ones ( < 64 KB).
|
||||
*
|
||||
* Whenever these conditions are not possible,
|
||||
* save the last 64KB of decoded data into a safe buffer where it can't be modified during decompression,
|
||||
* then indicate where this data is saved using LZ4_setStreamDecode(), before decompressing next block.
|
||||
*/
|
||||
LZ4LIB_API int
|
||||
LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode,
|
||||
const char* src, char* dst,
|
||||
int srcSize, int dstCapacity);
|
||||
|
||||
|
||||
/*! LZ4_decompress_safe_usingDict() :
|
||||
* Works the same as
|
||||
* a combination of LZ4_setStreamDecode() followed by LZ4_decompress_safe_continue()
|
||||
* However, it's stateless: it doesn't need any LZ4_streamDecode_t state.
|
||||
* Dictionary is presumed stable : it must remain accessible and unmodified during decompression.
|
||||
* Performance tip : Decompression speed can be substantially increased
|
||||
* when dst == dictStart + dictSize.
|
||||
*/
|
||||
LZ4LIB_API int
|
||||
LZ4_decompress_safe_usingDict(const char* src, char* dst,
|
||||
int srcSize, int dstCapacity,
|
||||
const char* dictStart, int dictSize);
|
||||
|
||||
/*! LZ4_decompress_safe_partial_usingDict() :
|
||||
* Behaves the same as LZ4_decompress_safe_partial()
|
||||
* with the added ability to specify a memory segment for past data.
|
||||
* Performance tip : Decompression speed can be substantially increased
|
||||
* when dst == dictStart + dictSize.
|
||||
*/
|
||||
LZ4LIB_API int
|
||||
LZ4_decompress_safe_partial_usingDict(const char* src, char* dst,
|
||||
int compressedSize,
|
||||
int targetOutputSize, int maxOutputSize,
|
||||
const char* dictStart, int dictSize);
|
||||
|
||||
#endif /* LZ4_H_2983827168210 */
|
||||
|
||||
|
||||
/*^*************************************
|
||||
* !!!!!! STATIC LINKING ONLY !!!!!!
|
||||
***************************************/
|
||||
|
||||
/*-****************************************************************************
|
||||
* Experimental section
|
||||
*
|
||||
* Symbols declared in this section must be considered unstable. Their
|
||||
* signatures or semantics may change, or they may be removed altogether in the
|
||||
* future. They are therefore only safe to depend on when the caller is
|
||||
* statically linked against the library.
|
||||
*
|
||||
* To protect against unsafe usage, not only are the declarations guarded,
|
||||
* the definitions are hidden by default
|
||||
* when building LZ4 as a shared/dynamic library.
|
||||
*
|
||||
* In order to access these declarations,
|
||||
* define LZ4_STATIC_LINKING_ONLY in your application
|
||||
* before including LZ4's headers.
|
||||
*
|
||||
* In order to make their implementations accessible dynamically, you must
|
||||
* define LZ4_PUBLISH_STATIC_FUNCTIONS when building the LZ4 library.
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef LZ4_STATIC_LINKING_ONLY
|
||||
|
||||
#ifndef LZ4_STATIC_3504398509
|
||||
#define LZ4_STATIC_3504398509
|
||||
|
||||
#ifdef LZ4_PUBLISH_STATIC_FUNCTIONS
|
||||
#define LZ4LIB_STATIC_API LZ4LIB_API
|
||||
#else
|
||||
#define LZ4LIB_STATIC_API
|
||||
#endif
|
||||
|
||||
|
||||
/*! LZ4_compress_fast_extState_fastReset() :
|
||||
* A variant of LZ4_compress_fast_extState().
|
||||
*
|
||||
* Using this variant avoids an expensive initialization step.
|
||||
* It is only safe to call if the state buffer is known to be correctly initialized already
|
||||
* (see above comment on LZ4_resetStream_fast() for a definition of "correctly initialized").
|
||||
* From a high level, the difference is that
|
||||
* this function initializes the provided state with a call to something like LZ4_resetStream_fast()
|
||||
* while LZ4_compress_fast_extState() starts with a call to LZ4_resetStream().
|
||||
*/
|
||||
LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
||||
|
||||
/*! LZ4_attach_dictionary() :
|
||||
* This is an experimental API that allows
|
||||
* efficient use of a static dictionary many times.
|
||||
*
|
||||
* Rather than re-loading the dictionary buffer into a working context before
|
||||
* each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a
|
||||
* working LZ4_stream_t, this function introduces a no-copy setup mechanism,
|
||||
* in which the working stream references the dictionary stream in-place.
|
||||
*
|
||||
* Several assumptions are made about the state of the dictionary stream.
|
||||
* Currently, only streams which have been prepared by LZ4_loadDict() should
|
||||
* be expected to work.
|
||||
*
|
||||
* Alternatively, the provided dictionaryStream may be NULL,
|
||||
* in which case any existing dictionary stream is unset.
|
||||
*
|
||||
* If a dictionary is provided, it replaces any pre-existing stream history.
|
||||
* The dictionary contents are the only history that can be referenced and
|
||||
* logically immediately precede the data compressed in the first subsequent
|
||||
* compression call.
|
||||
*
|
||||
* The dictionary will only remain attached to the working stream through the
|
||||
* first compression call, at the end of which it is cleared. The dictionary
|
||||
* stream (and source buffer) must remain in-place / accessible / unchanged
|
||||
* through the completion of the first compression call on the stream.
|
||||
*/
|
||||
LZ4LIB_STATIC_API void
|
||||
LZ4_attach_dictionary(LZ4_stream_t* workingStream,
|
||||
const LZ4_stream_t* dictionaryStream);
|
||||
|
||||
|
||||
/*! In-place compression and decompression
|
||||
*
|
||||
* It's possible to have input and output sharing the same buffer,
|
||||
* for highly constrained memory environments.
|
||||
* In both cases, it requires input to lay at the end of the buffer,
|
||||
* and decompression to start at beginning of the buffer.
|
||||
* Buffer size must feature some margin, hence be larger than final size.
|
||||
*
|
||||
* |<------------------------buffer--------------------------------->|
|
||||
* |<-----------compressed data--------->|
|
||||
* |<-----------decompressed size------------------>|
|
||||
* |<----margin---->|
|
||||
*
|
||||
* This technique is more useful for decompression,
|
||||
* since decompressed size is typically larger,
|
||||
* and margin is short.
|
||||
*
|
||||
* In-place decompression will work inside any buffer
|
||||
* which size is >= LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize).
|
||||
* This presumes that decompressedSize > compressedSize.
|
||||
* Otherwise, it means compression actually expanded data,
|
||||
* and it would be more efficient to store such data with a flag indicating it's not compressed.
|
||||
* This can happen when data is not compressible (already compressed, or encrypted).
|
||||
*
|
||||
* For in-place compression, margin is larger, as it must be able to cope with both
|
||||
* history preservation, requiring input data to remain unmodified up to LZ4_DISTANCE_MAX,
|
||||
* and data expansion, which can happen when input is not compressible.
|
||||
* As a consequence, buffer size requirements are much higher,
|
||||
* and memory savings offered by in-place compression are more limited.
|
||||
*
|
||||
* There are ways to limit this cost for compression :
|
||||
* - Reduce history size, by modifying LZ4_DISTANCE_MAX.
|
||||
* Note that it is a compile-time constant, so all compressions will apply this limit.
|
||||
* Lower values will reduce compression ratio, except when input_size < LZ4_DISTANCE_MAX,
|
||||
* so it's a reasonable trick when inputs are known to be small.
|
||||
* - Require the compressor to deliver a "maximum compressed size".
|
||||
* This is the `dstCapacity` parameter in `LZ4_compress*()`.
|
||||
* When this size is < LZ4_COMPRESSBOUND(inputSize), then compression can fail,
|
||||
* in which case, the return code will be 0 (zero).
|
||||
* The caller must be ready for these cases to happen,
|
||||
* and typically design a backup scheme to send data uncompressed.
|
||||
* The combination of both techniques can significantly reduce
|
||||
* the amount of margin required for in-place compression.
|
||||
*
|
||||
* In-place compression can work in any buffer
|
||||
* which size is >= (maxCompressedSize)
|
||||
* with maxCompressedSize == LZ4_COMPRESSBOUND(srcSize) for guaranteed compression success.
|
||||
* LZ4_COMPRESS_INPLACE_BUFFER_SIZE() depends on both maxCompressedSize and LZ4_DISTANCE_MAX,
|
||||
* so it's possible to reduce memory requirements by playing with them.
|
||||
*/
|
||||
|
||||
#define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize) (((compressedSize) >> 8) + 32)
|
||||
#define LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize) ((decompressedSize) + LZ4_DECOMPRESS_INPLACE_MARGIN(decompressedSize)) /**< note: presumes that compressedSize < decompressedSize. note2: margin is overestimated a bit, since it could use compressedSize instead */
|
||||
|
||||
#ifndef LZ4_DISTANCE_MAX /* history window size; can be user-defined at compile time */
|
||||
# define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */
|
||||
#endif
|
||||
|
||||
#define LZ4_COMPRESS_INPLACE_MARGIN (LZ4_DISTANCE_MAX + 32) /* LZ4_DISTANCE_MAX can be safely replaced by srcSize when it's smaller */
|
||||
#define LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCompressedSize) ((maxCompressedSize) + LZ4_COMPRESS_INPLACE_MARGIN) /**< maxCompressedSize is generally LZ4_COMPRESSBOUND(inputSize), but can be set to any lower value, with the risk that compression can fail (return code 0(zero)) */
|
||||
|
||||
#endif /* LZ4_STATIC_3504398509 */
|
||||
#endif /* LZ4_STATIC_LINKING_ONLY */
|
||||
|
||||
|
||||
|
||||
#ifndef LZ4_H_98237428734687
|
||||
#define LZ4_H_98237428734687
|
||||
|
||||
/*-************************************************************
|
||||
* Private Definitions
|
||||
**************************************************************
|
||||
* Do not use these definitions directly.
|
||||
* They are only exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`.
|
||||
* Accessing members will expose user code to API and/or ABI break in future versions of the library.
|
||||
**************************************************************/
|
||||
#define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
|
||||
#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
|
||||
#define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */
|
||||
|
||||
#if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
||||
# include <stdint.h>
|
||||
typedef int8_t LZ4_i8;
|
||||
typedef uint8_t LZ4_byte;
|
||||
typedef uint16_t LZ4_u16;
|
||||
typedef uint32_t LZ4_u32;
|
||||
#else
|
||||
typedef signed char LZ4_i8;
|
||||
typedef unsigned char LZ4_byte;
|
||||
typedef unsigned short LZ4_u16;
|
||||
typedef unsigned int LZ4_u32;
|
||||
#endif
|
||||
|
||||
/*! LZ4_stream_t :
|
||||
* Never ever use below internal definitions directly !
|
||||
* These definitions are not API/ABI safe, and may change in future versions.
|
||||
* If you need static allocation, declare or allocate an LZ4_stream_t object.
|
||||
**/
|
||||
|
||||
typedef struct LZ4_stream_t_internal LZ4_stream_t_internal;
|
||||
struct LZ4_stream_t_internal {
|
||||
LZ4_u32 hashTable[LZ4_HASH_SIZE_U32];
|
||||
const LZ4_byte* dictionary;
|
||||
const LZ4_stream_t_internal* dictCtx;
|
||||
LZ4_u32 currentOffset;
|
||||
LZ4_u32 tableType;
|
||||
LZ4_u32 dictSize;
|
||||
/* Implicit padding to ensure structure is aligned */
|
||||
};
|
||||
|
||||
#define LZ4_STREAM_MINSIZE ((1UL << LZ4_MEMORY_USAGE) + 32) /* static size, for inter-version compatibility */
|
||||
union LZ4_stream_u {
|
||||
char minStateSize[LZ4_STREAM_MINSIZE];
|
||||
LZ4_stream_t_internal internal_donotuse;
|
||||
}; /* previously typedef'd to LZ4_stream_t */
|
||||
|
||||
|
||||
/*! LZ4_initStream() : v1.9.0+
|
||||
* An LZ4_stream_t structure must be initialized at least once.
|
||||
* This is automatically done when invoking LZ4_createStream(),
|
||||
* but it's not when the structure is simply declared on stack (for example).
|
||||
*
|
||||
* Use LZ4_initStream() to properly initialize a newly declared LZ4_stream_t.
|
||||
* It can also initialize any arbitrary buffer of sufficient size,
|
||||
* and will @return a pointer of proper type upon initialization.
|
||||
*
|
||||
* Note : initialization fails if size and alignment conditions are not respected.
|
||||
* In which case, the function will @return NULL.
|
||||
* Note2: An LZ4_stream_t structure guarantees correct alignment and size.
|
||||
* Note3: Before v1.9.0, use LZ4_resetStream() instead
|
||||
**/
|
||||
LZ4LIB_API LZ4_stream_t* LZ4_initStream (void* buffer, size_t size);
|
||||
|
||||
|
||||
/*! LZ4_streamDecode_t :
|
||||
* Never ever use below internal definitions directly !
|
||||
* These definitions are not API/ABI safe, and may change in future versions.
|
||||
* If you need static allocation, declare or allocate an LZ4_streamDecode_t object.
|
||||
**/
|
||||
typedef struct {
|
||||
const LZ4_byte* externalDict;
|
||||
const LZ4_byte* prefixEnd;
|
||||
size_t extDictSize;
|
||||
size_t prefixSize;
|
||||
} LZ4_streamDecode_t_internal;
|
||||
|
||||
#define LZ4_STREAMDECODE_MINSIZE 32
|
||||
union LZ4_streamDecode_u {
|
||||
char minStateSize[LZ4_STREAMDECODE_MINSIZE];
|
||||
LZ4_streamDecode_t_internal internal_donotuse;
|
||||
} ; /* previously typedef'd to LZ4_streamDecode_t */
|
||||
|
||||
|
||||
|
||||
/*-************************************
|
||||
* Obsolete Functions
|
||||
**************************************/
|
||||
|
||||
/*! Deprecation warnings
|
||||
*
|
||||
* Deprecated functions make the compiler generate a warning when invoked.
|
||||
* This is meant to invite users to update their source code.
|
||||
* Should deprecation warnings be a problem, it is generally possible to disable them,
|
||||
* typically with -Wno-deprecated-declarations for gcc
|
||||
* or _CRT_SECURE_NO_WARNINGS in Visual.
|
||||
*
|
||||
* Another method is to define LZ4_DISABLE_DEPRECATE_WARNINGS
|
||||
* before including the header file.
|
||||
*/
|
||||
#ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
|
||||
# define LZ4_DEPRECATED(message) /* disable deprecation warnings */
|
||||
#else
|
||||
# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
|
||||
# define LZ4_DEPRECATED(message) [[deprecated(message)]]
|
||||
# elif defined(_MSC_VER)
|
||||
# define LZ4_DEPRECATED(message) __declspec(deprecated(message))
|
||||
# elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 45))
|
||||
# define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||
# elif defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 31)
|
||||
# define LZ4_DEPRECATED(message) __attribute__((deprecated))
|
||||
# else
|
||||
# pragma message("WARNING: LZ4_DEPRECATED needs custom implementation for this compiler")
|
||||
# define LZ4_DEPRECATED(message) /* disabled */
|
||||
# endif
|
||||
#endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
|
||||
|
||||
/*! Obsolete compression functions (since v1.7.3) */
|
||||
LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress (const char* src, char* dest, int srcSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress_limitedOutput (const char* src, char* dest, int srcSize, int maxOutputSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
|
||||
/*! Obsolete decompression functions (since v1.8.0) */
|
||||
LZ4_DEPRECATED("use LZ4_decompress_fast() instead") LZ4LIB_API int LZ4_uncompress (const char* source, char* dest, int outputSize);
|
||||
LZ4_DEPRECATED("use LZ4_decompress_safe() instead") LZ4LIB_API int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize);
|
||||
|
||||
/* Obsolete streaming functions (since v1.7.0)
|
||||
* degraded functionality; do not use!
|
||||
*
|
||||
* In order to perform streaming compression, these functions depended on data
|
||||
* that is no longer tracked in the state. They have been preserved as well as
|
||||
* possible: using them will still produce a correct output. However, they don't
|
||||
* actually retain any history between compression calls. The compression ratio
|
||||
* achieved will therefore be no better than compressing each chunk
|
||||
* independently.
|
||||
*/
|
||||
LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API void* LZ4_create (char* inputBuffer);
|
||||
LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API int LZ4_sizeofStreamState(void);
|
||||
LZ4_DEPRECATED("Use LZ4_resetStream() instead") LZ4LIB_API int LZ4_resetStreamState(void* state, char* inputBuffer);
|
||||
LZ4_DEPRECATED("Use LZ4_saveDict() instead") LZ4LIB_API char* LZ4_slideInputBuffer (void* state);
|
||||
|
||||
/*! Obsolete streaming decoding functions (since v1.7.0) */
|
||||
LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") LZ4LIB_API int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize);
|
||||
LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") LZ4LIB_API int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize);
|
||||
|
||||
/*! Obsolete LZ4_decompress_fast variants (since v1.9.0) :
|
||||
* These functions used to be faster than LZ4_decompress_safe(),
|
||||
* but this is no longer the case. They are now slower.
|
||||
* This is because LZ4_decompress_fast() doesn't know the input size,
|
||||
* and therefore must progress more cautiously into the input buffer to not read beyond the end of block.
|
||||
* On top of that `LZ4_decompress_fast()` is not protected vs malformed or malicious inputs, making it a security liability.
|
||||
* As a consequence, LZ4_decompress_fast() is strongly discouraged, and deprecated.
|
||||
*
|
||||
* The last remaining LZ4_decompress_fast() specificity is that
|
||||
* it can decompress a block without knowing its compressed size.
|
||||
* Such functionality can be achieved in a more secure manner
|
||||
* by employing LZ4_decompress_safe_partial().
|
||||
*
|
||||
* Parameters:
|
||||
* originalSize : is the uncompressed size to regenerate.
|
||||
* `dst` must be already allocated, its size must be >= 'originalSize' bytes.
|
||||
* @return : number of bytes read from source buffer (== compressed size).
|
||||
* The function expects to finish at block's end exactly.
|
||||
* If the source stream is detected malformed, the function stops decoding and returns a negative result.
|
||||
* note : LZ4_decompress_fast*() requires originalSize. Thanks to this information, it never writes past the output buffer.
|
||||
* However, since it doesn't know its 'src' size, it may read an unknown amount of input, past input buffer bounds.
|
||||
* Also, since match offsets are not validated, match reads from 'src' may underflow too.
|
||||
* These issues never happen if input (compressed) data is correct.
|
||||
* But they may happen if input data is invalid (error or intentional tampering).
|
||||
* As a consequence, use these functions in trusted environments with trusted data **only**.
|
||||
*/
|
||||
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe() instead")
|
||||
LZ4LIB_API int LZ4_decompress_fast (const char* src, char* dst, int originalSize);
|
||||
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_continue() instead")
|
||||
LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int originalSize);
|
||||
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_usingDict() instead")
|
||||
LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int originalSize, const char* dictStart, int dictSize);
|
||||
|
||||
/*! LZ4_resetStream() :
|
||||
* An LZ4_stream_t structure must be initialized at least once.
|
||||
* This is done with LZ4_initStream(), or LZ4_resetStream().
|
||||
* Consider switching to LZ4_initStream(),
|
||||
* invoking LZ4_resetStream() will trigger deprecation warnings in the future.
|
||||
*/
|
||||
LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr);
|
||||
|
||||
|
||||
#endif /* LZ4_H_98237428734687 */
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,413 @@
|
||||
/*
|
||||
LZ4 HC - High Compression Mode of LZ4
|
||||
Header File
|
||||
Copyright (C) 2011-2020, Yann Collet.
|
||||
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
You can contact the author at :
|
||||
- LZ4 source repository : https://github.com/lz4/lz4
|
||||
- LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||
*/
|
||||
#ifndef LZ4_HC_H_19834876238432
|
||||
#define LZ4_HC_H_19834876238432
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* --- Dependency --- */
|
||||
/* note : lz4hc requires lz4.h/lz4.c for compilation */
|
||||
#include "lz4.h" /* stddef, LZ4LIB_API, LZ4_DEPRECATED */
|
||||
|
||||
|
||||
/* --- Useful constants --- */
|
||||
#define LZ4HC_CLEVEL_MIN 3
|
||||
#define LZ4HC_CLEVEL_DEFAULT 9
|
||||
#define LZ4HC_CLEVEL_OPT_MIN 10
|
||||
#define LZ4HC_CLEVEL_MAX 12
|
||||
|
||||
|
||||
/*-************************************
|
||||
* Block Compression
|
||||
**************************************/
|
||||
/*! LZ4_compress_HC() :
|
||||
* Compress data from `src` into `dst`, using the powerful but slower "HC" algorithm.
|
||||
* `dst` must be already allocated.
|
||||
* Compression is guaranteed to succeed if `dstCapacity >= LZ4_compressBound(srcSize)` (see "lz4.h")
|
||||
* Max supported `srcSize` value is LZ4_MAX_INPUT_SIZE (see "lz4.h")
|
||||
* `compressionLevel` : any value between 1 and LZ4HC_CLEVEL_MAX will work.
|
||||
* Values > LZ4HC_CLEVEL_MAX behave the same as LZ4HC_CLEVEL_MAX.
|
||||
* @return : the number of bytes written into 'dst'
|
||||
* or 0 if compression fails.
|
||||
*/
|
||||
LZ4LIB_API int LZ4_compress_HC (const char* src, char* dst, int srcSize, int dstCapacity, int compressionLevel);
|
||||
|
||||
|
||||
/* Note :
|
||||
* Decompression functions are provided within "lz4.h" (BSD license)
|
||||
*/
|
||||
|
||||
|
||||
/*! LZ4_compress_HC_extStateHC() :
|
||||
* Same as LZ4_compress_HC(), but using an externally allocated memory segment for `state`.
|
||||
* `state` size is provided by LZ4_sizeofStateHC().
|
||||
* Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() should do properly).
|
||||
*/
|
||||
LZ4LIB_API int LZ4_sizeofStateHC(void);
|
||||
LZ4LIB_API int LZ4_compress_HC_extStateHC(void* stateHC, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
|
||||
|
||||
|
||||
/*! LZ4_compress_HC_destSize() : v1.9.0+
|
||||
* Will compress as much data as possible from `src`
|
||||
* to fit into `targetDstSize` budget.
|
||||
* Result is provided in 2 parts :
|
||||
* @return : the number of bytes written into 'dst' (necessarily <= targetDstSize)
|
||||
* or 0 if compression fails.
|
||||
* `srcSizePtr` : on success, *srcSizePtr is updated to indicate how much bytes were read from `src`
|
||||
*/
|
||||
LZ4LIB_API int LZ4_compress_HC_destSize(void* stateHC,
|
||||
const char* src, char* dst,
|
||||
int* srcSizePtr, int targetDstSize,
|
||||
int compressionLevel);
|
||||
|
||||
|
||||
/*-************************************
|
||||
* Streaming Compression
|
||||
* Bufferless synchronous API
|
||||
**************************************/
|
||||
typedef union LZ4_streamHC_u LZ4_streamHC_t; /* incomplete type (defined later) */
|
||||
|
||||
/*! LZ4_createStreamHC() and LZ4_freeStreamHC() :
|
||||
* These functions create and release memory for LZ4 HC streaming state.
|
||||
* Newly created states are automatically initialized.
|
||||
* A same state can be used multiple times consecutively,
|
||||
* starting with LZ4_resetStreamHC_fast() to start a new stream of blocks.
|
||||
*/
|
||||
LZ4LIB_API LZ4_streamHC_t* LZ4_createStreamHC(void);
|
||||
LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr);
|
||||
|
||||
/*
|
||||
These functions compress data in successive blocks of any size,
|
||||
using previous blocks as dictionary, to improve compression ratio.
|
||||
One key assumption is that previous blocks (up to 64 KB) remain read-accessible while compressing next blocks.
|
||||
There is an exception for ring buffers, which can be smaller than 64 KB.
|
||||
Ring-buffer scenario is automatically detected and handled within LZ4_compress_HC_continue().
|
||||
|
||||
Before starting compression, state must be allocated and properly initialized.
|
||||
LZ4_createStreamHC() does both, though compression level is set to LZ4HC_CLEVEL_DEFAULT.
|
||||
|
||||
Selecting the compression level can be done with LZ4_resetStreamHC_fast() (starts a new stream)
|
||||
or LZ4_setCompressionLevel() (anytime, between blocks in the same stream) (experimental).
|
||||
LZ4_resetStreamHC_fast() only works on states which have been properly initialized at least once,
|
||||
which is automatically the case when state is created using LZ4_createStreamHC().
|
||||
|
||||
After reset, a first "fictional block" can be designated as initial dictionary,
|
||||
using LZ4_loadDictHC() (Optional).
|
||||
|
||||
Invoke LZ4_compress_HC_continue() to compress each successive block.
|
||||
The number of blocks is unlimited.
|
||||
Previous input blocks, including initial dictionary when present,
|
||||
must remain accessible and unmodified during compression.
|
||||
|
||||
It's allowed to update compression level anytime between blocks,
|
||||
using LZ4_setCompressionLevel() (experimental).
|
||||
|
||||
'dst' buffer should be sized to handle worst case scenarios
|
||||
(see LZ4_compressBound(), it ensures compression success).
|
||||
In case of failure, the API does not guarantee recovery,
|
||||
so the state _must_ be reset.
|
||||
To ensure compression success
|
||||
whenever `dst` buffer size cannot be made >= LZ4_compressBound(),
|
||||
consider using LZ4_compress_HC_continue_destSize().
|
||||
|
||||
Whenever previous input blocks can't be preserved unmodified in-place during compression of next blocks,
|
||||
it's possible to copy the last blocks into a more stable memory space, using LZ4_saveDictHC().
|
||||
Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer' (<= 64 KB)
|
||||
|
||||
After completing a streaming compression,
|
||||
it's possible to start a new stream of blocks, using the same LZ4_streamHC_t state,
|
||||
just by resetting it, using LZ4_resetStreamHC_fast().
|
||||
*/
|
||||
|
||||
LZ4LIB_API void LZ4_resetStreamHC_fast(LZ4_streamHC_t* streamHCPtr, int compressionLevel); /* v1.9.0+ */
|
||||
LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize);
|
||||
|
||||
LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr,
|
||||
const char* src, char* dst,
|
||||
int srcSize, int maxDstSize);
|
||||
|
||||
/*! LZ4_compress_HC_continue_destSize() : v1.9.0+
|
||||
* Similar to LZ4_compress_HC_continue(),
|
||||
* but will read as much data as possible from `src`
|
||||
* to fit into `targetDstSize` budget.
|
||||
* Result is provided into 2 parts :
|
||||
* @return : the number of bytes written into 'dst' (necessarily <= targetDstSize)
|
||||
* or 0 if compression fails.
|
||||
* `srcSizePtr` : on success, *srcSizePtr will be updated to indicate how much bytes were read from `src`.
|
||||
* Note that this function may not consume the entire input.
|
||||
*/
|
||||
LZ4LIB_API int LZ4_compress_HC_continue_destSize(LZ4_streamHC_t* LZ4_streamHCPtr,
|
||||
const char* src, char* dst,
|
||||
int* srcSizePtr, int targetDstSize);
|
||||
|
||||
LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize);
|
||||
|
||||
|
||||
|
||||
/*^**********************************************
|
||||
* !!!!!! STATIC LINKING ONLY !!!!!!
|
||||
***********************************************/
|
||||
|
||||
/*-******************************************************************
|
||||
* PRIVATE DEFINITIONS :
|
||||
* Do not use these definitions directly.
|
||||
* They are merely exposed to allow static allocation of `LZ4_streamHC_t`.
|
||||
* Declare an `LZ4_streamHC_t` directly, rather than any type below.
|
||||
* Even then, only do so in the context of static linking, as definitions may change between versions.
|
||||
********************************************************************/
|
||||
|
||||
#define LZ4HC_DICTIONARY_LOGSIZE 16
|
||||
#define LZ4HC_MAXD (1<<LZ4HC_DICTIONARY_LOGSIZE)
|
||||
#define LZ4HC_MAXD_MASK (LZ4HC_MAXD - 1)
|
||||
|
||||
#define LZ4HC_HASH_LOG 15
|
||||
#define LZ4HC_HASHTABLESIZE (1 << LZ4HC_HASH_LOG)
|
||||
#define LZ4HC_HASH_MASK (LZ4HC_HASHTABLESIZE - 1)
|
||||
|
||||
|
||||
/* Never ever use these definitions directly !
|
||||
* Declare or allocate an LZ4_streamHC_t instead.
|
||||
**/
|
||||
typedef struct LZ4HC_CCtx_internal LZ4HC_CCtx_internal;
|
||||
struct LZ4HC_CCtx_internal
|
||||
{
|
||||
LZ4_u32 hashTable[LZ4HC_HASHTABLESIZE];
|
||||
LZ4_u16 chainTable[LZ4HC_MAXD];
|
||||
const LZ4_byte* end; /* next block here to continue on current prefix */
|
||||
const LZ4_byte* prefixStart; /* Indexes relative to this position */
|
||||
const LZ4_byte* dictStart; /* alternate reference for extDict */
|
||||
LZ4_u32 dictLimit; /* below that point, need extDict */
|
||||
LZ4_u32 lowLimit; /* below that point, no more dict */
|
||||
LZ4_u32 nextToUpdate; /* index from which to continue dictionary update */
|
||||
short compressionLevel;
|
||||
LZ4_i8 favorDecSpeed; /* favor decompression speed if this flag set,
|
||||
otherwise, favor compression ratio */
|
||||
LZ4_i8 dirty; /* stream has to be fully reset if this flag is set */
|
||||
const LZ4HC_CCtx_internal* dictCtx;
|
||||
};
|
||||
|
||||
#define LZ4_STREAMHC_MINSIZE 262200 /* static size, for inter-version compatibility */
|
||||
union LZ4_streamHC_u {
|
||||
char minStateSize[LZ4_STREAMHC_MINSIZE];
|
||||
LZ4HC_CCtx_internal internal_donotuse;
|
||||
}; /* previously typedef'd to LZ4_streamHC_t */
|
||||
|
||||
/* LZ4_streamHC_t :
|
||||
* This structure allows static allocation of LZ4 HC streaming state.
|
||||
* This can be used to allocate statically on stack, or as part of a larger structure.
|
||||
*
|
||||
* Such state **must** be initialized using LZ4_initStreamHC() before first use.
|
||||
*
|
||||
* Note that invoking LZ4_initStreamHC() is not required when
|
||||
* the state was created using LZ4_createStreamHC() (which is recommended).
|
||||
* Using the normal builder, a newly created state is automatically initialized.
|
||||
*
|
||||
* Static allocation shall only be used in combination with static linking.
|
||||
*/
|
||||
|
||||
/* LZ4_initStreamHC() : v1.9.0+
|
||||
* Required before first use of a statically allocated LZ4_streamHC_t.
|
||||
* Before v1.9.0 : use LZ4_resetStreamHC() instead
|
||||
*/
|
||||
LZ4LIB_API LZ4_streamHC_t* LZ4_initStreamHC(void* buffer, size_t size);
|
||||
|
||||
|
||||
/*-************************************
|
||||
* Deprecated Functions
|
||||
**************************************/
|
||||
/* see lz4.h LZ4_DISABLE_DEPRECATE_WARNINGS to turn off deprecation warnings */
|
||||
|
||||
/* deprecated compression functions */
|
||||
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC (const char* source, char* dest, int inputSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel);
|
||||
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
||||
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
|
||||
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
||||
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
|
||||
/* Obsolete streaming functions; degraded functionality; do not use!
|
||||
*
|
||||
* In order to perform streaming compression, these functions depended on data
|
||||
* that is no longer tracked in the state. They have been preserved as well as
|
||||
* possible: using them will still produce a correct output. However, use of
|
||||
* LZ4_slideInputBufferHC() will truncate the history of the stream, rather
|
||||
* than preserve a window-sized chunk of history.
|
||||
*/
|
||||
#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
|
||||
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API void* LZ4_createHC (const char* inputBuffer);
|
||||
LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") LZ4LIB_API int LZ4_freeHC (void* LZ4HC_Data);
|
||||
#endif
|
||||
LZ4_DEPRECATED("use LZ4_saveDictHC() instead") LZ4LIB_API char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
|
||||
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
|
||||
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
||||
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API int LZ4_sizeofStreamStateHC(void);
|
||||
LZ4_DEPRECATED("use LZ4_initStreamHC() instead") LZ4LIB_API int LZ4_resetStreamStateHC(void* state, char* inputBuffer);
|
||||
|
||||
|
||||
/* LZ4_resetStreamHC() is now replaced by LZ4_initStreamHC().
|
||||
* The intention is to emphasize the difference with LZ4_resetStreamHC_fast(),
|
||||
* which is now the recommended function to start a new stream of blocks,
|
||||
* but cannot be used to initialize a memory segment containing arbitrary garbage data.
|
||||
*
|
||||
* It is recommended to switch to LZ4_initStreamHC().
|
||||
* LZ4_resetStreamHC() will generate deprecation warnings in a future version.
|
||||
*/
|
||||
LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel);
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LZ4_HC_H_19834876238432 */
|
||||
|
||||
|
||||
/*-**************************************************
|
||||
* !!!!! STATIC LINKING ONLY !!!!!
|
||||
* Following definitions are considered experimental.
|
||||
* They should not be linked from DLL,
|
||||
* as there is no guarantee of API stability yet.
|
||||
* Prototypes will be promoted to "stable" status
|
||||
* after successful usage in real-life scenarios.
|
||||
***************************************************/
|
||||
#ifdef LZ4_HC_STATIC_LINKING_ONLY /* protection macro */
|
||||
#ifndef LZ4_HC_SLO_098092834
|
||||
#define LZ4_HC_SLO_098092834
|
||||
|
||||
#define LZ4_STATIC_LINKING_ONLY /* LZ4LIB_STATIC_API */
|
||||
#include "lz4.h"
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*! LZ4_setCompressionLevel() : v1.8.0+ (experimental)
|
||||
* It's possible to change compression level
|
||||
* between successive invocations of LZ4_compress_HC_continue*()
|
||||
* for dynamic adaptation.
|
||||
*/
|
||||
LZ4LIB_STATIC_API void LZ4_setCompressionLevel(
|
||||
LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel);
|
||||
|
||||
/*! LZ4_favorDecompressionSpeed() : v1.8.2+ (experimental)
|
||||
* Opt. Parser will favor decompression speed over compression ratio.
|
||||
* Only applicable to levels >= LZ4HC_CLEVEL_OPT_MIN.
|
||||
*/
|
||||
LZ4LIB_STATIC_API void LZ4_favorDecompressionSpeed(
|
||||
LZ4_streamHC_t* LZ4_streamHCPtr, int favor);
|
||||
|
||||
/*! LZ4_resetStreamHC_fast() : v1.9.0+
|
||||
* When an LZ4_streamHC_t is known to be in a internally coherent state,
|
||||
* it can often be prepared for a new compression with almost no work, only
|
||||
* sometimes falling back to the full, expensive reset that is always required
|
||||
* when the stream is in an indeterminate state (i.e., the reset performed by
|
||||
* LZ4_resetStreamHC()).
|
||||
*
|
||||
* LZ4_streamHCs are guaranteed to be in a valid state when:
|
||||
* - returned from LZ4_createStreamHC()
|
||||
* - reset by LZ4_resetStreamHC()
|
||||
* - memset(stream, 0, sizeof(LZ4_streamHC_t))
|
||||
* - the stream was in a valid state and was reset by LZ4_resetStreamHC_fast()
|
||||
* - the stream was in a valid state and was then used in any compression call
|
||||
* that returned success
|
||||
* - the stream was in an indeterminate state and was used in a compression
|
||||
* call that fully reset the state (LZ4_compress_HC_extStateHC()) and that
|
||||
* returned success
|
||||
*
|
||||
* Note:
|
||||
* A stream that was last used in a compression call that returned an error
|
||||
* may be passed to this function. However, it will be fully reset, which will
|
||||
* clear any existing history and settings from the context.
|
||||
*/
|
||||
LZ4LIB_STATIC_API void LZ4_resetStreamHC_fast(
|
||||
LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel);
|
||||
|
||||
/*! LZ4_compress_HC_extStateHC_fastReset() :
|
||||
* A variant of LZ4_compress_HC_extStateHC().
|
||||
*
|
||||
* Using this variant avoids an expensive initialization step. It is only safe
|
||||
* to call if the state buffer is known to be correctly initialized already
|
||||
* (see above comment on LZ4_resetStreamHC_fast() for a definition of
|
||||
* "correctly initialized"). From a high level, the difference is that this
|
||||
* function initializes the provided state with a call to
|
||||
* LZ4_resetStreamHC_fast() while LZ4_compress_HC_extStateHC() starts with a
|
||||
* call to LZ4_resetStreamHC().
|
||||
*/
|
||||
LZ4LIB_STATIC_API int LZ4_compress_HC_extStateHC_fastReset (
|
||||
void* state,
|
||||
const char* src, char* dst,
|
||||
int srcSize, int dstCapacity,
|
||||
int compressionLevel);
|
||||
|
||||
/*! LZ4_attach_HC_dictionary() :
|
||||
* This is an experimental API that allows for the efficient use of a
|
||||
* static dictionary many times.
|
||||
*
|
||||
* Rather than re-loading the dictionary buffer into a working context before
|
||||
* each compression, or copying a pre-loaded dictionary's LZ4_streamHC_t into a
|
||||
* working LZ4_streamHC_t, this function introduces a no-copy setup mechanism,
|
||||
* in which the working stream references the dictionary stream in-place.
|
||||
*
|
||||
* Several assumptions are made about the state of the dictionary stream.
|
||||
* Currently, only streams which have been prepared by LZ4_loadDictHC() should
|
||||
* be expected to work.
|
||||
*
|
||||
* Alternatively, the provided dictionary stream pointer may be NULL, in which
|
||||
* case any existing dictionary stream is unset.
|
||||
*
|
||||
* A dictionary should only be attached to a stream without any history (i.e.,
|
||||
* a stream that has just been reset).
|
||||
*
|
||||
* The dictionary will remain attached to the working stream only for the
|
||||
* current stream session. Calls to LZ4_resetStreamHC(_fast) will remove the
|
||||
* dictionary context association from the working stream. The dictionary
|
||||
* stream (and source buffer) must remain in-place / accessible / unchanged
|
||||
* through the lifetime of the stream session.
|
||||
*/
|
||||
LZ4LIB_STATIC_API void LZ4_attach_HC_dictionary(
|
||||
LZ4_streamHC_t *working_stream,
|
||||
const LZ4_streamHC_t *dictionary_stream);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LZ4_HC_SLO_098092834 */
|
||||
#endif /* LZ4_HC_STATIC_LINKING_ONLY */
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* jbinit - https://github.com/palera1n/jbinit
|
||||
*
|
||||
* This file is part of jbinit
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef PALEINFO_H
|
||||
#define PALEINFO_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define PALEINFO_VERSION 2U
|
||||
typedef uint64_t palerain_option_t;
|
||||
|
||||
// unified palera1n options
|
||||
#define palerain_option_rootful (UINT64_C(1) << 0) /* rootful jailbreak */
|
||||
#define palerain_option_rootless (UINT64_C(1) << 1) /* rootless jailbreak */
|
||||
#define palerain_option_setup_rootful (UINT64_C(1) << 2) /* create fakefs */
|
||||
/* reserved */
|
||||
#define palerain_option_setup_partial_root (UINT64_C(1) << 4) /* fakefs creating should be partial */
|
||||
#define palerain_option_checkrain_is_clone (UINT64_C(1) << 5) /* supplied checkra1n is checkra1n clone */
|
||||
#define palerain_option_rootless_livefs (UINT64_C(1) << 6) /* mount root livefs on rootless */
|
||||
// #define palerain_option_no_ssv (UINT64_C(1) << 7) /* no signed system volume */
|
||||
// #define palerain_option_force_fakefs (UINT64_C(1) << 8) /* force fakefs, even without SSV */
|
||||
#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_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_demote (UINT64_C(1) << 14) /* Demote effective production fuse status */
|
||||
#define palerain_option_pongo_full (UINT64_C(1) << 15) /* Boot to pongo with default images and options */
|
||||
#define palerain_option_palerain_version (UINT64_C(1) << 16) /* Print version */
|
||||
#define palerain_option_exit_recovery (UINT64_C(1) << 17) /* Exit recovery mode */
|
||||
#define palerain_option_reboot_device (UINT64_C(1) << 18) /* Reboot device in normal mode */
|
||||
#define palerain_option_enter_recovery (UINT64_C(1) << 19) /* Enter recovery mode */
|
||||
#define palerain_option_device_info (UINT64_C(1) << 20) /* Print device info */
|
||||
#define palerain_option_no_colors (UINT64_C(1) << 21) /* no colors */
|
||||
#define palerain_option_bind_mount (UINT64_C(1) << 22) /* bind mounts should be used (always true iOS 15+)*/
|
||||
#define palerain_option_overlay (UINT64_C(1) << 23) /* there is an overlay (should always be true) */
|
||||
#define palerain_option_force_revert (UINT64_C(1) << 24) /* Unjailbreak */
|
||||
#define palerain_option_safemode (UINT64_C(1) << 25) /* Enter safe mode */
|
||||
#define palerain_option_verbose_boot (UINT64_C(1) << 26) /* verbose boot */
|
||||
|
||||
#define palerain_option_jbinit_log_to_file (UINT64_C(1) << 50) /* make ramdisk log to file (jbinit2) */
|
||||
#define palerain_option_setup_rootful_forced (UINT64_C(1) << 51) /* create fakefs over an existing one (jbinit2) */
|
||||
|
||||
#define palerain_option_flower_chain (UINT64_C(1) << 61) /* Flower chain */
|
||||
#define palerain_option_test1 (UINT64_C(1) << 62) /* Developer test option 1 */
|
||||
#define palerain_option_test2 (UINT64_C(1) << 63) /* Developer test option 2 */
|
||||
|
||||
#define PALEINFO_MAGIC 'PLSH'
|
||||
|
||||
/* paleinfo version 2, appended to ramdisk */
|
||||
struct paleinfo {
|
||||
uint32_t magic; /* 'PLSH' */
|
||||
uint32_t version; /* 2 */
|
||||
uint64_t kbase; /* kernel base */
|
||||
uint64_t kslide; /* kernel slide */
|
||||
uint64_t flags; /* unified palera1n flags */
|
||||
char rootdev[0x10]; /* ex. disk0s1s8 */
|
||||
}__attribute__((packed));
|
||||
|
||||
#endif
|
||||
+8
-13
@@ -6,7 +6,7 @@
|
||||
#endif
|
||||
|
||||
#include "xxd-embedded.h"
|
||||
#include "kerninfo.h"
|
||||
#include "paleinfo.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <usbmuxd.h>
|
||||
#include <libirecovery.h>
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define LOG(loglevel, ...) p1_log(loglevel, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#define CLEAR() printf("\33[2K\r");
|
||||
@@ -150,13 +151,12 @@ typedef unsigned char niarelap_file_t[];
|
||||
|
||||
extern unsigned int verbose;
|
||||
|
||||
extern char* pongo_path;
|
||||
#ifdef TUI
|
||||
extern bool tui_started;
|
||||
#endif
|
||||
|
||||
extern checkrain_option_t host_flags;
|
||||
extern checkrain_option_p host_flags_p;
|
||||
extern uint64_t palerain_flags;
|
||||
extern uint64_t* palerain_flags_p;
|
||||
|
||||
extern pthread_t dfuhelper_thread, pongo_thread;
|
||||
extern int pongo_thr_running, dfuhelper_thr_running;
|
||||
@@ -165,7 +165,7 @@ extern niarelap_file_t *kpf_to_upload_1, *ramdisk_to_upload_1, *overlay_to_uploa
|
||||
extern niarelap_file_t **kpf_to_upload, **ramdisk_to_upload, **overlay_to_upload;
|
||||
extern override_file_t override_ramdisk, override_kpf, override_overlay;
|
||||
|
||||
extern uint32_t checkrain_flags, palerain_flags, kpf_flags;
|
||||
extern uint64_t palerain_flags;
|
||||
extern pthread_mutex_t log_mutex;
|
||||
|
||||
extern pthread_mutex_t spin_mutex, found_pongo_mutex, ecid_dfu_wait_mutex;
|
||||
@@ -173,12 +173,7 @@ extern pthread_mutex_t spin_mutex, found_pongo_mutex, ecid_dfu_wait_mutex;
|
||||
extern int pongo_thr_running, dfuhelper_thr_running;
|
||||
extern bool device_has_booted;
|
||||
extern char xargs_cmd[0x270];
|
||||
extern char checkrain_flags_cmd[0x20];
|
||||
extern char palerain_flags_cmd[0x20];
|
||||
extern char kpf_flags_cmd[0x20];
|
||||
extern char dtpatch_cmd[0x20];
|
||||
extern char rootfs_cmd[512];
|
||||
extern char* ext_checkra1n;
|
||||
extern char palerain_flags_cmd[0x30];
|
||||
|
||||
void thr_cleanup(void* ptr);
|
||||
void* dfuhelper(void* ptr);
|
||||
@@ -197,7 +192,7 @@ int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid);
|
||||
int autoboot_cmd(const uint64_t ecid);
|
||||
int exitrecv_cmd(const uint64_t ecid);
|
||||
|
||||
int exec_checkra1n(void);
|
||||
int exec_checkm8(void);
|
||||
int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *orig_len, char *filename);
|
||||
void* pongo_helper(void* ptr);
|
||||
const unsigned char *
|
||||
@@ -230,7 +225,7 @@ void print_credits(void);
|
||||
|
||||
#ifdef TUI
|
||||
#include <newt.h>
|
||||
newtComponent get_tui_log();
|
||||
newtComponent get_tui_log(void);
|
||||
newtComponent set_tui_log(newtComponent co);
|
||||
#endif
|
||||
#endif
|
||||
+10
-10
@@ -11,7 +11,7 @@
|
||||
#include <locale.h>
|
||||
#include <unistd.h>
|
||||
#include <newt.h>
|
||||
#include <kerninfo.h>
|
||||
#include <paleinfo.h>
|
||||
|
||||
#define WIDTH 76
|
||||
#define HEIGHT 19
|
||||
@@ -20,7 +20,7 @@
|
||||
#define PI_STEP_CURRENT NEWT_COLORSET_CUSTOM(1)
|
||||
#define PI_STEP_OTHER NEWT_COLORSET_CUSTOM(2)
|
||||
|
||||
#define CHECKBOX_STATE(flags, opt) checkrain_options_enabled(flags, opt) ? '*' : ' '
|
||||
#define CHECKBOX_STATE(flags, opt) (flags & opt) != 0 ? '*' : ' '
|
||||
|
||||
typedef enum tui_screens {
|
||||
ERROR_SCREEN = -1,
|
||||
@@ -33,17 +33,17 @@ typedef enum tui_screens {
|
||||
} tui_screen_t;
|
||||
|
||||
typedef struct bitfield_checkbox_info {
|
||||
checkrain_option_p flags_p;
|
||||
checkrain_option_t opt;
|
||||
uint64_t* flags_p;
|
||||
uint64_t opt;
|
||||
} tui_bit_info_t;
|
||||
|
||||
tui_screen_t tui_screen_main();
|
||||
tui_screen_t tui_screen_options();
|
||||
tui_screen_t tui_screen_enter_recovery();
|
||||
tui_screen_t tui_screen_enter_dfu();
|
||||
tui_screen_t tui_screen_jailbreak();
|
||||
tui_screen_t tui_screen_main(void);
|
||||
tui_screen_t tui_screen_options(void);
|
||||
tui_screen_t tui_screen_enter_recovery(void);
|
||||
tui_screen_t tui_screen_enter_dfu(void);
|
||||
tui_screen_t tui_screen_jailbreak(void);
|
||||
|
||||
int redraw_screen();
|
||||
int redraw_screen(void);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -5,9 +5,6 @@
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
extern unsigned char checkra1n[];
|
||||
extern unsigned int checkra1n_len;
|
||||
|
||||
extern unsigned char checkra1n_kpf_pongo[];
|
||||
extern unsigned int checkra1n_kpf_pongo_len;
|
||||
|
||||
@@ -17,9 +14,6 @@ extern unsigned int ramdisk_dmg_len;
|
||||
extern unsigned char binpack_dmg[];
|
||||
extern unsigned int binpack_dmg_len;
|
||||
|
||||
extern unsigned char Pongo_bin[];
|
||||
extern unsigned int Pongo_bin_len;
|
||||
|
||||
#if defined(__APPLE__) && (TARGET_OS_IPHONE || defined(DEV_BUILD))
|
||||
extern unsigned char libcheckra1nhelper_dylib[];
|
||||
extern unsigned int libcheckra1nhelper_dylib_len;
|
||||
|
||||
+2
-2
@@ -8,8 +8,8 @@ Depends: usbmuxd
|
||||
Section: Utilities
|
||||
Priority: optional
|
||||
Homepage: https://palera.in
|
||||
Description: iOS 15.0-16.4.1 semi-tethered checkm8 jailbreak
|
||||
palera1n is an iOS/iPadOS 15.0-15.3.1 semi tethered jailbreak
|
||||
Description: iOS 15.0-16.5.1 semi-tethered checkm8 jailbreak
|
||||
palera1n is an iOS/iPadOS 15.0-16.5.1 semi tethered jailbreak
|
||||
based on the checkm8 exploit.
|
||||
.
|
||||
palera1n is able to jailbreak the device in fakefs-rootful mode,
|
||||
|
||||
@@ -7,8 +7,8 @@ Author: palera1n team
|
||||
Section: Utilities
|
||||
Priority: optional
|
||||
Homepage: https://palera.in
|
||||
Description: iOS 15.0-16.4.1 semi-tethered checkm8 jailbreak
|
||||
palera1n is an iOS/iPadOS 15.0-15.3.1 semi tethered jailbreak
|
||||
Description: iOS 15.0-16.5 semi-tethered checkm8 jailbreak
|
||||
palera1n is an iOS/iPadOS 15.0-16.5 semi tethered jailbreak
|
||||
based on the checkm8 exploit.
|
||||
.
|
||||
palera1n is able to jailbreak the device in fakefs-rootful mode,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
From 632cdb6de3f1693fb90d60d81552b723e8dd5e84 Mon Sep 17 00:00:00 2001
|
||||
From a2d012f3ba459f6debe636b576ad9aeab7b3c2aa Mon Sep 17 00:00:00 2001
|
||||
From: Nick Chan <[email protected]>
|
||||
Date: Wed, 25 Jan 2023 01:53:00 +0800
|
||||
Date: Sat, 27 May 2023 23:50:23 +0800
|
||||
Subject: [PATCH] Allow empty x509 cert issuer
|
||||
|
||||
---
|
||||
@@ -8,25 +8,24 @@ Subject: [PATCH] Allow empty x509 cert issuer
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/library/x509_crt.c b/library/x509_crt.c
|
||||
index 0eee97cb6..46702f683 100644
|
||||
index cf62532f2..ef25b3d77 100644
|
||||
--- a/library/x509_crt.c
|
||||
+++ b/library/x509_crt.c
|
||||
@@ -1185,14 +1185,14 @@ static int x509_crt_parse_der_core( mbedtls_x509_crt *crt,
|
||||
if( ( ret = mbedtls_asn1_get_tag( &p, end, &len,
|
||||
MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
|
||||
{
|
||||
- mbedtls_x509_crt_free( crt );
|
||||
- return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_X509_INVALID_FORMAT, ret ) );
|
||||
+ // mbedtls_x509_crt_free( crt );
|
||||
+ // return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_X509_INVALID_FORMAT, ret ) );
|
||||
@@ -1061,13 +1061,13 @@ static int x509_crt_parse_der_core(mbedtls_x509_crt *crt,
|
||||
|
||||
if ((ret = mbedtls_asn1_get_tag(&p, end, &len,
|
||||
MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) != 0) {
|
||||
- mbedtls_x509_crt_free(crt);
|
||||
- return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_FORMAT, ret);
|
||||
+ /*mbedtls_x509_crt_free(crt);
|
||||
+ return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_FORMAT, ret);*/
|
||||
}
|
||||
|
||||
if( ( ret = mbedtls_x509_get_name( &p, p + len, &crt->issuer ) ) != 0 )
|
||||
{
|
||||
- mbedtls_x509_crt_free( crt );
|
||||
- return( ret );
|
||||
+ // mbedtls_x509_crt_free( crt );
|
||||
+ // return( ret );
|
||||
if ((ret = mbedtls_x509_get_name(&p, p + len, &crt->issuer)) != 0) {
|
||||
- mbedtls_x509_crt_free(crt);
|
||||
- return ret;
|
||||
+ /*mbedtls_x509_crt_free(crt);
|
||||
+ return ret;*/
|
||||
}
|
||||
|
||||
crt->issuer_raw.len = p - crt->issuer_raw.p;
|
||||
|
||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
+10
-50
@@ -2,7 +2,7 @@ all: palera1n
|
||||
|
||||
OBJECTS = main.o dfuhelper.o devhelper.o lockdown_helper.o
|
||||
OBJECTS += optparse.o override_file.o log.o lock_vars.o credits.o
|
||||
OBJECTS += fake_embedded.o exec_checkra1n.o pongo_helper.o
|
||||
OBJECTS += fake_embedded.o checkm8.o pongo_helper.o
|
||||
OBJECTS += boyermoore_memmem.o
|
||||
|
||||
ifeq (,$(findstring macosx, $(CFLAGS)))
|
||||
@@ -35,19 +35,6 @@ else
|
||||
CFLAGS += -DNO_OVERLAY
|
||||
BUILD_OPTIONS += NO_OVERLAY
|
||||
endif
|
||||
ifneq ($(NO_CHECKRAIN),1)
|
||||
OBJECTS += xxd-checkra1n.o
|
||||
else
|
||||
CFLAGS += -DNO_CHECKRAIN
|
||||
BUILD_OPTIONS += NO_CHECKRAIN
|
||||
endif
|
||||
|
||||
ifneq ($(NO_CUSTOM_PONGO),1)
|
||||
OBJECTS += xxd-Pongo.bin.o
|
||||
else
|
||||
CFLAGS += -DNO_CUSTOM_PONGO
|
||||
BUILD_OPTIONS += NO_CUSTOM_PONGO
|
||||
endif
|
||||
|
||||
ifeq ($(TUI),1)
|
||||
OBJECTS += tui_screen_enter_recovery.o tui_screen_enter_dfu.o tui_main.o
|
||||
@@ -56,7 +43,6 @@ BUILD_OPTIONS += TUI
|
||||
CFLAGS += -DTUI
|
||||
endif
|
||||
|
||||
CHECKRA1N_VERSION ?= 0.1337.1
|
||||
LIPO = lipo
|
||||
LDID = ldid
|
||||
|
||||
@@ -76,11 +62,15 @@ endif
|
||||
|
||||
ifeq ($(USE_LIBUSB),1)
|
||||
OBJECTS += usb_libusb.o
|
||||
CFLAGS += -DUSE_LIBUSB=1
|
||||
CFLAGS += -DHAVE_LIBUSB -DUSE_LIBUSB=1
|
||||
ifeq ($(TARGET_OS),Windows)
|
||||
LIBS += -lusb-1.0
|
||||
else
|
||||
LIBS += $(DEP)/lib/libusb-1.0.a
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(ROOTFUL),0)
|
||||
ifeq ($(ROOTFUL),1)
|
||||
CFLAGS += -DROOTFUL=1
|
||||
BUILD_OPTIONS += ROOTFUL
|
||||
endif
|
||||
@@ -89,35 +79,8 @@ ifeq ($(BUILD_OPTIONS),)
|
||||
BUILD_OPTIONS = (none)
|
||||
endif
|
||||
|
||||
CFLAGS += -DBUILD_OPTIONS=\""$(BUILD_OPTIONS)"\"
|
||||
|
||||
checkra1n-%:
|
||||
curl -LO https://assets.checkra.in/downloads/preview/$(CHECKRA1N_VERSION)/$@
|
||||
chmod 755 $@
|
||||
|
||||
checkra1n: checkra1n-macos usb.xml
|
||||
ifeq ($(TARGET_OS),Darwin)
|
||||
ifneq (,$(findstring arm64, $(CFLAGS)))
|
||||
$(LIPO) -thin arm64 -output checkra1n checkra1n-macos
|
||||
else ifneq (,$(findstring x86_64, $(CFLAGS)))
|
||||
$(LIPO) -thin x86_64 -output checkra1n checkra1n-macos
|
||||
else ifeq ($(shell arch),i386)
|
||||
$(LIPO) -thin x86_64 -output checkra1n checkra1n-macos
|
||||
else
|
||||
$(LIPO) -thin $(shell arch) -output checkra1n checkra1n-macos
|
||||
endif
|
||||
ifeq (,$(findstring macosx, $(CFLAGS)))
|
||||
ifneq (,$(findstring version-min=, $(CFLAGS)))
|
||||
vtool -remove-build-version 1 -replace -output checkra1n checkra1n
|
||||
vtool -set-build-version $(FAKE_PLATFORM) $(FAKE_MINOS) $(FAKE_SDK) -replace -output checkra1n checkra1n
|
||||
install_name_tool -change /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit /System/Library/Frameworks/IOKit.framework/IOKit checkra1n
|
||||
install_name_tool -change /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation checkra1n
|
||||
$(LDID) -Susb.xml checkra1n
|
||||
endif
|
||||
endif
|
||||
else
|
||||
cp checkra1n-$(CHECKRA1N_NAME) checkra1n
|
||||
endif
|
||||
LIBS += lz4/lz4.c lz4/lz4hc.c
|
||||
CFLAGS += -DBUILD_OPTIONS=\""$(BUILD_OPTIONS)"\" -Wno-pointer-sign -Wno-pointer-arith -Wno-pedantic
|
||||
|
||||
xxd-%.c: %
|
||||
xxd -iC $< > $@
|
||||
@@ -140,14 +103,11 @@ checkra1n-kpf-pongo:
|
||||
curl -LO https://cdn.nickchan.lol/palera1n/artifacts/kpf/checkra1n-kpf-pongo
|
||||
|
||||
ramdisk.dmg:
|
||||
curl -LO https://cdn.nickchan.lol/palera1n/artifacts/jbinit_rootless/ramdisk.dmg
|
||||
curl -LO https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg
|
||||
|
||||
binpack.dmg:
|
||||
curl -LO https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg
|
||||
|
||||
Pongo.bin:
|
||||
curl -LO https://cdn.nickchan.lol/palera1n/artifacts/kpf/Pongo.bin
|
||||
|
||||
clean:
|
||||
rm -rf *.o palera1n checkra1n checkra1n.c palera1n.dSYM libcheckra1nhelper.dylib
|
||||
|
||||
|
||||
+1058
File diff suppressed because it is too large.
Load diff
+2
-3
@@ -3,7 +3,6 @@
|
||||
#ifndef BAKERAIN_DEVELOPE_R
|
||||
#define BAKERAIN_DEVELOPE_R "kok3shidoll"
|
||||
#endif
|
||||
#define THE_PLUSH "Ploosh"
|
||||
|
||||
#define T void
|
||||
#define R print_credits(void) {
|
||||
@@ -12,8 +11,8 @@
|
||||
#define B stderr
|
||||
#define L ,
|
||||
#define E "# == palera1n-c == \n#\n"
|
||||
#define M "# Made by: Nick Chan, " THE_PLUSH ", Samara, Nebula, staturnz, " BAKERAIN_DEVELOPE_R " \n#\n"
|
||||
#define A "# Thanks to: pythonplayer123, llsc12, Mineek, tihmstar, nikias\n"
|
||||
#define M "# Made by: Nick Chan, Ploosh, Samara, Nebula, staturnz, " BAKERAIN_DEVELOPE_R ", Mineek\n#\n"
|
||||
#define A "# Thanks to: pythonplayer123, llsc12, tihmstar, nikias\n"
|
||||
#define K "# (libimobiledevice), checkra1n team (Siguza, axi0mx, littlelailo\n"
|
||||
#define I "# et al.), Procursus Team (Hayden Seay, Cameron Katri, Keto et.al)\n\n"
|
||||
#define N )
|
||||
|
||||
+2
-2
@@ -7,9 +7,9 @@
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#ifdef WIN
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
+30
-19
@@ -8,11 +8,16 @@
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef WIN
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
@@ -37,7 +42,7 @@ int dfuhelper_thr_running = false;
|
||||
void step(int time, int time2, char *text, bool (*cond)(uint64_t), uint64_t cond_arg) {
|
||||
for (int i = time2; i < time; i++) {
|
||||
printf(
|
||||
checkrain_options_enabled(host_flags, host_option_no_colors)
|
||||
(palerain_flags & palerain_option_no_colors)
|
||||
? "\r\033[K%s (%d)"
|
||||
: BCYN "\r\033[K%s (%d)" CRESET, text, time - i + time2
|
||||
);
|
||||
@@ -46,7 +51,7 @@ void step(int time, int time2, char *text, bool (*cond)(uint64_t), uint64_t cond
|
||||
if (cond != NULL && cond(cond_arg)) pthread_exit(NULL);
|
||||
}
|
||||
printf(
|
||||
checkrain_options_enabled(host_flags, host_option_no_colors)
|
||||
(palerain_flags & palerain_option_no_colors)
|
||||
? "\r%s (%d)"
|
||||
: CYN "\r%s (%d)" CRESET, text, time2
|
||||
);
|
||||
@@ -68,7 +73,7 @@ int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
|
||||
return -1;
|
||||
}
|
||||
if (!strncmp(dev.productType, "iPhone10,", strlen("iPhone10,"))) {
|
||||
if (!checkrain_options_enabled(host_flags, host_option_device_info))
|
||||
if (!(palerain_flags & palerain_option_device_info))
|
||||
LOG(LOG_VERBOSE2, "Product %s requires passcode to be disabled", dev.productType);
|
||||
unsigned char passcode_state = 0;
|
||||
ret = passstat_cmd(&passcode_state, usbmuxd_device->udid);
|
||||
@@ -79,14 +84,14 @@ int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
|
||||
}
|
||||
if (passcode_state) {
|
||||
LOG(LOG_ERROR, "Passcode must be disabled on this device");
|
||||
if (!checkrain_options_enabled(host_flags, host_option_device_info))
|
||||
if (!(palerain_flags & palerain_option_device_info))
|
||||
LOG(LOG_ERROR, "Additionally, passcode must never be set since a restore on iOS 16+");
|
||||
devinfo_free(&dev);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkrain_options_enabled(host_flags, host_option_device_info)) {
|
||||
if ((palerain_flags & palerain_option_device_info)) {
|
||||
printf("Mode: normal\n");
|
||||
printf("ProductType: %s\n", dev.productType);
|
||||
printf("Architecture: %s\n", dev.CPUArchitecture);
|
||||
@@ -98,10 +103,16 @@ int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
|
||||
unsubscribe_cmd();
|
||||
return 0;
|
||||
}
|
||||
LOG(LOG_INFO, "Telling device with udid %s to enter recovery mode immediately", usbmuxd_device->udid);
|
||||
if (verbose > 1) {
|
||||
/* (LOG_VERBOSE - 3) or below*/
|
||||
LOG(LOG_INFO, "Telling device with udid %s to enter recovery mode immediately", usbmuxd_device->udid);
|
||||
} else {
|
||||
/* At least (LOG_VERBOSE2 - 3) */
|
||||
LOG(LOG_INFO, "Entering recovery mode");
|
||||
}
|
||||
enter_recovery_cmd(usbmuxd_device->udid);
|
||||
devinfo_free(&dev);
|
||||
if (checkrain_options_enabled(host_flags, host_option_enter_recovery)) {
|
||||
if ((palerain_flags & palerain_option_enter_recovery)) {
|
||||
device_has_booted = true;
|
||||
set_spin(0);
|
||||
unsubscribe_cmd();
|
||||
@@ -181,9 +192,9 @@ void device_event_cb(const usbmuxd_event_t *event, void* userdata) {
|
||||
switch (event->event) {
|
||||
case UE_DEVICE_ADD:
|
||||
LOG(LOG_VERBOSE, "Normal mode device connected");
|
||||
if (checkrain_options_enabled(host_flags, host_option_exit_recovery)) {
|
||||
if ((palerain_flags & palerain_option_exit_recovery)) {
|
||||
break;
|
||||
} else if (checkrain_options_enabled(host_flags, host_option_reboot_device)) {
|
||||
} else if ((palerain_flags & palerain_option_reboot_device)) {
|
||||
int ret = reboot_cmd(event->device.udid);
|
||||
if (!ret) {
|
||||
LOG(LOG_INFO, "Restarted device");
|
||||
@@ -211,9 +222,9 @@ void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
|
||||
event->mode == IRECV_K_RECOVERY_MODE_2 ||
|
||||
event->mode == IRECV_K_RECOVERY_MODE_3 ||
|
||||
event->mode == IRECV_K_RECOVERY_MODE_4) {
|
||||
if (!checkrain_options_enabled(host_flags, host_option_device_info))
|
||||
if (!(palerain_flags & palerain_option_device_info))
|
||||
LOG(LOG_VERBOSE, "Recovery mode device %ld connected", event->device_info->ecid);
|
||||
if (checkrain_options_enabled(host_flags, host_option_exit_recovery)) {
|
||||
if ((palerain_flags & palerain_option_exit_recovery)) {
|
||||
ret = exitrecv_cmd(event->device_info->ecid);
|
||||
if (!ret) {
|
||||
LOG(LOG_INFO, "Exited recovery mode");
|
||||
@@ -228,7 +239,7 @@ void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (checkrain_options_enabled(host_flags, host_option_device_info)) {
|
||||
if ((palerain_flags & palerain_option_device_info)) {
|
||||
recvinfo_t info;
|
||||
ret = recvinfo_cmd(&info, event->device_info->ecid);
|
||||
if (ret) {
|
||||
@@ -247,14 +258,14 @@ void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (checkrain_options_enabled(host_flags, host_option_enter_recovery) ||
|
||||
checkrain_options_enabled(host_flags, host_option_reboot_device)) return;
|
||||
if ((palerain_flags & palerain_option_enter_recovery) ||
|
||||
(palerain_flags & palerain_option_reboot_device)) return;
|
||||
pthread_create(&recovery_thread, NULL, (pthread_start_t)connected_recovery_mode, event->device_info);
|
||||
} else if (event->mode == IRECV_K_DFU_MODE) {
|
||||
if (!checkrain_options_enabled(host_flags, host_option_device_info))
|
||||
if (!(palerain_flags & palerain_option_device_info))
|
||||
LOG(LOG_VERBOSE, "DFU mode device %ld connected", event->device_info->ecid);
|
||||
|
||||
if (checkrain_options_enabled(host_flags, host_option_device_info)) {
|
||||
if ((palerain_flags & palerain_option_device_info)) {
|
||||
recvinfo_t info;
|
||||
ret = recvinfo_cmd(&info, event->device_info->ecid);
|
||||
if (ret) {
|
||||
@@ -274,9 +285,9 @@ void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
|
||||
}
|
||||
|
||||
if (
|
||||
checkrain_options_enabled(host_flags, host_option_exit_recovery) ||
|
||||
checkrain_options_enabled(host_flags, host_option_enter_recovery) ||
|
||||
checkrain_options_enabled(host_flags, host_option_reboot_device)) {
|
||||
(palerain_flags & palerain_option_exit_recovery) ||
|
||||
(palerain_flags & palerain_option_enter_recovery) ||
|
||||
(palerain_flags & palerain_option_reboot_device)) {
|
||||
break;
|
||||
}
|
||||
pthread_create(&dfu_thread, NULL, (pthread_start_t)connected_dfu_mode, event->device_info);
|
||||
|
||||
@@ -1,183 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <spawn.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
extern char **environ;
|
||||
|
||||
#include <palerain.h>
|
||||
#include <xxd-embedded.h>
|
||||
char* pongo_path = NULL;
|
||||
bool external_pongo = false;
|
||||
char* ext_checkra1n = NULL;
|
||||
|
||||
#define tmpdir getenv("TMPDIR") == NULL ? "/tmp" : getenv("TMPDIR")
|
||||
|
||||
int exec_checkra1n(void) {
|
||||
LOG(LOG_INFO, "About to execute checkra1n");
|
||||
int fd_checkra1n, fd_pongo, ret;
|
||||
char* checkra1n_path = NULL;
|
||||
if (ext_checkra1n != NULL) {
|
||||
checkra1n_path = ext_checkra1n;
|
||||
goto checkra1n_exec;
|
||||
}
|
||||
#ifndef NO_CUSTOM_PONGO
|
||||
if (pongo_path == NULL) {
|
||||
pongo_path = malloc(strlen(tmpdir) + 20);
|
||||
snprintf(pongo_path, strlen(tmpdir) + 20, "%s/Pongo.bin.XXXXXX", tmpdir);
|
||||
fd_pongo = mkstemp(pongo_path);
|
||||
if (fd_pongo == -1) {
|
||||
LOG(LOG_FATAL, "Cannot open temporary file %s: %d (%s)", pongo_path, errno, strerror(errno));
|
||||
free(pongo_path);
|
||||
return -1;
|
||||
}
|
||||
ssize_t didWrite_Pongo_bin = write(fd_pongo, Pongo_bin, Pongo_bin_len);
|
||||
if (didWrite_Pongo_bin != (ssize_t)Pongo_bin_len) {
|
||||
LOG(LOG_FATAL, "Size written to %s does not match expected: %lld != %d: %d (%s)", pongo_path, didWrite_Pongo_bin, Pongo_bin_len, errno, strerror(errno));
|
||||
close(fd_pongo);
|
||||
unlink(pongo_path);
|
||||
free(pongo_path);
|
||||
pongo_path = NULL;
|
||||
return -1;
|
||||
}
|
||||
} else external_pongo = true;
|
||||
#endif
|
||||
checkra1n_path = malloc(strlen(tmpdir) + 20);
|
||||
snprintf(checkra1n_path, strlen(tmpdir) + 20, "%s/checkra1n.XXXXXX", tmpdir);
|
||||
fd_checkra1n = mkstemp(checkra1n_path);
|
||||
if (fd_checkra1n == -1) {
|
||||
LOG(LOG_FATAL, "Cannot open temporary file %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
||||
free(checkra1n_path);
|
||||
checkra1n_path = NULL;
|
||||
return -1;
|
||||
}
|
||||
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: %lld != %d: %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);
|
||||
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))
|
||||
char* libcheckra1nhelper_dylib_path = NULL;
|
||||
{
|
||||
struct utsname name;
|
||||
uname(&name);
|
||||
unsigned long darwinMajor = strtoul(name.release, NULL, 10);
|
||||
assert(darwinMajor != 0);
|
||||
#if !defined(FORCE_HELPER)
|
||||
if (darwinMajor < 20) {
|
||||
#endif
|
||||
libcheckra1nhelper_dylib_path = malloc(strlen(tmpdir) + 40);
|
||||
snprintf(libcheckra1nhelper_dylib_path, strlen(tmpdir) + 40, "%s/libcheckra1nhelper.dylib.XXXXXX", tmpdir);
|
||||
int helper_fd = mkstemp(libcheckra1nhelper_dylib_path);
|
||||
if (helper_fd == -1) {
|
||||
LOG(LOG_FATAL, "Cannot open temporary file: %d (%s)", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
ssize_t didWrite_libcheckra1nhelper = write(helper_fd, libcheckra1nhelper_dylib, libcheckra1nhelper_dylib_len);
|
||||
if ((unsigned int)didWrite_libcheckra1nhelper != libcheckra1nhelper_dylib_len) {
|
||||
LOG(LOG_FATAL, "Size written does not match expected: %lld != %d: %d (%s)", didWrite_libcheckra1nhelper, libcheckra1nhelper_dylib_len, errno, strerror(errno));
|
||||
close(helper_fd);
|
||||
unlink(libcheckra1nhelper_dylib_path);
|
||||
return -1;
|
||||
}
|
||||
close(helper_fd);
|
||||
ret = chmod(libcheckra1nhelper_dylib_path, 0700);
|
||||
if (ret) {
|
||||
LOG(LOG_FATAL, "Cannot chmod %s: %d (%s)", libcheckra1nhelper_dylib_path, errno, strerror(errno));
|
||||
unlink(libcheckra1nhelper_dylib_path);
|
||||
return -1;
|
||||
}
|
||||
setenv("DYLD_INSERT_LIBRARIES", libcheckra1nhelper_dylib_path, 1);
|
||||
#if !defined(FORCE_HELPER)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
checkra1n_exec: {};
|
||||
char args[0x10] = "-E";
|
||||
if (checkrain_options_enabled(host_flags, host_option_demote)) strncat(args, "d", 0xf);
|
||||
if (!checkrain_options_enabled(host_flags, palerain_option_checkrain_is_clone)) {
|
||||
strncat(args, "p", 0xf);
|
||||
if (verbose >= 2) strncat(args, "v", 0xf);
|
||||
if (checkrain_options_enabled(host_flags, host_option_no_colors)) strncat(args, "n", 0xf);
|
||||
} else {
|
||||
strncat(args, "R", 0xf);
|
||||
}
|
||||
LOG(LOG_VERBOSE5, args);
|
||||
if (pongo_path != NULL) LOG(LOG_VERBOSE5, pongo_path);
|
||||
pid_t pid;
|
||||
if (pongo_path != NULL) {
|
||||
ret = posix_spawn(&pid, checkra1n_path, NULL, NULL, (char* []){
|
||||
checkra1n_path,
|
||||
args,
|
||||
"-k",
|
||||
pongo_path,
|
||||
NULL
|
||||
}, environ);
|
||||
} else {
|
||||
ret = posix_spawn(&pid, checkra1n_path, NULL, NULL, (char* []){
|
||||
checkra1n_path,
|
||||
args,
|
||||
NULL
|
||||
}, environ);
|
||||
}
|
||||
if (ret) {
|
||||
LOG(LOG_FATAL, "Cannot posix spawn %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
||||
if (ext_checkra1n != NULL) unlink(checkra1n_path);
|
||||
return -1;
|
||||
}
|
||||
LOG(LOG_VERBOSE2, "%s spawned successfully", checkra1n_path);
|
||||
sleep(2);
|
||||
if (ext_checkra1n == NULL) {
|
||||
unlink(checkra1n_path);
|
||||
free(checkra1n_path);
|
||||
checkra1n_path = NULL;
|
||||
}
|
||||
waitpid(pid, NULL, 0);
|
||||
if (!external_pongo && pongo_path != NULL) {
|
||||
unlink(pongo_path);
|
||||
}
|
||||
if (pongo_path != NULL) free(pongo_path);
|
||||
pongo_path = NULL;
|
||||
#if defined(__APPLE__) && defined(__arm64__) && (TARGET_OS_IPHONE || defined(FORCE_HELPER))
|
||||
if (libcheckra1nhelper_dylib_path != NULL) {
|
||||
unlink(libcheckra1nhelper_dylib_path);
|
||||
unsetenv("DYLD_INSERT_LIBRARIES");
|
||||
unsetenv("DYLD_FORCE_FLAT_NAMESPACE");
|
||||
free(libcheckra1nhelper_dylib_path);
|
||||
libcheckra1nhelper_dylib_path = NULL;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -10,17 +10,7 @@ unsigned char* ramdisk_dmg = NULL;
|
||||
unsigned int ramdisk_dmg_len = 0;
|
||||
#endif
|
||||
|
||||
#ifdef NO_CHECKRAIN
|
||||
unsigned char* checkra1n = NULL;
|
||||
unsigned int checkra1n_len = 0;
|
||||
#endif
|
||||
|
||||
#ifdef NO_OVERLAY
|
||||
unsigned char* binpack_dmg = NULL;
|
||||
unsigned int binpack_dmg_len = 0;
|
||||
#endif
|
||||
|
||||
#ifdef NO_CUSTOM_PONGO
|
||||
unsigned char* Pongo_bin = NULL;
|
||||
unsigned int Pongo_bin_len = 0;
|
||||
#endif
|
||||
+9
-4
@@ -9,17 +9,22 @@
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef WIN
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <spawn.h>
|
||||
#include <sys/mman.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <inttypes.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
#include <spawn.h>
|
||||
#include <sys/mman.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
@@ -27,7 +32,7 @@
|
||||
#include <ANSI-color-codes.h>
|
||||
#include <palerain.h>
|
||||
#include <xxd-embedded.h>
|
||||
#include <kerninfo.h>
|
||||
#include <paleinfo.h>
|
||||
|
||||
pthread_mutex_t spin_mutex, found_pongo_mutex, ecid_dfu_wait_mutex;
|
||||
#ifdef TUI
|
||||
@@ -90,7 +95,7 @@ uint64_t set_ecid_wait_for_dfu(uint64_t ecid) {
|
||||
}
|
||||
|
||||
#ifdef TUI
|
||||
newtComponent get_tui_log() {
|
||||
newtComponent get_tui_log(void) {
|
||||
pthread_mutex_lock(&tui_log_mutex);
|
||||
newtComponent ret = tui_log_output;
|
||||
pthread_mutex_unlock(&tui_log_mutex);
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
#ifndef HAVE_LIBIMOBILEDEVICE
|
||||
#include "lockdown_helper.h"
|
||||
#include <usbmuxd.h>
|
||||
#ifdef WIN
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -12,7 +12,7 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
|
||||
{
|
||||
if (verbose >= 5
|
||||
#ifdef TUI
|
||||
&& !checkrain_options_enabled(host_flags, host_option_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;
|
||||
@@ -57,12 +57,12 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
|
||||
snprintf(colour_bold, 0x10, "%s", BWHT);
|
||||
break;
|
||||
}
|
||||
if (checkrain_options_enabled(host_flags, host_option_no_colors)) {
|
||||
if ((palerain_flags & palerain_option_no_colors)) {
|
||||
colour[0] = '\0';
|
||||
colour_bold[0] = '\0';
|
||||
}
|
||||
#ifdef TUI
|
||||
if (checkrain_options_enabled(host_flags, host_option_tui) && tui_started) {
|
||||
if ((palerain_flags & palerain_option_tui) && tui_started) {
|
||||
newtComponent co = get_tui_log();
|
||||
if (co == NULL) {
|
||||
return 0; /* 0 bytes printed */
|
||||
@@ -79,26 +79,26 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
|
||||
time_t curtime;
|
||||
time(&curtime);
|
||||
struct tm* timeinfo = localtime(&curtime);
|
||||
if (!checkrain_options_enabled(host_flags, host_option_no_colors))
|
||||
if (!(palerain_flags & palerain_option_no_colors))
|
||||
snprintf(timestring, 0x80, "%s[%s%02d/%02d/%d %02d:%02d:%02d%s]", CRESET, HBLK, timeinfo->tm_mon + 1, timeinfo->tm_mday, timeinfo->tm_year - 100, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, CRESET);
|
||||
else
|
||||
snprintf(timestring, 0x80, "[%02d/%02d/%d %02d:%02d:%02d]", timeinfo->tm_mon + 1, timeinfo->tm_mday, timeinfo->tm_year - 100, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||
if (verbose >= 2 && !checkrain_options_enabled(host_flags, host_option_no_colors)) {
|
||||
if (verbose >= 2 && !(palerain_flags & palerain_option_no_colors)) {
|
||||
printf("%s| - %s%s <%s> " CRESET "%s" HBLU "%s" CRESET ":" BLU "%d" CRESET ":" BMAG "%s()" CRESET ": \n%s| ----> ", colour_bold, timestring, colour_bold, type, WHT, fname, lineno, fxname, colour_bold);
|
||||
} else if (!checkrain_options_enabled(host_flags, host_option_no_colors)) {
|
||||
} else if (!(palerain_flags & palerain_option_no_colors)) {
|
||||
printf(" - %s %s<%s>%s: ", timestring, colour_bold, type, CRESET);
|
||||
} else if (verbose >= 2 && checkrain_options_enabled(host_flags, host_option_no_colors)) {
|
||||
} else if (verbose >= 2 && (palerain_flags & palerain_option_no_colors)) {
|
||||
printf("%s| - %s%s <%s> %s:%d:%s(): \n%s| ----> ", colour_bold, timestring, colour_bold, type, fname, lineno, fxname, colour_bold);
|
||||
} else if (checkrain_options_enabled(host_flags, host_option_no_colors)) {
|
||||
} else if ((palerain_flags & palerain_option_no_colors)) {
|
||||
printf(" - %s %s<%s>: ", timestring, colour_bold, type);
|
||||
}
|
||||
printf("%s", colour);
|
||||
ret = vprintf(format, args);
|
||||
va_end(args);
|
||||
|
||||
if (verbose < 2 && !checkrain_options_enabled(host_flags, host_option_no_colors))
|
||||
if (verbose < 2 && !(palerain_flags & palerain_option_no_colors))
|
||||
printf(CRESET "\n");
|
||||
else if (!checkrain_options_enabled(host_flags, host_option_no_colors))
|
||||
else if (!(palerain_flags & palerain_option_no_colors))
|
||||
printf("\n%s-%s\n", colour, CRESET);
|
||||
else if (verbose < 2)
|
||||
printf("\n");
|
||||
|
||||
+2764
File diff suppressed because it is too large.
Load diff
+1637
File diff suppressed because it is too large.
Load diff
+26
-37
@@ -10,16 +10,21 @@
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef WIN
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <spawn.h>
|
||||
#include <sys/mman.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <inttypes.h>
|
||||
#include <errno.h>
|
||||
#include <spawn.h>
|
||||
#include <sys/mman.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
@@ -27,14 +32,13 @@
|
||||
#include <ANSI-color-codes.h>
|
||||
#include <palerain.h>
|
||||
#include <xxd-embedded.h>
|
||||
#include <kerninfo.h>
|
||||
#include <paleinfo.h>
|
||||
|
||||
#define CMD_LEN_MAX 512
|
||||
#define OVERRIDE_MAGIC 0xd803b376
|
||||
|
||||
unsigned int verbose = 0;
|
||||
char xargs_cmd[0x270] = "xargs ", checkrain_flags_cmd[0x20] = "deadbeef", palerain_flags_cmd[0x20] = "deadbeef";
|
||||
char kpf_flags_cmd[0x20] = "deadbeef", dtpatch_cmd[0x20] = "deadbeef", rootfs_cmd[512] = "deadbeef";
|
||||
char xargs_cmd[0x270] = "xargs ", palerain_flags_cmd[0x30] = "deadbeef";
|
||||
extern char** environ;
|
||||
|
||||
niarelap_file_t* kpf_to_upload_1 = &checkra1n_kpf_pongo;
|
||||
@@ -47,7 +51,7 @@ niarelap_file_t** overlay_to_upload = &overlay_to_upload_1;
|
||||
|
||||
override_file_t override_ramdisk, override_kpf, override_overlay;
|
||||
|
||||
uint32_t checkrain_flags = 0, palerain_flags = 0, kpf_flags = 0;
|
||||
uint64_t palerain_flags = 0;
|
||||
|
||||
pthread_mutex_t log_mutex;
|
||||
pthread_t dfuhelper_thread, pongo_thread;
|
||||
@@ -57,25 +61,6 @@ void thr_cleanup(void* ptr) {
|
||||
}
|
||||
|
||||
int build_checks(void) {
|
||||
#ifndef NO_CHECKRAIN
|
||||
#if defined(__APPLE__)
|
||||
struct mach_header_64* c1_header = (struct mach_header_64*)&checkra1n[0];
|
||||
if (c1_header->magic != MH_MAGIC_64 && c1_header->magic != MH_CIGAM_64) {
|
||||
LOG(LOG_FATAL, "Broken build: checkra1n is not a thin Mach-O");
|
||||
return -1;
|
||||
}
|
||||
if (c1_header->cputype != _mh_execute_header.cputype) {
|
||||
LOG(LOG_FATAL, "Broken build: checkra1n CPU type does not match palera1n CPU type");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
if (checkra1n_len <= (UCHAR_MAX + 1)) {
|
||||
LOG(LOG_FATAL, "checkra1n too small");
|
||||
}
|
||||
if (boyermoore_horspool_memmem(&checkra1n[0], checkra1n_len, (const unsigned char *)"[ra1npoc15-part] thanks to", strlen("[ra1npoc15-part] thanks to")) != NULL) {
|
||||
host_flags |= palerain_option_checkrain_is_clone;
|
||||
}
|
||||
#endif
|
||||
#ifndef NO_KPF
|
||||
struct mach_header_64 *kpf_hdr = (struct mach_header_64 *)checkra1n_kpf_pongo;
|
||||
if (kpf_hdr->magic != MH_MAGIC_64 && kpf_hdr->magic != MH_CIGAM_64) {
|
||||
@@ -111,9 +96,9 @@ int palera1n(int argc, char *argv[]) {
|
||||
pthread_mutex_init(&ecid_dfu_wait_mutex, NULL);
|
||||
if ((ret = build_checks())) return ret;
|
||||
if ((ret = optparse(argc, argv))) goto cleanup;
|
||||
if (!checkrain_options_enabled(host_flags, host_option_device_info) && checkrain_options_enabled(host_flags, host_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 (checkrain_options_enabled(host_flags, host_option_tui)) {
|
||||
if ((palerain_flags & palerain_option_tui)) {
|
||||
ret = tui();
|
||||
if (ret) goto cleanup;
|
||||
else goto normal_exit;
|
||||
@@ -133,7 +118,7 @@ int palera1n(int argc, char *argv[]) {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!checkrain_options_enabled(host_flags, host_option_device_info))
|
||||
if (!(palerain_flags & palerain_option_device_info))
|
||||
LOG(LOG_INFO, "Waiting for devices");
|
||||
|
||||
if (access("/var/run/usbmuxd", F_OK) != 0)
|
||||
@@ -143,16 +128,16 @@ int palera1n(int argc, char *argv[]) {
|
||||
pthread_create(&dfuhelper_thread, NULL, dfuhelper, NULL);
|
||||
pthread_join(dfuhelper_thread, NULL);
|
||||
set_spin(0);
|
||||
if (checkrain_options_enabled(host_flags, host_option_dfuhelper_only |
|
||||
host_option_reboot_device |
|
||||
host_option_exit_recovery |
|
||||
host_option_enter_recovery |
|
||||
host_option_device_info
|
||||
if ((palerain_flags & (palerain_option_dfuhelper_only |
|
||||
palerain_option_reboot_device |
|
||||
palerain_option_exit_recovery |
|
||||
palerain_option_enter_recovery |
|
||||
palerain_option_device_info)
|
||||
) || device_has_booted)
|
||||
goto normal_exit;
|
||||
if (exec_checkra1n()) goto cleanup;
|
||||
if (exec_checkm8()) goto cleanup;
|
||||
|
||||
if (checkrain_options_enabled(host_flags, host_option_pongo_exit | host_option_demote))
|
||||
if ((palerain_flags & (palerain_option_pongo_exit | palerain_option_demote)))
|
||||
goto normal_exit;
|
||||
set_spin(1);
|
||||
sleep(2);
|
||||
@@ -165,18 +150,23 @@ int palera1n(int argc, char *argv[]) {
|
||||
normal_exit:
|
||||
cleanup:
|
||||
if (override_kpf.magic == OVERRIDE_MAGIC) {
|
||||
#ifndef WIN
|
||||
munmap(override_kpf.ptr, (size_t)override_kpf.len);
|
||||
#endif
|
||||
close(override_kpf.fd);
|
||||
}
|
||||
if (override_ramdisk.magic == OVERRIDE_MAGIC) {
|
||||
#ifndef WIN
|
||||
munmap(override_ramdisk.ptr, (size_t)override_ramdisk.len);
|
||||
#endif
|
||||
close(override_ramdisk.fd);
|
||||
}
|
||||
if (override_overlay.magic == OVERRIDE_MAGIC) {
|
||||
#ifndef WIN
|
||||
munmap(override_overlay.ptr, (size_t)override_overlay.len);
|
||||
#endif
|
||||
close(override_overlay.fd);
|
||||
}
|
||||
if (ext_checkra1n != NULL) free(ext_checkra1n);
|
||||
pthread_mutex_destroy(&log_mutex);
|
||||
pthread_mutex_destroy(&spin_mutex);
|
||||
pthread_mutex_destroy(&found_pongo_mutex);
|
||||
@@ -184,7 +174,6 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char* argv[]) {
|
||||
return palera1n(argc, argv);
|
||||
}
|
||||
+54
-101
@@ -12,15 +12,18 @@
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <palerain.h>
|
||||
#ifndef WIN
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#include <inttypes.h>
|
||||
|
||||
checkrain_option_t host_flags = 0;
|
||||
checkrain_option_p host_flags_p = &host_flags;
|
||||
uint64_t* palerain_flags_p = &palerain_flags;
|
||||
static bool force_use_verbose_boot = false;
|
||||
|
||||
static struct option longopts[] = {
|
||||
{"setup-partial-fakefs", no_argument, NULL, 'B'},
|
||||
{"setup-fakefs", no_argument, NULL, 'c'},
|
||||
{"clean-fakefs", no_argument, NULL, 'c'},
|
||||
{"dfuhelper", no_argument, NULL, 'D'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"pongo-shell", no_argument, NULL, 'p'},
|
||||
@@ -30,7 +33,6 @@ static struct option longopts[] = {
|
||||
{"boot-args", required_argument, NULL, 'e'},
|
||||
{"fakefs", no_argument, NULL, 'f'},
|
||||
{"rootless", no_argument, NULL, 'l'},
|
||||
{"jbinit-log-to-file", no_argument, NULL, 'L'},
|
||||
{"demote", no_argument, NULL, 'd'},
|
||||
{"force-revert", no_argument, NULL, palerain_option_case_force_revert},
|
||||
{"no-colors", no_argument, NULL, 'S'},
|
||||
@@ -40,7 +42,6 @@ static struct option longopts[] = {
|
||||
{"override-overlay", required_argument, NULL, 'o'},
|
||||
{"override-ramdisk", required_argument, NULL, 'r'},
|
||||
{"override-kpf", required_argument, NULL, 'K'},
|
||||
{"override-checkra1n", required_argument, NULL, 'i'},
|
||||
{"reboot-device", no_argument, NULL, 'R'},
|
||||
{"exit-recovery", no_argument, NULL, 'n'},
|
||||
{"enter-recovery", no_argument, NULL, 'E'},
|
||||
@@ -59,19 +60,19 @@ static int usage(int e, char* prog_name)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: %s [-"
|
||||
"DEhpvVldsSLRnPI"
|
||||
"DEhpvVdsSLRnPI"
|
||||
#ifdef DEV_BUILD
|
||||
"12"
|
||||
#endif
|
||||
#ifdef ROOTFUL
|
||||
"cfB"
|
||||
"cCfBl"
|
||||
#endif
|
||||
#ifdef TUI
|
||||
"t"
|
||||
#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]\n"
|
||||
"Copyright (C) 2023, palera1n team, All Rights Reserved.\n\n"
|
||||
"iOS/iPadOS 15.0-16.4.1 arm64 jailbreaking tool\n\n"
|
||||
"iOS/iPadOS 15.0-16.5.1 arm64 jailbreaking tool\n\n"
|
||||
"\t--version\t\t\t\tPrint version\n"
|
||||
"\t--force-revert\t\t\t\tRemove jailbreak\n"
|
||||
#ifdef DEV_BUILD
|
||||
@@ -81,6 +82,7 @@ static int usage(int e, char* prog_name)
|
||||
#ifdef ROOTFUL
|
||||
"\t-B, --setup-partial-fakefs\t\tSetup partial fakefs\n"
|
||||
"\t-c, --setup-fakefs\t\t\tSetup fakefs\n"
|
||||
"\t-C, --clean-fakefs\t\t\tClean fakefs\n"
|
||||
#endif
|
||||
"\t-d, --demote\t\t\t\tDemote\n"
|
||||
"\t-D, --dfuhelper\t\t\t\tExit after entering DFU\n"
|
||||
@@ -90,10 +92,11 @@ static int usage(int e, char* prog_name)
|
||||
"\t-f, --fakefs \t\t\t\tBoots fakefs\n"
|
||||
#endif
|
||||
"\t-h, --help\t\t\t\tShow this help\n"
|
||||
"\t-i, --override-checkra1n <file>\t\tOverride checkra1n\n"
|
||||
"\t-k, --override-pongo <file>\t\tOverride Pongo image\n"
|
||||
"\t-K, --override-kpf <file>\t\tOverride kernel patchfinder\n"
|
||||
#ifdef ROOTFUL
|
||||
"\t-l, --rootless\t\t\t\tBoots rootless. This is the default\n"
|
||||
#endif
|
||||
"\t-L, --jbinit-log-to-file\t\tMake jbinit log to /cores/jbinit.log (can be read from sandbox while jailbroken)\n"
|
||||
"\t-n, --exit-recovery\t\t\tExit recovery mode\n"
|
||||
"\t-I, --device-info\t\t\tPrint info about the connected device\n"
|
||||
@@ -122,31 +125,34 @@ int optparse(int argc, char* argv[]) {
|
||||
int opt;
|
||||
int index;
|
||||
while ((opt = getopt_long(argc, argv,
|
||||
"DEhpvVldsSLtRnPIe:o:r:K:k:i:"
|
||||
"DEhpvVlLdsStRnPIe:o:r:K:k:i:"
|
||||
#ifdef DEV_BUILD
|
||||
"12"
|
||||
#endif
|
||||
"fcB"
|
||||
"fCcB"
|
||||
,longopts, NULL)) != -1)
|
||||
{
|
||||
switch (opt) {
|
||||
case 'B':
|
||||
palerain_flags |= palerain_option_setup_partial_root;
|
||||
palerain_flags |= palerain_option_setup_rootful;
|
||||
kpf_flags |= checkrain_option_verbose_boot;
|
||||
palerain_flags |= palerain_option_verbose_boot;
|
||||
break;
|
||||
case 'c':
|
||||
palerain_flags |= palerain_option_setup_rootful;
|
||||
kpf_flags |= checkrain_option_verbose_boot;
|
||||
palerain_flags |= palerain_option_verbose_boot;
|
||||
break;
|
||||
case 'C':
|
||||
palerain_flags |= palerain_option_clean_fakefs;
|
||||
break;
|
||||
case 'p':
|
||||
host_flags |= host_option_pongo_exit;
|
||||
palerain_flags |= palerain_option_pongo_exit;
|
||||
break;
|
||||
case 'P':
|
||||
host_flags |= host_option_pongo_full;
|
||||
palerain_flags |= palerain_option_pongo_full;
|
||||
break;
|
||||
case 'D':
|
||||
host_flags |= host_option_dfuhelper_only;
|
||||
palerain_flags |= palerain_option_dfuhelper_only;
|
||||
break;
|
||||
case 'h':
|
||||
usage(0, argv[0]);
|
||||
@@ -155,7 +161,7 @@ int optparse(int argc, char* argv[]) {
|
||||
verbose++;
|
||||
break;
|
||||
case 'V':
|
||||
kpf_flags |= checkrain_option_verbose_boot;
|
||||
palerain_flags |= palerain_option_verbose_boot;
|
||||
force_use_verbose_boot = true;
|
||||
break;
|
||||
case 'e':
|
||||
@@ -169,32 +175,24 @@ int optparse(int argc, char* argv[]) {
|
||||
snprintf(xargs_cmd, sizeof(xargs_cmd), "xargs %s", optarg);
|
||||
break;
|
||||
case 'f':
|
||||
snprintf(rootfs_cmd, sizeof(rootfs_cmd), "rootfs %s", optarg);
|
||||
snprintf(dtpatch_cmd, 0x20, "dtpatch %s", optarg);
|
||||
palerain_flags |= palerain_option_rootful;
|
||||
palerain_flags &= ~palerain_option_rootless;
|
||||
break;
|
||||
case 'l':
|
||||
palerain_flags &= ~palerain_option_rootful;
|
||||
palerain_flags |= palerain_option_rootless;
|
||||
break;
|
||||
case 'L':
|
||||
palerain_flags |= palerain_option_jbinit_log_to_file;
|
||||
break;
|
||||
case 'd':
|
||||
host_flags |= host_option_demote;
|
||||
palerain_flags |= palerain_option_demote;
|
||||
break;
|
||||
case 'E':
|
||||
host_flags |= host_option_enter_recovery;
|
||||
palerain_flags |= palerain_option_enter_recovery;
|
||||
break;
|
||||
case 's':
|
||||
checkrain_flags |= checkrain_option_safemode;
|
||||
break;
|
||||
case 'k':
|
||||
if (access(optarg, F_OK) != 0) {
|
||||
LOG(LOG_FATAL, "Cannot access pongo file at %s: %d (%s)", optarg, errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
pongo_path = malloc(strlen(optarg) + 1);
|
||||
strcpy(pongo_path, optarg);
|
||||
palerain_flags |= palerain_option_safemode;
|
||||
break;
|
||||
case 'o':
|
||||
if (override_file(&override_overlay, overlay_to_upload, &binpack_dmg_len, optarg))
|
||||
@@ -219,62 +217,21 @@ int optparse(int argc, char* argv[]) {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case 'i': {};
|
||||
struct stat st;
|
||||
if (stat(optarg, &st) != 0) {
|
||||
LOG(LOG_FATAL, "cannot stat external checkra1n file: %d (%s)", errno, strerror(errno));
|
||||
return -1;
|
||||
} else if (!(st.st_mode & S_IXUSR) && !(st.st_mode & S_IXGRP) && !(st.st_mode & S_IXOTH)) {
|
||||
LOG(LOG_FATAL, "%s is not executable", optarg);
|
||||
return -1;
|
||||
} else if (!S_ISREG(st.st_mode)) {
|
||||
LOG(LOG_FATAL, "%s is not a regular file", optarg);
|
||||
return -1;
|
||||
}
|
||||
if (st.st_size < (UCHAR_MAX+1)) {
|
||||
LOG(LOG_FATAL, "%s too small", optarg);
|
||||
return -1;
|
||||
}
|
||||
int checkra1n_fd = open(optarg, O_RDONLY);
|
||||
if (checkra1n_fd == -1) {
|
||||
LOG(LOG_FATAL, "Cannot open %s: %d (%s)", optarg, errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
void* addr = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, checkra1n_fd, 0);
|
||||
if (addr == MAP_FAILED) {
|
||||
LOG(LOG_ERROR, "Failed to map file %s: %d (%s)", optarg, errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (boyermoore_horspool_memmem(addr, st.st_size, (const unsigned char*)"[ra1npoc15-part] thanks to", strlen("[ra1npoc15-part] thanks to")) != NULL)
|
||||
{
|
||||
host_flags |= palerain_option_checkrain_is_clone;
|
||||
LOG(LOG_VERBOSE3, "%s is checkra1n clone", optarg);
|
||||
}
|
||||
else
|
||||
{
|
||||
host_flags &= ~palerain_option_checkrain_is_clone;
|
||||
LOG(LOG_VERBOSE3, "%s is checkra1n", optarg);
|
||||
}
|
||||
munmap(addr, st.st_size);
|
||||
close(checkra1n_fd);
|
||||
ext_checkra1n = calloc(1, strlen(optarg) + 1);
|
||||
snprintf(ext_checkra1n, strlen(optarg) + 1, "%s", optarg);
|
||||
break;
|
||||
case 'R':
|
||||
host_flags |= host_option_reboot_device;
|
||||
palerain_flags |= palerain_option_reboot_device;
|
||||
break;
|
||||
case 'n':
|
||||
host_flags |= host_option_exit_recovery;
|
||||
palerain_flags |= palerain_option_exit_recovery;
|
||||
break;
|
||||
case 'I':
|
||||
host_flags |= host_option_device_info;
|
||||
palerain_flags |= palerain_option_device_info;
|
||||
break;
|
||||
case 'S':
|
||||
host_flags |= host_option_no_colors;
|
||||
palerain_flags |= palerain_option_no_colors;
|
||||
break;
|
||||
#ifdef TUI
|
||||
case 't':
|
||||
host_flags |= host_option_tui;
|
||||
palerain_flags |= palerain_option_tui;
|
||||
break;
|
||||
#endif
|
||||
#ifdef DEV_BUILD
|
||||
@@ -286,17 +243,17 @@ int optparse(int argc, char* argv[]) {
|
||||
break;
|
||||
#endif
|
||||
case palerain_option_case_force_revert:
|
||||
checkrain_flags |= checkrain_option_force_revert;
|
||||
palerain_flags |= palerain_option_force_revert;
|
||||
break;
|
||||
case palerain_option_case_version:
|
||||
host_flags |= host_option_palerain_version;
|
||||
palerain_flags |= palerain_option_palerain_version;
|
||||
break;
|
||||
default:
|
||||
usage(1, argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (checkrain_options_enabled(host_flags, host_option_palerain_version)) {
|
||||
if ((palerain_flags & palerain_option_palerain_version)) {
|
||||
printf(
|
||||
"palera1n " PALERAIN_VERSION "\n"
|
||||
BUILD_COMMIT " " BUILD_NUMBER " (" BUILD_BRANCH ")\n\n"
|
||||
@@ -314,17 +271,12 @@ int optparse(int argc, char* argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((strstr(xargs_cmd, "serial=") != NULL) && !force_use_verbose_boot && checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful)) {
|
||||
kpf_flags &= ~checkrain_option_verbose_boot;
|
||||
if ((strstr(xargs_cmd, "serial=") != NULL) && !force_use_verbose_boot && (palerain_flags & palerain_option_setup_rootful)) {
|
||||
palerain_flags &= ~palerain_option_verbose_boot;
|
||||
}
|
||||
|
||||
snprintf(checkrain_flags_cmd, 0x20, "checkra1n_flags 0x%x", checkrain_flags);
|
||||
snprintf(palerain_flags_cmd, 0x20, "palera1n_flags 0x%x", palerain_flags);
|
||||
snprintf(kpf_flags_cmd, 0x20, "kpf_flags 0x%x", kpf_flags);
|
||||
LOG(LOG_VERBOSE3, "checkrain_flags: %s", checkrain_flags_cmd);
|
||||
snprintf(palerain_flags_cmd, 0x30, "palera1n_flags 0x%" PRIx64, palerain_flags);
|
||||
LOG(LOG_VERBOSE3, "palerain_flags: %s", palerain_flags_cmd);
|
||||
LOG(LOG_VERBOSE3, "kpf_flags: %s", kpf_flags_cmd);
|
||||
LOG(LOG_VERBOSE3, "host_flags: 0x%x", host_flags);
|
||||
if (override_kpf.magic == OVERRIDE_MAGIC) {
|
||||
LOG(LOG_VERBOSE4, "kpf override length %u -> %u", override_kpf.orig_len, checkra1n_kpf_pongo_len);
|
||||
LOG(LOG_VERBOSE4, "kpf override ptr %p -> %p", override_kpf.orig_ptr, **kpf_to_upload);
|
||||
@@ -338,25 +290,19 @@ int optparse(int argc, char* argv[]) {
|
||||
LOG(LOG_VERBOSE4, "overlay override ptr %p -> %p", override_overlay.orig_ptr, **overlay_to_upload);
|
||||
}
|
||||
|
||||
if (!checkrain_options_enabled(palerain_flags, palerain_option_rootful)) {
|
||||
if (checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful) || checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful_forced)) {
|
||||
if (!(palerain_flags & palerain_option_rootful)) {
|
||||
if ((palerain_flags & palerain_option_setup_rootful)) {
|
||||
LOG(LOG_FATAL, "Cannot setup rootful when rootless is requested. Use -f to enable rootful mode.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (!(
|
||||
checkrain_options_enabled(host_flags, host_option_dfuhelper_only) ||
|
||||
checkrain_options_enabled(host_flags, host_option_enter_recovery) ||
|
||||
checkrain_options_enabled(host_flags, host_option_exit_recovery) ||
|
||||
checkrain_options_enabled(host_flags, host_option_reboot_device)))
|
||||
(palerain_flags & palerain_option_dfuhelper_only) ||
|
||||
(palerain_flags & palerain_option_enter_recovery) ||
|
||||
(palerain_flags & palerain_option_exit_recovery) ||
|
||||
(palerain_flags & palerain_option_reboot_device)))
|
||||
{
|
||||
#ifdef NO_CHECKRAIN
|
||||
if (checkra1n_len == 0 && ext_checkra1n == NULL)
|
||||
{
|
||||
LOG(LOG_FATAL, "checkra1n omitted in build but no override specified");
|
||||
return -1;
|
||||
}
|
||||
if (!(checkrain_options_enabled(host_flags, host_option_pongo_exit) || checkrain_options_enabled(host_flags, host_option_pongo_exit)))
|
||||
if (!((palerain_flags & palerain_option_pongo_exit) || (palerain_flags & palerain_option_pongo_exit)))
|
||||
{
|
||||
#ifdef NO_KPF
|
||||
if (checkra1n_kpf_pongo_len == 0)
|
||||
@@ -366,7 +312,6 @@ int optparse(int argc, char* argv[]) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
for (index = optind; index < argc; index++)
|
||||
@@ -384,19 +329,27 @@ int optparse(int argc, char* argv[]) {
|
||||
usage(1, argv[0]);
|
||||
}
|
||||
}
|
||||
#ifndef WIN
|
||||
if (verbose >= 2) setenv("LIBUSB_DEBUG", "1", 1);
|
||||
#endif
|
||||
|
||||
if (verbose >= 3)
|
||||
{
|
||||
libusbmuxd_set_debug_level(verbose - 2);
|
||||
irecv_set_debug_level(1);
|
||||
#ifndef WIN
|
||||
setenv("LIBUSB_DEBUG", "2", 1);
|
||||
#endif
|
||||
}
|
||||
if (verbose >= 4) {
|
||||
idevice_set_debug_level(1);
|
||||
#ifndef WIN
|
||||
setenv("LIBUSB_DEBUG", "3", 1);
|
||||
#endif
|
||||
}
|
||||
#ifndef WIN
|
||||
if (verbose >= 5)
|
||||
setenv("LIBUSB_DEBUG", "4", 1);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -11,7 +11,12 @@
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
#ifndef WIN
|
||||
#include <sys/mman.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
@@ -31,11 +36,19 @@ int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *
|
||||
return errno;
|
||||
}
|
||||
LOG(LOG_VERBOSE5, "override_file: fstat fd %d succeeded!", fd);
|
||||
#ifdef WIN
|
||||
void *addr = VirtualAlloc(NULL, st.st_size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
if (addr == NULL) {
|
||||
LOG(LOG_ERROR, "Failed to map file %s: %d (%s)", filename, errno, strerror(errno));
|
||||
return errno;
|
||||
}
|
||||
#else
|
||||
void *addr = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (addr == MAP_FAILED) {
|
||||
LOG(LOG_ERROR, "Failed to map file %s: %d (%s)", filename, errno, strerror(errno));
|
||||
return errno;
|
||||
}
|
||||
#endif
|
||||
LOG(LOG_VERBOSE5, "override_file: Override file mapped successfully");
|
||||
finfo->magic = OVERRIDE_MAGIC;
|
||||
finfo->fd = fd;
|
||||
|
||||
+8
-8
@@ -7,8 +7,10 @@
|
||||
#include <stdlib.h> // exit, strtoull
|
||||
#include <string.h> // strlen, strerror, memcpy, memmove
|
||||
#include <unistd.h> // close
|
||||
#ifndef WIN
|
||||
#include <sys/mman.h> // mmap, munmap
|
||||
#include <sys/stat.h> // fstst
|
||||
#endif
|
||||
|
||||
#include <palerain.h>
|
||||
#include <ANSI-color-codes.h>
|
||||
@@ -33,7 +35,7 @@ void *pongo_usb_callback(stuff_t *arg) {
|
||||
if (get_found_pongo())
|
||||
return NULL;
|
||||
set_found_pongo(1);
|
||||
if (checkrain_options_enabled(palerain_flags, palerain_option_setup_rootful)) {
|
||||
if ((palerain_flags & palerain_option_setup_rootful)) {
|
||||
strncat(xargs_cmd, " wdt=-1", 0x270 - strlen(xargs_cmd) - 1);
|
||||
}
|
||||
LOG(LOG_INFO, "Found PongoOS USB Device");
|
||||
@@ -43,10 +45,8 @@ void *pongo_usb_callback(stuff_t *arg) {
|
||||
issue_pongo_command(handle, "sep auto");
|
||||
upload_pongo_file(handle, **kpf_to_upload, checkra1n_kpf_pongo_len);
|
||||
issue_pongo_command(handle, "modload");
|
||||
issue_pongo_command(handle, kpf_flags_cmd);
|
||||
issue_pongo_command(handle, checkrain_flags_cmd);
|
||||
issue_pongo_command(handle, palerain_flags_cmd);
|
||||
if (checkrain_options_enabled(palerain_flags, palerain_option_rootful))
|
||||
if ((palerain_flags & palerain_option_rootful))
|
||||
{
|
||||
issue_pongo_command(handle, "rootfs");
|
||||
}
|
||||
@@ -66,13 +66,13 @@ void *pongo_usb_callback(stuff_t *arg) {
|
||||
issue_pongo_command(handle, "overlay");
|
||||
}
|
||||
issue_pongo_command(handle, xargs_cmd);
|
||||
if (checkrain_options_enabled(host_flags, host_option_pongo_full)) goto done;
|
||||
if ((palerain_flags & palerain_option_pongo_full)) goto done;
|
||||
issue_pongo_command(handle, "bootx");
|
||||
LOG(LOG_INFO, "Booting Kernel...");
|
||||
if (checkrain_options_enabled(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, "Once the device boots up to iOS, run again without the -B (Create BindFS) option to jailbreak.");
|
||||
} else if (checkrain_options_enabled(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, "Once the device boots up to iOS, run again without the -c (Create FakeFS) option to jailbreak.");
|
||||
}
|
||||
@@ -163,7 +163,7 @@ int upload_pongo_file(usb_device_handle_t handle, unsigned char *buf, unsigned i
|
||||
if (verbose < 3 || verbose > 4) {
|
||||
LOG(LOG_VERBOSE, "Uploaded %llu bytes to PongoOS", (unsigned long long)buf_len);
|
||||
} else {
|
||||
if (checkrain_options_enabled(host_flags, host_option_no_colors))
|
||||
if ((palerain_flags & palerain_option_no_colors))
|
||||
printf("/send mem:%p:%p\nUploaded %llu bytes]\n", (void*)buf, (void*)(buf + buf_len), (unsigned long long)buf_len);
|
||||
else
|
||||
printf("/send mem:%p:%p\n" BCYN "[Uploaded %llu bytes]\n" CRESET, (void*)buf, (void*)(buf + buf_len), (unsigned long long)buf_len);
|
||||
|
||||
+4
-4
@@ -12,15 +12,15 @@
|
||||
#include <palerain.h>
|
||||
#include <tui.h>
|
||||
|
||||
int redraw_screen() {
|
||||
int redraw_screen(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int destroy_window() {
|
||||
int destroy_window(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int init_window() {
|
||||
int init_window(void) {
|
||||
setlocale(LC_ALL, NULL);
|
||||
setenv(
|
||||
"NEWT_COLORS",
|
||||
@@ -61,7 +61,7 @@ int init_window() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tui() {
|
||||
int tui(void) {
|
||||
int ret = 0;
|
||||
if ((ret = init_window())) return ret;
|
||||
ret = MAIN_SCREEN;
|
||||
|
||||
@@ -12,4 +12,4 @@
|
||||
#include <palerain.h>
|
||||
#include <tui.h>
|
||||
|
||||
tui_screen_t tui_screen_enter_dfu() { return JAILBREAKING_SCREEN; }
|
||||
tui_screen_t tui_screen_enter_dfu(void) { return JAILBREAKING_SCREEN; }
|
||||
@@ -12,4 +12,4 @@
|
||||
#include <palerain.h>
|
||||
#include <tui.h>
|
||||
|
||||
tui_screen_t tui_screen_enter_recovery() { return ENTER_DFU_SCREEN; }
|
||||
tui_screen_t tui_screen_enter_recovery(void) { return ENTER_DFU_SCREEN; }
|
||||
@@ -12,4 +12,4 @@
|
||||
#include <palerain.h>
|
||||
#include <tui.h>
|
||||
|
||||
tui_screen_t tui_screen_jailbreak() { return EXIT_SCREEN; }
|
||||
tui_screen_t tui_screen_jailbreak(void) { return EXIT_SCREEN; }
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <palerain.h>
|
||||
#include <tui.h>
|
||||
|
||||
tui_screen_t tui_screen_main() {
|
||||
tui_screen_t tui_screen_main(void) {
|
||||
int ret = MAIN_SCREEN;
|
||||
bool can_start = false;
|
||||
newtCenteredWindow(WIDTH, HEIGHT, NULL);
|
||||
|
||||
@@ -21,16 +21,14 @@ void bitfield_check_cb(newtComponent box, void* data) {
|
||||
}
|
||||
|
||||
|
||||
tui_screen_t tui_screen_options() {
|
||||
tui_bit_info_t verbose_info = { &kpf_flags, checkrain_option_verbose_boot };
|
||||
tui_screen_t tui_screen_options(void) {
|
||||
tui_bit_info_t verbose_info = { &palerain_flags, palerain_option_verbose_boot };
|
||||
tui_bit_info_t rootful_info = { &palerain_flags, palerain_option_rootful };
|
||||
tui_bit_info_t setup_rootful_info = { &palerain_flags, palerain_option_setup_rootful };
|
||||
tui_bit_info_t force_revert_info = { &checkrain_flags, checkrain_option_force_revert };
|
||||
tui_bit_info_t safemode_info = { &checkrain_flags, checkrain_option_safemode };
|
||||
tui_bit_info_t force_revert_info = { &palerain_flags, palerain_option_force_revert };
|
||||
tui_bit_info_t safemode_info = { &palerain_flags, palerain_option_safemode };
|
||||
tui_bit_info_t flower_chain_info = { &palerain_flags, palerain_option_flower_chain };
|
||||
|
||||
static checkrain_option_t flower_flags = 0, flower_option_flower_chain = (1 << 0);
|
||||
tui_bit_info_t flower_chain_info = { &flower_flags, flower_option_flower_chain };
|
||||
|
||||
const char* bootargs_entered = NULL;
|
||||
int ret = MAIN_SCREEN;
|
||||
|
||||
@@ -41,11 +39,11 @@ tui_screen_t tui_screen_options() {
|
||||
newtTextboxSetText(optionsNotice, "You may set the following options. If you don't know what they mean you'll probably have no reason to set them.");
|
||||
// newtTextboxSetColors(optionsNotice, NEWT_COLORSET_LABEL, NEWT_COLORSET_LABEL);
|
||||
|
||||
newtComponent verboseBootBox = newtCheckbox(1, 3, "Verbose boot", CHECKBOX_STATE(kpf_flags, checkrain_option_verbose_boot), NULL, NULL);
|
||||
newtComponent verboseBootBox = newtCheckbox(1, 3, "Verbose boot", CHECKBOX_STATE(palerain_flags, palerain_option_verbose_boot), NULL, NULL);
|
||||
newtComponent rootfulBox = newtCheckbox(1, 4, "Rootful", CHECKBOX_STATE(palerain_flags, palerain_option_rootful), NULL, NULL);
|
||||
newtComponent rootfulSetupBox = newtCheckbox(1, 5, "Setup fakefs", CHECKBOX_STATE(palerain_flags, palerain_option_setup_rootful), NULL, NULL);
|
||||
newtComponent forceRevertBox = newtCheckbox(1, 6, "Restore system", CHECKBOX_STATE(checkrain_flags, checkrain_option_force_revert), NULL, NULL);
|
||||
newtComponent safeModeBox = newtCheckbox(1, 7, "Safe mode", CHECKBOX_STATE(checkrain_flags, checkrain_option_safemode), NULL, NULL);
|
||||
newtComponent forceRevertBox = newtCheckbox(1, 6, "Restore system", CHECKBOX_STATE(palerain_flags, palerain_option_force_revert), NULL, NULL);
|
||||
newtComponent safeModeBox = newtCheckbox(1, 7, "Safe mode", CHECKBOX_STATE(palerain_flags, palerain_option_safemode), NULL, NULL);
|
||||
|
||||
newtComponentAddCallback(verboseBootBox, bitfield_check_cb, &verbose_info);
|
||||
newtComponentAddCallback(rootfulBox, bitfield_check_cb, &rootful_info);
|
||||
@@ -56,7 +54,7 @@ tui_screen_t tui_screen_options() {
|
||||
newtComponent bootCmdlineLabel = newtLabel(1, 8, "Kernel command line:");
|
||||
newtComponent bootCmdlineEntry = newtEntry(1, 9, &xargs_cmd[6], WIDTH - 2, &bootargs_entered, NEWT_ENTRY_SCROLL);
|
||||
|
||||
newtComponent flowerChainBox = newtCheckbox(1, 10, "Flower chain", CHECKBOX_STATE(flower_flags, flower_option_flower_chain), NULL, NULL);
|
||||
newtComponent flowerChainBox = newtCheckbox(1, 10, "Flower chain", CHECKBOX_STATE(palerain_flags, palerain_option_flower_chain), NULL, NULL);
|
||||
newtComponentAddCallback(flowerChainBox, bitfield_check_cb, &flower_chain_info);
|
||||
|
||||
|
||||
|
||||
+53
-52
@@ -34,8 +34,10 @@
|
||||
#include <stdlib.h> // exit, strtoull
|
||||
#include <string.h> // strlen, strerror, memcpy, memmove
|
||||
#include <unistd.h> // close
|
||||
#ifndef WIN
|
||||
#include <sys/mman.h> // mmap, munmap
|
||||
#include <sys/stat.h> // fstst
|
||||
#endif
|
||||
|
||||
#include <palerain.h>
|
||||
#define ERR(...) LOG(LOG_ERROR, __VA_ARGS__)
|
||||
@@ -114,12 +116,12 @@ usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, int len)
|
||||
|
||||
static int FoundDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_event event, void *arg)
|
||||
{
|
||||
LOG(LOG_VERBOSE, "PongoOS USB Device connected");
|
||||
stuff_t *stuff = arg;
|
||||
if(stuff->handle)
|
||||
{
|
||||
return LIBUSB_SUCCESS;
|
||||
}
|
||||
LOG(LOG_VERBOSE, "PongoOS USB Device connected");
|
||||
|
||||
libusb_device_handle *handle;
|
||||
int r = libusb_open(dev, &handle);
|
||||
@@ -162,12 +164,12 @@ static int FoundDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_e
|
||||
|
||||
static int LostDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_event event, void *arg)
|
||||
{
|
||||
LOG(LOG_VERBOSE, "PongoOS USB Device disconnected");
|
||||
stuff_t *stuff = arg;
|
||||
if(stuff->dev != dev)
|
||||
{
|
||||
return LIBUSB_SUCCESS;
|
||||
}
|
||||
LOG(LOG_VERBOSE, "PongoOS USB Device disconnected");
|
||||
|
||||
io_stop(stuff);
|
||||
libusb_close(stuff->handle);
|
||||
@@ -181,6 +183,7 @@ static int LostDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_ev
|
||||
int wait_for_pongo(void)
|
||||
{
|
||||
stuff_t stuff;
|
||||
stuff.handle = NULL;
|
||||
libusb_hotplug_callback_handle hp[2];
|
||||
libusb_context* ctx = NULL;
|
||||
|
||||
@@ -198,14 +201,6 @@ int wait_for_pongo(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
r = libusb_hotplug_register_callback(ctx, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, 0, PONGO_USB_VENDOR, PONGO_USB_PRODUCT, LIBUSB_HOTPLUG_MATCH_ANY, FoundDevice, &stuff, &hp[0]);
|
||||
if(r != LIBUSB_SUCCESS)
|
||||
{
|
||||
ERR("libusb_hotplug: %s", libusb_error_name(r));
|
||||
libusb_exit(ctx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
r = libusb_hotplug_register_callback(ctx, LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT, 0, PONGO_USB_VENDOR, PONGO_USB_PRODUCT, LIBUSB_HOTPLUG_MATCH_ANY, LostDevice, &stuff, &hp[1]);
|
||||
if(r != LIBUSB_SUCCESS)
|
||||
{
|
||||
@@ -214,55 +209,61 @@ int wait_for_pongo(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
libusb_device **list;
|
||||
ssize_t sz = libusb_get_device_list(ctx, &list);
|
||||
if(sz < 0)
|
||||
{
|
||||
ERR("libusb_get_device_list: %s", libusb_error_name((int)sz));
|
||||
libusb_exit(ctx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(ssize_t i = 0; i < sz; ++i)
|
||||
{
|
||||
struct libusb_device_descriptor desc;
|
||||
r = libusb_get_device_descriptor(list[i], &desc);
|
||||
if(r != LIBUSB_SUCCESS)
|
||||
{
|
||||
ERR("libusb_get_device_descriptor: %s", libusb_error_name(r));
|
||||
// continue anyway
|
||||
}
|
||||
if(desc.idVendor != PONGO_USB_VENDOR || desc.idProduct != PONGO_USB_PRODUCT)
|
||||
{
|
||||
libusb_unref_device(list[i]);
|
||||
continue;
|
||||
}
|
||||
r = FoundDevice(ctx, list[i], LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, &stuff);
|
||||
for(ssize_t j = i + 1; j < sz; ++j)
|
||||
{
|
||||
libusb_unref_device(list[j]);
|
||||
}
|
||||
if(r != LIBUSB_SUCCESS)
|
||||
{
|
||||
libusb_free_device_list(list, 0);
|
||||
libusb_exit(ctx);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
libusb_free_device_list(list, 0);
|
||||
|
||||
while(get_spin())
|
||||
{
|
||||
while (1) {
|
||||
r = libusb_handle_events(ctx);
|
||||
if(r != LIBUSB_SUCCESS)
|
||||
{
|
||||
ERR("libusb_handle_events: %s", libusb_error_name(r));
|
||||
break;
|
||||
}
|
||||
|
||||
libusb_device **list;
|
||||
ssize_t sz = libusb_get_device_list(ctx, &list);
|
||||
bool done = false;
|
||||
if(sz < 0)
|
||||
{
|
||||
ERR("libusb_get_device_list: %s", libusb_error_name((int)sz));
|
||||
libusb_exit(ctx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(ssize_t i = 0; i < sz; ++i)
|
||||
{
|
||||
struct libusb_device_descriptor desc;
|
||||
r = libusb_get_device_descriptor(list[i], &desc);
|
||||
if(r != LIBUSB_SUCCESS)
|
||||
{
|
||||
ERR("libusb_get_device_descriptor: %s", libusb_error_name(r));
|
||||
// continue anyway
|
||||
}
|
||||
if(desc.idVendor != PONGO_USB_VENDOR || desc.idProduct != PONGO_USB_PRODUCT)
|
||||
{
|
||||
libusb_unref_device(list[i]);
|
||||
continue;
|
||||
}
|
||||
r = FoundDevice(ctx, list[i], LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, &stuff);
|
||||
for (ssize_t j = i; j < sz; ++j) {
|
||||
libusb_unref_device(list[j]);
|
||||
}
|
||||
|
||||
if(r != LIBUSB_SUCCESS)
|
||||
{
|
||||
libusb_free_device_list(list, 0);
|
||||
libusb_exit(ctx);
|
||||
return -1;
|
||||
} else {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
libusb_free_device_list(list, 0);
|
||||
|
||||
if (done) goto end;
|
||||
}
|
||||
|
||||
libusb_exit(ctx);
|
||||
return 0;
|
||||
end:
|
||||
libusb_exit(ctx);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user