나는 프로세스를 높이기 위해 this article을 따라 갔지만 디버깅 할 때는 아래 코드를 사용하여 무한한 수의 쉘을 생성합니다. 발생하는 행이 표시됩니다.ShellExecuteInfo를 통한 상승 과정 - 무한 껍질?
MSDN 기사 here을 살펴 봤지만 많은 통찰력을주지 못했습니다. 내가 뭘 잘못하고 있는지 조언 해주세요.
저는 C++을 처음 사용합니다.
wchar_t szPath[MAX_PATH];
if (GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath)))
{
// Launch itself as admin
SHELLEXECUTEINFO sei = { sizeof(sei) };
sei.lpVerb = L"runas";
sei.lpFile = szPath;
sei.hwnd = NULL;
sei.nShow = SW_NORMAL;
if (!ShellExecuteEx(&sei)) //get infinite shells here
{
DWORD dwError = GetLastError();
if (dwError == ERROR_CANCELLED)
{
// The user refused to allow privileges elevation.
std::cout << "User did not allow elevation" << std::endl;
}
}
else
{
//other lines of code omitted.
}
}
자신의 복사본을 시작한 것으로 보이는 복사본이 시작됩니다. –