removed nesting

This commit is contained in:
2026-02-04 18:33:05 +03:00
parent d64d60cfcd
commit c25a3da196

View File

@@ -259,8 +259,11 @@ namespace
{ {
const auto* lc = reinterpret_cast<const LoadCommand*>(base + cmd_offset); const auto* lc = reinterpret_cast<const LoadCommand*>(base + cmd_offset);
if (lc->cmd == segment_cmd) if (lc->cmd != segment_cmd)
{ {
cmd_offset += lc->cmdsize;
continue;
}
const auto* segment = reinterpret_cast<const SegmentType*>(base + cmd_offset); const auto* segment = reinterpret_cast<const SegmentType*>(base + cmd_offset);
std::size_t sect_offset = cmd_offset + sizeof(SegmentType); std::size_t sect_offset = cmd_offset + sizeof(SegmentType);
@@ -268,23 +271,19 @@ namespace
{ {
const auto* section = reinterpret_cast<const SectionType*>(base + sect_offset); const auto* section = reinterpret_cast<const SectionType*>(base + sect_offset);
if (get_section_name(section->sectname) == target_section_name && section->size > 0) if (get_section_name(section->sectname) != target_section_name && section->size > 0)
{ {
sect_offset += sizeof(SectionType);
continue;
}
const auto* section_begin = base + static_cast<std::size_t>(section->addr); const auto* section_begin = base + static_cast<std::size_t>(section->addr);
const auto* section_end = section_begin + static_cast<std::size_t>(section->size); const auto* section_end = section_begin + static_cast<std::size_t>(section->size);
const auto scan_result = const auto scan_result = omath::PatternScanner::scan_for_pattern(section_begin, section_end, pattern);
omath::PatternScanner::scan_for_pattern(section_begin, section_end, pattern);
if (scan_result != section_end) if (scan_result != section_end)
return reinterpret_cast<std::uintptr_t>(scan_result); return reinterpret_cast<std::uintptr_t>(scan_result);
} }
sect_offset += sizeof(SectionType);
}
}
cmd_offset += lc->cmdsize;
} }
return std::nullopt; return std::nullopt;