Browse Source

Format init.cpp

pull/25/head
Anders Jenbo 8 years ago
parent
commit
f70183dfe9
  1. 771
      Source/init.cpp
  2. 2
      Source/init.h

771
Source/init.cpp

@ -4,7 +4,7 @@
_SNETVERSIONDATA fileinfo; _SNETVERSIONDATA fileinfo;
int init_cpp_init_value; // weak int init_cpp_init_value; // weak
int gbActive; // weak int gbActive; // weak
char diablo_exe_path[260]; char diablo_exe_path[260];
void *unused_mpq; void *unused_mpq;
char patch_rt_mpq_path[260]; char patch_rt_mpq_path[260];
@ -22,506 +22,465 @@ const int init_inf = 0x7F800000; // weak
char gszVersionNumber[260] = "internal version unknown"; char gszVersionNumber[260] = "internal version unknown";
char gszProductName[260] = "Diablo v1.09"; char gszProductName[260] = "Diablo v1.09";
struct init_cpp_init struct init_cpp_init {
{ init_cpp_init()
init_cpp_init() {
{ init_cpp_init_value = init_inf;
init_cpp_init_value = init_inf; }
}
} _init_cpp_init; } _init_cpp_init;
// 47AE20: using guessed type int init_inf; // 47AE20: using guessed type int init_inf;
// 63497C: using guessed type int init_cpp_init_value; // 63497C: using guessed type int init_cpp_init_value;
void __fastcall init_cleanup(bool show_cursor) void __fastcall init_cleanup(bool show_cursor)
{ {
int v1; // edi int v1; // edi
v1 = show_cursor; v1 = show_cursor;
pfile_flush_W(); pfile_flush_W();
init_disable_screensaver(0); init_disable_screensaver(0);
init_run_office_from_start_menu(); init_run_office_from_start_menu();
if ( diabdat_mpq ) if (diabdat_mpq) {
{ SFileCloseArchive(diabdat_mpq);
SFileCloseArchive(diabdat_mpq); diabdat_mpq = 0;
diabdat_mpq = 0; }
} if (patch_rt_mpq) {
if ( patch_rt_mpq ) SFileCloseArchive(patch_rt_mpq);
{ patch_rt_mpq = 0;
SFileCloseArchive(patch_rt_mpq); }
patch_rt_mpq = 0; if (unused_mpq) {
} SFileCloseArchive(unused_mpq);
if ( unused_mpq ) unused_mpq = 0;
{ }
SFileCloseArchive(unused_mpq); UiDestroy();
unused_mpq = 0; effects_cleanup_sfx();
} sound_cleanup();
UiDestroy(); NetClose();
effects_cleanup_sfx(); dx_cleanup();
sound_cleanup(); MI_Dummy(v1);
NetClose(); StormDestroy();
dx_cleanup(); if (v1)
MI_Dummy(v1); ShowCursor(1);
StormDestroy();
if ( v1 )
ShowCursor(1);
} }
void __cdecl init_run_office_from_start_menu() void __cdecl init_run_office_from_start_menu()
{ {
HWND v0; // eax HWND v0; // eax
char pszPath[256]; // [esp+0h] [ebp-104h] char pszPath[256]; // [esp+0h] [ebp-104h]
LPITEMIDLIST ppidl; // [esp+100h] [ebp-4h] LPITEMIDLIST ppidl; // [esp+100h] [ebp-4h]
if ( killed_mom_parent ) if (killed_mom_parent) {
{ *pszPath = empty_string;
*pszPath = empty_string; killed_mom_parent = 0;
killed_mom_parent = 0; memset(pszPath + 1, 0, sizeof(pszPath) - 1);
memset(pszPath + 1, 0, sizeof(pszPath) - 1); // *(_WORD *)&pszPath[253] = 0;
// *(_WORD *)&pszPath[253] = 0; //pszPath[255] = 0;
//pszPath[255] = 0; ppidl = 0;
ppidl = 0; v0 = GetDesktopWindow();
v0 = GetDesktopWindow(); if (!SHGetSpecialFolderLocation(v0, CSIDL_STARTMENU, &ppidl)) {
if ( !SHGetSpecialFolderLocation(v0, CSIDL_STARTMENU, &ppidl) ) SHGetPathFromIDList(ppidl, pszPath);
{ init_run_office(pszPath);
SHGetPathFromIDList(ppidl, pszPath); }
init_run_office(pszPath); }
}
}
} }
// 634CA0: using guessed type int killed_mom_parent; // 634CA0: using guessed type int killed_mom_parent;
void __fastcall init_run_office(char *dir) void __fastcall init_run_office(char *dir)
{ {
char *v1; // esi char *v1; // esi
HANDLE v2; // ebx HANDLE v2; // ebx
bool v3; // zf bool v3; // zf
HWND v4; // eax HWND v4; // eax
char Directory[260]; // [esp+8h] [ebp-348h] char Directory[260]; // [esp+8h] [ebp-348h]
char FileName[260]; // [esp+10Ch] [ebp-244h] char FileName[260]; // [esp+10Ch] [ebp-244h]
struct _WIN32_FIND_DATAA FindFileData; // [esp+210h] [ebp-140h] struct _WIN32_FIND_DATAA FindFileData; // [esp+210h] [ebp-140h]
v1 = dir; v1 = dir;
strcpy(FileName, dir); strcpy(FileName, dir);
if ( FileName[0] && Directory[strlen(FileName) + 259] == '\\' ) if (FileName[0] && Directory[strlen(FileName) + 259] == '\\')
strcat(FileName, "*"); strcat(FileName, "*");
else else
strcat(FileName, "\\*"); strcat(FileName, "\\*");
v2 = FindFirstFile(FileName, &FindFileData); v2 = FindFirstFile(FileName, &FindFileData);
if ( v2 != (HANDLE)-1 ) if (v2 != (HANDLE)-1) {
{ do {
do if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
{ if (strcmp(FindFileData.cFileName, ".") && strcmp(FindFileData.cFileName, "..")) {
if ( FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) *Directory = empty_string;
{ memset(Directory + 1, 0, sizeof(Directory) - 1);
if ( strcmp(FindFileData.cFileName, ".") && strcmp(FindFileData.cFileName, "..") ) v3 = *v1 == 0;
{ // *(_WORD *)&Directory[257] = 0;
*Directory = empty_string; //Directory[259] = 0;
memset(Directory + 1, 0, sizeof(Directory) - 1); if (v3 || v1[strlen(v1) - 1] != '\\')
v3 = *v1 == 0; sprintf(Directory, "%s\\%s\\", v1, FindFileData.cFileName);
// *(_WORD *)&Directory[257] = 0; else
//Directory[259] = 0; sprintf(Directory, "%s%s\\", v1, FindFileData.cFileName);
if ( v3 || v1[strlen(v1) - 1] != '\\' ) init_run_office(Directory);
sprintf(Directory, "%s\\%s\\", v1, FindFileData.cFileName); }
else } else if (!_strcmpi(FindFileData.cFileName, "Microsoft Office Shortcut Bar.lnk")) {
sprintf(Directory, "%s%s\\", v1, FindFileData.cFileName); v4 = GetDesktopWindow();
init_run_office(Directory); ShellExecute(v4, "open", FindFileData.cFileName, &empty_string, v1, SW_SHOWNORMAL);
} }
} } while (FindNextFile(v2, &FindFileData));
else if ( !_strcmpi(FindFileData.cFileName, "Microsoft Office Shortcut Bar.lnk") ) FindClose(v2);
{ }
v4 = GetDesktopWindow();
ShellExecute(v4, "open", FindFileData.cFileName, &empty_string, v1, SW_SHOWNORMAL);
}
}
while ( FindNextFile(v2, &FindFileData) );
FindClose(v2);
}
} }
void __fastcall init_disable_screensaver(bool disable) void __fastcall init_disable_screensaver(bool disable)
{ {
bool v1; // al bool v1; // al
char Data[16]; // [esp+4h] [ebp-20h] char Data[16]; // [esp+4h] [ebp-20h]
DWORD Type; // [esp+14h] [ebp-10h] DWORD Type; // [esp+14h] [ebp-10h]
DWORD cbData; // [esp+18h] [ebp-Ch] DWORD cbData; // [esp+18h] [ebp-Ch]
HKEY phkResult; // [esp+1Ch] [ebp-8h] HKEY phkResult; // [esp+1Ch] [ebp-8h]
bool v6; // [esp+20h] [ebp-4h] bool v6; // [esp+20h] [ebp-4h]
// BUGFIX: this is probably the worst possible way to do this. Alternatives: ExtEscape() with SETPOWERMANAGEMENT, // BUGFIX: this is probably the worst possible way to do this. Alternatives: ExtEscape() with SETPOWERMANAGEMENT,
// SystemParametersInfo() with SPI_SETSCREENSAVEACTIVE/SPI_SETPOWEROFFACTIVE/SPI_SETLOWPOWERACTIVE // SystemParametersInfo() with SPI_SETSCREENSAVEACTIVE/SPI_SETPOWEROFFACTIVE/SPI_SETLOWPOWERACTIVE
v6 = disable; v6 = disable;
if ( !RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ|KEY_WRITE, &phkResult) ) if (!RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ | KEY_WRITE, &phkResult)) {
{ if (v6) {
if ( v6 ) cbData = 16;
{ if (!RegQueryValueEx(phkResult, "ScreenSaveActive", 0, &Type, (LPBYTE)Data, &cbData))
cbData = 16; screensaver_enabled_prev = Data[0] != '0';
if ( !RegQueryValueEx(phkResult, "ScreenSaveActive", 0, &Type, (LPBYTE)Data, &cbData) ) v1 = 0;
screensaver_enabled_prev = Data[0] != '0'; } else {
v1 = 0; v1 = screensaver_enabled_prev;
} }
else Data[1] = 0;
{ Data[0] = (v1 != 0) + '0';
v1 = screensaver_enabled_prev; RegSetValueEx(phkResult, "ScreenSaveActive", 0, REG_SZ, (const BYTE *)Data, 2u);
} RegCloseKey(phkResult);
Data[1] = 0; }
Data[0] = (v1 != 0) + '0';
RegSetValueEx(phkResult, "ScreenSaveActive", 0, REG_SZ, (const BYTE *)Data, 2u);
RegCloseKey(phkResult);
}
} }
void __fastcall init_create_window(int nCmdShow) void __fastcall init_create_window(int nCmdShow)
{ {
int nHeight; // eax int nHeight; // eax
HWND hWnd; // esi HWND hWnd; // esi
WNDCLASSEXA wcex; // [esp+8h] [ebp-34h] WNDCLASSEXA wcex; // [esp+8h] [ebp-34h]
int nWidth; // [esp+38h] [ebp-4h] int nWidth; // [esp+38h] [ebp-4h]
init_kill_mom_parent(); init_kill_mom_parent();
pfile_init_save_directory(); pfile_init_save_directory();
memset(&wcex, 0, sizeof(wcex)); memset(&wcex, 0, sizeof(wcex));
wcex.cbSize = sizeof(wcex); wcex.cbSize = sizeof(wcex);
wcex.style = CS_HREDRAW|CS_VREDRAW; wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WindowProc; wcex.lpfnWndProc = WindowProc;
wcex.hInstance = ghInst; wcex.hInstance = ghInst;
wcex.hIcon = LoadIcon(ghInst, MAKEINTRESOURCE(IDI_ICON1)); wcex.hIcon = LoadIcon(ghInst, MAKEINTRESOURCE(IDI_ICON1));
wcex.hCursor = LoadCursor(0, IDC_ARROW); wcex.hCursor = LoadCursor(0, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = "DIABLO"; wcex.lpszMenuName = "DIABLO";
wcex.lpszClassName = "DIABLO"; wcex.lpszClassName = "DIABLO";
wcex.hIconSm = (HICON)LoadImage(ghInst, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); wcex.hIconSm = (HICON)LoadImage(ghInst, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
if ( !RegisterClassEx(&wcex) ) if (!RegisterClassEx(&wcex))
TermMsg("Unable to register window class"); TermMsg("Unable to register window class");
if ( GetSystemMetrics(SM_CXSCREEN) >= 640 ) if (GetSystemMetrics(SM_CXSCREEN) >= 640)
nWidth = GetSystemMetrics(SM_CXSCREEN); nWidth = GetSystemMetrics(SM_CXSCREEN);
else else
nWidth = 640; nWidth = 640;
if ( GetSystemMetrics(SM_CYSCREEN) >= 480 ) if (GetSystemMetrics(SM_CYSCREEN) >= 480)
nHeight = GetSystemMetrics(SM_CYSCREEN); nHeight = GetSystemMetrics(SM_CYSCREEN);
else else
nHeight = 480; nHeight = 480;
hWnd = CreateWindowEx(0, "DIABLO", "DIABLO", WS_POPUP, 0, 0, nWidth, nHeight, NULL, NULL, ghInst, NULL); hWnd = CreateWindowEx(0, "DIABLO", "DIABLO", WS_POPUP, 0, 0, nWidth, nHeight, NULL, NULL, ghInst, NULL);
if ( !hWnd ) if (!hWnd)
TermMsg("Unable to create main window"); TermMsg("Unable to create main window");
ShowWindow(hWnd, SW_SHOWNORMAL); // nCmdShow used only in beta: ShowWindow(hWnd, nCmdShow) ShowWindow(hWnd, SW_SHOWNORMAL); // nCmdShow used only in beta: ShowWindow(hWnd, nCmdShow)
UpdateWindow(hWnd); UpdateWindow(hWnd);
init_await_mom_parent_exit(); init_await_mom_parent_exit();
dx_init(hWnd); dx_init(hWnd);
BlackPalette(); BlackPalette();
snd_init(hWnd); snd_init(hWnd);
init_archives(); init_archives();
init_disable_screensaver(1); init_disable_screensaver(1);
} }
void __cdecl init_kill_mom_parent() void __cdecl init_kill_mom_parent()
{ {
HWND v0; // eax HWND v0; // eax
v0 = init_find_mom_parent(); v0 = init_find_mom_parent();
if ( v0 ) if (v0) {
{ PostMessage(v0, WM_CLOSE, 0, 0);
PostMessage(v0, WM_CLOSE, 0, 0); killed_mom_parent = 1;
killed_mom_parent = 1; }
}
} }
// 634CA0: using guessed type int killed_mom_parent; // 634CA0: using guessed type int killed_mom_parent;
HWND __cdecl init_find_mom_parent() HWND __cdecl init_find_mom_parent()
{ {
HWND i; // eax HWND i; // eax
HWND v1; // esi HWND v1; // esi
char ClassName[256]; // [esp+4h] [ebp-100h] char ClassName[256]; // [esp+4h] [ebp-100h]
for ( i = GetForegroundWindow(); ; i = GetWindow(v1, GW_HWNDNEXT) ) for (i = GetForegroundWindow();; i = GetWindow(v1, GW_HWNDNEXT)) {
{ v1 = i;
v1 = i; if (!i)
if ( !i ) break;
break; GetClassName(i, ClassName, 255);
GetClassName(i, ClassName, 255); if (!_strcmpi(ClassName, "MOM Parent"))
if ( !_strcmpi(ClassName, "MOM Parent") ) break;
break; }
} return v1;
return v1;
} }
void __cdecl init_await_mom_parent_exit() void __cdecl init_await_mom_parent_exit()
{ {
DWORD v0; // edi DWORD v0; // edi
v0 = GetTickCount(); v0 = GetTickCount();
do do {
{ if (!init_find_mom_parent())
if ( !init_find_mom_parent() ) break;
break; Sleep(250);
Sleep(250); } while (GetTickCount() - v0 <= 4000);
}
while ( GetTickCount() - v0 <= 4000 );
} }
void __cdecl init_archives() void __cdecl init_archives()
{ {
void *a1; // [esp+8h] [ebp-8h] void *a1; // [esp+8h] [ebp-8h]
#ifdef COPYPROT #ifdef COPYPROT
int v1; // [esp+Ch] [ebp-4h] int v1; // [esp+Ch] [ebp-4h]
#endif #endif
fileinfo.size = 20; fileinfo.size = 20;
fileinfo.versionstring = gszVersionNumber; fileinfo.versionstring = gszVersionNumber;
fileinfo.executablefile = diablo_exe_path; fileinfo.executablefile = diablo_exe_path;
fileinfo.originalarchivefile = diabdat_mpq_path; fileinfo.originalarchivefile = diabdat_mpq_path;
fileinfo.patcharchivefile = patch_rt_mpq_path; fileinfo.patcharchivefile = patch_rt_mpq_path;
init_get_file_info(); init_get_file_info();
#ifdef COPYPROT #ifdef COPYPROT
while ( 1 ) while (1) {
{
#endif #endif
diabdat_mpq = init_test_access(diabdat_mpq_path, "\\diabdat.mpq", "DiabloCD", 1000, 1); diabdat_mpq = init_test_access(diabdat_mpq_path, "\\diabdat.mpq", "DiabloCD", 1000, 1);
#ifdef COPYPROT #ifdef COPYPROT
if ( diabdat_mpq ) if (diabdat_mpq)
break; break;
UiCopyProtError(&v1); UiCopyProtError(&v1);
if ( v1 == COPYPROT_CANCEL ) if (v1 == COPYPROT_CANCEL)
FileErrDlg("diabdat.mpq"); FileErrDlg("diabdat.mpq");
} }
#endif #endif
if ( !WOpenFile("ui_art\\title.pcx", &a1, 1) ) if (!WOpenFile("ui_art\\title.pcx", &a1, 1))
FileErrDlg("Main program archive: diabdat.mpq"); FileErrDlg("Main program archive: diabdat.mpq");
WCloseFile(a1); WCloseFile(a1);
patch_rt_mpq = init_test_access(patch_rt_mpq_path, "\\patch_rt.mpq", "DiabloInstall", 2000, 0); patch_rt_mpq = init_test_access(patch_rt_mpq_path, "\\patch_rt.mpq", "DiabloInstall", 2000, 0);
} }
void *__fastcall init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int flags, bool on_cd) void *__fastcall init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int flags, bool on_cd)
{ {
char *v5; // esi char *v5; // esi
char *v7; // eax char *v7; // eax
char Filename[260]; // [esp+Ch] [ebp-314h] char Filename[260]; // [esp+Ch] [ebp-314h]
char Buffer[260]; // [esp+110h] [ebp-210h] char Buffer[260]; // [esp+110h] [ebp-210h]
char v15[260]; // [esp+214h] [ebp-10Ch] char v15[260]; // [esp+214h] [ebp-10Ch]
char *mpq_namea; // [esp+318h] [ebp-8h] char *mpq_namea; // [esp+318h] [ebp-8h]
void *archive; // [esp+31Ch] [ebp-4h] void *archive; // [esp+31Ch] [ebp-4h]
mpq_namea = mpq_name; mpq_namea = mpq_name;
v5 = mpq_path; v5 = mpq_path;
if ( !GetCurrentDirectory(0x104u, Buffer) ) if (!GetCurrentDirectory(0x104u, Buffer))
TermMsg("Can't get program path"); TermMsg("Can't get program path");
init_strip_trailing_slash(Buffer); init_strip_trailing_slash(Buffer);
if ( !SFileSetBasePath(Buffer) ) if (!SFileSetBasePath(Buffer))
TermMsg("SFileSetBasePath"); TermMsg("SFileSetBasePath");
if ( !GetModuleFileName(ghInst, Filename, 0x104u) ) if (!GetModuleFileName(ghInst, Filename, 0x104u))
TermMsg("Can't get program name"); TermMsg("Can't get program name");
v7 = strrchr(Filename, '\\'); v7 = strrchr(Filename, '\\');
if ( v7 ) if (v7)
*v7 = 0; *v7 = 0;
init_strip_trailing_slash(Filename); init_strip_trailing_slash(Filename);
strcpy(v5, Buffer); strcpy(v5, Buffer);
strcat(v5, mpq_namea); strcat(v5, mpq_namea);
#ifdef COPYPROT #ifdef COPYPROT
if ( SFileOpenArchive(v5, flags, on_cd, &archive) ) if (SFileOpenArchive(v5, flags, on_cd, &archive))
#else #else
if ( SFileOpenArchive(v5, flags, 0, &archive) ) if (SFileOpenArchive(v5, flags, 0, &archive))
#endif #endif
return archive; return archive;
if ( strcmp(Filename, Buffer) ) if (strcmp(Filename, Buffer)) {
{ strcpy(v5, Filename);
strcpy(v5, Filename); strcat(v5, mpq_namea);
strcat(v5, mpq_namea);
#ifdef COPYPROT #ifdef COPYPROT
if ( SFileOpenArchive(v5, flags, on_cd, &archive) ) if (SFileOpenArchive(v5, flags, on_cd, &archive))
#else #else
if ( SFileOpenArchive(v5, flags, 0, &archive) ) if (SFileOpenArchive(v5, flags, 0, &archive))
#endif #endif
return archive; return archive;
} }
v15[0] = 0; v15[0] = 0;
if ( reg_loc ) if (reg_loc) {
{ if (SRegLoadString("Archives", (const char *)reg_loc, 0, v15, 260)) {
if ( SRegLoadString("Archives", (const char *)reg_loc, 0, v15, 260) ) init_strip_trailing_slash(v15);
{ strcpy(v5, v15);
init_strip_trailing_slash(v15); strcat(v5, mpq_namea);
strcpy(v5, v15);
strcat(v5, mpq_namea);
#ifdef COPYPROT #ifdef COPYPROT
if ( SFileOpenArchive(v5, flags, on_cd, &archive) ) if (SFileOpenArchive(v5, flags, on_cd, &archive))
#else #else
if ( SFileOpenArchive(v5, flags, 0, &archive) ) if (SFileOpenArchive(v5, flags, 0, &archive))
#endif #endif
return archive; return archive;
} }
} }
if ( on_cd && init_read_test_file(v15, mpq_namea, flags, &archive) ) if (on_cd && init_read_test_file(v15, mpq_namea, flags, &archive)) {
{ strcpy(v5, v15);
strcpy(v5, v15); return archive;
return archive; }
} return 0;
return 0;
} }
char *__fastcall init_strip_trailing_slash(char *path) char *__fastcall init_strip_trailing_slash(char *path)
{ {
char *result; // eax char *result; // eax
result = strrchr(path, '\\'); result = strrchr(path, '\\');
if ( result ) if (result) {
{ if (!result[1])
if ( !result[1] ) *result = 0;
*result = 0; }
} return result;
return result;
} }
int __fastcall init_read_test_file(char *mpq_path, char *mpq_name, int flags, void **archive) int __fastcall init_read_test_file(char *mpq_path, char *mpq_name, int flags, void **archive)
{ {
char *v4; // edi char *v4; // edi
DWORD v5; // eax DWORD v5; // eax
const char *v7; // ebx const char *v7; // ebx
const char *v8; // esi const char *v8; // esi
char Buffer[260]; // [esp+Ch] [ebp-108h] char Buffer[260]; // [esp+Ch] [ebp-108h]
char *mpq_patha; // [esp+110h] [ebp-4h] char *mpq_patha; // [esp+110h] [ebp-4h]
v4 = mpq_name; v4 = mpq_name;
mpq_patha = mpq_path; mpq_patha = mpq_path;
v5 = GetLogicalDriveStrings(0x104u, Buffer); v5 = GetLogicalDriveStrings(0x104u, Buffer);
if ( !v5 || v5 > 0x104 ) if (!v5 || v5 > 0x104)
return 0; return 0;
while ( *v4 == '\\' ) while (*v4 == '\\')
++v4; ++v4;
v7 = Buffer; v7 = Buffer;
if ( !Buffer[0] ) if (!Buffer[0])
return 0; return 0;
while ( 1 ) while (1) {
{ v8 = v7;
v8 = v7; v7 += strlen(v7) + 1;
v7 += strlen(v7) + 1; if (GetDriveType(v8) == DRIVE_CDROM) {
if ( GetDriveType(v8) == DRIVE_CDROM ) strcpy(mpq_patha, v8);
{ strcat(mpq_patha, v4);
strcpy(mpq_patha, v8); if (SFileOpenArchive(mpq_patha, flags, 1, archive))
strcat(mpq_patha, v4); break;
if ( SFileOpenArchive(mpq_patha, flags, 1, archive) ) }
break; if (!*v7)
} return 0;
if ( !*v7 ) }
return 0; return 1;
}
return 1;
} }
void __cdecl init_get_file_info() void __cdecl init_get_file_info()
{ {
int v0; // eax int v0; // eax
DWORD v1; // edi DWORD v1; // edi
void *v2; // ebx void *v2; // ebx
unsigned int uBytes; // [esp+8h] [ebp-Ch] unsigned int uBytes; // [esp+8h] [ebp-Ch]
DWORD dwHandle; // [esp+Ch] [ebp-8h] DWORD dwHandle; // [esp+Ch] [ebp-8h]
VS_FIXEDFILEINFO *lpBuffer; // [esp+10h] [ebp-4h] VS_FIXEDFILEINFO *lpBuffer; // [esp+10h] [ebp-4h]
if ( GetModuleFileName(ghInst, diablo_exe_path, 0x104u) ) if (GetModuleFileName(ghInst, diablo_exe_path, 0x104u)) {
{ v0 = GetFileVersionInfoSize(diablo_exe_path, &dwHandle);
v0 = GetFileVersionInfoSize(diablo_exe_path, &dwHandle); v1 = v0;
v1 = v0; if (v0) {
if ( v0 ) v2 = DiabloAllocPtr(v0);
{ if (GetFileVersionInfo(diablo_exe_path, 0, v1, v2)) {
v2 = DiabloAllocPtr(v0); if (VerQueryValue(v2, "\\", (LPVOID *)&lpBuffer, &uBytes))
if ( GetFileVersionInfo(diablo_exe_path, 0, v1, v2) ) sprintf(
{ gszVersionNumber,
if ( VerQueryValue(v2, "\\", (LPVOID *)&lpBuffer, &uBytes) ) "version %d.%d.%d.%d",
sprintf( lpBuffer->dwProductVersionMS >> 16,
gszVersionNumber, lpBuffer->dwProductVersionMS & 0xFFFF,
"version %d.%d.%d.%d", lpBuffer->dwProductVersionLS >> 16,
lpBuffer->dwProductVersionMS >> 16, lpBuffer->dwProductVersionLS & 0xFFFF);
lpBuffer->dwProductVersionMS & 0xFFFF, }
lpBuffer->dwProductVersionLS >> 16, mem_free_dbg(v2);
lpBuffer->dwProductVersionLS & 0xFFFF); }
} }
mem_free_dbg(v2);
}
}
} }
LRESULT __stdcall MainWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) LRESULT __stdcall MainWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{ {
if ( Msg > WM_ERASEBKGND ) if (Msg > WM_ERASEBKGND) {
{ if (Msg == WM_ACTIVATEAPP) {
if ( Msg == WM_ACTIVATEAPP ) init_activate_window(hWnd, wParam);
{ } else {
init_activate_window(hWnd, wParam); if (Msg == WM_QUERYNEWPALETTE) {
} SDrawRealizePalette();
else return 1;
{ }
if ( Msg == WM_QUERYNEWPALETTE ) if (Msg == WM_PALETTECHANGED && (HWND)wParam != hWnd)
{ SDrawRealizePalette();
SDrawRealizePalette(); }
return 1; } else {
} switch (Msg) {
if ( Msg == WM_PALETTECHANGED && (HWND)wParam != hWnd ) case WM_ERASEBKGND:
SDrawRealizePalette(); return 0;
} case WM_CREATE:
} ghMainWnd = hWnd;
else break;
{ case WM_DESTROY:
switch ( Msg ) init_cleanup(1);
{ ghMainWnd = 0;
case WM_ERASEBKGND: PostQuitMessage(0);
return 0; break;
case WM_CREATE: case WM_PAINT:
ghMainWnd = hWnd; drawpanflag = 255;
break; break;
case WM_DESTROY: case WM_CLOSE:
init_cleanup(1); return 0;
ghMainWnd = 0; }
PostQuitMessage(0); }
break; return DefWindowProc(hWnd, Msg, wParam, lParam);
case WM_PAINT:
drawpanflag = 255;
break;
case WM_CLOSE:
return 0;
}
}
return DefWindowProc(hWnd, Msg, wParam, lParam);
} }
// 52571C: using guessed type int drawpanflag; // 52571C: using guessed type int drawpanflag;
void __fastcall init_activate_window(HWND hWnd, bool bActive) void __fastcall init_activate_window(HWND hWnd, bool bActive)
{ {
LONG dwNewLong; // eax LONG dwNewLong; // eax
gbActive = bActive; gbActive = bActive;
UiAppActivate(bActive); UiAppActivate(bActive);
dwNewLong = GetWindowLong(hWnd, GWL_STYLE); dwNewLong = GetWindowLong(hWnd, GWL_STYLE);
if ( gbActive && fullscreen ) if (gbActive && fullscreen)
dwNewLong &= ~WS_SYSMENU; dwNewLong &= ~WS_SYSMENU;
else else
dwNewLong |= WS_SYSMENU; dwNewLong |= WS_SYSMENU;
SetWindowLong(hWnd, GWL_STYLE, dwNewLong); SetWindowLong(hWnd, GWL_STYLE, dwNewLong);
if ( gbActive ) if (gbActive) {
{ drawpanflag = 255;
drawpanflag = 255; ResetPal();
ResetPal(); }
}
} }
// 52571C: using guessed type int drawpanflag; // 52571C: using guessed type int drawpanflag;
// 634980: using guessed type int gbActive; // 634980: using guessed type int gbActive;
LRESULT __stdcall WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) LRESULT __stdcall WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{ {
LRESULT result; // eax LRESULT result; // eax
if ( CurrentProc ) if (CurrentProc)
result = CurrentProc(hWnd, Msg, wParam, lParam); result = CurrentProc(hWnd, Msg, wParam, lParam);
else else
result = MainWndProc(hWnd, Msg, wParam, lParam); result = MainWndProc(hWnd, Msg, wParam, lParam);
return result; return result;
} }
WNDPROC __fastcall SetWindowProc(WNDPROC NewProc) WNDPROC __fastcall SetWindowProc(WNDPROC NewProc)
{ {
WNDPROC OldProc; // eax WNDPROC OldProc; // eax
OldProc = CurrentProc; OldProc = CurrentProc;
CurrentProc = NewProc; CurrentProc = NewProc;
return OldProc; return OldProc;
} }

2
Source/init.h

@ -4,7 +4,7 @@
extern _SNETVERSIONDATA fileinfo; extern _SNETVERSIONDATA fileinfo;
extern int init_cpp_init_value; // weak extern int init_cpp_init_value; // weak
extern int gbActive; // weak extern int gbActive; // weak
extern char diablo_exe_path[260]; extern char diablo_exe_path[260];
extern void *unused_mpq; extern void *unused_mpq;
extern char patch_rt_mpq_path[260]; extern char patch_rt_mpq_path[260];

Loading…
Cancel
Save