summaryrefslogtreecommitdiff
path: root/Source/Core/WinUpdater/Main.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2022-11-16 02:41:25 +0100
committerAdmiral H. Curtiss <pikachu025@gmail.com>2022-11-22 01:28:02 +0100
commitf0fb8c22b0383d65570cbb13a270cf33137dc530 (patch)
treed9840741fa9ae0a1ca1f947d103067aa3a8509d1 /Source/Core/WinUpdater/Main.cpp
parent8f5a58f8be7e6979e277eb16934b140e4bbf10a4 (diff)
Updater: Check for write permissions in directory of Updater.exe.
Diffstat (limited to 'Source/Core/WinUpdater/Main.cpp')
-rw-r--r--Source/Core/WinUpdater/Main.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/Source/Core/WinUpdater/Main.cpp b/Source/Core/WinUpdater/Main.cpp
index caa9f40958..85b29e8226 100644
--- a/Source/Core/WinUpdater/Main.cpp
+++ b/Source/Core/WinUpdater/Main.cpp
@@ -31,7 +31,15 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
// Test for write permissions
bool need_admin = false;
- FILE* test_fh = fopen("Updater.log", "w");
+ auto path = GetModuleName(hInstance);
+ if (!path)
+ {
+ UI::Error("Failed to get updater filename.");
+ return 1;
+ }
+
+ FILE* test_fh =
+ _wfopen((std::filesystem::path(*path).parent_path() / "Updater.log").c_str(), L"w");
if (test_fh == nullptr)
need_admin = true;
@@ -47,13 +55,6 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
return 1;
}
- auto path = GetModuleName(hInstance);
- if (!path)
- {
- MessageBox(nullptr, L"Failed to get updater filename.", L"Error", MB_ICONERROR);
- return 1;
- }
-
// Relaunch the updater as administrator
ShellExecuteW(nullptr, L"runas", path->c_str(), pCmdLine, NULL, SW_SHOW);
return 0;