Skip to content

Commit 0060f4b

Browse files
committed
fix: Problems with legacy windows char conversions
1 parent 6ee6967 commit 0060f4b

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/winextras.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,6 @@ QString WinExtras::getForegroundWindowExePath()
270270
if (windowProcess != NULL)
271271
{
272272
WCHAR filename[MAX_PATH];
273-
TCHAR filename_xp[MAX_PATH];
274-
// qDebug() << QString::number(sizeof(filename)/sizeof(TCHAR));
275273
if (pQueryFullProcessImageNameW)
276274
{
277275
// Windows Vista and later
@@ -283,12 +281,8 @@ QString WinExtras::getForegroundWindowExePath()
283281
exePath = QString::fromWCharArray(filename);
284282
} else
285283
{
286-
// Windows XP
287-
memset(filename_xp, 0, sizeof(filename_xp));
288-
GetModuleFileNameEx(windowProcess, NULL, filename_xp, MAX_PATH * sizeof(TCHAR));
289-
exePath = QString(filename_xp);
284+
qWarning() << "Windows XP is not supported";
290285
}
291-
292286
CloseHandle(windowProcess);
293287
}
294288

@@ -360,8 +354,12 @@ bool WinExtras::elevateAntiMicro()
360354
char *tempfile = ba.data();
361355
tempverb[5] = '\0';
362356
tempfile[antiProgramLocation.length()] = '\0';
363-
sei.lpVerb = tempverb;
364-
sei.lpFile = tempfile;
357+
wchar_t lpVerb[20];
358+
wchar_t lpFile[MAX_PATH];
359+
mbstowcs(lpVerb, tempverb, strlen(tempverb) + 1); // Plus null
360+
mbstowcs(lpFile, tempfile, strlen(tempfile) + 1); // Plus null
361+
sei.lpVerb = lpVerb;
362+
sei.lpFile = lpFile;
365363
sei.hwnd = NULL;
366364
sei.nShow = SW_NORMAL;
367365
BOOL result = ShellExecuteEx(&sei);

0 commit comments

Comments
 (0)