From dd6c1c9faf578f1342a2a19c3f7481d8d19d1556 Mon Sep 17 00:00:00 2001 From: YZBruh Date: Tue, 9 Apr 2024 23:53:27 +0300 Subject: [PATCH] pmt: apply version 1.7.0 changes --- binary/checkers.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/binary/checkers.c b/binary/checkers.c index 3c4c259..4f077bc 100644 --- a/binary/checkers.c +++ b/binary/checkers.c @@ -1,13 +1,3 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "include/common.h" - /* By YZBruh */ /* @@ -26,16 +16,31 @@ * limitations under the License. */ -extern bool use_cust_cxt; +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include "include/pmt.h" + +extern bool pmt_use_cust_cxt; extern bool pmt_ab; extern bool pmt_logical; +extern bool pmt_force_mode; extern char *cust_cxt; /* check parts */ void check_psf() { /* true = ab | false = a */ - if (use_cust_cxt) { + if (pmt_use_cust_cxt) { static char cust_cxt_ck_path[150]; sprintf(cust_cxt_ck_path, "%s/boot_a", cust_cxt); if (access(cust_cxt_ck_path, F_OK) != 0) { @@ -52,7 +57,7 @@ void check_psf() } /* true = logical | false = classic */ - if (use_cust_cxt) { + if (pmt_use_cust_cxt) { static char cust_cxt_ckl_path[150]; sprintf(cust_cxt_ckl_path, "%s/super", cust_cxt); if (access(cust_cxt_ckl_path, F_OK) != 0) { @@ -74,8 +79,17 @@ void check_root() { /* a quick, easy method to verify root :D */ if (chdir("/dev/block") != 0) { - error("Root privileges could not be detected! Please run this binary with root.\n"); + if (!pmt_force_mode) { + fprintf(stderr, ANSI_RED "Root privileges could not be detected! Please run this binary with root. Error reason: %s\n" ANSI_RESET, strerror(errno)); + exit(27); + } else { + exit(27); + } } } +#ifdef __cplusplus +} +#endif + /* end of code */