Skip to content

Small helper tool to aid comparing functions between devilution and the original binary

License

Notifications You must be signed in to change notification settings

Chance4us/devilution-comparer

 
 

Repository files navigation

Devilution-comparer

Small binary comparison helper tool for devilution.

Generates an orig.asm and a compare.asm in the current directory and can watch the respective *.pdb for changes.

It can also generate a full disassembly of all specified functions in the config file (see the subcommand generate-full) for that.

Use --help for parameter info.

Example call:

devilution-comparer path\to\Diablo_orig.exe devilution\bld\WinRel\Diablo.exe InitMonsterTRN -w

Requirements

This uses Rust in the 2018 edition (so currently nightly only). In order to generate bindings to the Zydis library, you will also need clang/llvm to generate those.

Since the pdb crate doesn't support the old PDB file format generated by VC++ < 7 yet, this tool needs cvdump.exe from Microsoft (MIT License, license found in cvdump-LICENSE) in its directory. If you aren't on windows, this tool tries to run wine cvdump.exe instead.

The config file

The config file contains a mapping from function name/symbol to its offset (and optionally its size). It has to reside in the path of the devilution-comparer, just like cvdump.

It is specified in the TOML format, version 0.5.

The size element in the function definitions is optional, but is needed for some functions like the full export of the original file.

--help

Generates orig.asm and compare.asm in the current working directory. Finds the function specified in the devilution
binary, disassembles it, then disassembles the original binary with the same length at the specified offset. The
disassembled original code will be written into orig.asm, the devilution code into compare.asm.

Note that the disassembler will use the function offset read from the PDB for both decompilations in order to align the
addresses in the output files (including relative jumps).

USAGE:
    devilution-comparer.exe [FLAGS] <DIABLO_FILE> <DEVILUTION_FILE> <DEBUG_SYMBOL>
    devilution-comparer.exe [FLAGS] <SUBCOMMAND>

FLAGS:
    -h, --help           Prints help information
        --no-imms        Hides all immediate values. Use with caution.
        --no-mem-disp    Hide memory displacements and indirect calls. This cleans up the output tremendously, but can
                         cause you to miss wrong stack variables or globals. Use only with caution.
    -i, --show-ip        Shows leading addresses in the output.
    -V, --version        Prints version information
    -w, --watch          Enable watching for changes to the PDB file, updating the output files on change.

ARGS:
    <DIABLO_FILE>        Path to the original Diablo.exe to use
    <DEVILUTION_FILE>    Sets the debug binary file to use. The respective .pdb file needs to exist in the same
                         folder as well. Currently for files generated by VC6 only.
    <DEBUG_SYMBOL>       Function name/debug symbol to compare. This has to be defined for the original binary in
                         the comparer-config.toml. Is the size attribute missing, devilution-comparer will use the
                         size of the devilution function for the original binary as well.

SUBCOMMANDS:
    generate-full    Generates a 'full.asm' file with all functions defined in comparer-config.toml.
    help             Prints this message or the help of the given subcommand(s)

About

Small helper tool to aid comparing functions between devilution and the original binary

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 94.5%
  • Shell 3.5%
  • PowerShell 2.0%