build ncurses with more stuff

This commit is contained in:
Nick Chan committed 2023-01-28 20:41:18 +08:00
1 parent 07169da20e
commit bd7da74546
9 files changed
+179 -7

No files matched your search

+10
View File
@@ -133,6 +133,11 @@ jobs:
--with-build-cppflags="${{ env.CPPFLAGS_FOR_BUILD }}" \
--with-build-ldflags="${{ env.LDFLAGS_FOR_BUILD }}" \
--with-pthread \
--enable-const \
--enable-ext-colors \
--enable-ext-mouse \
--enable-ext-putwin \
--enable-wattr-macros \
--disable-overwrite \
--without-debug \
--without-tests \
@@ -458,6 +463,11 @@ jobs:
--with-build-cpp="cc -E" \
--with-build-cppflags=" " \
--with-build-ldflags=" " \
--enable-const \
--enable-ext-colors \
--enable-ext-mouse \
--enable-ext-putwin \
--enable-wattr-macros \
--with-pthread \
--disable-overwrite \
--without-debug \
+2 -2
View File
@@ -2,7 +2,7 @@ SRC = $(shell pwd)
DEP = $(SRC)/dep_root
STRIP = strip
CC ?= cc
CFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC) -Wall -Wextra -DPALERAIN_VERSION=\"2.0.0\" -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable
CFLAGS += -I$(DEP)/include -I$(DEP)/include/ncursestw -I$(SRC)/include -I$(SRC) -Wall -Wextra -DPALERAIN_VERSION=\"2.0.0\" -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable
LIBS += $(DEP)/lib/libimobiledevice-1.0.a $(DEP)/lib/libirecovery-1.0.a $(DEP)/lib/libusbmuxd-2.0.a $(DEP)/lib/libimobiledevice-glue-1.0.a $(DEP)/lib/libplist-2.0.a -pthread
ifeq ($(TARGET_OS),)
TARGET_OS = $(shell uname -s)
@@ -18,7 +18,7 @@ CFLAGS += -fdata-sections -ffunction-sections
LDFLAGS += -static -no-pie -Wl,--gc-sections
endif
LIBS += $(DEP)/lib/libmbedtls.a $(DEP)/lib/libmbedcrypto.a $(DEP)/lib/libmbedx509.a $(DEP)/lib/libreadline.a
LIBS += $(DEP)/lib/libusb-1.0.a
LIBS += $(DEP)/lib/libusb-1.0.a $(DEP)/lib/libncursestw.a
ifeq ($(DEV_BUILD),1)
CFLAGS += -O0 -g -DDEV_BUILD -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-return=runtime
+7 -1
View File
@@ -21,6 +21,11 @@
#define USB_RET_SUCCESS LIBUSB_SUCCESS
#define USB_RET_NOT_RESPONDING LIBUSB_ERROR_OTHER
#define USB_RET_IO LIBUSB_ERROR_IO
#ifndef PALERAIN_VERSION
#define PALERAIN_VERSION "2.0.0"
#endif
#if defined(__APPLE__)
#include <mach-o/loader.h>
#include <mach-o/ldsyms.h>
@@ -97,7 +102,7 @@ extern int spin, demote;
extern char* pongo_path;
extern bool dfuhelper_only;
extern bool pongo_exit;
extern bool pongo_exit, use_tui;
extern pthread_t dfuhelper_thread, pongo_thread;
extern int pongo_thr_running, dfuhelper_thr_running;
@@ -150,5 +155,6 @@ const char *usb_strerror(usb_ret_t err);
int wait_for_pongo();
int issue_pongo_command();
int upload_pongo_file();
int tui();
int optparse(int argc, char* argv[]);
#endif
+28
View File
@@ -0,0 +1,28 @@
#ifndef TUI_H
#define TUI_H
#define NCURSES_WIDECHAR 1
#include <ncurses.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <inttypes.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <locale.h>
#include <unistd.h>
struct button {
char name[0x10];
};
struct button_list {
uint8_t count;
uint8_t current;
uint8_t height;
struct button buttons[];
};
#endif
File renamed without changes.
+1 -1
View File
@@ -1,7 +1,7 @@
all: palera1n
OBJECTS = main.o dfuhelper.o devhelper.o lockdown_helper.o exec_checkra1n.o
OBJECTS += pongo_usb.o optparse.o override_file.o pongo_helper.o log.o
OBJECTS += pongo_usb.o optparse.o override_file.o pongo_helper.o log.o window.o
OBJECTS += xxd-checkra1n.o xxd-checkra1n-kpf-pongo.o xxd-ramdisk.dmg.o
OBJECTS += xxd-binpack.dmg.o
+6
View File
@@ -81,6 +81,7 @@ int build_checks() {
}
bool dfuhelper_only = false, pongo_exit = false, start_from_pongo = false, palerain_version = false;
bool use_tui = false;
int palera1n(int argc, char *argv[]) {
int ret = 0;
@@ -90,6 +91,11 @@ int palera1n(int argc, char *argv[]) {
if (palerain_version) goto normal_exit;
if (start_from_pongo == true)
goto pongo;
if (use_tui) {
ret = tui();
if (ret) goto cleanup;
else goto normal_exit;
}
LOG(LOG_INFO, "Waiting for devices");
do_pongo_sleep = 1;
pthread_t dfuhelper_thread;
+9 -3
View File
@@ -12,6 +12,7 @@
#include <errno.h>
#include "common.h"
static struct option longopts[] = {
{"setup-fakefs", no_argument, NULL, 'c'},
{"setup-fakefs-forced", no_argument, NULL, 'C'},
@@ -34,13 +35,14 @@ static struct option longopts[] = {
{"override-ramdisk", required_argument, NULL, 'r'},
{"override-kpf", required_argument, NULL, 'K'},
{"disable-ohio", no_argument, NULL, 'O'},
{"tui", no_argument, NULL, 't'},
{NULL, 0, NULL, 0}
};
static int usage(int e, char* prog_name)
{
fprintf(stderr,
"Usage: %s [-cCDhpPvVldsOL] [-e boot arguments] [-f root device] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file]\n"
"Usage: %s [-cCDhpPvVldsOLt] [-e boot arguments] [-f root device] [-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+ arm64 jailbreaking tool\n\n"
"\t--version\t\t\t\tPrint version\n"
@@ -64,7 +66,8 @@ static int usage(int e, char* prog_name)
"\t-o, --override-overlay <file>\t\tOverride overlay\n"
"\t-r, --override-ramdisk <file>\t\tOverride ramdisk\n"
"\t-K, --override-kpf <file>\t\tOverride kernel patchfinder\n"
"\t-O, --disable-ohio\t\t\tDisable Ohio\n",
"\t-O, --disable-ohio\t\t\tDisable Ohio\n"
"\t-t, --tui\t\t\t\tTerminal user interface\n",
prog_name);
exit(e);
}
@@ -72,7 +75,7 @@ static int usage(int e, char* prog_name)
int optparse(int argc, char* argv[]) {
int opt;
int index;
while ((opt = getopt_long(argc, argv, "cCDhpvVldsOLe:f:o:r:K:k:", longopts, NULL)) != -1)
while ((opt = getopt_long(argc, argv, "cCDhpvVldsOLte:f:o:r:K:k:", longopts, NULL)) != -1)
{
switch (opt) {
case 'c':
@@ -163,6 +166,9 @@ int optparse(int argc, char* argv[]) {
case 'O':
ohio = false;
break;
case 't':
use_tui = true;
break;
case checkrain_option_force_revert:
checkrain_flags |= checkrain_option_force_revert;
break;
+116
View File
@@ -0,0 +1,116 @@
#define NCURSES_WIDECHAR 1
#include <ncursestw/ncurses.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <locale.h>
#include <unistd.h>
#include "common.h"
#include "tui.h"
#define MSG_COLOR 1
#define ICON_COLOR 2
#define COLOR_GREY init_color(0, 300, 300, 300)
struct button_list main_menu_buttons = {
.count = 3,
.current = 2,
.height = 22,
.buttons = {
{ .name = "Exit" },
{ .name = "Start" },
{ .name = "Options "},
},
};
int show_buttons(struct button_list* list) {
uint8_t start = 78;
char button_buf[0x20];
for (uint8_t i = 0; i < list->count; i++) {
start -= (strlen(list->buttons[i].name) + 5);
snprintf(button_buf, 0x20, "[ %s ] ", list->buttons[i].name);
mvaddstr(list->height, start, button_buf);
}
return 0;
}
int main_menu() {
mvaddstr(1, 2, "Welcome to palera1n!");
move(2,1);
whline(stdscr, ACS_HLINE, 80 - 2);
if (has_colors() == TRUE) {
start_color();
init_pair(MSG_COLOR, COLOR_YELLOW, COLOR_BLACK);
init_pair(ICON_COLOR, COLOR_GREY, COLOR_BLACK);
}
move(5,2);
attron(COLOR_PAIR(MSG_COLOR));
mvaddstr(3,2, "Connect your iPhone, iPad, or iPod Touch");
mvaddstr(4,2, "to begin.");
attroff(COLOR_PAIR(MSG_COLOR));
attron(COLOR_PAIR(ICON_COLOR));
mvaddwstr(5, 43, L"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
mvaddwstr(6, 43, L"MMMMMMMMMMMMMWNOddONWMMMMMMMMMMMMM");
mvaddwstr(7, 43, L"MMMMMMMMMMMMWNx. .xNWMMMMMMMMMMMM");
mvaddwstr(8, 43, L"MMMMMMMMMMMMW0;....;OWMMMMMMMMMMMM");
mvaddwstr(9, 43, L"MMMMMMMMMMMMW0;....;OWMMMMMMMMMMMM");
mvaddwstr(10, 43, L"MMMMMMMMMMMWXo'.....lKWMMMMMMMMMMM");
mvaddwstr(11, 43, L"MMMMMMMMMMWNkc;'....'dNWMMMMMMMMMM");
mvaddwstr(12, 43, L"MMMMMMMMMMN0dc:,''''.:ONWMMMMMMMMM");
mvaddwstr(13, 43, L"MMMMMMMMMWKxllc;,'''',lKWMMMMMMMMM");
mvaddwstr(14, 43, L"MMMMMMMMWNkoolc;,,,,;;:xXWMMMMMMMM");
mvaddwstr(15, 43, L"MMMMMMMMW0olllc;,,,,,,,:OWMMMMMMMM");
mvaddwstr(16, 43, L"MMMMMMMMNOollc:,'....'';xNMMMMMMMM");
mvaddwstr(17, 43, L"MMMMMMMMW0dllc:,''''''':OWMMMMMMMM");
mvaddwstr(18, 43, L"MMMMMMMMWN0dc::;;,,,,,cONWMMMMMMMM");
mvaddwstr(19, 43, L"MMMMMMMMMMWXOxoc::cldkXWMMMMMMMMMM");
mvaddwstr(20, 43, L"MMMMMMMMMMMMWWNNXXNNWWMMMMMMMMMMMM");
mvaddwstr(21, 43, L"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
attroff(COLOR_PAIR(ICON_COLOR));
move(21,1);
whline(stdscr, ACS_HLINE, 80 - 2);
show_buttons(&main_menu_buttons);
refresh();
return 0;
}
int init_window() {
setlocale(LC_ALL, NULL);
initscr();
int height, width;
getmaxyx(stdscr, height, width);
if (width < 80 || height < 24) {
LOG(LOG_ERROR, "Terminal size must be at least 80x24");
return -1;
}
if (has_colors() == FALSE) {
LOG(LOG_VERBOSE2, "Terminal without color support detected");
}
resizeterm(24, 80);
cbreak();
noecho();
keypad(stdscr, TRUE);
box(stdscr, 0, 0);
mvaddstr(0, 80 - strlen("[ palera1n version " PALERAIN_VERSION " ]") - 3 , "[ palera1n version " PALERAIN_VERSION " ]");
return 0;
}
int destroy_window() {
endwin();
return 0;
}
int tui() {
int ret;
ret = init_window();
main_menu();
sleep(5);
destroy_window();
return ret;
}