mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-24 02:59:49 +02:00
feat: add Windows building support, needs cleanup.
This commit is contained in:
1 parent
0df72933a8
commit
5c41f37b39
14 files changed
+80
-12
No files matched your search
@@ -8,6 +8,7 @@ contrib/
|
|||||||
checkra1n*
|
checkra1n*
|
||||||
payload.c
|
payload.c
|
||||||
src/palera1n
|
src/palera1n
|
||||||
|
src/palera1n.exe
|
||||||
!xxd-embedded.h
|
!xxd-embedded.h
|
||||||
src/binpack.dmg
|
src/binpack.dmg
|
||||||
src/ramdisk.dmg
|
src/ramdisk.dmg
|
||||||
|
|||||||
@@ -7,11 +7,19 @@ CC ?= cc
|
|||||||
CFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC) -D_XOPEN_SOURCE=500
|
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 += -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
|
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 -lm
|
|
||||||
ifeq ($(TARGET_OS),)
|
ifeq ($(TARGET_OS),)
|
||||||
TARGET_OS = $(shell uname -s)
|
TARGET_OS = $(shell uname -s)
|
||||||
endif
|
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)
|
ifeq ($(TARGET_OS),Darwin)
|
||||||
CFLAGS += -Wno-nullability-extension
|
CFLAGS += -Wno-nullability-extension
|
||||||
ifeq (,$(findstring version-min=, $(CFLAGS)))
|
ifeq (,$(findstring version-min=, $(CFLAGS)))
|
||||||
@@ -21,9 +29,11 @@ LDFLAGS += -Wl,-dead_strip
|
|||||||
LIBS += -framework CoreFoundation -framework IOKit
|
LIBS += -framework CoreFoundation -framework IOKit
|
||||||
else
|
else
|
||||||
CFLAGS += -fdata-sections -ffunction-sections
|
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
|
endif
|
||||||
LIBS += $(DEP)/lib/libmbedtls.a $(DEP)/lib/libmbedcrypto.a $(DEP)/lib/libmbedx509.a $(DEP)/lib/libreadline.a
|
|
||||||
|
|
||||||
ifeq ($(TUI),1)
|
ifeq ($(TUI),1)
|
||||||
LIBS += $(DEP)/lib/libnewt.a $(DEP)/lib/libpopt.a $(DEP)/lib/libslang.a
|
LIBS += $(DEP)/lib/libnewt.a $(DEP)/lib/libpopt.a $(DEP)/lib/libslang.a
|
||||||
@@ -46,7 +56,7 @@ else
|
|||||||
CFLAGS += -Os -g
|
CFLAGS += -Os -g
|
||||||
BUILD_STYLE = RELEASE
|
BUILD_STYLE = RELEASE
|
||||||
endif
|
endif
|
||||||
LIBS += -lc
|
#LIBS += -lc
|
||||||
|
|
||||||
ifneq ($(BAKERAIN_DEVELOPE_R),)
|
ifneq ($(BAKERAIN_DEVELOPE_R),)
|
||||||
CFLAGS += -DBAKERAIN_DEVELOPE_R="\"$(BAKERAIN_DEVELOPE_R)\""
|
CFLAGS += -DBAKERAIN_DEVELOPE_R="\"$(BAKERAIN_DEVELOPE_R)\""
|
||||||
|
|||||||
@@ -78,7 +78,6 @@
|
|||||||
#define BHWHT "\033[1;97m"
|
#define BHWHT "\033[1;97m"
|
||||||
|
|
||||||
//Reset
|
//Reset
|
||||||
#define reset "\033[0m"
|
|
||||||
#define CRESET "\033[0m"
|
#define CRESET "\033[0m"
|
||||||
#define COLOR_RESET "\033[0m"
|
#define COLOR_RESET "\033[0m"
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <usbmuxd.h>
|
#include <usbmuxd.h>
|
||||||
#include <libirecovery.h>
|
#include <libirecovery.h>
|
||||||
#include <libimobiledevice/libimobiledevice.h>
|
#include <libimobiledevice/libimobiledevice.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#define LOG(loglevel, ...) p1_log(loglevel, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
#define LOG(loglevel, ...) p1_log(loglevel, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||||
#define CLEAR() printf("\33[2K\r");
|
#define CLEAR() printf("\33[2K\r");
|
||||||
|
|||||||
@@ -63,8 +63,12 @@ endif
|
|||||||
ifeq ($(USE_LIBUSB),1)
|
ifeq ($(USE_LIBUSB),1)
|
||||||
OBJECTS += usb_libusb.o
|
OBJECTS += usb_libusb.o
|
||||||
CFLAGS += -DHAVE_LIBUSB -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
|
LIBS += $(DEP)/lib/libusb-1.0.a
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(ROOTFUL),1)
|
ifeq ($(ROOTFUL),1)
|
||||||
CFLAGS += -DROOTFUL=1
|
CFLAGS += -DROOTFUL=1
|
||||||
|
|||||||
+2
-2
@@ -7,9 +7,9 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#ifdef WIN32
|
#ifdef WIN
|
||||||
#include <windows.h>
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|||||||
@@ -8,11 +8,16 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#ifdef WIN
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#endif
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|||||||
+7
-2
@@ -9,17 +9,22 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifdef WIN
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <spawn.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#endif
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <spawn.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <libimobiledevice/libimobiledevice.h>
|
#include <libimobiledevice/libimobiledevice.h>
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
#ifndef HAVE_LIBIMOBILEDEVICE
|
#ifndef HAVE_LIBIMOBILEDEVICE
|
||||||
#include "lockdown_helper.h"
|
#include "lockdown_helper.h"
|
||||||
#include <usbmuxd.h>
|
#include <usbmuxd.h>
|
||||||
|
#ifdef WIN
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
+13
-2
@@ -10,16 +10,21 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifdef WIN
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <spawn.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#endif
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <spawn.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <libimobiledevice/libimobiledevice.h>
|
#include <libimobiledevice/libimobiledevice.h>
|
||||||
@@ -145,15 +150,21 @@ int palera1n(int argc, char *argv[]) {
|
|||||||
normal_exit:
|
normal_exit:
|
||||||
cleanup:
|
cleanup:
|
||||||
if (override_kpf.magic == OVERRIDE_MAGIC) {
|
if (override_kpf.magic == OVERRIDE_MAGIC) {
|
||||||
|
#ifndef WIN
|
||||||
munmap(override_kpf.ptr, (size_t)override_kpf.len);
|
munmap(override_kpf.ptr, (size_t)override_kpf.len);
|
||||||
|
#endif
|
||||||
close(override_kpf.fd);
|
close(override_kpf.fd);
|
||||||
}
|
}
|
||||||
if (override_ramdisk.magic == OVERRIDE_MAGIC) {
|
if (override_ramdisk.magic == OVERRIDE_MAGIC) {
|
||||||
|
#ifndef WIN
|
||||||
munmap(override_ramdisk.ptr, (size_t)override_ramdisk.len);
|
munmap(override_ramdisk.ptr, (size_t)override_ramdisk.len);
|
||||||
|
#endif
|
||||||
close(override_ramdisk.fd);
|
close(override_ramdisk.fd);
|
||||||
}
|
}
|
||||||
if (override_overlay.magic == OVERRIDE_MAGIC) {
|
if (override_overlay.magic == OVERRIDE_MAGIC) {
|
||||||
|
#ifndef WIN
|
||||||
munmap(override_overlay.ptr, (size_t)override_overlay.len);
|
munmap(override_overlay.ptr, (size_t)override_overlay.len);
|
||||||
|
#endif
|
||||||
close(override_overlay.fd);
|
close(override_overlay.fd);
|
||||||
}
|
}
|
||||||
pthread_mutex_destroy(&log_mutex);
|
pthread_mutex_destroy(&log_mutex);
|
||||||
|
|||||||
@@ -12,7 +12,9 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <palerain.h>
|
#include <palerain.h>
|
||||||
|
#ifndef WIN
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
uint64_t* palerain_flags_p = &palerain_flags;
|
uint64_t* palerain_flags_p = &palerain_flags;
|
||||||
@@ -327,19 +329,27 @@ int optparse(int argc, char* argv[]) {
|
|||||||
usage(1, argv[0]);
|
usage(1, argv[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifndef WIN
|
||||||
if (verbose >= 2) setenv("LIBUSB_DEBUG", "1", 1);
|
if (verbose >= 2) setenv("LIBUSB_DEBUG", "1", 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (verbose >= 3)
|
if (verbose >= 3)
|
||||||
{
|
{
|
||||||
libusbmuxd_set_debug_level(verbose - 2);
|
libusbmuxd_set_debug_level(verbose - 2);
|
||||||
irecv_set_debug_level(1);
|
irecv_set_debug_level(1);
|
||||||
|
#ifndef WIN
|
||||||
setenv("LIBUSB_DEBUG", "2", 1);
|
setenv("LIBUSB_DEBUG", "2", 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (verbose >= 4) {
|
if (verbose >= 4) {
|
||||||
idevice_set_debug_level(1);
|
idevice_set_debug_level(1);
|
||||||
|
#ifndef WIN
|
||||||
setenv("LIBUSB_DEBUG", "3", 1);
|
setenv("LIBUSB_DEBUG", "3", 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifndef WIN
|
||||||
if (verbose >= 5)
|
if (verbose >= 5)
|
||||||
setenv("LIBUSB_DEBUG", "4", 1);
|
setenv("LIBUSB_DEBUG", "4", 1);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,12 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#ifndef WIN
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#else
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -31,11 +36,19 @@ int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *
|
|||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
LOG(LOG_VERBOSE5, "override_file: fstat fd %d succeeded!", fd);
|
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);
|
void *addr = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||||
if (addr == MAP_FAILED) {
|
if (addr == MAP_FAILED) {
|
||||||
LOG(LOG_ERROR, "Failed to map file %s: %d (%s)", filename, errno, strerror(errno));
|
LOG(LOG_ERROR, "Failed to map file %s: %d (%s)", filename, errno, strerror(errno));
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
LOG(LOG_VERBOSE5, "override_file: Override file mapped successfully");
|
LOG(LOG_VERBOSE5, "override_file: Override file mapped successfully");
|
||||||
finfo->magic = OVERRIDE_MAGIC;
|
finfo->magic = OVERRIDE_MAGIC;
|
||||||
finfo->fd = fd;
|
finfo->fd = fd;
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
#include <stdlib.h> // exit, strtoull
|
#include <stdlib.h> // exit, strtoull
|
||||||
#include <string.h> // strlen, strerror, memcpy, memmove
|
#include <string.h> // strlen, strerror, memcpy, memmove
|
||||||
#include <unistd.h> // close
|
#include <unistd.h> // close
|
||||||
|
#ifndef WIN
|
||||||
#include <sys/mman.h> // mmap, munmap
|
#include <sys/mman.h> // mmap, munmap
|
||||||
#include <sys/stat.h> // fstst
|
#include <sys/stat.h> // fstst
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <palerain.h>
|
#include <palerain.h>
|
||||||
#include <ANSI-color-codes.h>
|
#include <ANSI-color-codes.h>
|
||||||
|
|||||||
@@ -34,8 +34,10 @@
|
|||||||
#include <stdlib.h> // exit, strtoull
|
#include <stdlib.h> // exit, strtoull
|
||||||
#include <string.h> // strlen, strerror, memcpy, memmove
|
#include <string.h> // strlen, strerror, memcpy, memmove
|
||||||
#include <unistd.h> // close
|
#include <unistd.h> // close
|
||||||
|
#ifndef WIN
|
||||||
#include <sys/mman.h> // mmap, munmap
|
#include <sys/mman.h> // mmap, munmap
|
||||||
#include <sys/stat.h> // fstst
|
#include <sys/stat.h> // fstst
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <palerain.h>
|
#include <palerain.h>
|
||||||
#define ERR(...) LOG(LOG_ERROR, __VA_ARGS__)
|
#define ERR(...) LOG(LOG_ERROR, __VA_ARGS__)
|
||||||
|
|||||||
Reference in new issue
Block a user