Describe the bug
Some executables have a code segment at 0xffe, and in Ghidra's MzLoader.java, it's using
space.getAddress(Conv.shortToInt(dos.e_cs()) + csStart, 0); to calculate the segment value.
The Conv.shortToInt will zero padding the higher 16 bit, resulting an unsigned short.
However the dos.e_cs() can be negative, and this is causing problem.
Several places in MzLoader.java also have this problem :)
Attachments
This example is from DEFCON Quals 2020
BBS.zip
Environment (please complete the following information):
I also encountered this problem and have mostly fixed it in my fork. I'll have to clean up a bit and then I'll create a pull request.
Most helpful comment
I also encountered this problem and have mostly fixed it in my fork. I'll have to clean up a bit and then I'll create a pull request.