Skip to content

Commit

Permalink
modify paleinfo to supported rooted and rootless in 1 build (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
asdfugil committed Jan 22, 2023
1 parent 7ca6999 commit 2fa84a0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
16 changes: 14 additions & 2 deletions checkra1n/kpf/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2718,7 +2718,7 @@ bool allow_update_mount_callback(struct xnu_pf_patch *patch, uint32_t *opcode_st
return true;
}

checkrain_option_t gkpf_flags, checkra1n_flags;
checkrain_option_t gkpf_flags, checkra1n_flags, palera1n_flags;

int gkpf_didrun = 0;
int gkpf_spin_on_fail = 1;
Expand Down Expand Up @@ -3191,8 +3191,14 @@ void command_kpf() {
info->slide = xnu_slide_value(hdr);
info->flags = checkra1n_flags;
}
if (pinfo && rootdev) {
if (pinfo) {
strcpy(pinfo->rootdev, rootdev);
pinfo->version = 1;
pinfo->flags = palera1n_flags;
pinfo->magic = PALEINFO_MAGIC;
}
if (checkrain_option_enabled(palera1n_flags, checkrain_option_enabled(palera1n_flags, palerain_option_rootful)) && rootdev[0] == 0) {
panic("cannot have rootful when rootdev is unset");
}
if (checkrain_option_enabled(gkpf_flags, checkrain_option_verbose_boot))
gBootArgs->Video.v_display = 0;
Expand Down Expand Up @@ -3224,6 +3230,11 @@ void kpf_flags_cmd(const char *cmd, char *args)
set_flags(args, &gkpf_flags, "kpf_flags");
}

void palera1n_flags_cmd(const char *cmd, char *args)
{
set_flags(args, &palera1n_flags, "palera1n_flags");
}

void overlay_cmd(const char* cmd, char* args) {
if (gkpf_didrun) {
iprintf("KPF ran already, overlay cannot be set anymore\n");
Expand Down Expand Up @@ -3368,6 +3379,7 @@ void module_entry() {
command_register("dtpatch", "run dt patcher", dtpatcher);
command_register("rootfs", "set rootdev for paleinfo", set_rootdev);
command_register("launchd", "set launchd for palera1n", set_launchd);
command_register("palera1n_flags", "set flags for palera1n userland", palera1n_flags_cmd);
}
char* module_name = "checkra1n-kpf2-12.0,16.3-ploosh";

Expand Down
9 changes: 8 additions & 1 deletion include/kerninfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
#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)

#define PALEINFO_MAGIC 'PLSH'

typedef uint32_t checkrain_option_t, *checkrain_option_p;

typedef enum {
Expand All @@ -70,6 +75,9 @@ struct kerninfo {
checkrain_option_t flags;
};
struct paleinfo {
uint32_t magic; // 'PLSH' / 0x504c5348
uint32_t version; // 1
checkrain_option_t flags;
char rootdev[0x10];
};
struct kpfinfo {
Expand Down Expand Up @@ -99,5 +107,4 @@ static inline bool checkrain_option_enabled(checkrain_option_t flags, checkrain_
}
return (flags & opt) != 0;
}

#endif

0 comments on commit 2fa84a0

Please sign in to comment.