GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 修复一些bug · namelin2/SKRoot-linuxKernelRoot@280285a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • patch_kernel_root
    • analyze_kernel.cpp
    • analyze_kernel.h
    • exe
      • patch_kernel_root.exe
    • kernel_symbol_parser.cpp
    • kernel_symbol_parser.h
    • patch_kernel_root.cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎patch_kernel_root/analyze_kernel.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/analyze_kernel.cpp
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ KernelSymbolOffset AnalyzeKernel::get_symbol_offset() {
2525
return m_kernel_sym_offset;
2626
}
2727

28+
bool AnalyzeKernel::is_kernel_version_less_equal(const std::string& ver) {
29+
return m_kernel_sym_parser.is_kernel_version_less_equal(ver);
30+
}
31+
2832
bool AnalyzeKernel::find_symbol_offset() {
2933
m_kernel_sym_offset._text_offset = m_kernel_sym_parser.kallsyms_lookup_name("_text");
3034
m_kernel_sym_offset._stext_offset = m_kernel_sym_parser.kallsyms_lookup_name("_stext");
Collapse file

‎patch_kernel_root/analyze_kernel.h‎

Copy file name to clipboardExpand all lines: patch_kernel_root/analyze_kernel.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class AnalyzeKernel
3131
public:
3232
bool analyze_kernel_symbol();
3333
KernelSymbolOffset get_symbol_offset();
34+
bool is_kernel_version_less_equal(const std::string& ver);
3435
private:
3536
bool find_symbol_offset();
3637
const std::vector<char>& m_file_buf;
Collapse file

‎patch_kernel_root/exe/patch_kernel_root.exe‎

Copy file name to clipboard
1 KB
Binary file not shown.
Collapse file

‎patch_kernel_root/kernel_symbol_parser.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/kernel_symbol_parser.cpp
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,12 @@ uint64_t KernelSymbolParser::kallsyms_lookup_name(const char* name, bool include
5353
} else {
5454
return 0;
5555
}
56-
}
56+
}
57+
58+
bool KernelSymbolParser::is_kernel_version_less_equal(const std::string& ver) {
59+
std::string current_version = m_kernel_ver_parser.find_kernel_versions();
60+
if (!current_version.empty()) {
61+
return m_kernel_ver_parser.is_version_less_equal(current_version, ver);
62+
}
63+
return false;
64+
}
Collapse file

‎patch_kernel_root/kernel_symbol_parser.h‎

Copy file name to clipboardExpand all lines: patch_kernel_root/kernel_symbol_parser.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class KernelSymbolParser
1414
public:
1515
bool init_kallsyms_lookup_name();
1616
uint64_t kallsyms_lookup_name(const char* name, bool include_str_mode = false);
17+
bool is_kernel_version_less_equal(const std::string& ver);
1718
private:
1819
const std::vector<char>& m_file_buf;
1920
KernelVersionParser m_kernel_ver_parser;
Collapse file

‎patch_kernel_root/patch_kernel_root.cpp‎

Copy file name to clipboardExpand all lines: patch_kernel_root/patch_kernel_root.cpp
+10-14Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,8 @@ int main(int argc, char* argv[]) {
227227
}
228228
#endif
229229

230-
#ifdef _DEBUG
231-
//const char* file_path = R"***(C:\Users\maily\Desktop\kernel)***";
232-
//const char* file_path = R"***(C:\Users\maily\Desktop\k20.img-kernel)***";
233-
//const char* file_path = R"***(C:\Users\maily\Desktop\mi8v9)***";
234-
//const char* file_path = R"***(C:\Users\maily\Desktop\mi8v10)***";
235-
//const char* file_path = R"***(C:\Users\maily\Desktop\mi5)***";
236-
//const char* file_path = R"***(C:\Users\maily\Desktop\mi6max)***";
237-
//const char* file_path = R"***(C:\Users\maily\Desktop\skr_fix_6s\o.img-kernel)***";
238-
//const char* file_path = R"***(C:\Users\maily\Desktop\vmlinux\vmlinux)***";
239-
#else
230+
240231
const char* file_path = argv[0];
241-
#endif
242232
if (!check_file_path(file_path)) {
243233
std::cout << "Please enter the correct Linux kernel binary file path. " << std::endl;
244234
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;
@@ -309,12 +299,18 @@ int main(int argc, char* argv[]) {
309299
size_t hook_start = patch_ret_cmd(file_buf, sym.__cfi_check_offset, vec_patch_bytes_data);
310300
v_hook_func_start_addr.push_back(hook_start);
311301
} else {
312-
if (sym.panic_offset) {
313-
v_hook_func_start_addr.push_back(sym.panic_offset);
302+
if (analyze_kernel.is_kernel_version_less_equal("6.1.0")) {
303+
v_hook_func_start_addr.push_back(0x300);
304+
} else {
305+
if (sym.panic_offset) {
306+
v_hook_func_start_addr.push_back(sym.panic_offset);
307+
}
314308
}
315309
}
316310
if (v_hook_func_start_addr.size() == 0) {
317-
v_hook_func_start_addr.push_back(0x300);
311+
std::cout << "Failed to find hook start addr" << std::endl;
312+
system("pause");
313+
return 0;
318314
}
319315

320316
if (sym.__cfi_check_fail_offset) {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.