[Command] Don't crash on shell execute

This commit is contained in:
momo5502 2017-06-11 21:25:00 +02:00
parent 29ef5d6379
commit a327915008
4 changed files with 14 additions and 3 deletions

View File

@ -257,7 +257,7 @@ namespace Components
{
if (params->length() > 1)
{
ShellExecuteA(nullptr, "open", params->get(1), nullptr, nullptr, SW_SHOWNORMAL);
Utils::OpenUrl(params->get(1));
}
});
}

View File

@ -201,12 +201,12 @@ namespace Components
UIScript::Add("visitWebsite", [](UIScript::Token)
{
ShellExecuteA(nullptr, "open", Utils::Cache::GetStaticUrl("").data(), nullptr, nullptr, SW_SHOWNORMAL);
Utils::OpenUrl(Utils::Cache::GetStaticUrl(""));
});
UIScript::Add("visitWiki", [](UIScript::Token)
{
ShellExecuteA(nullptr, "open", Utils::Cache::GetStaticUrl("/wiki/").data(), nullptr, nullptr, SW_SHOWNORMAL);
Utils::OpenUrl(Utils::Cache::GetStaticUrl("/wiki/"));
});
Localization::Set("MPUI_CHANGELOG_TEXT", "Loading...");

View File

@ -110,6 +110,15 @@ namespace Utils
return GetModuleHandleA(Utils::String::XOR(std::string(reinterpret_cast<char*>(ntdll), sizeof ntdll), -1).data());
}
void OpenUrl(std::string url)
{
try
{
ShellExecuteA(nullptr, "open", url.data(), nullptr, nullptr, SW_SHOWNORMAL);
}
catch (...) {}
}
bool HasIntercection(unsigned int base1, unsigned int len1, unsigned int base2, unsigned int len2)
{
return !(base1 + len1 <= base2 || base2 + len2 <= base1);

View File

@ -19,6 +19,8 @@ namespace Utils
void* GetThreadStartAddress(HANDLE hThread);
HMODULE GetNTDLL();
void OpenUrl(std::string url);
bool HasIntercection(unsigned int base1, unsigned int len1, unsigned int base2, unsigned int len2);
template <typename T> inline void RotLeft(T& object, size_t bits)