Read a NUL-terminated string from a kernel VA via the kernel page table. Returns empty string if the read fails or the area is unmapped.
| 37 | // Read a NUL-terminated string from a kernel VA via the kernel page table. |
| 38 | // Returns empty string if the read fails or the area is unmapped. |
| 39 | std::string read_kernel_string(const Engine& eng, VAddr va, std::size_t maxlen) { |
| 40 | if (!eng.kernel().dtb_validated) return {}; |
| 41 | std::vector<char> buf(maxlen, 0); |
| 42 | eng.kernel_pt().read(va, buf.data(), maxlen); |
| 43 | std::size_t n = 0; |
| 44 | while (n < maxlen && buf[n]) ++n; |
| 45 | return std::string(buf.data(), n); |
| 46 | } |
| 47 | |
| 48 | ByteBuf gen_banner_via_kernel_pt(const Engine& eng) { |
| 49 | const auto* sym = eng.isf().find_symbol("linux_banner"); |
no test coverage detected