1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//! # `proka-exec`
//!
//! [](https://www.rust-lang.org/)
//! [](https://opensource.org/license/gpl-3.0)
//! [](https://github.com/RainSTR-Studio/proka-exec/stargazers)
//! [](https://github.com/RainSTR-Studio/proka-exec/issues)
//! [](https://github.com/RainSTR-Studio/proka-exec/pulls)
//! [](https://prokadoc.pages.dev/)
//!
//! Copyright (C) 2026 RainSTR Studio. Licensed under GNU GPLv3.
//!
//! ---
//!
//! ## Introduction
//! This crate provides the definitions of headers, section index, section metadata,
//! and some utils to help you parse the executable easily.
//!
//! ## Structures of this executable
//! This executable is structured as follows:
//! - PKE headers - Records the basic information of this executable;
//! - Section index - Records the section header's offset and section name's length;
//! - Section metadata- Records the section flags, data offset and its length;
//! - Data - The binary content.
//!
//! We can use this picture to explain their segmented structure:
//!
//! `[Headers] [Section Index 1] [Section Index 2] ... [Section Metadata 1] [Section Metadata 2] ... [Data]`
//!
//! Simultaneously, the `[Section Metadata]` can be separated as follows:
//!
//! `[Section Headers] [Section Name]`
//!
//! In the picture above, the `[Section Headers]`'s length is fixed, which is recorded in [`SECTION_HDR_SIZE`];
//! The section name is different - It's dynamic, so you can store almost infinite words in it!
//!
//! ## Steps to use this crate
//! ### Parsing
//! Before you parse it, you should do these steps:
//!
//! - Read the executable file content;
//! - Make this file's content to a slice (`&[u8]`)
//! - Use [`Parser`] to parse the executable.
//!
//! After this, you can do further operations through this parser by
//! calling its functions.
//!
//! ### Building
//! Here we provided a tool [`Builder`] to help you do building process easily.
//!
//! Before parsing, make sure you have enabled feature `alloc`, or you can't find where [`Builder`] is.
//!
//! Then you can do these steps:
//! - Set up author name (32 bytes limit);
//! - Set up program name (32 bytes limit);
//! - Set up the executable type (UserApp/CoreDrv);
//! - Append section content (Can push multiple sections);
//! - Build the executable.
//!
//! ## Example Usage
//! ### Parsing
//! ```rust
//! use proka_exec::Parser;
//! use std::path::PathBuf;
//!
//! let file = PathBuf::from("tests/testbin/sample.pke");
//! let content = std::fs::read(file).expect("Failed to read file");
//! let parser = Parser::init(&content).expect("Failed to parse PKE format");
//!
//! // More API see below
//! ```
//!
//! ### Building
//! ```rust
//! use proka_exec::{Builder, header::ExecMode};
//! use std::path::PathBuf;
//!
//! static EXAMPLE_CONTENT: &[u8] = b"Hello, World!";
//!
//! let mut builder = Builder::new();
//! builder.set_author("example");
//! builder.set_name("appname");
//! builder.set_mode(ExecMode::UserApp);
//! builder.append(EXAMPLE_CONTENT, ".example.section", false, false, None); // (data, name, is_loadable, is_execable, entry)
//! let content = builder.build().expect("Failed to build executable");
//! std::fs::write("example.pke", &content).expect("Failed to write file");
//! ```
//!
//!
//! # LICENSE
//! This crate is under license [GPL-v3](https://github.com/RainSTR-Studio/proka-exec/blob/main/LICENSE),
//! and you must follow its rules.
//!
//! See [LICENSE](https://github.com/RainSTR-Studio/proka-exec/blob/main/LICENSE) file for more details.
//!
//! ## MSRV
//! This crate's MSRV is `1.85.0` stable.
// Alloc features...
extern crate alloc;
use ;
use ;
pub use *;
pub use ;
/// Generic result type in this crate
pub type Result<T> = Result;
/// The header size.
pub const HEADER_SIZE: usize = ;
/// The section header size.
pub const SECTION_HDR_SIZE: usize = ;
/// The section entry size.
pub const SECTION_INDEX_SIZE: usize = ;
/// The version of this crate.
pub const VERSION_CURRENT: u32 = 3;
/// The minimum version of this crate.
pub const VERSION_MINIMAL: u32 = 3;
/// The error type of parsing header.