uxmal / reko

Reko is a binary decompiler.
https://uxmal.github.io/reko
GNU General Public License v2.0
2.1k stars 251 forks source link

MS-DOS: Doesn't take CS segment into account #1250

Open rfalke opened 1 year ago

rfalke commented 1 year ago

Reko version: b3d6f88 Subject: https://github.com/rfalke/decompiler-subjects/tree/master/from_holdec/i386_16bit_segment/ia32_mz

The output function is called two times with a far call. The linear address is the same but the CS is different. The CS is used in the output function and outputs first 'a' and then 'q' ('a'+16).

Reko doesn't reflect this twist:

void fn0800_0000()
{
    fn0800_0017();
    fn0800_0017();
    msdos_terminate(0x00);
}

void fn0800_0017()
{
    msdos_direct_console_output(seg0800->b0021);
}

char g_b0021 = 'a'; // 0800:0021

I assume that there are multiple ways to model this (if it is supported at all):

Sample output for (2):

void fn0800_0000()
{
    fn0800_0017();
    fn0801_0007();
    msdos_terminate(0x00);
}

void fn0800_0017()
{
    msdos_direct_console_output(seg0800->b0021);
}

void fn0801_0007()
{
    msdos_direct_console_output(seg0801->b00??);
}

char g_b0021 = 'a'; // 0800:0021
char g_b00?? = 'q';
uxmal commented 1 year ago

This will have to be rolled into the scannerv2 effort.