GeezerVison is showing github.com — 一键自动化流程补丁内核 · rym4n/SKRoot-linuxKernelRoot@1784724
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard Collapse file
Copy file name to clipboardExpand all lines: patch_kernel_root/patch_kernel_root.cpp +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -203,6 +203,14 @@ bool parser_seccomp_offset(const std::vector<char> &file_buf, size_t start, std: |
203 | 203 | return find_current_task_next_register_offset(file_buf, start, mode_name, v_seccomp_offset); |
204 | 204 | } |
205 | 205 |
|
| 206 | +bool check_file_path(const char* file_path) { |
| 207 | + int len = strlen(file_path); |
| 208 | + if (len > 4 && strcmp(file_path + len - 4, ".img") == 0) { |
| 209 | + return false; |
| 210 | + } |
| 211 | + return true; |
| 212 | +} |
| 213 | + |
206 | 214 | int main(int argc, char* argv[]) { |
207 | 215 | ++argv; |
208 | 216 | --argc; |
@@ -215,6 +223,14 @@ int main(int argc, char* argv[]) { |
215 | 223 | return 0; |
216 | 224 | } |
217 | 225 | const char* file_path = argv[0]; |
| 226 | + |
| 227 | + if (!check_file_path(file_path)) { |
| 228 | + std::cout << "Please enter the correct Linux kernel binary file path. " << std::endl; |
| 229 | + std::cout << "For example, if it is boot.img, you need to first decompress boot.img and then extract the kernel file inside." << std::endl; |
| 230 | + system("pause"); |
| 231 | + return 0; |
| 232 | + } |
| 233 | + |
218 | 234 | std::vector<char> file_buf = read_file_buf(file_path); |
219 | 235 | if (!file_buf.size()) { |
220 | 236 | std::cout << "Fail to open file:" << file_path << std::endl; |
|