GeezerVison is showing github.com — feat: 调整目录结构,兼容Pro版(模块版) · Corner514/SKRoot-linuxKernelRoot@2e5e233
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: patch_kernel_root/3rdparty/aarch64_asm_helper.h +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,7 +51,7 @@ static std::pair<std::shared_ptr<char>, size_t> aarch64_asm_to_bytes(const aarch | 51 | 51 | size_t data_size = buf.size(); | 52 | 52 | std::shared_ptr<char> data_container(new (std::nothrow) char[data_size], std::default_delete<char[]>()); | 53 | 53 | memcpy(data_container.get(), data, data_size); | 54 | | - return { data_container, data_size}; | | 54 | + return { data_container, data_size }; | 55 | 55 | } | 56 | 56 |
| 57 | 57 |
| |
Collapse file Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/kernel_symbol_parser.cpp +5-13Lines changed: 5 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,30 +21,30 @@ KernelSymbolParser::~KernelSymbolParser() | 21 | 21 |
| 22 | 22 | bool KernelSymbolParser::init_kallsyms_lookup_name() { | 23 | 23 |
| 24 | | - std::string current_version = m_kernel_ver_parser.find_kernel_versions(); | | 24 | + std::string current_version = m_kernel_ver_parser.get_kernel_version(); | 25 | 25 | if (current_version.empty()) { | 26 | 26 | std::cout << "Failed to read Linux kernel version" << std::endl; | 27 | 27 | return false; | 28 | 28 | } | 29 | 29 | std::cout << "Find the current Linux kernel version: " << current_version << std::endl; | 30 | 30 | std::cout << std::endl; | 31 | 31 |
| 32 | | - if (m_kernel_ver_parser.is_version_less(current_version, "4.6.0")) { | | 32 | + if (m_kernel_ver_parser.is_kernel_version_less("4.6.0")) { | 33 | 33 | if (!m_kallsyms_lookup_name.init()) { | 34 | 34 | std::cout << "Failed to analyze kernel kallsyms lookup name information" << std::endl; | 35 | 35 | return false; | 36 | 36 | } | 37 | | - } else if (m_kernel_ver_parser.is_version_less(current_version, "6.1.42")) { | | 37 | + } else if (m_kernel_ver_parser.is_kernel_version_less("6.1.42")) { | 38 | 38 | if (!m_kallsyms_lookup_name_4_6_0.init()) { | 39 | 39 | std::cout << "Failed to analyze kernel kallsyms lookup name information" << std::endl; | 40 | 40 | return false; | 41 | 41 | } | 42 | | - } else if (m_kernel_ver_parser.is_version_less(current_version, "6.1.60")) { | | 42 | + } else if (m_kernel_ver_parser.is_kernel_version_less("6.1.60")) { | 43 | 43 | if (!m_kallsyms_lookup_name_6_1_42.init()) { | 44 | 44 | std::cout << "Failed to analyze kernel kallsyms lookup name information" << std::endl; | 45 | 45 | return false; | 46 | 46 | } | 47 | | - } else if (m_kernel_ver_parser.is_version_less(current_version, "6.6.30")) { | | 47 | + } else if (m_kernel_ver_parser.is_kernel_version_less("6.6.30")) { | 48 | 48 | if (!m_kallsyms_lookup_name_6_1_60.init()) { | 49 | 49 | std::cout << "Failed to analyze kernel kallsyms lookup name information" << std::endl; | 50 | 50 | return false; | @@ -94,11 +94,3 @@ std::unordered_map<std::string, uint64_t> KernelSymbolParser::kallsyms_lookup_na | 94 | 94 | } | 95 | 95 | return result; | 96 | 96 | } | 97 | | - | 98 | | -bool KernelSymbolParser::is_kernel_version_less(const std::string& ver) const { | 99 | | - std::string current_version = m_kernel_ver_parser.find_kernel_versions(); | 100 | | - if (!current_version.empty()) { | 101 | | - return m_kernel_ver_parser.is_version_less(current_version, ver); | 102 | | - } | 103 | | - return false; | 104 | | -} |
Collapse file Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/kernel_symbol_parser.h -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,7 +17,6 @@ class KernelSymbolParser | 17 | 17 | bool init_kallsyms_lookup_name(); | 18 | 18 | uint64_t kallsyms_lookup_name(const char* name); | 19 | 19 | std::unordered_map<std::string, uint64_t> kallsyms_lookup_names_like(const char* name); | 20 | | - bool is_kernel_version_less(const std::string& ver) const; | 21 | 20 | private: | 22 | 21 | const std::vector<char>& m_file_buf; | 23 | 22 | KernelVersionParser m_kernel_ver_parser; | |
Collapse file Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/kernel_version_parser.cpp +13-4Lines changed: 13 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 | #define MIN(x, y)(x < y) ? (x) : (y) | 7 | 7 | #endif // !MIN | 8 | 8 |
| 9 | | -KernelVersionParser::KernelVersionParser(const std::vector<char>& file_buf) : m_file_buf(file_buf) | 10 | | -{ | | 9 | +KernelVersionParser::KernelVersionParser(const std::vector<char>& file_buf) : m_file_buf(file_buf) { | | 10 | + m_ver = find_kernel_versions(); | 11 | 11 | } | 12 | 12 |
| 13 | | -KernelVersionParser::~KernelVersionParser() | 14 | | -{ | | 13 | +KernelVersionParser::~KernelVersionParser() {} | | 14 | + | | 15 | +std::string KernelVersionParser::get_kernel_version() const { | | 16 | + return m_ver; | | 17 | +} | | 18 | + | | 19 | +bool KernelVersionParser::is_kernel_version_less(const std::string& ver) const { | | 20 | + if (!m_ver.empty()) { | | 21 | + return is_version_less(m_ver, ver); | | 22 | + } | | 23 | + return false; | 15 | 24 | } | 16 | 25 |
| 17 | 26 | // Helper function to extract and print the version number starting from the given index | |
Collapse file Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/kernel_version_parser.h +6-2Lines changed: 6 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,10 +8,14 @@ class KernelVersionParser | 8 | 8 | ~KernelVersionParser(); | 9 | 9 |
| 10 | 10 | public: | 11 | | - std::string find_kernel_versions() const; | 12 | | - bool is_version_less(const std::string& v1, const std::string& v2) const; | | 11 | + std::string get_kernel_version() const; | | 12 | + bool is_kernel_version_less(const std::string& ver) const; | 13 | 13 | private: | | 14 | + std::string find_kernel_versions() const; | 14 | 15 | std::string extract_version(const std::vector<char>& buffer, size_t start_index) const; | | 16 | + bool is_version_less(const std::string& v1, const std::string& v2) const; | 15 | 17 | std::vector<int> parse_version(const std::string& version) const; | | 18 | + | 16 | 19 | const std::vector<char>& m_file_buf; | | 20 | + std::string m_ver; | 17 | 21 | }; |
Collapse file Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/symbol_analyze.cpp -4Lines changed: 0 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,10 +24,6 @@ KernelSymbolOffset SymbolAnalyze::get_symbol_offset() { | 24 | 24 | return m_kernel_sym_offset; | 25 | 25 | } | 26 | 26 |
| 27 | | -bool SymbolAnalyze::is_kernel_version_less(const std::string& ver) const { | 28 | | - return m_kernel_sym_parser.is_kernel_version_less(ver); | 29 | | -} | 30 | | - | 31 | 27 | bool SymbolAnalyze::find_symbol_offset() { | 32 | 28 | m_kernel_sym_offset._text = kallsyms_matching_single("_text"); | 33 | 29 | m_kernel_sym_offset._stext = kallsyms_matching_single("_stext"); | |
Collapse file Copy file name to clipboardExpand all lines: patch_kernel_root/analyze/symbol_analyze.h -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -55,7 +55,6 @@ class SymbolAnalyze | 55 | 55 | public: | 56 | 56 | bool analyze_kernel_symbol(); | 57 | 57 | KernelSymbolOffset get_symbol_offset(); | 58 | | - bool is_kernel_version_less(const std::string& ver) const; | 59 | 58 | private: | 60 | 59 | bool find_symbol_offset(); | 61 | 60 | uint64_t kallsyms_matching_single(const char* name, bool fuzzy = false); | |
Collapse file Copy file name to clipboardExpand all lines: patch_kernel_root/patch_avc_denied.cpp +4-9Lines changed: 4 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,14 +5,10 @@ using namespace asmjit; | 5 | 5 | using namespace asmjit::a64; | 6 | 6 | using namespace asmjit::a64::Predicate; | 7 | 7 |
| 8 | | -PatchAvcDenied::PatchAvcDenied(const std::vector<char>& file_buf, const KernelSymbolOffset& sym, | 9 | | - const SymbolAnalyze& symbol_analyze) : PatchBase(file_buf, sym, symbol_analyze) { | | 8 | +PatchAvcDenied::PatchAvcDenied(const std::vector<char>& file_buf, const SymbolRegion& avc_denied) | | 9 | + : PatchBase(file_buf), m_avc_denied(avc_denied) {} | 10 | 10 |
| 11 | | -} | 12 | | - | 13 | | -PatchAvcDenied::~PatchAvcDenied() | 14 | | -{ | 15 | | -} | | 11 | +PatchAvcDenied::~PatchAvcDenied() {} | 16 | 12 |
| 17 | 13 | int PatchAvcDenied::get_need_read_cap_cnt() { | 18 | 14 | int cnt = get_cap_cnt(); | @@ -27,8 +23,7 @@ size_t PatchAvcDenied::patch_avc_denied_first_guide(const SymbolRegion& hook_fun | 27 | 23 | size_t hook_func_start_addr = hook_func_start_region.offset; | 28 | 24 | if (hook_func_start_addr == 0) { return 0; } | 29 | 25 | std::cout << "Start hooking addr: " << std::hex << hook_func_start_addr << std::endl << std::endl; | 30 | | - size_t avc_denied_addr = m_sym.avc_denied.offset + m_sym.avc_denied.size - 4; | 31 | | - | | 26 | + size_t avc_denied_addr = m_avc_denied.offset + m_avc_denied.size - 4; | 32 | 27 |
| 33 | 28 | aarch64_asm_info asm_info = init_aarch64_asm(); | 34 | 29 | auto& a = asm_info.a; | |
Collapse file Copy file name to clipboardExpand all lines: patch_kernel_root/patch_avc_denied.h +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 | class PatchAvcDenied : public PatchBase | 6 | 6 | { | 7 | 7 | public: | 8 | | - PatchAvcDenied(const std::vector<char>& file_buf, const KernelSymbolOffset& sym, | 9 | | - const SymbolAnalyze& analyze_kernel); | | 8 | + PatchAvcDenied(const std::vector<char>& file_buf, const SymbolRegion &avc_denied); | 10 | 9 | ~PatchAvcDenied(); | 11 | 10 |
| 12 | 11 | size_t patch_avc_denied_first_guide(const SymbolRegion& hook_func_start_region, const std::vector<size_t>& task_struct_offset_cred, | @@ -17,4 +16,5 @@ class PatchAvcDenied : public PatchBase | 17 | 16 | size_t patch_avc_denied_end_guide(const SymbolRegion& hook_func_start_region, std::vector<patch_bytes_data>& vec_out_patch_bytes_data); | 18 | 17 | private: | 19 | 18 | int get_need_read_cap_cnt(); | | 19 | + SymbolRegion m_avc_denied = {0}; | 20 | 20 | }; |
Collapse file Copy file name to clipboardExpand all lines: patch_kernel_root/patch_base.cpp +6-11Lines changed: 6 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,18 +5,13 @@ using namespace asmjit; | 5 | 5 | using namespace asmjit::a64; | 6 | 6 | using namespace asmjit::a64::Predicate; | 7 | 7 |
| 8 | | -PatchBase::PatchBase(const std::vector<char>& file_buf, const KernelSymbolOffset& sym, | 9 | | - const SymbolAnalyze& symbol_analyze) : m_file_buf(file_buf), m_sym(sym), m_symbol_analyze(symbol_analyze) { | | 8 | +PatchBase::PatchBase(const std::vector<char>& file_buf) : m_file_buf(file_buf), m_kernel_ver_parser(file_buf) {} | 10 | 9 |
| 11 | | -} | 12 | | - | 13 | | -PatchBase::~PatchBase() | 14 | | -{ | 15 | | -} | | 10 | +PatchBase::~PatchBase() {} | 16 | 11 |
| 17 | 12 | int PatchBase::get_cred_atomic_usage_len() { | 18 | 13 | int len = 8; | 19 | | - if (m_symbol_analyze.is_kernel_version_less("6.6.0")) { | | 14 | + if (m_kernel_ver_parser.is_kernel_version_less("6.6.0")) { | 20 | 15 | len = 4; | 21 | 16 | } | 22 | 17 | return len; | @@ -31,10 +26,10 @@ int PatchBase::get_cred_securebits_padding() { | 31 | 26 |
| 32 | 27 | uint64_t PatchBase::get_cap_ability_max() { | 33 | 28 | uint64_t cap = 0x3FFFFFFFFF; | 34 | | - if (m_symbol_analyze.is_kernel_version_less("5.8.0")) { | | 29 | + if (m_kernel_ver_parser.is_kernel_version_less("5.8.0")) { | 35 | 30 | cap = 0x3FFFFFFFFF; | 36 | 31 | } | 37 | | - else if (m_symbol_analyze.is_kernel_version_less("5.9.0")) { | | 32 | + else if (m_kernel_ver_parser.is_kernel_version_less("5.9.0")) { | 38 | 33 | cap = 0xFFFFFFFFFF; | 39 | 34 | } | 40 | 35 | else { | @@ -45,7 +40,7 @@ uint64_t PatchBase::get_cap_ability_max() { | 45 | 40 |
| 46 | 41 | int PatchBase::get_cap_cnt() { | 47 | 42 | int cnt = 0; | 48 | | - if (m_symbol_analyze.is_kernel_version_less("4.3.0")) { | | 43 | + if (m_kernel_ver_parser.is_kernel_version_less("4.3.0")) { | 49 | 44 | cnt = 4; | 50 | 45 | } else { | 51 | 46 | cnt = 5; | |
|