A loaded module has a recognizable name byte string at a known offset inside its `struct module` (offset 0x18 on 6.x x86_64). Names are printable, NUL-terminated, ≤ 56 chars.
| 488 | // inside its `struct module` (offset 0x18 on 6.x x86_64). Names are |
| 489 | // printable, NUL-terminated, ≤ 56 chars. |
| 490 | bool plausible_modname(const u8* p, std::size_t len) { |
| 491 | if (len < 2) return false; |
| 492 | if (p[0] < 0x20 || p[0] >= 0x7F) return false; |
| 493 | bool seen_nul = false; |
| 494 | for (std::size_t i = 0; i < len; ++i) { |
| 495 | u8 c = p[i]; |
| 496 | if (c == 0) { seen_nul = true; continue; } |
| 497 | if (seen_nul) return false; |
| 498 | if (c < 0x20 || c >= 0x7F) return false; |
| 499 | // Module names contain underscores, dashes, alphanumeric. |
| 500 | if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || |
| 501 | (c >= '0' && c <= '9') || c == '_' || c == '-')) return false; |
| 502 | } |
| 503 | return seen_nul; |
| 504 | } |
| 505 | |
| 506 | } // anon |
| 507 |
nothing calls this directly
no outgoing calls
no test coverage detected