Diablo 2 mods
 


Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: Mon Jul 22, 2013 6:28 am 
 Post subject: [1.13c] Function Tables
 
Offline
Principality
User avatar

Age: 22
Joined: Thu Aug 13, 2009 2:54 pm
Posts: 2014
Location: localhost
Gender: Male
Diablo II 1.13c Function Tables

This thread is meant to document various function tables used by the game.
Credits are due to various users here @The Phrozenkeep


D2GS Client->Server Packets (D2Game.0xFA078)
This table contains receptor functions for D2GS packets sent by the clients to the server.
Don't know what the field labeled as BOOL b does. I believe it may be related to hack detection, although I'm pretty sure it's not used outside of realm.

struct
{
   int (__fastcall* D2GsClt2SrvPacket_t)(D2GameStrc* pGame, D2UnitStrc* pUnit, void* pPacket, int nPacketSize);
   BOOL b;
};


********************************************************************

D2GS Server->Client Packets (D2Client.0xDDE60)
This table contains the receptor functions for D2GS packets sent by the server to the client.
A size of -1 in the the nPacketSize field means the packet has variable size
struct
{
   void (__fastcall* D2GsSrv2CltPacket_t)(void* pPacket);
   int nPacketSize;
   void (__fastcall* D2GsSrv2CltPacketEx_t)(D2UnitStrc* pUnit, void* pPacket)
};


********************************************************************

Skills SrvStFunc (D2Game.0x107338)
This table contains the skills SrvStFunc functions.

struct
{
   int (__fastcall* D2SkillSrvStFunc_t)(D2GameStrc* pGame, D2UnitStrc* pUnit, int nSkill, int nSkillLevel);
};


********************************************************************

Skills SrvDoFunc (D2Game.0x1074A8)
This table contains the skills SrvDoFunc functions.

struct
{
   int (__fastcall* D2SkillSrvDoFunc_t)(D2GameStrc* pGame, D2UnitStrc* pUnit, int nSkill, int nSkillLevel);
};


********************************************************************

Skills CltStFunc (D2Client.0xDE928)
This table contains the skills CltStFunc functions.

struct
{
   int (__fastcall* D2SkillCltStFunc_t)(D2UnitStrc* pUnit, int nSkill, int nSkillLevel);
};


********************************************************************

Skills CltDoFunc (D2Client.0xDEA48)
This table contains the skills CltDoFunc functions.

struct
{
   int (__fastcall* D2SkillCltDoFunc_t)(D2UnitStrc* pUnit, int nSkill, int nSkillLevel);
};


********************************************************************

Objects Server Init (D2Game.0x10E050)
This table contains object init functions (InitFn in Objects.txt)

struct D2ObjInitFnStrc
{
   D2GameStrc* pGame;            //0x00
   D2UnitStrc* pObject;         //0x04
   D2RoomStrc* pRoom;            //0x08
   D2ObjDataStrc* pObjData;      //0x0C
   D2ObjectsTXT* pObjectRecord;   //0x10
   int nX;                     //0x14
   int nY;                     //0x18
};

struct
{
   int (__fastcall* D2ObjInit_t)(D2ObjInitFnStrc* pInitFn);
};


********************************************************************

Objects Server Operate (D2Game.0x107BB8)
This table contains objects operating functions (OperateFn in Objects.txt)

struct D2ObjOperateFnStrc
{
   D2GameStrc* pGame;         //0x00
   D2UnitStrc* pObject;      //0x04
   D2UnitStrc* pPlayer;      //0x08
   D2ObjDataStrc* pObjData;   //0x0C
   int nObjectClass;         //0x10
};

struct
{
   int (__fastcall* D2ObjOperate_t)(D2ObjOperateFnStrc* pOperateFn);
};



********************************************************************

Items Spell Functions (D2Game.0x107238)
This table contains item spell functions (pSpell column from Armor/Misc/Weapons.txt)
On the second callback, the return value defines whether the item is destroyed or not (0 = no, 1 = yes)

struct
{
   int (__fastcall* D2ItemSpellInit_t)(D2GameStrc* pGame, D2UnitStrc* pUnit, D2UnitStrc* pItem, D2UnitStrc* pTarget, int nX, int nY, int nSkill);
   int (__fastcall* D2ItemSpell_t)(D2GameStrc* pGame, D2UnitStrc* pUnit, D2UnitStrc* pItem, D2UnitStrc* pTarget, int nX, int nY, int nSkill);
};


********************************************************************

Event Functions (D2Game.0x1077A8)
This table is used both by skills and item stats.
In the case of items it's used for ItemEventFuncs, and for skills it's used by various things in skills.txt
The prototype args are polymorphic.

struct
{
   union
   {
      int (__fastcall* D2ItemEventFunc)(D2GameStrc* pGame, int nEvent, D2UnitStrc* pUnit, D2UnitStrc* pTarget, D2DamageStrc* pDamage, DWORD dwStat, DWORD dwArg);
      int (__fastcall* D2SkillEventFunc)(D2GameStrc* pGame, int nEvent, D2UnitStrc* pUnit, D2UnitStrc* pTarget, D2DamageStrc* pDamage, int nSkill, int nSkillLevel);
   };
};


********************************************************************

Item Properties Functions (D2Common.0x9B0C8)
This table contains functions used to handle item properties. More information can be found here

struct
{
   int (__fastcall* D2PropFunc_t)(int nPropType, D2UnitStrc* pSrcUnit, D2UnitStrc* pUnit, D2PropertyStrc* pProp, int nSet, int nStat, int nParam, int nPrevValue, int nState, DWORD dwListFlags, DWORD dw0);
};


********************************************************************

Cube Special Outputs (D2Game.0xFA5E8)
This table contains functions for special cube outputs, like the cow level portal.
However only one entry is used in single player. (The functions for uber trist aren't available, they just return 0)

struct
{
   int (__fastcall* D2CubeOutput_t)(D2GameStrc* pGame, D2UnitStrc* pUnit);
};


********************************************************************

Missiles SrvDoFunc Functions (D2Game.0x10D970)
This table contains missiles SrvDoFunc functions (pSrvDoFunc field in Missiles.txt)

struct
{
   void (__fastcall* D2MslSrvDoFunc_t)(D2GameStrc* pGame, D2UnitStrc* pMissile);
};


********************************************************************

Missiles SrvHitFunc Functions (D2Game.0x10DA48)
This table contains missiles SrvHitFunc functions (pSrvHitFunc field in Missiles.txt)

struct
{
   int (__fastcall* D2MslSrvHitFunc_t)(D2GameStrc* pGame, D2UnitStrc* pMissile, D2UnitStrc* pTarget);
};


********************************************************************

Missiles SrvDmgFunc Functions (D2Game.0x10DB68)
This table contains missiles SrvDmgFunc functions (pSrvDmgFunc field in Missiles.txt)

struct
{
   void (__fastcall* D2MslSrvDmgFunc_t)(D2GameStrc* pGame, D2UnitStrc* pMissile, D2UnitStrc* pTarget, D2DamageStrc* pDamage);
};


********************************************************************

Missiles CltDoFunc Functions (D2Client.0xDD8A0)
This table contains missiles CltDoFunc functions (pCltDoFunc field in Missiles.txt)

struct
{
   void (__fastcall* D2MslCltDoFunc_t)(D2UnitStrc* pMissile);
};


********************************************************************

Missiles CltHitFunc Functions (D2Client.0xDDA10)
This table contains missiles CltHitFunc functions (pCltHitFunc field in Missiles.txt)

struct
{
   int (__fastcall* D2MslCltHitFunc_t)(D2UnitStrc* pMissile, D2UnitStrc* pTarget);
};

_________________
1.13c Code Edits Compilation | 1.13c Function Tables
D2Template | Median XL: Sigma


Last edited by kidpaddle94 on Tue Apr 12, 2016 1:34 pm, edited 9 times in total.

Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 22, 2013 11:45 am 
 Post subject: Re: [1.13c] Major Function Tables
 
Offline
Paladin
User avatar

Joined: Wed Jun 05, 2013 8:31 pm
Posts: 124
Gender: None specified
Seems like we need function table category and pages in our wiki. Thanks for the share.

EDIT:

Are these the base addresses of the tables? If so, what are the sizes of the tables?


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 22, 2013 11:49 am 
 Post subject: Re: [1.13c] Major Function Tables
 
Offline
Site Admin
Site Admin
User avatar

Joined: Sat Jan 11, 2003 12:51 pm
Posts: 10618
Gender: None specified
it's the relative address to tables, so base address is not included.

_________________
CLICK HERE To Read The Forum Terms of Service

Diabolic Studios Website | Diabolic Studios Forum


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 22, 2013 11:56 am 
 Post subject: Re: [1.13c] Major Function Tables
 
Offline
Principality
User avatar

Age: 22
Joined: Thu Aug 13, 2009 2:54 pm
Posts: 2014
Location: localhost
Gender: Male
kingpin wrote:
it's the relative address to tables, so base address is not included.


^ This

I post addresses using the file offset at 90% of time, as these addresses do not reallocate.
It just makes it simpler for everyone I think.

_________________
1.13c Code Edits Compilation | 1.13c Function Tables
D2Template | Median XL: Sigma


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 22, 2013 11:59 am 
 Post subject: Re: [1.13c] Major Function Tables
 
Offline
Site Admin
Site Admin
User avatar

Joined: Sat Jan 11, 2003 12:51 pm
Posts: 10618
Gender: None specified
I would probably say use both.

_________________
CLICK HERE To Read The Forum Terms of Service

Diabolic Studios Website | Diabolic Studios Forum


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 22, 2013 12:38 pm 
 Post subject: Re: [1.13c] Major Function Tables
 
Offline
Paladin
User avatar

Joined: Wed Jun 05, 2013 8:31 pm
Posts: 124
Gender: None specified
Slight miscommunication there on my side, what I meant was "is this the displacement for the beginning of the table" (and I suppose the answer is yes), not "is this the displacement or the base address". I could see from the size of the numbers that it can't be the base address ; ) Thanks anyhow, you answered that part of my question.

So how large are the tables? Same as what Nefarius posted?


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 22, 2013 1:01 pm 
 Post subject: Re: [1.13c] Major Function Tables
 
Offline
Principality
User avatar

Age: 22
Joined: Thu Aug 13, 2009 2:54 pm
Posts: 2014
Location: localhost
Gender: Male
JDS wrote:
Slight miscommunication there on my side, what I meant was "is this the displacement for the beginning of the table" (and I suppose the answer is yes), not "is this the displacement or the base address". I could see from the size of the numbers that it can't be the base address ; ) Thanks anyhow, you answered that part of my question.

So how large are the tables? Same as what Nefarius posted?


Oh okay. Well, every address listed are the address of the beginning of the table.
As for the size, I didn't feel the need of listing it as you can easily find it out by looking at the table.

Just by looking at code where the table base address is referenced, at 80% of time you will find all kind of checks that look like this:
6FCB1D29  |.  66:3D BF00    |CMP AX,0BF
6FCB1D2D  |.  7D 39         |JGE SHORT D2Game.6FCB1D68


Some times it's a constant reference, but some times it point to a variable pointer (which most of time is located at the end of the table)
Like in the case of items pspells
6FCCD175  |>  3B1D 3073D26F CMP EBX,DWORD PTR DS:[6FD27330]
6FCCD17B  |.  0F8D 87000000 JGE D2Game.6FCCD208

6FD27330              1F 00 00 00                   ...


Those are IMO the most convenient as you can easily patch the lookup to your own variable

_________________
1.13c Code Edits Compilation | 1.13c Function Tables
D2Template | Median XL: Sigma


Last edited by kidpaddle94 on Tue Jul 23, 2013 7:30 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 22, 2013 1:14 pm 
 Post subject: Re: [1.13c] Major Function Tables
 
Offline
Site Admin
Site Admin
User avatar

Joined: Sat Jan 11, 2003 12:51 pm
Posts: 10618
Gender: None specified
Remember some tables may have multiple places where it's used, so hope you posting all places it's loaded at. Didn't check the entries you added, but know from alot tables I moved into c++. There have been multiple entries to take care off.

Also, add the limit is kinda important if you want extend the table, or basically just want to know how many free table entries there is that you can add directly in asm. I think for general knowledge it's good also. But, know that takes time, so maybe something's to think about in future.

_________________
CLICK HERE To Read The Forum Terms of Service

Diabolic Studios Website | Diabolic Studios Forum


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 22, 2013 2:16 pm 
 Post subject: Re: [1.13c] Major Function Tables
 
Offline
Senior Moderator
Senior Moderator
User avatar

Age: 25
Joined: Sat Mar 25, 2006 1:22 pm
Posts: 8721
Location: The Land of the Dead
Gender: Male
kingpin wrote:
Remember some tables may have multiple places where it's used, so hope you posting all places it's loaded at. Didn't check the entries you added, but know from alot tables I moved into c++. There have been multiple entries to take care off.

Also, add the limit is kinda important if you want extend the table, or basically just want to know how many free table entries there is that you can add directly in asm. I think for general knowledge it's good also. But, know that takes time, so maybe something's to think about in future.
More importantly, in later versions (1.11b+) where the more aggressive optimizer is used, certain refs to constant entries in tables are inlined (the pointers are copied out and used for compares or directly as defaults etc), certain tables may also be disjointly referenced (ie: there are refs to element 0, 1 etc. or the base of the table is offset because of optimizations).

Also be careful with free entries etc, I've caught a few case where something looks like free space but gets overwritten by massive memsets/init loops (and as an addendum to this, the starts of some tables are actually used as sentinel/end addresses for compiler optimized loops, if you replace them without checking, you can cause many memory related problems).

_________________
Image
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 22, 2013 3:39 pm 
 Post subject: Re: [1.13c] Major Function Tables
 
Offline
Paladin
User avatar

Joined: Wed Jun 05, 2013 8:31 pm
Posts: 124
Gender: None specified
Are they loaded directly from the data region of some dll, or are they put there by some other init code? I.e., if I modify the table in memory and write my changes to the executable (assuming that's possible), while the changes still be there when I load the dll the next time?

Sorry for all the questions but I'm currently putting up this: http://phrozen-library.wikia.com/wiki/C ... tion_Table


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 22, 2013 4:11 pm 
 Post subject: Re: [1.13c] Major Function Tables
 
Offline
Site Admin
Site Admin
User avatar

Joined: Sat Jan 11, 2003 12:51 pm
Posts: 10618
Gender: None specified
changes are there as long as you do BaseAddress + relative address. This because of ASLR or like they did in 1.10+, dll got reallocated and if you did full address it would very probably crash because it tries access a memory it shouldn't.

in c++ you would do this:

static DWORD CommonOffset = (DWORD)LoadLibrary("D2Common.dll");

then access the adress you do this: (CommonOffset + relativeaddress).

What could be important is to mention LoadLibrary.

Just as a note for other modders, always follow this and don't try to cheat it, because if you do your mod will be incompatible with win7/vista.

_________________
CLICK HERE To Read The Forum Terms of Service

Diabolic Studios Website | Diabolic Studios Forum


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 22, 2013 6:26 pm 
 Post subject: Re: [1.13c] Major Function Tables
 
Offline
Paladin
User avatar

Joined: Wed Jun 05, 2013 8:31 pm
Posts: 124
Gender: None specified
Thanks, that answered my question :)


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 15, 2016 4:21 pm 
 Post subject: Re: [1.13c] Function Tables
 
Offline
Principality
User avatar

Age: 22
Joined: Thu Aug 13, 2009 2:54 pm
Posts: 2014
Location: localhost
Gender: Male
Updated.

_________________
1.13c Code Edits Compilation | 1.13c Function Tables
D2Template | Median XL: Sigma


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Black Rock template by onyx (based on BlackSoul for phpBB2)