Skip to content

Commit

Permalink
updated to v11.01 by Yohann
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaosMarc committed Jan 23, 2017
1 parent 1f35a1a commit 3f60030
Show file tree
Hide file tree
Showing 140 changed files with 4,076 additions and 8,172 deletions.
233 changes: 117 additions & 116 deletions Commons/D2Funcs.h

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions Commons/D2UnitStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
struct CBPlayerData;
struct CBItemData;
struct Unit;
struct SkillsBIN;
struct SkillData;
struct ObjectsBIN;

/*=================================================================*/
/* Skill Structure. */
Expand Down Expand Up @@ -345,12 +348,14 @@ struct NetClient
WORD isHardCoreGame:1;
};
};
BYTE uk2[0x170]; //+0C
BYTE uk2; //+0C
char name[0x10]; //+0D
BYTE uk3[0x15F]; //+1D
BYTE* savefile; //+17C
DWORD finalSize; //+180
DWORD counter; //+184
DWORD currentSize; //+188
BYTE uk3[0x1C]; //+18C
BYTE uk4[0x1C]; //+18C
Game* ptGame; //+1A8
//+1A8 is ptGame
//+4A8 ptNextClient
Expand Down
180 changes: 74 additions & 106 deletions Commons/VersionInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,118 +1,86 @@
/*=================================================================
File created by Yohann NICOLAS.
Get Game version.
=================================================================*/

//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include "VersionInfo.h"
#pragma comment(lib, "Version.Lib") //ïî ñðàâíåíèþ ñ Delphi 7 - òàêîé ãåììîðîé! :(
#include <windows.h>

#pragma comment(lib, "Version.Lib")

const char* VersionStrings[16] = { "1.00","1.07","1.08","1.09","1.09b","1.09d","1.10","1.11","1.11b","1.12","1.13c","1.13d","1.14a","1.14b","1.14c","1.14d" };

bool IsFile(char* sPath)
const char* GetVersionString(int version)
{
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;
return VersionStrings[version];
}

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; // ôóíêöèÿ óñïåøíà
}
eGameVersion GetD2Version(LPCVOID pVersionResource)
{
UINT uLen;
VS_FIXEDFILEINFO* ptFixedFileInfo;
if (!VerQueryValue(pVersionResource, "\\", (LPVOID*)&ptFixedFileInfo, &uLen))
return UNKNOW;

if (uLen == 0)
return UNKNOW;

#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;
WORD major = HIWORD(ptFixedFileInfo->dwFileVersionMS);
WORD minor = LOWORD(ptFixedFileInfo->dwFileVersionMS);
WORD revision = HIWORD(ptFixedFileInfo->dwFileVersionLS);
WORD subrevision = LOWORD(ptFixedFileInfo->dwFileVersionLS);

if (major != 1)
return UNKNOW;
if (minor == 0 && revision == 7 && subrevision == 0) return V107;
if (minor == 0 && revision == 8 && subrevision == 28) return V108;
if (minor == 0 && revision == 9 && subrevision == 19) return V109;
if (minor == 0 && revision == 9 && subrevision == 20) return V109b;
if (minor == 0 && revision == 9 && subrevision == 22) return V109d;
if (minor == 0 && revision == 10 && subrevision == 39) return V110;
if (minor == 0 && revision == 11 && subrevision == 45) return V111;
if (minor == 0 && revision == 11 && subrevision == 46) return V111b;
if (minor == 0 && revision == 12 && subrevision == 49) return V112;
if (minor == 0 && revision == 13 && subrevision == 60) return V113c;
if (minor == 0 && revision == 13 && subrevision == 64) return V113d;
if (minor == 14 && revision == 0 && subrevision == 64) return V114a;
if (minor == 14 && revision == 1 && subrevision == 68) return V114b;
if (minor == 14 && revision == 2 && subrevision == 70) return V114c;
if (minor == 14 && revision == 3 && subrevision == 71) return V114d;
return UNKNOW;
}

eGameVersion GetD2Version(char* gameExe)
{
DWORD len = GetFileVersionInfoSize(gameExe, NULL);
if (len == 0)
return UNKNOW;

BYTE* pVersionResource = new BYTE[len];
GetFileVersionInfo(gameExe, NULL, len, pVersionResource);
eGameVersion version = GetD2Version(pVersionResource);
delete pVersionResource;

return version;
}

int GetD2Version(char* PathGameExe)
eGameVersion GetD2Version()
{
TFileVersion GameVer = {-1};
if (! GetAppVersion(PathGameExe, &GameVer)) return -1;
int ver = GetVerD2(GameVer);
return ver;
}
HMODULE hModule = GetModuleHandle(NULL);
HRSRC hResInfo = FindResource(hModule, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION);
HGLOBAL hResData = LoadResource(hModule, hResInfo);
LPVOID pVersionResource = LockResource(hResData);
//DWORD dwSize = SizeofResource(hInst, hResInfo);
//LPVOID pVersionResource = LocalAlloc(LMEM_FIXED, dwSize);
//CopyMemory(pVersionResource, pRes, dwSize);

eGameVersion version = GetD2Version(pVersionResource);
FreeResource(hResData);
//LocalFree(pVersionResource);
return version;
}

///////////////////////// END OF FILE ///////////////////////
52 changes: 28 additions & 24 deletions Commons/VersionInfo.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
#include <windows.h>
/*=================================================================
File created by Yohann NICOLAS.
union TFileVersion
{
__int64 full;
struct {
WORD subrevision;
WORD revision;
WORD minor;
WORD major;
};
WORD w[4];
};
Get Game version.
=================================================================*/
#pragma once

enum eGameVersion
{
v109b=0,
v109d,
v110,
v111,
v111b,
v112,
v113c,
v113d,
v114a
UNKNOW = -1,
V100 = 0,
V107,
V108,
V109,
V109b,
V109d,
V110,
V111,
V111b,
V112,
V113c,
V113d,
V114a,
V114b,
V114c,
V114d
};

bool GetAppVersion(char* FileName, TFileVersion* VerInfo); // ïîëó÷åíèå âåðñèè ôàéëà
bool GetD2Path(char* buf, DWORD bufsize);
int GetD2Version(char* PathGameExe);
const char* GetVersionString(int version);
eGameVersion GetD2Version(char* gamePath);
eGameVersion GetD2Version();

///////////////////////// END OF FILE ///////////////////////
25 changes: 19 additions & 6 deletions Commons/updatingConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum UpdateClientConst
{
UC_SELECT_STASH=0x18,
UC_SHARED_GOLD,
UC_PAGE_NAME,
UC_ADD_STAT,
UC_ADD_SYNERGY,
UC_TEST1,
Expand Down Expand Up @@ -40,15 +41,27 @@ enum UpdateServerConst
US_SELECT_PREVIOUS_INDEX2,
US_SELECT_NEXT_INDEX2,
US_WORLDEVENT,
US_STARTSAVE,
US_SAVE,
US_MAXGOLD,
US_PUTGOLD,
US_TAKEGOLD,

//For CB
US_TEST1,
US_TEST2,
US_TEST3
US_RENAME,
US_PAGENAME,
US_SET_INDEX,
US_RESET_INDEX,
US_INSERT_PAGE,
US_DELETE_PAGE,
US_SWAP3,
US_SWAP2,
US_SWAP1,
US_SWAP0,
US_SWAP0_TOGGLE,
US_TOGGLE1,
US_TOGGLE2,
US_TOGGLE3,
US_TEST1, //For CB
US_TEST2, //For CB
US_TEST3 //For CB
};

/*================================= END OF FILE =================================*/
6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

{project} Copyright (C) {year} {fullname}
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand Down
4 changes: 1 addition & 3 deletions PlugY/BigStash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
=================================================================*/

#include "common.h"
#include "error.h"
#include "d2functions.h"
#include "plugYFiles.h" // Install_PlugYFiles()
#include "common.h"

bool active_bigStash = false;
bool active_bigStash_tested = false;
Expand Down
2 changes: 0 additions & 2 deletions PlugY/ClientSaveFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
=================================================================*/
/*
#include "common.h"
#include "error.h"
#include "d2functions.h"
#include <stdio.h>
#define BUFFER_SIZE 0x4000
Expand Down
Loading

0 comments on commit 3f60030

Please sign in to comment.