Skip to content

Commit

Permalink
updated to v11.00 by Lautour http://d2mods.info/forum/viewtopic.php?f…
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaosMarc committed Apr 18, 2016
1 parent 32b737d commit 5a1eb33
Show file tree
Hide file tree
Showing 56 changed files with 5,676 additions and 966 deletions.
326 changes: 164 additions & 162 deletions Commons/D2Funcs.h

Large diffs are not rendered by default.

118 changes: 118 additions & 0 deletions Commons/VersionInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#include "VersionInfo.h"
#pragma comment(lib, "Version.Lib") //ïî ñðàâíåíèþ ñ Delphi 7 - òàêîé ãåììîðîé! :(


bool IsFile(char* sPath)
{
bool bFile = false;
HANDLE hFile = CreateFile
(
sPath,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
);
if(hFile != INVALID_HANDLE_VALUE)
{
CloseHandle(hFile);
bFile = true;
}
return bFile;
}

bool GetAppVersion(char* FileName, TFileVersion* VerInfo){ // ïîëó÷åíèå âåðñèè ôàéëà
VerInfo->full = -1;
if(!IsFile(FileName)){ // Ïðîâåðÿåì íàëè÷èå ôàéëà
return false; // Åñëè íåò ô-öèÿ íåóñïåøíà
}
DWORD FSize = GetFileVersionInfoSize(FileName,NULL); // ðàçìåð èíôû î âåðñèè ôàéëà
if(FSize==0){ // Åñëè 0 ôóíêöèÿ íåóñïåøíà
return false;
}
LPVOID pBlock = (char*)malloc(FSize); // àäðåñ áóôåðà äëÿ ðåñóðñîâ âåðñèè
GetFileVersionInfo(FileName,NULL,FSize,pBlock); // ïîëó÷àåì ðåñóðñ èíôîðìàöèè î âåðñèè
LPVOID MS;
UINT LS;
try{
VerQueryValue(pBlock,"\\",&MS,&LS); // èçâëåêàåì èíôîðìàöèþ èç ðåñóðñà
}
catch(...){
return false; // â ñëó÷àå îøèáêè ôóíêöèÿ íåóñïåøíà
}
VS_FIXEDFILEINFO FixedFileInfo; // ñòðóêòóðà ñ èíôîðìàöèåé î âåðñèè ôàéëà
memmove(&FixedFileInfo, MS, LS); // ïðèâîäèì èíôîðìàöèþ ê ñòðóêòóðå

DWORD FileVersionMS = FixedFileInfo.dwFileVersionMS;
DWORD FileVersionLS = FixedFileInfo.dwFileVersionLS;

VerInfo->major = HIWORD(FileVersionMS) ; // ïîëó÷àåì çíà÷åíèÿ
VerInfo->minor = LOWORD(FileVersionMS); // è ïðèñâàèâàåè èõ âõîäíîìó óêàçàòåëþ
VerInfo->revision = HIWORD(FileVersionLS);
VerInfo->subrevision = LOWORD(FileVersionLS);

return true; // ôóíêöèÿ óñïåøíà
}


#define SUBKEY "Software\\Blizzard Entertainment\\Diablo II"
#define GAMEFILE "\\Game.exe"
bool GetD2Path(char* buf, DWORD bufsize)
{
HKEY hKey;
DWORD type;
int res;
if (RegOpenKeyEx(HKEY_CURRENT_USER, SUBKEY, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
res = RegQueryValueEx(hKey,"InstallPath",NULL,&type,(LPBYTE)buf,&bufsize);
RegCloseKey(hKey);
if (res!=ERROR_SUCCESS) return false;
} else if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SUBKEY, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
res = RegQueryValueEx(hKey,"InstallPath",NULL,&type,(LPBYTE)buf,&bufsize);
RegCloseKey(hKey);
if (res!=ERROR_SUCCESS) return false;
} else {
return false;
}
strcat(buf, GAMEFILE);
if (GetFileAttributes(buf) == INVALID_FILE_ATTRIBUTES)
return false;
return true;
};

int GetVerD2(TFileVersion GameVer)
{
if ((GameVer.major != 1)||(GameVer.minor != 0)) return -1;
switch (GameVer.revision)
{
case 9:
if (GameVer.subrevision == 20) return v109b;
if (GameVer.subrevision == 22) return v109d;
break;
case 10:
if (GameVer.subrevision == 39) return v110;
break;
case 11:
if (GameVer.subrevision == 45) return v111;
if (GameVer.subrevision == 46) return v111b;
break;
case 12:
if (GameVer.subrevision == 49) return v112;
break;
case 13:
if (GameVer.subrevision == 60) return v113c;
if (GameVer.subrevision == 64) return v113d;
break;
}
return -1;
}


int GetD2Version(char* PathGameExe)
{
TFileVersion GameVer = {-1};
if (! GetAppVersion(PathGameExe, &GameVer)) return -1;
int ver = GetVerD2(GameVer);
return ver;
}
30 changes: 30 additions & 0 deletions Commons/VersionInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <windows.h>

union TFileVersion
{
__int64 full;
struct {
WORD subrevision;
WORD revision;
WORD minor;
WORD major;
};
WORD w[4];
};

enum eGameVersion
{
v109b=0,
v109d,
v110,
v111,
v111b,
v112,
v113c,
v113d,
v114a
};

bool GetAppVersion(char* FileName, TFileVersion* VerInfo); // ïîëó÷åíèå âåðñèè ôàéëà
bool GetD2Path(char* buf, DWORD bufsize);
int GetD2Version(char* PathGameExe);
7 changes: 5 additions & 2 deletions PlugY/BigStash.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*=================================================================
File created by Yohann NICOLAS.
Add support 1.13d by L'Autour.
Use a more big stash
Expand Down Expand Up @@ -78,23 +79,25 @@ void Install_BigStash()
log_msg("Patch D2Common & D2Client for make 10x10 squares in the stash. (BigStash)\n");

// modification of stash grid
mem_seek R7(D2Common, C9F3, CA03, 14ED3, 5FCB5, 2A505, 1BDB5, 82CA5);
mem_seek R7(D2Common, C9F3, CA03, 14ED3, 5FCB5, 2A505, 1BDB5, 82CA5, 6CC25);
MEMC_REF4( D2CompileTxtFile, caller_modifStashGrid);
//01B64ED2 |. E8 99AEFFFF CALL D2Common.#10578
//6FDAFCB4 |. E8 A7C3FCFF CALL D2Common.#10653
//6FD7A504 |. E8 5743FEFF CALL D2Common.#10496 ; \#10496
//6FD6BDB4 |. E8 97600200 CALL D2Common.#10244 ; \#10244
//6FDD2CA4 |. E8 97C2FDFF CALL D2Common.#10849 ; \#10849
//6FDBCC24 |. E8 B7FEF9FF CALL D2Common.#10037 ; \#10037

// modification of stash background
mem_seek R7(D2Client, 45B1C, 45B1C, 4C61C, A643C, 749BC, A9D7C, 8CC1C);
mem_seek R7(D2Client, 45B1C, 45B1C, 4C61C, A643C, 749BC, A9D7C, 8CC1C, 943FC);
memt_byte( 0x68, 0xE8 ); // CALL caller_changeTradeStash
MEMT_REF4( 0x00000104, caller_changeTradeStash);
//6FAEC61C |. 68 04010000 PUSH 104
//6FB5643C |. 68 04010000 PUSH 104
//6FB249BC |. 68 04010000 PUSH 104
//6FB59D7C |. 68 04010000 PUSH 104
//6FB3CC1C |. 68 04010000 PUSH 104
//6FB443FC |. 68 04010000 PUSH 104

log_msg("\n");

Expand Down
34 changes: 25 additions & 9 deletions PlugY/Commands.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*=================================================================
File created by Yohann NICOLAS.
Add support 1.13d by L'Autour.
Updating server.
Expand All @@ -15,6 +16,7 @@
#include "newInterface_CubeListing.h"
#include "extraOptions.h"


bool active_Commands=true;

bool active_listAllCubeFormula=true;
Expand Down Expand Up @@ -140,13 +142,15 @@ void updateSharedGold(DWORD goldAmount)

int STDCALL commands (char* ptText)
{
//return 0;
Unit* ptChar = D2GetClientPlayer();

//return 0;
char command[MAX_CMD_SIZE];
ZeroMemory(command,MAX_CMD_SIZE);
//return 0;
strncpy(command,ptText,MAX_CMD_SIZE-1);
strlwr(command);

//return 0;
strlwr(command);
if (!strncmp(command,CMD_RENAME,strlen(CMD_RENAME)))
{
if (!active_multiPageStash) return 1;
Expand Down Expand Up @@ -220,7 +224,6 @@ int STDCALL commands (char* ptText)
active_AlwaysDisplayLifeMana = !active_AlwaysDisplayLifeMana;
return 0;
}

return 1;
}

Expand Down Expand Up @@ -248,6 +251,19 @@ FCT_ASM ( caller_Commands_111 )
RETN 8
}}

FCT_ASM ( caller_Commands_113d )
TEST EAX,EAX
JE MANAGESOUNDCHAOSDEBUG
PUSH EDI
CALL commands
TEST EAX,EAX
JNZ MANAGESOUNDCHAOSDEBUG
ADD DWORD PTR SS:[ESP],7
MANAGESOUNDCHAOSDEBUG:
RETN 8
}}


void Install_Commands()
{
static int isInstalled = false;
Expand All @@ -261,9 +277,9 @@ void Install_Commands()
active_savegame = version_D2Common >= V111;

// Run custom commmand
mem_seek R7(D2Client, 2C120, 2C110, 32BDD, C1EE6, 91C16, 86926, 70AE6);
memt_byte( 0x83, 0xE8 ); // CALL
MEMT_REF4( 0xC08508C4 , version_D2Client >= V111 ? caller_Commands_111 : caller_Commands);
mem_seek R7(D2Client, 2C120, 2C110, 32BDD, C1EE6, 91C16, 86926, 70AE6, B1FD6);
memt_byte( 0x83, 0xE8 ); // CALL
MEMT_REF4( 0xC08508C4 , version_D2Client == V113d ? caller_Commands_113d : version_D2Client >= V111 ? caller_Commands_111 : caller_Commands);
//6FB71EE6 . 83C4 08 ADD ESP,8
//6FB71EE7 . 85C0 TEST EAX,EAX
//6FB41C16 |. 83C4 08 ADD ESP,8
Expand All @@ -272,9 +288,9 @@ void Install_Commands()
//6FB36929 |. 85C0 TEST EAX,EAX
//6FB20AE6 |. 83C4 08 ADD ESP,8
//6FB20AE9 |. 85C0 TEST EAX,EAX
//6FB20AE6 |. 83C4 08 ADD ESP,8
//6FB20AE9 |. 85C0 TEST EAX,EAX

//6FB61FD6 |. 83C4 08 ADD ESP,8
//6FB61FD9 |. 85C0 TEST EAX,EAX
log_msg("\n");

isInstalled = true;
Expand Down
Loading

0 comments on commit 5a1eb33

Please sign in to comment.