2024年3月14日发(作者:)

CloseHandle(hToken);

return;

}

egeCount = 1;

eges[0].Luid = sedebugnameValue;

eges[0].Attributes = SE_PRIVILEGE_ENABLED;

if (!AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(tkp), NULL, NULL)) {

CloseHandle(hToken);

return;

}

}

char* ConvertLPWSTRToLPSTR(LPWSTR lpwszStrIn)

{

LPSTR pszOut = NULL;

if (lpwszStrIn != NULL)

{

int nInputStrLen = wcslen(lpwszStrIn);

// Double NULL Termination

int nOutputStrLen = WideCharToMultiByte(CP_ACP, 0, lpwszStrIn, nInputStrLen, NULL, 0, 0, 0) + 2;

pszOut = new char[nOutputStrLen];

if (pszOut)

{

memset(pszOut, 0x00, nOutputStrLen);

WideCharToMultiByte(CP_ACP, 0, lpwszStrIn, nInputStrLen, pszOut, nOutputStrLen, 0, 0);

}

}

return pszOut;

}

//冻结

void Freeze()

{

//枚举进程信息

PROCESSENTRY32 pe32;

= sizeof(pe32);

HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

int processPid;

//CString strTmp;

BOOL b = ::Process32First(hProcessSnap, &pe32);

while (b)

{

processPid = 32ProcessID;

char *exeFile = ConvertLPWSTRToLPSTR(ile);

if (strcmp(exeFile, "") == 0)

{

break;

}

delete[] exeFile;

b = ::Process32Next(hProcessSnap, &pe32);

}

::CloseHandle(hProcessSnap);

THREADENTRY32 th32;

= sizeof(th32);

HANDLE hThreadSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);

globlePid = processPid;

unsigned long Pid;

Pid = processPid;

b = ::Thread32First(hThreadSnap, &th32);

while (b)

{

if (32OwnerProcessID == Pid)

{

HANDLE oth = OpenThread(THREAD_ALL_ACCESS, FALSE, 32ThreadID);

if (!(::SuspendThread(oth)))

{

qDebug() << "freeze successed";

}

else

{

qDebug() << "freeze failed";

}

CloseHandle(oth);

break;

}

::Thread32Next(hThreadSnap, &th32);

}

::CloseHandle(hThreadSnap);