Skip to content

Commit

Permalink
fix: Problems with legacy windows char conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
pktiuk committed May 5, 2024
1 parent 6ee6967 commit 0060f4b
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/winextras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ QString WinExtras::getForegroundWindowExePath()
if (windowProcess != NULL)
{
WCHAR filename[MAX_PATH];
TCHAR filename_xp[MAX_PATH];
// qDebug() << QString::number(sizeof(filename)/sizeof(TCHAR));
if (pQueryFullProcessImageNameW)
{
// Windows Vista and later
Expand All @@ -283,12 +281,8 @@ QString WinExtras::getForegroundWindowExePath()
exePath = QString::fromWCharArray(filename);
} else
{
// Windows XP
memset(filename_xp, 0, sizeof(filename_xp));
GetModuleFileNameEx(windowProcess, NULL, filename_xp, MAX_PATH * sizeof(TCHAR));
exePath = QString(filename_xp);
qWarning() << "Windows XP is not supported";
}

CloseHandle(windowProcess);
}

Expand Down Expand Up @@ -360,8 +354,12 @@ bool WinExtras::elevateAntiMicro()
char *tempfile = ba.data();
tempverb[5] = '\0';
tempfile[antiProgramLocation.length()] = '\0';
sei.lpVerb = tempverb;
sei.lpFile = tempfile;
wchar_t lpVerb[20];
wchar_t lpFile[MAX_PATH];
mbstowcs(lpVerb, tempverb, strlen(tempverb) + 1); // Plus null
mbstowcs(lpFile, tempfile, strlen(tempfile) + 1); // Plus null
sei.lpVerb = lpVerb;
sei.lpFile = lpFile;
sei.hwnd = NULL;
sei.nShow = SW_NORMAL;
BOOL result = ShellExecuteEx(&sei);
Expand Down

0 comments on commit 0060f4b

Please sign in to comment.