2022-05-19 01:51:26 -07:00
|
|
|
#include "electronic_registration.h"
|
|
|
|
|
2022-05-29 12:08:13 -07:00
|
|
|
#ifdef _WIN32
|
2022-05-19 01:51:26 -07:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
2022-05-29 12:08:13 -07:00
|
|
|
#endif
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-09-15 02:38:23 -07:00
|
|
|
#include "platform_compat.h"
|
2022-10-06 06:32:46 -07:00
|
|
|
#include "settings.h"
|
2022-09-15 02:38:23 -07:00
|
|
|
|
2022-09-23 05:43:44 -07:00
|
|
|
namespace fallout {
|
|
|
|
|
2022-05-19 01:51:26 -07:00
|
|
|
// 0x440DD0
|
|
|
|
void runElectronicRegistration()
|
|
|
|
{
|
2022-10-06 06:32:46 -07:00
|
|
|
int timesRun = settings.system.times_run;
|
2022-05-19 01:51:26 -07:00
|
|
|
if (timesRun > 0 && timesRun < 5) {
|
2022-05-29 12:08:13 -07:00
|
|
|
#ifdef _WIN32
|
2022-05-28 02:34:49 -07:00
|
|
|
char path[COMPAT_MAX_PATH];
|
2022-05-19 01:51:26 -07:00
|
|
|
if (GetModuleFileNameA(NULL, path, sizeof(path)) != 0) {
|
|
|
|
char* pch = strrchr(path, '\\');
|
|
|
|
if (pch == NULL) {
|
|
|
|
pch = path;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(pch, "\\ereg");
|
|
|
|
|
|
|
|
STARTUPINFOA startupInfo;
|
|
|
|
memset(&startupInfo, 0, sizeof(startupInfo));
|
|
|
|
startupInfo.cb = sizeof(startupInfo);
|
|
|
|
|
|
|
|
PROCESS_INFORMATION processInfo;
|
|
|
|
|
|
|
|
// FIXME: Leaking processInfo.hProcess and processInfo.hThread:
|
|
|
|
// https://docs.microsoft.com/en-us/cpp/code-quality/c6335.
|
|
|
|
if (CreateProcessA("ereg\\reg32a.exe", NULL, NULL, NULL, FALSE, 0, NULL, path, &startupInfo, &processInfo)) {
|
|
|
|
WaitForSingleObject(processInfo.hProcess, INFINITE);
|
|
|
|
}
|
|
|
|
}
|
2022-05-29 12:08:13 -07:00
|
|
|
#endif
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-10-06 06:32:46 -07:00
|
|
|
settings.system.times_run = timesRun + 1;
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
|
|
|
if (timesRun == 0) {
|
2022-10-06 06:32:46 -07:00
|
|
|
settings.system.times_run = 1;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-09-23 05:43:44 -07:00
|
|
|
|
|
|
|
} // namespace fallout
|