Thanks a lot!
I now have a working LUA-script that returns true or false based on those variables and with the few test saves I have it seems to work so far at least.
If you don't mind, could you expand a bit on these parts:
I figured this out by opening the 64-bit Windows version of v0.47.04 in IDA Freeware 7.0, running some scripts to import the structure definitions and locate the globals, then searching for the code that displays the " SIEGE " indicator.
I downloaded the software, opened the df exe and looked around, but while I can search, I don't see much to relate it back to dfhack which I'm guessing is the lack of said structure definitions.
The structure definitions are all found in the
DFHack/df-structures GitHub repository. You'll need a suitable version of Perl in order to make proper use of them, as mentioned in the DFHack
build instructions.
There are also several important scripts in the
DFHack/df_misc repository, some of which require Ruby and the
metasm module:
- dump_df_globals.rb - run it against the Dwarf Fortress EXE with the "--idc" output to produce a bunch of "MakeName(...);" lines, which you then copy/paste into IDA's "File -> Script command" window. This will assign labels to all of the global variables.
- codegen_c_hdr.pl - copy into the "df-structures" repository, run codegen.pl, then run codegen_c_hdr.pl codegen\codegen.out.xml codegen_win64.h, and finally feed that into IDA's "File -> Load File -> Parse C header file".
- ms_rtti64.idc - just feed this directly into IDA's "File -> Script file" and wait a minute or so. This will identify all of the virtual classes used in DF (such as building and item subtypes) and make it a bit easier to find some things.
Note that the version of
codegen_c_hdr.pl in the repository doesn't actually work right now, since it hasn't been kept up-to-date with updates to the structures XML format. I'll see if I can remedy that in the near future.
Of course, once you've done those setup tasks, there's still the matter of learning
how to locate relevant code and figure out what it's doing, but entire
books could be written on such topics and I don't have the time to do that right now.