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.

Difference between revisions of "User:Jifodus/Dwarf Fortress Utility Framework"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
(New page: I'm currently writing a framework for Dwarf Fortress utilities. The general idea is to use C++ interfaces in a cross-compiler fashion that is very easy to use. Please note, since this is ...)
 
Line 3: Line 3:
 
Please note, since this is still currently under development, I don't have the time to make a pretty WikiPage. I also will not post the interface & file format document for the same reason. Once there is a release, I will have a solid data format that will probably never change, as well as unchanging interfaces.
 
Please note, since this is still currently under development, I don't have the time to make a pretty WikiPage. I also will not post the interface & file format document for the same reason. Once there is a release, I will have a solid data format that will probably never change, as well as unchanging interfaces.
  
 +
==Overview==
 +
 +
===Features===
 +
 +
====Current Features====
 +
* Written in C++, using interfaces
 +
** Incomplete memory data stored in Lua format
 +
* Sample utility for implementation reference
 +
* API header & library
 +
* Complete source code
 +
* Identify Dwarf Fortress version via PE executable timestamp
 +
 +
====Expected Initial Release====
 
I'm scheduling the initial release date to be December 15, 2007. At that time, the following features will be in place:
 
I'm scheduling the initial release date to be December 15, 2007. At that time, the following features will be in place:
 
* Written in C++, using interfaces
 
* Written in C++, using interfaces
Line 15: Line 28:
 
* Complete source code
 
* Complete source code
  
After the first release, and it's been thouroghly bug checked, the next release will have:
+
====Second Release====
 +
After the first release, and it's been extensively bug checked, the next release will have:
 
* Auto-retrieve memory data off the internet
 
* Auto-retrieve memory data off the internet
 
* Auto-update framework code itself
 
* Auto-update framework code itself
 
* Have an installer that will install the DLL and data file to a shared location, so multiple utilities can use the same library
 
* Have an installer that will install the DLL and data file to a shared location, so multiple utilities can use the same library
* Implement specific subsets of the std library; reduce utility size more, no large dependencies
+
* Implement specific subsets of the std library; reduce utility size more, no large dependencies for the utilities
 
** std::string
 
** std::string
 
** std::vector
 
** std::vector
Line 25: Line 39:
 
** File IO
 
** File IO
  
 +
====Future====
 
And further down the road (through auto-update):
 
And further down the road (through auto-update):
 
* Easy to use GUI framework; for making tools with a nice GUI
 
* Easy to use GUI framework; for making tools with a nice GUI
 
* Cross-process memory allocation
 
* Cross-process memory allocation
  
Expected Data Format/Requirements
+
==Data Format==
 
 
Native/internal type strings:
 
* string
 
* vector
 
* pointer
 
* dword
 
* word
 
* byte
 
* float
 
* double
 
* raw (array fixed-size array of bytes; size defined by the type)
 
 
 
Object Data Requirements
 
 
 
* string
 
** length : dword -- The length of the string
 
** capacity : dword -- The capacity of the string
 
** buffer : raw -- [Optional] The 16 byte string buffer embedded in the string object
 
** buffer_ptr : pointer -- A pointer to the character data
 
* vector
 
** begin : pointer -- The start of the vector
 
** end : pointer -- The end of the vector
 
** last : pointer -- The just beyond the last possible item in the vector
 
 
 
Requirements For Data Files
 
 
 
Stuff between {} denotes a set of information
 
 
 
-- To format a new type
 
{
 
  type_name, -- [Required]
 
  size, -- [Optional], [Default: 0] In bytes
 
  -- Any number of members can be included into a type definition
 
  member = {
 
  type, -- [Required]
 
  offset, -- [Required]
 
  size, -- [Optional]
 
  subtypes = { -- [Optional], Used to specify the type the vector wraps
 
    array,
 
    of,
 
    more,
 
    types
 
  }, -- (end subtypes)
 
  fixed_size_array_count -- [Optional] [Default: 1]
 
  }, -- (end member)
 
  -- more?
 
}
 
 
 
-- To format a memory location
 
{
 
  pointer_name,
 
  type,
 
  address
 
}
 
 
 
So for example a string can be formatted like this:
 
 
 
{
 
  "string",
 
  28, -- 4 + 16 + 4 + 4
 
  "length" = { dword, 20 },
 
  "capacity" = { dword, 24 },
 
  "buffer" = { type = raw, offset = 4, fixed_size_array_count = 16 }
 
  "buffer_ptr" = { type = pointer, offset = 4 }
 
}
 
 
 
A pointer to the creature vector could be
 
  
{
+
===Requirements===
  "main_creature_vec_location",
+
The framework requires definitions of the following types:
  { type = vector, subtypes = { creature } },
+
* raw: a raw array of bytes; internally it allows access to an array of type.size * type.fixed_array bytes.
  "0x0141FA30"
+
* pointer: a pointer to a location in Dwarf Fortress's memory; can represent a 32-bit pointer
}
+
* dword: an integer type that is 4 bytes
 +
* word: an integer type that is 2 bytes
 +
* byte: an integer type that is 1 byte
 +
* float: a 32-bit floating point type
 +
* double: a 64-bit floating point type
 +
* string: a type that represents a std::string
 +
** required members:
 +
*** '''dword''' length: defines how many characters string contains
 +
*** '''dword''' capacity: defines the maximum number of characters the string buffer can contain
 +
*** '''pointer''' buffer_ptr: a pointer to a memory location containing the string data
 +
** optional members:
 +
*** '''raw''' buffer: a fixed-size array of characters containing the string when length < the fixed size of the buffer
 +
* vector: a type representing a std::vector
 +
** required members:
 +
*** '''pointer''' begin: a pointer to the begining of the memory block
 +
*** '''pointer''' end: a pointer to just beyond of the last valid element in the vector
 +
*** '''pointer''' last: a pointer to just beyond the end of the memory block
  
Of course, this is just a basic idea of what the data files will need. The data will also have to at least include version information.
+
===Data Files===
 +
The data files must supply the following information:
 +
* Types: each element of the type list represents one type; there is a special type called '''Main''', '''Main''' represents the global memory map
 +
* Signatures: each signature is designed to uniquely identify each version of Dwarf Fortress
  
Anyway, a quick overview of the framework as it's supposed to be for the first release.
+
====Lua Data Files====
 +
Classes:
 +
* '''Type''': 'type =' The value can either be a set containing a type override or the string of a type name.
 +
** Type: 'type =' A string representing the Type Name of the type to override.
 +
** Subtypes: An array of type overrides and/or Type Names, that are subtypes of this type.
 +
** Size: 'size =' An integer overriding the size of the type.
 +
** Fixed Array Size: 'fixed_size =' An integer overriding the fixed array size of the type.
 +
* Types: 'Types'
 +
** Version: String representing version
 +
*** TypeName: String representing name of the type, special type is '''Main'''.
 +
**** Size: 'size =' an integer representing
 +
**** Members: 'members' a table of of name value pairs; The name being the Member Name; The value is a set containing the Type and Offset.
 +
***** Member Name: String representing the name
 +
****** Type: 'type =' The value can either be a set containing a '''Type''' override or the name of the of a type.
 +
****** Offset: 'offset =' The member offset (from the base address).
 +
****** Pointer: 'pointer =' The pointer in memory for which the member can be found. Used for the '''Main''' type.
 +
* Signatures 'Signatures'
 +
** Version: String representing the version (same string as types).
 +
*** PE Timestamp: 'pe_timestamp' The PE header timestamp value.
 +
*** .text Adler32: 'adler32' The Adler32 CRC of the ".text" section of the executable.
 +
*** Text Segments: 'text_segments' An array of segments of the ".text" section of the executable.
 +
**** Address: [1] = The offset into the ".text" section that the following raw data can be found.
 +
**** Raw Data: [2] = The data the ".text" segment is supposed to contain.

Revision as of 05:52, 14 December 2007

I'm currently writing a framework for Dwarf Fortress utilities. The general idea is to use C++ interfaces in a cross-compiler fashion that is very easy to use.

Please note, since this is still currently under development, I don't have the time to make a pretty WikiPage. I also will not post the interface & file format document for the same reason. Once there is a release, I will have a solid data format that will probably never change, as well as unchanging interfaces.

Overview

Features

Current Features

  • Written in C++, using interfaces
    • Incomplete memory data stored in Lua format
  • Sample utility for implementation reference
  • API header & library
  • Complete source code
  • Identify Dwarf Fortress version via PE executable timestamp

Expected Initial Release

I'm scheduling the initial release date to be December 15, 2007. At that time, the following features will be in place:

  • Written in C++, using interfaces
  • Memory data
    • Stored in a Lua format
    • Stored in a CSV format
    • Stored in an XML format?
  • Sample utility for implementation reference: reimplementation of StartProfile
  • Library self-contained in DLL
  • API header & library
  • Cross-compiler portable
  • Complete source code

Second Release

After the first release, and it's been extensively bug checked, the next release will have:

  • Auto-retrieve memory data off the internet
  • Auto-update framework code itself
  • Have an installer that will install the DLL and data file to a shared location, so multiple utilities can use the same library
  • Implement specific subsets of the std library; reduce utility size more, no large dependencies for the utilities
    • std::string
    • std::vector
    • Console IO
    • File IO

Future

And further down the road (through auto-update):

  • Easy to use GUI framework; for making tools with a nice GUI
  • Cross-process memory allocation

Data Format

Requirements

The framework requires definitions of the following types:

  • raw: a raw array of bytes; internally it allows access to an array of type.size * type.fixed_array bytes.
  • pointer: a pointer to a location in Dwarf Fortress's memory; can represent a 32-bit pointer
  • dword: an integer type that is 4 bytes
  • word: an integer type that is 2 bytes
  • byte: an integer type that is 1 byte
  • float: a 32-bit floating point type
  • double: a 64-bit floating point type
  • string: a type that represents a std::string
    • required members:
      • dword length: defines how many characters string contains
      • dword capacity: defines the maximum number of characters the string buffer can contain
      • pointer buffer_ptr: a pointer to a memory location containing the string data
    • optional members:
      • raw buffer: a fixed-size array of characters containing the string when length < the fixed size of the buffer
  • vector: a type representing a std::vector
    • required members:
      • pointer begin: a pointer to the begining of the memory block
      • pointer end: a pointer to just beyond of the last valid element in the vector
      • pointer last: a pointer to just beyond the end of the memory block

Data Files

The data files must supply the following information:

  • Types: each element of the type list represents one type; there is a special type called Main, Main represents the global memory map
  • Signatures: each signature is designed to uniquely identify each version of Dwarf Fortress

Lua Data Files

Classes:

  • Type: 'type =' The value can either be a set containing a type override or the string of a type name.
    • Type: 'type =' A string representing the Type Name of the type to override.
    • Subtypes: An array of type overrides and/or Type Names, that are subtypes of this type.
    • Size: 'size =' An integer overriding the size of the type.
    • Fixed Array Size: 'fixed_size =' An integer overriding the fixed array size of the type.
  • Types: 'Types'
    • Version: String representing version
      • TypeName: String representing name of the type, special type is Main.
        • Size: 'size =' an integer representing
        • Members: 'members' a table of of name value pairs; The name being the Member Name; The value is a set containing the Type and Offset.
          • Member Name: String representing the name
            • Type: 'type =' The value can either be a set containing a Type override or the name of the of a type.
            • Offset: 'offset =' The member offset (from the base address).
            • Pointer: 'pointer =' The pointer in memory for which the member can be found. Used for the Main type.
  • Signatures 'Signatures'
    • Version: String representing the version (same string as types).
      • PE Timestamp: 'pe_timestamp' The PE header timestamp value.
      • .text Adler32: 'adler32' The Adler32 CRC of the ".text" section of the executable.
      • Text Segments: 'text_segments' An array of segments of the ".text" section of the executable.
        • Address: [1] = The offset into the ".text" section that the following raw data can be found.
        • Raw Data: [2] = The data the ".text" segment is supposed to contain.