-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attempting to decompile DOS Commander Keen 4 #1287
Comments
Oh, I now downloaded https://github.com/uxmal/reko/releases/download/version-0.11.4/WindowsDecompiler-0.11.4-x64-2b56adbc68.zip instead of https://github.com/uxmal/reko/releases/download/version-0.11.4/Reko-0.11.4-x64-2b56adbc68.msi and the .zip version worked, whereas the .msi version didn't. I was now able to view the decompiled function. Although something feels wrong there. I have a function where I believe the orange block on the left generates the decompiled code on the right. (btw, it would be cool to get highlights on the other side when clicking on a line on one side!) The decompilation of that assembly reads
but I don't think that is correct? Shouldn't it be
? |
Wow, a lot to unpack there! Thanks for taking the time to report this so thoroughly. In order:
do
;
while (__in<byte>(0x03DA) & 0x01); I will investigate after I fix the loading issue.
|
Thanks for the detailed reply. In the end I was able to get the decompilation done, and I ended up with manually cleaning up the result for documentation: Reko provided decompilation: Eq_6 fn238C_07C5(Eq_6 ds, Eq_6 wArg04, Eq_6 bArg06, union Eq_6 & cxOut)
{
__cli();
do
;
while ((__in<byte>(0x03DA) & 0x01) == 0x00);
do
;
while ((__in<byte>(0x03DA) & 0x01) != 0x00);
__out<byte>(0x03D4, 0x0C);
__out<byte>(0x03D5, SLICE(wArg04, byte, 8));
__out<byte>(0x03D4, 0x0D);
__out<byte>(0x03D5, (byte) wArg04);
Mem43[ds:0xE314:word16] = 0x00;
while (Mem43[ds:0xE314:word16] <u 0x09)
{
__sti();
__cli();
if ((__in<byte>(0x03DA) & 0x08) != 0x00)
break;
}
__out<byte>(0x03C0, 0x33);
__out<byte>(0x03C0, bArg06);
__sti();
cxOut = wArg04;
return bArg06;
} My manual cleanup with comments: extern volatile int global_interrupt_timer;
void scroll_screen(int start_address, int pixel_shift)
{
disable();
while (!(inp(0x3DA) & 1)) /*nop*/ ; // Skip visible regions, i.e. wait until we are in start of blank
while (inp(0x3DA) & 1) /*nop*/ ; // Skip blank regions, i.e. wait until we are in visible picture area
// We are now in start of a visible scanline
outp(0x3D4, 0xC);
outp(0x3D5, start_address >> 8);
outp(0x3D4, 0xD);
outp(0x3D5, start_address);
// Wait until start of vertical retrace
global_interrupt_timer = 0;
while(global_interrupt_timer < 9)
{
enable();
NOP();
disable();
if (inp(0x3DA) & 8)
break;
}
outp(0x3C0, 0x33);
outp(0x3C0, pixel_shift);
enable();
} This is for investigating https://www.vogons.org/viewtopic.php?f=63&t=96028 I wonder if some of the transformations above might be something that could be interesting to clean up automatically? E.g. do
;
while ((__in<byte>(0x03DA) & 0x01) == 0x00); to while ((__in<byte>(0x03DA) & 0x01) == 0x00) /*nop*/; also maybe The construct Last, the line I don't know if it is interesting to be "proper C" out of the box, since the pattern Something that I struggled for quite a while is that I had two custom functions that I had located using IDA: Another thing I was struggling was to figure out when I saw that Great tool overall - it is hard to find good disassembler + decompilers out there. |
Attached a crash log of the Restart/Open crash. (I got this both when clicking on the |
* New unpacking script for LzExe 0.91 (addresses part of #1287) * New `reko.dasm` OllyScript command. * Change CMakeLists.txt to use correct version number.
How strange. I'm unable to reproduce this on my development rig. |
I have the same exception, while trying to open any procedure in the program I compiled with gcc/x86_64-w64-mingw32/12.2.0/ Reko decompiler version 0.11.5.0 (git:a2c8f84b9c) |
@NancyAurum: your binary uncovered some juicy bugs in Reko that I've fixed in commit c7ac7f3. However, I cannot reproduce the exception you are reporting. What exactly are you doing when installing Reko? Are you using the MSI files provided, or building from source? |
I installed the Reko on Windows 11 using the pre-compiled MSI you provide. I also have Visual Studio 2022, which I believe could be overriding some CLR stuff. Generally I wanted to use Reko to check if the compiler generated code good enough. |
I wanted to decompile a couple of functions from old Commander Keen 4 game.
but the link did not point to a .NET 6.0 download. Instead searched with google to get https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-6.0.413-windows-x64-installer
Used 7-zip to decompress the archive to get to KEEN4E.exe.
Noticed Reko was not able to decompile that exe directly. Although there is a LZ uncompressor tool at https://keenwiki.shikadi.net/wiki/UNLZEXE (namely https://files.shikadi.net/keenwiki/tools/t.unlzexe_v.0.81_win_32-bit.gerstrong.2010-07-04.zip ) to produce an uncompressed KEEN4E.exe.
I was able to then disassemble the file into the IDE.
I then wanted to find all locations in the binary that contain an assembly instruction with an immediate
3DAh
as operand, (e.g.mov cx, 3DAh
. Though I was not quite able to figure out how to do that. So I downloaded IDA Freeware 5.0 from https://www.scummvm.org/news/20180331/ where I was able to find a function entry point 0x27D8 that contains an interesting immediate3DAh
that I'd like to examine. Unfortunately IDA does not provide a decompiler, so I switched back to looking at the function at 0x27D8 with Reko.I then proceeded to disassemble KEEN4E.exe with Reko, and in the function list that appeared, I double clicked on "fn0800_27d8" to view its contents.
I was met with an exception
Could not load file or assembly 'DynamicData, Version=7.1.0.0'
:Not sure if I am missing some DLL installation. Manually installing https://download.visualstudio.microsoft.com/download/pr/8d1443fd-a5e1-438d-8cb8-6ccb9849a54a/4f89f2b74a9c272789dfac8658a87673/dotnet-sdk-6.0.413-win-x64.exe did not work to resolve that. I was thinking maybe version 7.1.0.0 might have been referring to .NET 4.7.1, but attempting to install that came back with an error that it was already installed.
Is the missing assembly due to me missing some installation, or I wonder if my use case is too dumb to work with a modern tool?
Thanks!
The text was updated successfully, but these errors were encountered: