v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Editing 40d:Memory hacking

Jump to navigation Jump to search

Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.

You are editing a page for an older version of Dwarf Fortress ("Main" is the current version, not "40d"). Please make sure you intend to do this. If you are here by mistake, see the current page instead.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
{{Quality|Superior|11:03, 18 May 2015 (UTC)}}
+
== New string format ==
{{av}}
 
== Versions ==
 
See the following subpages for version specific information
 
* '''[[Memory hacking/v0.27.169.33g|v0.27.169.33g]]'''
 
* [[Memory hacking/v0.27.169.33f|v0.27.169.33f]]
 
* [[Memory hacking/v0.27.169.33e|v0.27.169.33e]]
 
* [[Memory hacking/v0.27.169.33d|v0.27.169.33d]]
 
* [[Memory hacking/v0.27.169.33c|v0.27.169.33c]]
 
* [[Memory hacking/v0.27.169.33b|v0.27.169.33b]]
 
* [[Memory hacking/v0.27.169.33a|v0.27.169.33a]]
 
* [[Memory hacking/v0.28.181.40d16|v0.28.181.40d16]]
 
* [[Memory hacking/v0.28.181.40d17|v0.28.181.40d17]]
 
* [[Memory hacking/v0.28.181.40d18|v0.28.181.40d18]]
 
* [[Memory hacking/v0.28.181.40d19|v0.28.181.40d19]]
 
 
 
== Data Types ==
 
=== String ===
 
  
 
{|  border="1" cellpadding="2" width="100%"
 
{|  border="1" cellpadding="2" width="100%"
 
| Offset || Size || Type || Description
 
| Offset || Size || Type || Description
 
|-
 
|-
| 0x00 || 4 || Junk || Junk data that exists due to a curious artifact in the C++ standard. Technically it's the allocator - in reality, the default allocator has no data associated with it.
+
|0x00 || 16 || Character buffer || Holds the string data if capacity < 16
|-
 
| 0x04 || 16 || Character buffer || Holds the string data if capacity < 16
 
 
|-
 
|-
| 0x04 || 4 || Character pointer || Points to the string data if capacity >= 16
+
|0x00 || 4 || Character pointer || Points to the string data if capacity >= 16
 
|-
 
|-
| 0x14 || 4 || Length || Current length of the string
+
|0x10 || 4 || Length || Current length of the string
 
|-
 
|-
| 0x18 || 4 || Capacity || Current capacity of the string buffer (also indicates which mode the string is in)
+
|0x14 || 4 || Capacity || Current capacity of the string buffer (also indicates which mode the string is in)
 
|}
 
|}
  
Yes, the second two items overlap. This is correct. This is the MSVC Express string format - Toady appears to be using standard C++ structures pretty much everywhere.
+
Yes, the first two items overlap. This is correct. This is the MSVC Express string format - Toady appears to be using standard C++ structures pretty much everywhere.
  
=== Vector ===
+
== Vector format ==
  
 
{|  border="1" cellpadding="2" width="100%"
 
{|  border="1" cellpadding="2" width="100%"
 
| Offset || Size || Type || Description
 
| Offset || Size || Type || Description
 
|-
 
|-
| 0x00 || 4 || Junk || Junk data that exists due to a curious artifact in the C++ standard. Technically it's the allocator - in reality, the default allocator has no data associated with it.
+
|0x00 || 4 || vtable || (not useful)
|-
 
| 0x04 || 4 || Array start
 
 
|-
 
|-
| 0x08 || 4 || Array end || (End - Start)/4 = # of elements (if pointers)
+
|0x04 || 4 || Array start
 
|-
 
|-
| 0x0C || 4 || Array allocated end || (Allocated End - Start)/4 = capacity (if pointers)
+
|0x08 || 4 || Array end || (End - Start)/4 = # of elements
 
|}
 
|}
  
== Type ID list ==
+
== Attention! ==
 +
We need to be very clear about what version(s) these addresses apply to.  Please list version numbers along with addresses.
 +
 
 +
== Addresses for 27.169.33a ==
  
Most likely incomplete, but this was all that could be found so far.
+
{| border="1" cellpadding="2" width="100%"
 +
! width="25%" | Name
 +
! width="50%" | Notes
 +
! width="25%" | Address
  
{|  border="1" cellpadding="2" width="100%"
 
| ID || Meaning
 
 
|-
 
|-
| <code>0x00</code> || Miner
+
| colspan="3" | '''Useful Variables'''
 +
 
 
|-
 
|-
| <code>0x01</code> || Woodworker
+
| Art defacement malus
 +
| normally -1000 (18 FC FF FF)
 +
| 0079DC2F
 +
 
 
|-
 
|-
| <code>0x02</code> || Carpenter
+
| Current Year
 +
|  
 +
| 00C34378
 +
 
|-
 
|-
| <code>0x03</code> || Bowyer
+
| Dwarf Race ID
 +
| As in the race identifier in the [[#Creature Structure]]
 +
| 01237AD0 (probably)
 +
 
|-
 
|-
| <code>0x04</code> || Woodcutter
+
| Creature Vector
 +
|
 +
| 01416A48 (probably)
 +
 
 +
|}
 +
 
 +
 
 +
== Creature Structure ==
 +
 
 +
Appears to be still valid in version 27.169.33a (keep this updated when things don't seem to shift around)
 +
 
 +
Structure Offsets:
 +
{|  border="1" cellpadding="2" width="100%"
 +
| Offset || Size || Type || Description
 
|-
 
|-
| <code>0x05</code> || Stoneworker
+
|0x00 || 4 || Vptr || Virtual function table pointer
 
|-
 
|-
| <code>0x06</code> || Engraver
+
|0x04 || 24 || First name || See above string format
 
|-
 
|-
| <code>0x07</code> || Mason
+
|0x32 || 4 || Surname word 1 || No part of speech, like in the old structure
 
|-
 
|-
| <code>0x08</code> || Ranger
+
|0x36 || 4 || Surname word 2 ||  
 
|-
 
|-
| <code>0x09</code> || Animal Caretaker
+
|0x70 || 24 || Custom profession name || See above string format
 
|-
 
|-
| <code>0x0A</code> || Animal Trainer
+
|0x88 || 2 || Type ID #1 || rowspan="2"| Dwarf types. 0x88 is the original dwarf type, 0x8a is the current dwarf type (I'm told Toady stores the original dwarf type for legends). The key is in the "Type ID" table, woefully incomplete.
 
|-
 
|-
| <code>0x0B</code> || Hunter
+
|0x8a || 2 || Type ID #2
 
|-
 
|-
| <code>0x0C</code> || Trapper
+
|0x8C || 4 || Creature Race || A6 is the dwarf default (this may be different if the user has a mod installed)
 
|-
 
|-
| <code>0x0D</code> || Animal Dissector
+
|0xe4 || 4 || Flags || (1 << 1) if creature is dead (redundant?)
 
|-
 
|-
| <code>0x0E</code> || Metalsmith
+
|0xe8 || 4 || Flags || (1 << 7) if creature is dead (redundant?)
 +
(1 << 17) if creature is ready for slaughter
 
|-
 
|-
| <code>0x0F</code> || Furnace Operator
+
|0x1F8 || 2 || Strange mood || 0xFFFF means no mood
 
|-
 
|-
| <code>0x10</code> || Weaponsmith
+
|0x41C || 4 || Strength || 0 to 5
 
|-
 
|-
| <code>0x11</code> || Armorer
+
|0x420 || 4 || Agility || 0 to 5
 
|-
 
|-
| <code>0x12</code> || Blacksmith
+
|0x424 || 4 || Toughness || 0 to 5
 
|-
 
|-
| <code>0x13</code> || Metalcrafter
+
|0x42C || 4 || Skill Start Ptr || Start of skill list
 
|-
 
|-
| <code>0x14</code> || Jeweler
+
|0x430 || 4 || Skill End Ptr || End of skill list
 
|-
 
|-
| <code>0x15</code> || Gem Cutter
+
|0x458 || 102 || Labor preferences || 102 1 byte values, corresponding to the profession list. Mostly bools, with notable exceptions of shieldtype,armortype, and weaponnum. I have No idea what the last one means.
 
|-
 
|-
| <code>0x16</code> || Gem Setter
+
|0x504 || 4 || Happiness level || 0 = miserable, >149 = ecstatic
 
|-
 
|-
| <code>0x17</code> || Craftsman
+
|}
|-
+
 
| <code>0x18</code> || Woodcrafter
+
== Type ID list ==
|-
+
 
| <code>0x19</code> || Stonecrafter
+
Hideously incomplete and may be completely wrong.
|-
+
 
| <code>0x1A</code> || Leatherworker
+
{| border="1" cellpadding="2" width="100%"
|-
+
| ID || Meaning
| <code>0x1B</code> || Bone Carver
 
|-
 
| <code>0x1C</code> || Weaver
 
|-
 
| <code>0x1D</code> || Clothier
 
|-
 
| <code>0x1E</code> || Glassmaker
 
|-
 
| <code>0x1F</code> || Strand Extractor
 
|-
 
| <code>0x20</code> || Queen
 
|-
 
| <code>0x21</code> || Queen Consort
 
|-
 
| <code>0x22</code> || Fishery Worker
 
|-
 
| <code>0x23</code> || Fisherman
 
|-
 
| <code>0x24</code> || Fish Dissector
 
 
|-
 
|-
| <code>0x25</code> || Fish Cleaner
+
|0x00 || Miner
 
|-
 
|-
| <code>0x26</code> || Farmer
+
|0x04 || Woodcutter
 
|-
 
|-
| <code>0x27</code> || Cheese Maker
+
|0x2f || Planter
 
|-
 
|-
| <code>0x28</code> || Milker
+
|0x29 || Cook
 
|-
 
|-
| <code>0x29</code> || Cook
+
|0x31 || Brewer
 
|-
 
|-
| <code>0x2A</code> || Thresher
+
|0x37 || Mechanic
 
|-
 
|-
| <code>0x2B</code> || Miller
+
|0x3e || Architect
 
|-
 
|-
| <code>0x2C</code> || Butcher
+
|0x6c || Peasant or creature
 
|-
 
|-
| <code>0x2D</code> || Tanner
 
|-
 
| <code>0x2E</code> || Dyer
 
|-
 
| <code>0x2F</code> || Planter
 
|-
 
| <code>0x30</code> || Herbalist
 
|-
 
| <code>0x31</code> || Brewer
 
|-
 
| <code>0x32</code> || Soap Maker
 
|-
 
| <code>0x33</code> || Potash Maker
 
|-
 
| <code>0x34</code> || Lye Maker
 
|-
 
| <code>0x35</code> || Wood Burner
 
|-
 
| <code>0x36</code> || Engineer
 
|-
 
| <code>0x37</code> || Mechanic
 
|-
 
| <code>0x38</code> || Siege Engineer
 
|-
 
| <code>0x39</code> || Siege Operator
 
|-
 
| <code>0x3A</code> || Pump Operator
 
|-
 
| <code>0x3B</code> || Clerk
 
|-
 
| <code>0x3C</code> || Administrator
 
|-
 
| <code>0x3D</code> || Trader
 
|-
 
| <code>0x3E</code> || Architect
 
|-
 
| <code>0x3F</code> || Alchemist
 
|-
 
| <code>0x40</code> || Tax Collector
 
|-
 
| <code>0x41</code> || Hammerer
 
|-
 
| <code>0x42</code> || Baroness
 
|-
 
| <code>0x43</code> || Countess
 
|-
 
| <code>0x44</code> || Duchess
 
|-
 
| <code>0x45</code> || Baroness Consort
 
|-
 
| <code>0x46</code> || Countess Consort
 
|-
 
| <code>0x47</code> || Duchness Consort
 
|-
 
| <code>0x48</code> || Philosopher
 
|-
 
| <code>0x49</code> || Advisor
 
|-
 
| <code>0x4A</code> || Dungeon Master
 
|-
 
| <code>0x4B</code> || Merchant
 
|-
 
| <code>0x4C</code> || Diplomat
 
|-
 
| <code>0x4D</code> || Guild Representative
 
|-
 
| <code>0x4E</code> || Merchant Baroness
 
|-
 
| <code>0x4F</code> || Merchant Princess
 
|-
 
| <code>0x50</code> || Outpost Liaison
 
|-
 
| <code>0x51</code> || Druid
 
|-
 
| <code>0x52</code> || Champion
 
|-
 
| <code>0x53</code> || Hammerman
 
|-
 
| <code>0x54</code> || Hammer Lord
 
|-
 
| <code>0x55</code> || Spearman
 
|-
 
| <code>0x56</code> || Spearmaster
 
|-
 
| <code>0x57</code> || Crossbowman
 
|-
 
| <code>0x58</code> || Elite Crossbowman
 
|-
 
| <code>0x59</code> || Wrestler
 
|-
 
| <code>0x5A</code> || Elite Wrestler
 
|-
 
| <code>0x5B</code> || Axeman
 
|-
 
| <code>0x5C</code> || Axe Lord
 
|-
 
| <code>0x5D</code> || Swordsman
 
|-
 
| <code>0x5E</code> || Swordmaster
 
|-
 
| <code>0x5F</code> || Maceman
 
|-
 
| <code>0x60</code> || Mace Lord
 
|-
 
| <code>0x61</code> || Pikeman
 
|-
 
| <code>0x62</code> || Pikemaster
 
|-
 
| <code>0x63</code> || Bowman
 
|-
 
| <code>0x64</code> || Elite Bowman
 
|-
 
| <code>0x65</code> || Blowgunner
 
|-
 
| <code>0x66</code> || Elite Blowgunner
 
|-
 
| <code>0x67</code> || Recruit
 
|-
 
| <code>0x68</code> || Hunting creature
 
|-
 
| <code>0x69</code> || War creature
 
|-
 
| <code>0x6A</code> || Master Thief
 
|-
 
| <code>0x6B</code> || Thief
 
|-
 
| <code>0x6C</code> || Peasant or creature
 
|-
 
| <code>0x6D</code> || Child
 
|-
 
| <code>0x6E</code> || Baby
 
|-
 
| <code>0x6F</code> || Drunk
 
|-
 
| <code>0x70</code> || Lasher
 
|-
 
| <code>0x71</code> || Master Lasher
 
 
|}
 
|}
  
 
== Profession list ==
 
== Profession list ==
 +
 +
Obviously could do with some formatting.
 +
 
  PROFESSION_MINE,
 
  PROFESSION_MINE,
 
  PROFESSION_HAUL_STONE,
 
  PROFESSION_HAUL_STONE,
Line 388: Line 242:
 
  PROFESSION_UNUSED_30,
 
  PROFESSION_UNUSED_30,
 
  PROFESSIONNUM,
 
  PROFESSIONNUM,
[[Category:Guides]] [[Category:Hacking]]
 

Please note that all contributions to Dwarf Fortress Wiki are considered to be released under the GFDL & MIT (see Dwarf Fortress Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)