| 423 | |
| 424 | |
| 425 | uint64_t KernelCache::FastGetImageCount(BinaryNinja::Ref<BinaryNinja::BinaryView> kcView) |
| 426 | { |
| 427 | if (!kcView->GetParentView()) |
| 428 | return 0; |
| 429 | auto reader = BinaryReader(kcView->GetParentView()); |
| 430 | uint32_t magic = reader.Read32(); |
| 431 | if (magic != MH_CIGAM_64 && magic != MH_MAGIC_64) // FIXME 32 bit |
| 432 | { |
| 433 | return 0; |
| 434 | } |
| 435 | reader.Seek(0xc); |
| 436 | uint32_t fileType = reader.Read32(); |
| 437 | if (fileType != MH_FILESET) |
| 438 | { |
| 439 | return 0; |
| 440 | } |
| 441 | uint32_t ncmds = reader.Read32(); |
| 442 | |
| 443 | uint64_t imageCount = 0; |
| 444 | |
| 445 | uint64_t off = 0x20; // FIXME 32 bit |
| 446 | while (ncmds--) |
| 447 | { |
| 448 | reader.Seek(off); |
| 449 | uint32_t cmd = reader.Read32(); |
| 450 | uint32_t cmdsize = reader.Read32(); |
| 451 | if (cmd == LC_FILESET_ENTRY) |
| 452 | { |
| 453 | imageCount++; |
| 454 | } |
| 455 | off += cmdsize; |
| 456 | } |
| 457 | |
| 458 | return imageCount; |
| 459 | } |
| 460 | |
| 461 | |
| 462 | const std::unordered_map<std::string, uint64_t>& KernelCache::AllImageStarts() const |
nothing calls this directly
no test coverage detected