Page 1 of 1

[1.13c] Load PlugY.dll from D2Launch.dll

Posted: Sat Mar 09, 2019 5:17 pm
by MagicMatze
Hello,

I want to load plugy 11.02 by editing the d2launch.dll files. I found these code edit:

Code: Select all

"Load an external dll in the game"
"This technique allows you to load up to four new dll in the game"

D2Launch.dll - E349

6FA4E349    85C0            TEST EAX,EAX
6FA4E34B    0F85 9B000000   JNZ D2Launch.6FA4E3EC
6FA4E351    68 04EBA56F     PUSH D2Launch.6FA5EB04                   		; ASCII "Bnclient.dll"
6FA4E356    FF15 D0C2A56F   CALL DWORD PTR DS:[<&KERNEL32.LoadLibraryA>]	; kernel32.LoadLibraryA
6FA4E35C    85C0            TEST EAX,EAX
6FA4E35E    A3 C056A66F     MOV DWORD PTR DS:[6FA656C0],EAX
6FA4E363    75 33           JNZ SHORT D2Launch.6FA4E398
6FA4E365    FF15 E4C2A56F   CALL DWORD PTR DS:[<&KERNEL32.GetLastError>]	; ntdll.RtlGetLastWin32Error
6FA4E36B    50              PUSH EAX
6FA4E36C    8D4424 04       LEA EAX,DWORD PTR SS:[ESP+4]
6FA4E370    68 E0EAA56F     PUSH D2Launch.6FA5EAE0                   		; ASCII "Cannot load Bnclient.dll: Error %d"
6FA4E375    50              PUSH EAX
6FA4E376    E8 A02CFFFF     CALL D2Launch.6FA4101B
6FA4E37B    83C4 0C         ADD ESP,0C
6FA4E37E    6A 10           PUSH 10
6FA4E380    68 D8EAA56F     PUSH D2Launch.6FA5EAD8                   		; ASCII "D2Multi"
6FA4E385    8D4C24 08       LEA ECX,DWORD PTR SS:[ESP+8]
6FA4E389    51              PUSH ECX
6FA4E38A    6A 00           PUSH 0
6FA4E38C    FF15 48C4A56F   CALL DWORD PTR DS:[<&USER32.MessageBoxA>]		; USER32.MessageBoxA
6FA4E392    33C0            XOR EAX,EAX
6FA4E394    83C4 64         ADD ESP,64
6FA4E397    C3              RETN

TO

6FA4E349    85C0            TEST EAX,EAX
6FA4E34B    0F85 9B000000   JNZ D2Launch.6FA4E3EC
6FA4E351    68 04EBA56F     PUSH D2Launch.6FA5EB04                   		; ASCII "Bnclient.dll"
6FA4E356    FF15 D0C2A56F   CALL DWORD PTR DS:[<&KERNEL32.LoadLibraryA>]	; kernel32.LoadLibraryA
6FA4E35C    85C0            TEST EAX,EAX
6FA4E35E    A3 C056A66F     MOV DWORD PTR DS:[6FA656C0],EAX
6FA4E363    50              PUSH EAX
6FA4E364    68 14FBA56F     PUSH D2Launch.6FA5FB14                   		; ASCII "LibraryName.dll"
6FA4E369    FF15 D0C2A56F   CALL DWORD PTR DS:[<&KERNEL32.LoadLibraryA>]	; kernel32.LoadLibraryA
6FA4E36F    58              POP EAX
6FA4E370    90              NOP
"...		...				..."
6FA4E397    90              NOP
On Address (Offset 1FB14 on D2Launch.dll) I write the ASCII name of the dll file (plugy.dll). When starting game.exe, plugy doesn't show up!
I have tested it also with basemod plugin (basemod.dll) and this works (can see ingame features activated by basemod plugin). Then I thought to add plugy.dll to the dlls to load in basemod.ini but this doesn't work, too.

Maybe plugy can't be loaded from d2launch.dll??

Andy help or idea I can load plugy with a code edit?

Re: [1.13c] Load PlugY.dll from D2Launch.dll

Posted: Mon Mar 11, 2019 9:54 am
by Znich
You need to call the initialization function Plugy.dll. Check out the source code from the Plugy installer.

Code: Select all

	0xFF,0x74,0x24,0x04,			//PUSH DWORD PTR SS:[ESP+4]
	0xFF,0x15,0x40,0xC0,0xA7,0x6F,  //CALL DWORD PTR DS:[<&KERNEL32.LoadLibraryA>]      ; kernel32.LoadLibraryA
	0x50,							//PUSH EAX
	0x68,0x80,0xBE,0xA7,0x6F,		//PUSH d2gfx.6FA7BE80                               ; ASCII "PlugY.dll"
	0xFF,0x15,0x40,0xC0,0xA7,0x6F,  //CALL DWORD PTR DS:[<&KERNEL32.LoadLibraryA>]      ; kernel32.LoadLibraryA
	0xA3,0xFC,0xEF,0xA8,0x6F,		//MOV DWORD PTR DS:[6FA8EFFC],EAX
	0x85,0xC0,						//TEST EAX,EAX
	0x74,0x2B,						//JE SHORT d2gfx.6FA7BE33
	0x50,							//PUSH EAX
	0x68,0x90,0xBE,0xA7,0x6F,		//PUSH d2gfx.6FA7BE10                            ;Init String
	0x50,							//PUSH EAX
	0xFF,0x15,0x3C,0xC0,0xA7,0x6F,	//CALL DWORD PTR DS:[<&KERNEL32.GetProcAddress>]    ; kernel32.GetProcAddress
	0x85,0xC0,						//TEST EAX,EAX
	0x74,0x04,						//JE SHORT d2gfx.6FA7BDC1
	0x6A,0x00,						//PUSH 0
	0xEB,0x13,						//JMP SHORT d2gfx.6FA7BDC1
	0x68,0x10,0x27,0x00,0x00,		//PUSH 2710	                                     ;Init Ordinal(10000)
	0xFF,0x74,0x24,0x04,			//PUSH DWORD PTR SS:[ESP+4]
	0xFF,0x15,0x3C,0xC0,0xA7,0x6F,	//CALL DWORD PTR DS:[<&KERNEL32.GetProcAddress>]    ; kernel32.GetProcAddress
	0x85,0xC0,						//TEST EAX,EAX
	0x74,0x02,						//JE SHORT d2gfx.6FA7BDC1
	0xFF,0xD0,						//CALL EAX
	0x58,							//POP EAX
	0x58,							//POP EAX
	0xC2,0x04,0x00,					//RETN 4
	0x00,0x00,0x00,0x00 			//HANDLE var;

Re: [1.13c] Load PlugY.dll from D2Launch.dll

Posted: Fri Mar 15, 2019 11:18 pm
by devurandom
Thanks for posting the question and all the info. helped me find some other issues that will get fixed in next release.

EDIT:

BaseMod has been updated to Load PlugY.dll, took some special workarounds, but it works now.
;)