Diablo 2 mods
 


Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Sep 14, 2017 3:59 pm 
 Post subject: Gardenia - PlugY fork
 
Offline
Knight

Joined: Sat Oct 16, 2010 4:29 pm
Posts: 39
Gender: None specified
Hello all,

I was gonna wait a bit longer before posting here about this but might as well do it now since I've cleaned up a bunch of stuff already. So basically I ended up forking the PlugY source code in order to do the following things:

1. Remove all features that weren't allowed by the Diablo II IncGamers Single Player Forum
2. Rewrite a lot of the core module loading code and offset/function pointer retrieval in order to facilitate the updating of the mod.
3. Use modern C++ practices.

I was able to remove a lot of preprocessor usages that were being used before (I still need to remove a lot more of them and move more of those preprocessor substitutions into the new object model) and implemented a proper object model for each of the libraries. Due to the new object model, it is much more easy to read the code and see what functions you would need to look for in the new version. I don't think that updating to 1.14 would be as difficult as before, and even if Blizzard merged all of the .dlls into the .exe, it might be easier providing that once you load up Game.exe and retrieve its base offset, every other offset that you would get would be based off of that one. With the new object model in place, the internal infrastructure can remain the same.

Example, if we wanted to get the D2GetDropRoom function pointer that is in the D2Common dll, we can easily do:

D2Common->D2GetDropRoom

If we wanted to get the D2LoadInventory function that is in D2Game, we could do:

D2Game->D2LoadInventory

All function pointers for the corresponding version are dynamically retrieved when the LibraryLoader first starts up (Before anything else).

You can find the source code here: https://github.com/fearedbliss/Gardenia

It is released under the GPLv3 since that's the license Yohann used. I'm not a pro at ASM so I'm still trying to learn ways to improve my reverse engineering skills and be able to better find offsets. At the moment the only idea I have is to use the latest 1.13d offsets and try to do a pattern match for each function that the app requires, that would probably only get us so far until something more than just updating the function pointer kicks in. If anyone wants to assist in updating it to 1.14, now would be the time to do so.

EDIT: I wasn't able to figure out how to get my Visual Studio's debugger to hit a breakpoint for the project, so I did all of this by just using the log file output. It was a pain but it's not the first time I've had to work on something without a debugger.

EDIT 2 (13/9/17): I figured out how to attach the debugger to the code. At the moment I'm able to debug anything after the DLL is loaded and called by D2 (attach to Game.exe). However, I'm still trying to get the debugger to work during the init stages of the DLL (Before D2 fully starts but the dll's init is called).. It might be as simple as attaching to the Gardenia.exe with specific settings (and of course having debug symbols).


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 14, 2017 6:15 pm 
 Post subject: Re: Gardenia - PlugY fork
 
Offline
Warrior
User avatar

Joined: Sat Jun 14, 2008 11:00 am
Posts: 12
Location: England
Gender: Male
Sounds great! Thanks for all the hard work so far :D


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 14, 2017 7:46 pm 
 Post subject: Re: Gardenia - PlugY fork
 
Offline
Senior Moderator
Senior Moderator
User avatar

Age: 26
Joined: Sat Mar 25, 2006 1:22 pm
Posts: 8811
Location: The Land of the Dead
Gender: Male
FearedBliss wrote:
EDIT 2 (13/9/17): I figured out how to attach the debugger to the code. At the moment I'm able to debug anything after the DLL is loaded and called by D2 (attach to Game.exe). However, I'm still trying to get the debugger to work during the init stages of the DLL (Before D2 fully starts but the dll's init is called).. It might be as simple as attaching to the Gardenia.exe with specific settings (and of course having debug symbols).
You are going to struggle a bit with this; I'd recommend using OllyDbg or x64DBG and using the break on new module loaded. Else an old trick that works, use MessageBoxA with MB_APPLMODAL from the DllMain function.

_________________
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: Tue Sep 19, 2017 1:15 pm 
 Post subject: Re: Gardenia - PlugY fork
 
Offline
Knight

Joined: Sat Oct 16, 2010 4:29 pm
Posts: 39
Gender: None specified
Thanks Necrolis for the tips. Slowing down the init so that I have enough time to attach to Game.exe before the DLL does its operations seems like the easiest way to go given the situation. Probably using a 10 second timer in DllMain would work as well, but I like your idea of using the modal dialog better. Also I do have olly and x32dbg on my machine so I will try the break on new module as well, I usually avoid having multiple debuggers or dissemblers attached but maybe it won't cause too much instability.

EDIT (19/9/17) - Necrolis, the messagebox tricked worked wonderfully. Now I can debug all of the dll code, thanks!

https://i.imgur.com/wiTMKV3.png


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 21, 2017 5:30 pm 
 Post subject: Re: Gardenia - PlugY fork
 
Offline
Knight

Joined: Sat Oct 16, 2010 4:29 pm
Posts: 39
Gender: None specified
Alright guys, after a few weeks of hard work and more than 40 hours, I'm happy to announce version 1.00 of Gardenia. Hopefully my efforts to rewrite/restructure/and encapsulate all of the D2 functions in the mod will allow people to more easily maintain and upgrade the mod. There are too many changes to list, but you can read the github commit descriptions if interested, many of them have detailed explanations of what happened in that commit. Personally I only cared for supporting versions 1.09b and 1.13d so those are the only ones that I'm supporting in my branch. More information can be found in the read me.

Ultimately, moving to a 1 version system is probably best, I probably will end up doing that. People could always just stick to an older version to play on the older versions of D2. Supporting only one version will allow a lot of flexibility, increase maintainability, and reduce workload.


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


Who is online

Users browsing this forum: No registered users and 4 guests


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)