mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-04 04:48:40 +00:00
test optional header fields
This commit is contained in:
committed by
Ryan Fleury
parent
fe967a3d36
commit
25710d39b7
+64
-2
@@ -599,7 +599,9 @@ t_simple_link_test(void)
|
||||
String8 main_obj;
|
||||
{
|
||||
COFF_ObjWriter *obj_writer = coff_obj_writer_alloc(0, COFF_MachineType_X64);
|
||||
COFF_ObjSection *text_sect = coff_obj_writer_push_section(obj_writer, str8_lit(".text"), COFF_SectionFlag_CntCode, str8_array_fixed(text_payload));
|
||||
COFF_ObjSection *text_sect = coff_obj_writer_push_section(obj_writer, str8_lit(".text"), PE_TEXT_SECTION_FLAGS, str8_array_fixed(text_payload));
|
||||
coff_obj_writer_push_section(obj_writer, str8_lit(".data"), PE_DATA_SECTION_FLAGS, str8_lit("qwe"));
|
||||
coff_obj_writer_push_section(obj_writer, str8_lit(".bss"), PE_BSS_SECTION_FLAGS, str8(0, 5));
|
||||
coff_obj_writer_push_symbol_extern(obj_writer, str8_lit("my_entry"), 0, text_sect);
|
||||
main_obj = coff_obj_writer_serialize(scratch.arena, obj_writer);
|
||||
coff_obj_writer_release(&obj_writer);
|
||||
@@ -626,7 +628,7 @@ t_simple_link_test(void)
|
||||
if (pe.is_pe32) {
|
||||
goto exit;
|
||||
}
|
||||
if (pe.section_count != 1) {
|
||||
if (pe.section_count != 3) {
|
||||
goto exit;
|
||||
}
|
||||
if (pe.arch != Arch_x64) {
|
||||
@@ -670,11 +672,71 @@ t_simple_link_test(void)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
COFF_SectionHeader *data_section = t_coff_section_header_from_name(string_table, section_table, pe.section_count, str8_lit(".data"));
|
||||
if (data_section == 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
COFF_SectionHeader *bss_section = t_coff_section_header_from_name(string_table, section_table, pe.section_count, str8_lit(".bss"));
|
||||
if (bss_section == 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
String8 text_data = str8_substr(exe, rng_1u64(text_section->foff, text_section->foff + text_section->vsize));
|
||||
if (!str8_match(text_data, str8_array_fixed(text_payload), 0)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
PE_OptionalHeader32Plus *opt = str8_deserial_get_raw_ptr(exe, pe.optional_header_off, sizeof(*opt));
|
||||
if (opt->sizeof_code != text_section->fsize) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->sizeof_inited_data != text_section->fsize + data_section->fsize) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->sizeof_uninited_data != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->code_base != 0x1000) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->image_base != 0x140000000) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->major_os_ver != 6) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->minor_os_ver != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->major_img_ver != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->minor_img_ver != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->major_subsystem_ver != 6) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->minor_subsystem_ver != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->win32_version_value != 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->sizeof_image != 0x3000) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->sizeof_headers != 0x200) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->dll_characteristics != 0x8120) {
|
||||
goto exit;
|
||||
}
|
||||
if (opt->loader_flags != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
result = T_Result_Pass;
|
||||
exit:;
|
||||
scratch_end(scratch);
|
||||
|
||||
Reference in New Issue
Block a user