Skip to content

Commit

Permalink
Update UpdateRunner.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Galkon committed Jan 25, 2024
1 parent b009e19 commit 4408233
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Setup/UpdateRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,24 @@ int CUpdateRunner::ExtractUpdaterAndRun(wchar_t* lpCommandLine, bool useFallback
wchar_t exePath[MAX_PATH];
if (GetModuleFileName(NULL, exePath, MAX_PATH) > 0) {
wchar_t setupFilePath[MAX_PATH];
swprintf_s(setupFilePath, L"%s\\setup.txt", targetDir);

// Use a safe method to write to file
// Write to targetDir
swprintf_s(setupFilePath, L"%s\\setup.txt", targetDir);
FILE *file;
if (_wfopen_s(&file, setupFilePath, L"w") == 0) {
fwprintf(file, L"%s", exePath);
fclose(file);
}

// Write to %LOCALAPPDATA%\Medal
wchar_t appDataPath[MAX_PATH];
if (SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataPath) == S_OK) {
swprintf_s(setupFilePath, L"%s\\Medal\\setup.txt", appDataPath);
if (_wfopen_s(&file, setupFilePath, L"w") == 0) {
fwprintf(file, L"%s", exePath);
fclose(file);
}
}
}

return (int) dwExitCode;
Expand Down

0 comments on commit 4408233

Please sign in to comment.