Temple.DLL internal workings discussion

Discussion in 'TemplePlus' started by chaos, Feb 9, 2015.

Remove all ads!
  1. DarkStorm

    DarkStorm Established Member

    Joined:
    Oct 2, 2003
    Messages:
    514
    Likes Received:
    3
    After digging into how keyboard/mouse work, this is also a pretty important one:

    101DE050 get_key_state
     
  2. chaos

    chaos Member

    Joined:
    Feb 8, 2015
    Messages:
    7
    Likes Received:
    0
    In the past I've tweaked the Python 2.2 headers to be compatible with IDA. My work folders are a mess, but I think I've found the right files. You can check "python-headers.zip" here:

    https://onedrive.live.com/?cid=28BA36BA0AE7093B&id=28BA36BA0AE7093B!109

    "Python.h" is all you'd want to include via the "File -> Load -> Parse C Header" menu.
     
  3. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    Hmm, I'm getting an error for a missing stdio.h when trying that. And copying it from my Visual Studio library is no go... any ideas?
     
  4. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,655
    Likes Received:
    352
    Re: Temple.DLL

    Sitra, since you have clearly mastered the .dll, be a dear and tell me where the feats are kept (particularly the hard-coded prerequisites). Use the Activator if you're not sure. I see no reason a few like Leadership and Deft Hands can't be done immediately, and if we could get GWS or Improved Precise Shot, that's be a bonus too :)
     
  5. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    Hey you, no abusing your mod privileges to spam my dll thread! :angry:

    Here's a dump of relevant info - I haven't explored it very thoroughly yet though.
    In principle feats are just conditions, though, and I hope to be able to extend those as well to create new effects as desired. (note: I have no real idea what the Activator is :p)

    Code:
    1007C080 ; int __cdecl Obj_Has_Feat__by_class(ObjHndl, int nFeat_Code, int nClass_Code, int nRange_Specialization_Feat)
    
    102BFD78 feat_properties_table
    
     Partial Flag specification:
                    0x00000002 - Feat disabled
                    0x00000004 - Race Specific Feat
                    0x00000008 - Class Specific Feat
                    0x00000010 - Fighter Feat???
                    0x00020000 - Metamagic Feat
                    0x00040000 - Rogue Feat
    
    102CA9E0 racist_feats_table
    
    102CAAF8 class_feats_table
      Each class has an entry.
        Each entry has 40 Subentries (fixed length with a terminator)
          Subentry: feat_num(int32) , lvl_req(int32)
         Terminator subentry is FFFFFFFF, FFFFFFFF
    
     
  6. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    Oh, and in related news, DS has kindly provided a working Python .til file - attached. (I'll also put it in the DLL thread)

    Put it in ida\til\pc
    In IDA, go to Loaded Type Libraries, right click (or press Ins) and select the file from the list.
     

    Attached Files:

  7. chaos

    chaos Member

    Joined:
    Feb 8, 2015
    Messages:
    7
    Likes Received:
    0
    @Sitra Achara: I do not recall how I got my Python headers to work. Good thing you and DarkStorm managed to.

    I was looking at the dispatcher types that Sitra Achara researched into. I came across the function at 100E2400. It looks like it uses dispatcher type 2 at address 100E243F. I saw this called from something I assume is finalization code. So maybe dispatcher type 2 is "destroyed".

    This lead me to this function: 100E2120. It looks like a lot of the calls to the dispatcher go through there. I went throught the calls very quickly.

    Below are some of the types I saw and what I assume them to be:

    6 - ping (I don't really know what "ping" means. I've seen it used in the code. Maybe it's executed every frame)
    9 - time related. I initially thought it might be for the onset of a new day. I no longer do.
    27 - enter combat
    37 - perform_activate_item_via_radial_menu_action (I've no idea what this is) :)
    40 - some spell resistance/immunity thing
    42 - trip
    45 - another spell resistance/immunity thing
    48 - begin round
    49 - reflex and save damage
    59 - begin restoration spell
     
  8. DarkStorm

    DarkStorm Established Member

    Joined:
    Oct 2, 2003
    Messages:
    514
    Likes Received:
    3
    That's likely, actually. I've seen terminology like "tig_kb_ping" which is executed every frame to grab the keyboard state (which buttons are pressed, etc.). Same for tig_mouse_ping.
     
  9. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,613
    Likes Received:
    537
    Thanks, added!
     
  10. chaos

    chaos Member

    Joined:
    Feb 8, 2015
    Messages:
    7
    Likes Received:
    0
    Maybe adding these is a bit rushed as I really didn't take the time to double check them. A remark that these are not certain might be in order.
     
  11. chaos

    chaos Member

    Joined:
    Feb 8, 2015
    Messages:
    7
    Likes Received:
    0
    @DarkStorm: What is your approach to running with DX9? Is it just regular temple.dll hacking or something fancier?

    I am interested in this, because I am doing some experiments in C++. I need the DX SDK from August 2007 just to get my stuff working. This seems like a huge overkill, considering that the latest Windows SDKs (that are included in the free versions of Visual Studio) now come with directX 9 included.


    @Sitra Archara: Here are some more dispatcher types: :)

    Code:
    UNKNOWN_SAVING_THROW_0xD = 0xD,
    UNKNOWN_SAVING_THROW_0xE = 0xE,
    UNKNOWN_SAVING_THROW_0x2C = 0x2C,
    STAT_BASE_LEVEL_GET = 0x42,
    SIZE_GET = 0x47,
    And some dispatcher keys (I wrote these in decimal for some unknown reason):

    Code:
    [SIZE="1"]1 - STAT_STRENGTH
    2 - STAT_DEXTERITY
    3 - STAT_CONSTITUTION
    4 - STAT_INTELLIGENCE
    5 - STAT_WISDOM
    6 - STAT_CHARISMA
    
    7 - SAVE_THROW_FORTITUDE
    8 - SAVE_THROW_REFLEX
    9 - SAVE_THROW_WILL
    
    20 - SKILL_APPRAISE
    21 - SKILL_BLUFF
    22 - SKILL_CONCENTRATION
    23 - SKILL_DIPLOMACY
    24 - SKILL_DISABLE_DEVICE
    25 - SKILL_GATHER_INFORMATION
    26 - SKILL_HEAL
    27 - SKILL_HIDE
    28 - SKILL_INTIMIDATE
    29 - SKILL_LISTEN
    30 - SKILL_MOVE_SILENTLY
    31 - SKILL_OPEN_LOCK
    32 - SKILL_SLEIGHT_OF_HAND
    33 - SKILL_SEARCH
    34 - SKILL_SENSE_MOTIVE
    35 - SKILL_SPELLCRAFT
    36 - SKILL_SPOT
    37 - SKILL_TUMBLE
    38 - SKILL_USE_MAGIC_DEVICE
    39 - SKILL_SURVIVAL
    40 - SKILL_PERFORM
    41 - SKILL_ALCHEMY
    42 - SKILL_BALANCE
    43 - SKILL_CLIMB
    44 - SKILL_CRAFT
    45 - SKILL_DECIPHER_SCRIPT
    46 - SKILL_DISGUISE
    47 - SKILL_ESCAPE_ARTIST
    48 - SKILL_FORGERY
    49 - SKILL_HANDLE_ANIMAL
    50 - SKILL_INNUENDO
    51 - SKILL_INTUIT_DIRECTION
    52 - SKILL_JUMP
    53 - SKILL_KNOWLEDGE_ARCANA
    54 - SKILL_KNOWLEDGE_RELIGION
    55 - SKILL_KNOWLEDGE_NATURE
    56 - SKILL_KNOWLEDGE_ALL
    57 - SKILL_PROFESSION
    58 - SKILL_READ_LIPS
    59 - SKILL_RIDE
    60 - SKILL_SWIM
    61 - SKILL_USE_ROPE[/SIZE]
     
  12. DarkStorm

    DarkStorm Established Member

    Joined:
    Oct 2, 2003
    Messages:
    514
    Likes Received:
    3
    I am using the SDK from 2010
     
  13. DarkStorm

    DarkStorm Established Member

    Joined:
    Oct 2, 2003
    Messages:
    514
    Likes Received:
    3
  14. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,655
    Likes Received:
    352
    Sitra: another quick spell question if you don't mind. Do you see any reference in the .dll to rules/SpellList.mes? I have always suspected that file does absolutely nothing (they seem to have given up seriously doing it around Control Undead) and would like a confirm or deny :)
     
  15. DarkStorm

    DarkStorm Established Member

    Joined:
    Oct 2, 2003
    Messages:
    514
    Likes Received:
    3
    I could not find any references to "SpellList" (even without .mes) in the DLL.
     
Our Host!