dfhack
dfhack copied to clipboard
Improve Memory-research.rst documentation
Give more guidance for how to get started on decompiling DF. For instance, the necessary steps for getting useful symbols in IDA Freeware 7.0 on Windows 64-bit:
- Run codegen.pl in df-structures to produce codegen/codegen.out.xml
- Run codegen_c_hdr.pl on codegen/codegen.out.xml to produce codegen.h
- Run ruby.exe dump_df_globals.rb --idc "..\path\to\Dwarf Fortress.exe" and save the MakeName statements
- Open Dwarf Fortress.exe in IDA, wait for it to finish analysis
- File -> Script file..., select ms_rtti64.idc, wait for script to finish
- File -> Script command..., paste in MakeName statements and run
- File -> Load File -> Parse C header file..., select codegen.h
Similar documentation could also be added for Ghidra, though @BenLubar might need to write that (since I don't recall how all of those scripts work).
For Ghidra, it's:
- Run
perl ./codegen.plto producecodegen/codegen.out.xml(the./is important so it can find the perl modules) - Make sure https://github.com/DFHack/df_misc/blob/master/import_df_structures.java is in
~/ghidra_scripts - Optional: create
import_df_structures.propertiesin the same directory asimport_df_structures.javausing the format specified by the comment at the top of the script so you don't have to navigate to the files manually every time - Open Dwarf Fortress in Ghidra, and when it asks if you want to run auto analysis, either say no or cancel the next dialogue box.
- Run the script from the green circle with ▶️ in it (search for DFHack or find DFHack in the tree list on the left to find it faster).
- It will ask for two files (codegen.out.xml and symbols.xml), which will be auto-selected if you did step 3 above.
- Wait for it to finish. It will run auto analysis as part of the script.
Similar documentation could also be added for Ghidra, though @BenLubar might need to write that (since I don't recall how all of those scripts work).
Would also love to see some guidance on using binary ninja with this even though it would only be static analysis.