Skip to content

Commit

Permalink
fix: Char type conversions for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
pktiuk committed May 6, 2024
1 parent f44118f commit 6d73ed0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/winextras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,13 @@ void WinExtras::removeFileAssociationFromRegistry()
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
}

wchar_t *convertCharArrayToLPCWSTR(const char *charArray)
{
wchar_t *wString = new wchar_t[1024];
MultiByteToWideChar(CP_ACP, 0, charArray, -1, wString, 1024);
return wString;
}

/**
* @brief Attempt to elevate process using runas
* @return Execution status
Expand All @@ -354,8 +361,8 @@ bool WinExtras::elevateAntiMicro()
char *tempfile = ba.data();
tempverb[5] = '\0';
tempfile[antiProgramLocation.length()] = '\0';
sei.lpVerb = tempverb;
sei.lpFile = tempfile;
sei.lpVerb = convertCharArrayToLPCWSTR(tempverb);
sei.lpFile = convertCharArrayToLPCWSTR(tempfile);
sei.hwnd = NULL;
sei.nShow = SW_NORMAL;
BOOL result = ShellExecuteEx(&sei);
Expand Down

0 comments on commit 6d73ed0

Please sign in to comment.