diff --git a/loader/launcher/windows/Bootstrapper.cpp b/loader/launcher/windows/Bootstrapper.cpp index e30447f6..9c4e4b34 100644 --- a/loader/launcher/windows/Bootstrapper.cpp +++ b/loader/launcher/windows/Bootstrapper.cpp @@ -18,10 +18,10 @@ int loadGeode(PVOID module) { } DWORD WINAPI load(PVOID module) { - std::array<TCHAR, MAX_PATH> szFileName; - GetModuleFileName(NULL, szFileName.data(), MAX_PATH); + std::array<WCHAR, MAX_PATH> szFileName; + GetModuleFileNameW(NULL, szFileName.data(), MAX_PATH); - ghc::filesystem::path path(szFileName.data()); + const ghc::filesystem::path path(szFileName.data()); auto workingDir = path.parent_path(); auto updatesDir = workingDir / "geode" / "update"; auto resourcesDir = workingDir / "geode" / "resources"; diff --git a/loader/src/platform/windows/util.cpp b/loader/src/platform/windows/util.cpp index ab6a59a2..2ee767c6 100644 --- a/loader/src/platform/windows/util.cpp +++ b/loader/src/platform/windows/util.cpp @@ -116,12 +116,17 @@ CCPoint cocos::getMousePos() { } ghc::filesystem::path dirs::getGameDir() { - std::array<TCHAR, MAX_PATH> szFileName; - GetModuleFileName(NULL, szFileName.data(), MAX_PATH); + // only fetch the path once, since ofc it'll never change + // throughout the execution + static const auto path = [] { + std::array<WCHAR, MAX_PATH> buffer; + GetModuleFileNameW(NULL, buffer.data(), MAX_PATH); - ghc::filesystem::path path(szFileName.data()); - auto currentPath = path.parent_path(); - return currentPath; + const ghc::filesystem::path path(buffer.data()); + return path.parent_path(); + }(); + + return path; } #endif