diff --git a/Code/immersive_launcher/Launcher.cpp b/Code/immersive_launcher/Launcher.cpp index 8f522a92e..d71fce5d1 100644 --- a/Code/immersive_launcher/Launcher.cpp +++ b/Code/immersive_launcher/Launcher.cpp @@ -149,14 +149,16 @@ bool HandleArguments(int aArgc, char** aArgv, bool& aAskSelect) aAskSelect = true; else if (std::strcmp(aArgv[i], "--exePath") == 0) { - if (!aArgv[i + 1]) + if(i + 1 >= aArgc) { + SetLastError(ERROR_BAD_PATHNAME); Die(L"No exe path specified", true); return false; } if (!oobe::PathArgument(aArgv[i + 1])) { + SetLastError(ERROR_BAD_ARGUMENTS); Die(L"Failed to parse path argument", true); return false; } diff --git a/Code/immersive_launcher/oobe/PathArgument.cpp b/Code/immersive_launcher/oobe/PathArgument.cpp index 55b5d781c..7b582b5c8 100644 --- a/Code/immersive_launcher/oobe/PathArgument.cpp +++ b/Code/immersive_launcher/oobe/PathArgument.cpp @@ -30,26 +30,30 @@ bool ValidatePath(const std::wstring& acPath) if (acPath.find_last_of('\\') == std::string::npos || acPath.ends_with(*"\\")) { + SetLastError(ERROR_BAD_PATHNAME); errorText += L"Invalid path\n"; } if (!acPath.ends_with(L".exe")) { + SetLastError(ERROR_BAD_ARGUMENTS); errorText += acPath.substr(acPath.find_last_of('\\') + 1, acPath.back()) + L" is not an executable file\n"; } else if (!acPath.ends_with(TARGET_NAME L".exe")) { + SetLastError(ERROR_FILE_NOT_FOUND); errorText += TARGET_NAME L".exe not found\n"; } if (!std::filesystem::exists(g_exePath) || !std::filesystem::exists(g_titlePath)) { + SetLastError(ERROR_BAD_PATHNAME); errorText += L"Path does not exist\n"; } if (!errorText.empty()) { - errorText += L"Path: " + acPath; + errorText += L"\nPath: " + acPath; DIE_NOW(errorText.c_str()) }