LAUNCHER: Simplify installation process
Thx to Jonas for helping me with the zone data
This commit is contained in:
parent
4312b99fd4
commit
6cf28d32e6
Binary file not shown.
|
@ -2,6 +2,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <queue>
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
#include <objbase.h>
|
#include <objbase.h>
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
|
@ -298,6 +299,16 @@ static TCHAR sz32Dir[MAX_PATH] = TEXT("");
|
||||||
static TCHAR sz64Path[MAX_PATH] = TEXT("");
|
static TCHAR sz64Path[MAX_PATH] = TEXT("");
|
||||||
static TCHAR sz64Dir[MAX_PATH] = TEXT("");
|
static TCHAR sz64Dir[MAX_PATH] = TEXT("");
|
||||||
|
|
||||||
|
static void restartInstall()
|
||||||
|
{
|
||||||
|
OSVERSIONINFO osvi;
|
||||||
|
memset(&osvi, 0, sizeof(osvi));
|
||||||
|
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
||||||
|
GetVersionEx(&osvi);
|
||||||
|
auto operation = osvi.dwMajorVersion >= 6 ? TEXT("runas") : TEXT("open");
|
||||||
|
ShellExecute(nullptr, operation, szModulePath, TEXT("::install"), szCurrentDir, SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL CALLBACK DlgLauncher(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
static BOOL CALLBACK DlgLauncher(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch(uMsg)
|
switch(uMsg)
|
||||||
|
@ -340,12 +351,7 @@ static BOOL CALLBACK DlgLauncher(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
|
||||||
case IDC_BUTTONINSTALL:
|
case IDC_BUTTONINSTALL:
|
||||||
{
|
{
|
||||||
EndDialog(hwndDlg, 0);
|
EndDialog(hwndDlg, 0);
|
||||||
OSVERSIONINFO osvi;
|
restartInstall();
|
||||||
memset(&osvi, 0, sizeof(osvi));
|
|
||||||
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
|
||||||
GetVersionEx(&osvi);
|
|
||||||
auto operation = osvi.dwMajorVersion >= 6 ? TEXT("runas") : TEXT("open");
|
|
||||||
ShellExecute(nullptr, operation, szModulePath, TEXT("::install"), szCurrentDir, SW_SHOWNORMAL);
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -382,6 +388,42 @@ const wchar_t* SHELLEXT_ICON_EXE_KEY = L"exefile\\shell\\Debug with x64dbg";
|
||||||
const wchar_t* SHELLEXT_DLL_KEY = L"dllfile\\shell\\Debug with x64dbg\\Command";
|
const wchar_t* SHELLEXT_DLL_KEY = L"dllfile\\shell\\Debug with x64dbg\\Command";
|
||||||
const wchar_t* SHELLEXT_ICON_DLL_KEY = L"dllfile\\shell\\Debug with x64dbg";
|
const wchar_t* SHELLEXT_ICON_DLL_KEY = L"dllfile\\shell\\Debug with x64dbg";
|
||||||
|
|
||||||
|
static void deleteZoneData(const std::wstring & rootDir)
|
||||||
|
{
|
||||||
|
wchar_t szTempPath[MAX_PATH] = L"";
|
||||||
|
std::queue<std::wstring> queue;
|
||||||
|
queue.push(rootDir);
|
||||||
|
while(!queue.empty())
|
||||||
|
{
|
||||||
|
auto dir = queue.front();
|
||||||
|
queue.pop();
|
||||||
|
WIN32_FIND_DATAW foundData;
|
||||||
|
HANDLE hSearch = FindFirstFileW((dir + L"\\*").c_str(), &foundData);
|
||||||
|
if(hSearch == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if((foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
{
|
||||||
|
if(wcscmp(foundData.cFileName, L".") != 0 && wcscmp(foundData.cFileName, L"..") != 0)
|
||||||
|
queue.push(dir + L"\\" + foundData.cFileName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wcscpy_s(szTempPath, dir.c_str());
|
||||||
|
wcscat_s(szTempPath, L"\\");
|
||||||
|
wcscat_s(szTempPath, foundData.cFileName);
|
||||||
|
wcscat_s(szTempPath, L":Zone.Identifier");
|
||||||
|
DeleteFileW(szTempPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while(FindNextFileW(hSearch, &foundData));
|
||||||
|
FindClose(hSearch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
||||||
{
|
{
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
|
@ -487,6 +529,13 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
||||||
auto argc = 0;
|
auto argc = 0;
|
||||||
auto argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
auto argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||||
|
|
||||||
|
// If x64dbg is not found, perform installation
|
||||||
|
if(bDoneSomething)
|
||||||
|
{
|
||||||
|
restartInstall();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(argc <= 1) //no arguments -> launcher dialog
|
if(argc <= 1) //no arguments -> launcher dialog
|
||||||
{
|
{
|
||||||
if(!FileExists(sz32Path) && BrowseFileOpen(nullptr, TEXT("x32dbg.exe\0x32dbg.exe\0\0"), nullptr, sz32Path, MAX_PATH, szCurrentDir))
|
if(!FileExists(sz32Path) && BrowseFileOpen(nullptr, TEXT("x32dbg.exe\0x32dbg.exe\0\0"), nullptr, sz32Path, MAX_PATH, szCurrentDir))
|
||||||
|
@ -513,6 +562,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
||||||
WritePrivateProfileString(TEXT("Launcher"), TEXT("x64dbg"), sz64Path, szIniPath);
|
WritePrivateProfileString(TEXT("Launcher"), TEXT("x64dbg"), sz64Path, szIniPath);
|
||||||
bDoneSomething = true;
|
bDoneSomething = true;
|
||||||
}
|
}
|
||||||
|
deleteZoneData(szCurrentDir);
|
||||||
|
deleteZoneData(szCurrentDir + std::wstring(L"\\..\\pluginsdk"));
|
||||||
if(MessageBox(nullptr, LoadResString(IDS_ASKSHELLEXT), LoadResString(IDS_QUESTION), MB_YESNO | MB_ICONQUESTION) == IDYES)
|
if(MessageBox(nullptr, LoadResString(IDS_ASKSHELLEXT), LoadResString(IDS_QUESTION), MB_YESNO | MB_ICONQUESTION) == IDYES)
|
||||||
{
|
{
|
||||||
TCHAR szLauncherCommand[MAX_PATH] = TEXT("");
|
TCHAR szLauncherCommand[MAX_PATH] = TEXT("");
|
||||||
|
|
Loading…
Reference in New Issue