Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/nyx/nyx_gui/hos/pkg2.h
1476 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2018-2025 CTCaer
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms and conditions of the GNU General Public License,
7
* version 2, as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef _PKG2_H_
19
#define _PKG2_H_
20
21
#include <bdk.h>
22
23
#define PKG2_MAGIC 0x31324B50
24
#define PKG2_SEC_BASE 0x80000000
25
#define PKG2_SEC_KERNEL 0
26
#define PKG2_SEC_INI1 1
27
#define PKG2_SEC_UNUSED 2
28
29
#define INI1_MAGIC 0x31494E49
30
31
//! TODO: Update on kernel change if needed.
32
// Offset of OP + 12 is the INI1 offset. On v2 with dynamic crt0 it's + 16.
33
#define PKG2_NEWKERN_GET_INI1_HEURISTIC 0xD2800015 // MOV X21, #0.
34
#define PKG2_NEWKERN_START 0x800
35
36
extern u32 pkg2_newkern_ini1_start;
37
extern u32 pkg2_newkern_ini1_end;
38
39
typedef struct _pkg2_hdr_t
40
{
41
u8 ctr[0x10];
42
u8 sec_ctr[0x40];
43
u32 magic;
44
u32 base;
45
u32 pad0;
46
u8 pkg2_ver;
47
u8 bl_ver;
48
u16 pad1;
49
u32 sec_size[4];
50
u32 sec_off[4];
51
u8 sec_sha256[0x80];
52
u8 data[];
53
} pkg2_hdr_t;
54
55
typedef struct _pkg2_ini1_t
56
{
57
u32 magic;
58
u32 size;
59
u32 num_procs;
60
u32 pad;
61
} pkg2_ini1_t;
62
63
typedef struct _pkg2_kip1_sec_t
64
{
65
u32 offset;
66
u32 size_decomp;
67
u32 size_comp;
68
u32 attrib;
69
} pkg2_kip1_sec_t;
70
71
#define KIP1_NUM_SECTIONS 6
72
73
typedef struct _pkg2_kip1_t
74
{
75
u32 magic;
76
u8 name[12];
77
u64 tid;
78
u32 proc_cat;
79
u8 main_thrd_prio;
80
u8 def_cpu_core;
81
u8 res;
82
u8 flags;
83
pkg2_kip1_sec_t sections[KIP1_NUM_SECTIONS];
84
u32 caps[0x20];
85
u8 data[];
86
} pkg2_kip1_t;
87
88
typedef struct _pkg2_kip1_info_t
89
{
90
pkg2_kip1_t *kip1;
91
u32 size;
92
link_t link;
93
} pkg2_kip1_info_t;
94
95
void pkg2_get_newkern_info(u8 *kern_data);
96
u32 pkg2_calc_kip1_size(pkg2_kip1_t *kip1);
97
98
pkg2_hdr_t *pkg2_decrypt(void *data, u8 kb);
99
100
#endif
101
102