-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated to v11.00 by Lautour http://d2mods.info/forum/viewtopic.php?f…
- Loading branch information
Showing
56 changed files
with
5,676 additions
and
966 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.