Skip to content

Commit 5ea647d

Browse files
committed
disasm: Recognize swars executable based on headers and sections
1 parent f9dd4ab commit 5ea647d

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/known_file.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,35 @@
2222
#include "label.hpp"
2323
#include "regions.hpp"
2424

25+
#include "le.hpp"
26+
2527
void
2628
KnownFile::check(Analyser &anal, LinearExecutable *le)
2729
{
28-
anal.known_type = KnownFile::KNOWN_SWARS_FINAL_MAIN;
30+
const LinearExecutable::Header *header = le->get_header();
31+
32+
anal.known_type = KnownFile::NOT_KNOWN;
33+
34+
if (header->eip_offset == 0xd581c &&
35+
header->esp_offset == 0x9ffe0 &&
36+
header->last_page_size == 0x34a &&
37+
header->fixup_section_size == 0x5d9ca &&
38+
header->loader_section_size == 0x5df3f &&
39+
header->object_count == 4)
40+
{
41+
if (le->get_object_header(0)->virtual_size == 0x12d030 &&
42+
le->get_object_header(0)->base_address == 0x10000 &&
43+
le->get_object_header(1)->virtual_size == 0x96 &&
44+
le->get_object_header(1)->base_address == 0x140000 &&
45+
le->get_object_header(2)->virtual_size == 0x9ffe0 &&
46+
le->get_object_header(2)->base_address == 0x150000 &&
47+
le->get_object_header(3)->virtual_size == 0x1b58 &&
48+
le->get_object_header(3)->base_address == 0x1f0000)
49+
{
50+
anal.known_type = KnownFile::KNOWN_SWARS_FINAL_MAIN;
51+
return;
52+
}
53+
}
2954
}
3055

3156
void

0 commit comments

Comments
 (0)