Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile

Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
New Server | HOMM1: info forum | HOMM2: info forum | HOMM3: info forum | HOMM4: info forum | HOMM5: info forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Heroes 4 - Lands of Axeoth > Thread: H4 dll researching
Thread: H4 dll researching This thread is 2 pages long: 1 2 · «PREV

Known Hero
posted January 07, 2019 11:57 PM

There should be more hidden on the russian df forum. Lost was being an Equi Leading Programmer for  quite some time.

But after all that time it looks faster to "re-discover" it again.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link

Famous Hero
posted January 08, 2019 01:53 PM

NimoStar said:
So you can understand what I am talking about:

The part about abilities in H4 is that the list is not a programmable set of instructions.

Its just like this

6A A0 6A B1 6A 07...

Those aren't instructions by themselves, its just a dataset for the part of the code which is the implementation.

We don't need to change the implementation, at least that wasn't the idea now (anyways the abilities implemented themselves are quite adequate), just that creatures are "Hardcoded" to have a certain number of abilities - for example, just 1 for the minotaur - and there is no space in the code to put more. Reading assembly code is not going to change that.

Therefore what equi team had done is: Take an "unused" chunk of space in h4 .exe code; replace the part on the Orc on the original list for an instruction to jump to that offset; and put after the altered part an instruction to jump back (tyhe formerly "blank" space has more hexes to write a longer list of abilities than the original). The only "programming" bits are the instruction which is a single hex, so seeing it in assembly instead of in hexadecimal is not going to make a difference in that.

Calculating the offsets is the hard part to make the jumps go to the exact hex needed.

I am not saying those tools aren't useful, just that they don't seem to do that, do they?

You can still skip the whole making calculations stuff. I suspect there is a better way to patch creature abilities because 6A A0 6A B1 6A 07... (if that's indeed an example) just sounds like pushing ability IDs on the stack which would later be converted for use in a faster and more convenient manner.

For example let's say the code you showed is at:
0x500000 6A
0x500001 A0
0x500002 6A
0x500003 B1
0x500004 6A
0x500005 07
0x500006 ...

Instead of going to 0x500000 and writing a JMP to 0x700000, copying all the instructions there and adding your own, then writing a jump back to 0x500006, with patcher_x86 and a dll you could make something like:

int __stdcall MinotaurAbilities(LoHook *h, HookContext *c)
c->Push(1); // give ability 1
c->Push(2); // give ability 2...
c->return_address = ...; // set the return address after original code
return NO_EXEC_DEFAULT; // skip the original overwritten code at 0x500000


_PI->WriteLoHook(0x500000, MinotaurAbilities); // setup the "code cave"

This code will 100% not work (just an example) but it is much less painless to add or remove from it, fix and correct, review later, and share. Plus, you don't need to do hex calculations to place the JMP, patcher_x86 takes care of it.
My Let's Plays: Metataxer's Revenge - The Empire of The World 2

 Send Instant Message | Send E-Mail | View Profile | PP | Quote Reply | Link

Known Hero
posted January 08, 2019 06:22 PM

RoseKavalier great posts, definitely deserve a QP for each of them (too bad we don't have an active mod here). When I can actually get a little further on the Resource Editor I will definitely be back here to try out the dll stuff.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link

Supreme Hero
Modding the Unmoddable
posted January 08, 2019 09:25 PM

Seems like a feasible idea.

Right now my personal situation doesnt allow me to learn and implement this sort of programming/coding, but will definitely give it a try later on if things calm down on RL
Discover H4 Greatest Mod!
(Also biggest of only two 2 mods for HOMM IV)

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link

Famous Hero
posted January 10, 2019 11:46 PM

Just adding this as a reminder in case someone manages to advance with the dll insertion.. http://heroescommunity.com/viewthread.php3?TID=45476

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread » This thread is 2 pages long: 1 2 · «PREV
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0237 seconds