Need a function for event timer
Moderators: Nefarius, Havvoric
- devurandom
- Angel
- Posts: 897
- Joined: Sat Mar 07, 2015 9:07 pm
Need a function for event timer
Hello,
Need a basic function I can hook for a once every XX seconds event check. Timing accuracy is not important, so I'd rather avoid hooking a top level function like StatRegen, since there's no need.
Can someone suggest another function to look for in D2game.dll ?
Thanks in Advance
Need a basic function I can hook for a once every XX seconds event check. Timing accuracy is not important, so I'd rather avoid hooking a top level function like StatRegen, since there's no need.
Can someone suggest another function to look for in D2game.dll ?
Thanks in Advance
Assembly Reference | 1.13d Code Edits | UVLoD | BaseMod Plugin
Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..
Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..
Re: Need a function for event timer
Code: Select all
D2FUNC(D2GAME, Timer, void, __fastcall, (game *pGame, UnitAny *pUnit, int Type, DWORD Frame, (void __fastcall * CALLBACK_E)(game* pGame, UnitAny* pUnit, int Type, DWORD arg1, DWORD arg2), DWORD arg1, DWORD arg2), 0x8EA80)
I hope that's what you mean
- Necrolis
- Throne
- Posts: 9125
- Joined: Sat Mar 25, 2006 1:22 pm
- Location: The Land of the Dead
- Contact:
Re: Need a function for event timer
There are a few options for timers; there are the quest ones which are a little more versatile (as they are recurring, just return false):
Then there is the event system that is used to create all delayed events (recurring events like stat regen just reset the callback in the callback). If you set a callback fn, the Event number can be anything:
Note: all addresses & protos are for 1.10
Code: Select all
/*
Date: Thu May 20 09:42:07 2010
Author: Necrolis
Function: QUESTS_CreateTimer
Address: D2Game.0x6FC94690
Comments:
*/
typedef bool (__fastcall * questupdate_t) (D2GameStrc* pGame, D2QuestDataStrc* pQuest);
void __fastcall QUESTS_CreateTimer(D2QuestDataStrc* pQuest, questupdate_t pfCallback, int nTicks)
Code: Select all
/*
Date: Wed Jun 17 18:00:47 2009
Author: Necrolis
Function: EVENTS_SetEvent
Address: D2Game.0x6FC351D0 & D2Game.0x6FC35570 & D2Game.0x6FC353D0
Comments:
*/
typedef void (__fastcall * EVENTCALLBACK) (D2GameStrc* pGame, D2UnitStrc* pUnit, int nEvent, DWORD dwArg, DWORD dwArgEx);
void __fastcall EVENTS_SetEvent(D2GameStrc* pGame, D2UnitStrc* pUnit, int nEvent, int dwFrame, EVENTCALLBACK pfExtra, DWORD dwArg, DWORD dwArgEx)
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal
- devurandom
- Angel
- Posts: 897
- Joined: Sat Mar 07, 2015 9:07 pm
Re: Need a function for event timer
Thanks for the quick reply's
Sorry, for not explaining well. I'm not up to speed yet on higher level language, but starting to map function address calls, and seeing the limitations of asm.
The addresses Necrolis posted are enough though to investigate and patch in some assembly to check if bean counter stored in memory address can trigger event.
Thanks!
Sorry, for not explaining well. I'm not up to speed yet on higher level language, but starting to map function address calls, and seeing the limitations of asm.
The addresses Necrolis posted are enough though to investigate and patch in some assembly to check if bean counter stored in memory address can trigger event.
Thanks!
Assembly Reference | 1.13d Code Edits | UVLoD | BaseMod Plugin
Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..
Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..
Re: Need a function for event timer
If you want very simple solution for that, hook D2GAME.6FCDFF40 (1.13d) (you can find offset on other patch quickly if you search for const 0x70000000)
Then add own checks
Code: Select all
void SERVER_ParseEvents(Game *pGame<eax>)
Code: Select all
if (!(ptGame->GameFrame % 20)) // code will run each 20 frames, 25 frames = 1 sec
QUESTS_Update(ptGame);
My CE Tools:
D2 Offset Calculator
D2 Offset Calculator
- Necrolis
- Throne
- Posts: 9125
- Joined: Sat Mar 25, 2006 1:22 pm
- Location: The Land of the Dead
- Contact:
Re: Need a function for event timer
In 1.10 that same bit of code is here (pretty sure I've posted this before):lolet" wrote:If you want very simple solution for that, hook D2GAME.6FCDFF40 (1.13d) (you can find offset on other patch quickly if you search for const 0x70000000)Then add own checksCode: Select all
void SERVER_ParseEvents(Game *pGame<eax>)
Code: Select all
if (!(ptGame->GameFrame % 20)) // code will run each 20 frames, 25 frames = 1 sec QUESTS_Update(ptGame);
Code: Select all
6FC38877 . 8B87 A8000000 MOV EAX,DWORD PTR DS:[EDI+A8]
6FC3887D . B9 14000000 MOV ECX,14
6FC38882 . 99 CDQ
6FC38883 . F7F9 IDIV ECX
6FC38885 . 85D2 TEST EDX,EDX
6FC38887 . 75 07 JNZ SHORT D2Game.6FC38890
6FC38889 . 8BCF MOV ECX,EDI
6FC3888B . E8 F0BC0500 CALL D2Game.6FC94580
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal
- devurandom
- Angel
- Posts: 897
- Joined: Sat Mar 07, 2015 9:07 pm
Re: Need a function for event timer
lolet" wrote:If you want very simple solution for that, hook D2GAME.6FCDFF40 (1.13d) (you can find offset on other patch quickly if you search for const 0x70000000)
Only one instance in this const in D2Game (1.13d). So correct value 8000000 to give mod 25?Necrolis" wrote: Fun fact: that mod by 20 is a bug, its a relic of when D2 used to run at 20 fps (a relic of D1), the shrine code has a similar bug; it should actually be mod 25.
All very useful information. I didn't find much searching before except for StatRegen.
How do you guys make these functions... from the code, some type of Hex-Rays analysis?
Assembly Reference | 1.13d Code Edits | UVLoD | BaseMod Plugin
Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..
Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..
- Necrolis
- Throne
- Posts: 9125
- Joined: Sat Mar 25, 2006 1:22 pm
- Location: The Land of the Dead
- Contact:
Re: Need a function for event timer
I don everything with ollydbg, its a lot faster these days though because of the massive base I have already built up.devurandom" wrote:How do you guys make these functions... from the code, some type of Hex-Rays analysis?
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal
- devurandom
- Angel
- Posts: 897
- Joined: Sat Mar 07, 2015 9:07 pm
Re: Need a function for event timer
I think I still have a lot to learn.
Assembly Reference | 1.13d Code Edits | UVLoD | BaseMod Plugin
Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..
Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..
- kidpaddle94
- Principality
- Posts: 2057
- Joined: Thu Aug 13, 2009 2:54 pm
- Location: localhost
Re: Need a function for event timer
I also myself always reverse from Ollydbg. Although I also use hex-rays sometimes to get a general idea.
Re: Need a function for event timer
In general you learn alot by rewrite all code in a function, some of us have been here since early days (I started 2003 and coded right away). So, it's 12 years of experience with d2's code, and those of us who rewrite the code in c++ quickly build up a list of functions.
For debugging I use ollydbg, and w32dsm.
For debugging I use ollydbg, and w32dsm.
- devurandom
- Angel
- Posts: 897
- Joined: Sat Mar 07, 2015 9:07 pm
Re: Need a function for event timer
Thanks for the info. Never thought I'd see the need to learn C++ coming from Unix, but I can see the need at this point. -Necessity is the mother of all invention.
@Whist.. Looking at D2Template, looks very enticing for my next dist.
@Whist.. Looking at D2Template, looks very enticing for my next dist.
Assembly Reference | 1.13d Code Edits | UVLoD | BaseMod Plugin
Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..
Fiat paper money is the most elaborate and well devised form of slavery the world has ever seen..
Re: Need a function for event timer
How does 1.13c do this with OllyDbg?Cossack wrote: ↑Tue Sep 29, 2015 8:06 amfor 1.13cCode: Select all
D2FUNC(D2GAME, Timer, void, __fastcall, (game *pGame, UnitAny *pUnit, int Type, DWORD Frame, (void __fastcall * CALLBACK_E)(game* pGame, UnitAny* pUnit, int Type, DWORD arg1, DWORD arg2), DWORD arg1, DWORD arg2), 0x8EA80)
I hope that's what you mean
Re: Need a function for event timer
x64dbg are more powerfull than ollydbg. Check it out! https://github.com/x64dbg/x64dbg
Re: Need a function for event timer
卡洛克 wrote: ↑Fri Mar 13, 2020 2:51 am<font style="vertical-align: inherit;"><font style="vertical-align: inherit;">[quote = devurandom post_id = 484024时间= 1443651178 user_id = 43175] </font></font>
<font style="vertical-align: inherit;"><font style="vertical-align: inherit;">我想我还有很多东西要学习。</font></font>
<font style="vertical-align: inherit;"><font style="vertical-align: inherit;">[/ quote] </font></font>
<font style="vertical-align: inherit;"><font style="vertical-align: inherit;">x64dbg比ollydbg更强大。</font><font style="vertical-align: inherit;">一探究竟!</font><font style="vertical-align: inherit;">https://github.com/x64dbg/x64dbg:D</font></font>
How to change C + + to OD and write DLL?