Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MouriNaruto committed Nov 30, 2018
1 parent 7f6a7dc commit 1542681
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions NSudoSDK/NSudoAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ static DWORD CreateCommandStoreItem(
return dwError;
}

static std::wstring NSudoExpandEnvironmentStrings(
const std::wstring& String)
{
std::wstring ExpandedString;

ExpandedString.resize(static_cast<size_t>(ExpandEnvironmentStringsW(
String.c_str(),
nullptr,
0) - 1));

ExpandEnvironmentStringsW(
String.c_str(),
&ExpandedString[0],
static_cast<DWORD>(ExpandedString.size() + 1));

return ExpandedString;
}

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -943,7 +961,7 @@ extern "C" {
return result;
}




static bool NSudoCreateProcessDirect(
Expand Down Expand Up @@ -987,7 +1005,7 @@ extern "C" {
result = CreateProcessAsUserW(
hToken,
nullptr,
const_cast<LPWSTR>(lpCommandLine),
const_cast<LPWSTR>(NSudoExpandEnvironmentStrings(lpCommandLine).c_str()),
nullptr,
nullptr,
FALSE,
Expand Down

0 comments on commit 1542681

Please sign in to comment.