Skip to content

Commit dca1591

Browse files
committed
More progress on the launcher
1 parent 24d30c5 commit dca1591

File tree

9 files changed

+69
-1590
lines changed

9 files changed

+69
-1590
lines changed

AutoitLauncher/GWToolbox.au3

Lines changed: 0 additions & 885 deletions
This file was deleted.

AutoitLauncher/OldLauncher.au3

Lines changed: 0 additions & 416 deletions
This file was deleted.

AutoitLauncher/StringSize.au3

Lines changed: 0 additions & 279 deletions
This file was deleted.

GWToolbox/Inject.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class InjectWindow
4848

4949
bool IsRunningAsAdmin();
5050
bool CreateProcessAsAdmin(const wchar_t *path, const wchar_t *args, const wchar_t *workdir);
51-
bool RestartAsAdmin(const wchar_t *args = L"");
51+
bool RestartAsAdmin(const wchar_t *args);
5252
bool EnableDebugPrivilege();
53-
5453
bool InjectRemoteThread(Process& process, LPCWSTR ImagePath, LPDWORD lpExitCode);

GWToolbox/Install.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#endif
77
#include <Windows.h>
88

9+
#include <assert.h>
910
#include <stdio.h>
1011
#include <string.h>
1112
#include <time.h>
@@ -79,6 +80,30 @@ static bool RegWriteDWORD(HKEY hKey, LPCWSTR KeyName, DWORD Value)
7980
return true;
8081
}
8182

83+
static bool RegReadStr(HKEY hKey, LPCWSTR KeyName, LPWSTR Buffer, size_t BufferLength)
84+
{
85+
assert(BufferLength > 0);
86+
87+
DWORD cbData = static_cast<DWORD>(BufferLength - 1) * sizeof(WCHAR);
88+
LSTATUS status = RegGetValueW(
89+
hKey,
90+
L"",
91+
KeyName,
92+
RRF_RT_REG_SZ,
93+
nullptr,
94+
Buffer,
95+
&cbData);
96+
97+
if (status != ERROR_SUCCESS)
98+
{
99+
fprintf(stderr, "RegGetValueW failed: status:%d\n", status);
100+
return false;
101+
}
102+
103+
Buffer[cbData / sizeof(WCHAR)] = 0;
104+
return true;
105+
}
106+
82107
static bool GetFileSize(const wchar_t *path, uint64_t *file_size)
83108
{
84109
HANDLE hFile = CreateFileW(
@@ -309,3 +334,21 @@ bool Uninstall(bool quiet)
309334

310335
return true;
311336
}
337+
338+
bool GetInstallationLocation(wchar_t *path, size_t length)
339+
{
340+
HKEY UninstallKey;
341+
if (!OpenUninstallHive(HKEY_CURRENT_USER, &UninstallKey)) {
342+
fprintf(stderr, "OpenUninstallHive failed\n");
343+
return false;
344+
}
345+
346+
if (!RegReadStr(UninstallKey, L"InstallLocation", path, length)) {
347+
fprintf(stderr, "RegReadStr failed\n");
348+
RegCloseKey(UninstallKey);
349+
return false;
350+
}
351+
352+
RegCloseKey(UninstallKey);
353+
return true;
354+
}

GWToolbox/Install.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
bool Install(bool quiet);
44
bool Uninstall(bool quiet);
5+
6+
bool GetInstallationLocation(wchar_t *path, size_t length);

GWToolbox/Options.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ void ParseCommandLine(int argc, char *argv[])
4242
} else if (strcmp(arg, "/reinstall") == 0) {
4343
options.reinstall = true;
4444
} else if (strcmp(arg, "/pid") == 0) {
45-
fprintf(stderr, "Process id\n");
4645
if (++i == argc) {
4746
fprintf(stderr, "'/pid' must be followed by a process id\n");
4847
PrintUsage(true);

GWToolbox/Path.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ bool PathCompose(wchar_t *dest, size_t length, const wchar_t *left, const wchar_
118118
return false;
119119
}
120120

121-
memmove(dest, left, left_size);
121+
if (dest != left) {
122+
memmove(dest, left, left_size);
123+
}
122124

123125
if (PathAppendW(dest, right) != TRUE) {
124126
fprintf(stderr, "PathAppendW failed\n");

0 commit comments

Comments
 (0)