Skip to content

Commit ee47203

Browse files
committed
silence compiler warnings
1 parent d587c5a commit ee47203

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

Client/src/SysInfo.win32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace {
2828
{ \
2929
return PA_ERROR(std::error_code(hRes, std::system_category())); \
3030
} \
31-
void
31+
(void)0
3232

3333
Result<std::string> WmiGetOsCaption()
3434
{

Core/src/Process.win32.cpp

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright 2021 <github.com/razaqq>
22

3+
#include "Core/Encoding.hpp"
34
#include "Core/Process.hpp"
5+
#include "Core/Result.hpp"
46

57
#define WIN32_SHOWWINDOW
68
#define WIN32_USER
@@ -34,18 +36,28 @@ void PotatoAlert::Core::ExitCurrentProcessWithError(uint32_t code)
3436

3537
bool c::CreateNewProcess(const std::filesystem::path& path, std::string_view args, bool elevated)
3638
{
37-
const char* lpVerb = elevated ? "runas" : "open";
38-
const std::string pathStr = path.string();
39-
const std::string argsStr = std::string(args);
40-
SHELLEXECUTEINFOA sei = { // TODO: use W version here
41-
sizeof(sei),
42-
SEE_MASK_NO_CONSOLE,
43-
nullptr,
44-
lpVerb,
45-
pathStr.c_str(),
46-
argsStr.c_str(),
47-
nullptr,
48-
SW_SHOWNORMAL
49-
};
50-
return ShellExecuteExA(&sei);
39+
const wchar_t* lpVerb = elevated ? L"runas" : L"open";
40+
const std::wstring& pathStr = path.native();
41+
42+
Result<size_t> size = Utf8ToWide(args);
43+
if (!size)
44+
{
45+
return false;
46+
}
47+
std::wstring argsStr(size.value(), L'\0');
48+
if (!Utf8ToWide(args, argsStr))
49+
{
50+
return false;
51+
}
52+
53+
SHELLEXECUTEINFOW sei = {}; // TODO: use W version here
54+
sei.cbSize = sizeof(SHELLEXECUTEINFOW);
55+
sei.fMask = SEE_MASK_NO_CONSOLE;
56+
sei.lpVerb = lpVerb;
57+
sei.lpFile = pathStr.c_str();
58+
sei.lpParameters = argsStr.c_str();
59+
sei.lpDirectory = nullptr;
60+
sei.nShow = SW_SHOWNORMAL;
61+
62+
return ShellExecuteExW(&sei);
5163
}

0 commit comments

Comments
 (0)