1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
handle = OpenProcess(PROCESS_ALL_ACCESS, false, process_id);
if(!handle)
{
string error = (string)itoa(GetLastError(), c, 10);
MainWindow::instance()->write("Could not get handle !", "console");
CloseHandle(handle);
if(error == "5")
{
MainWindow::instance()->write("ERROR_ACCESS_DENIED", "console");
handle = OpenProcess(WRITE_DAC | READ_CONTROL | WRITE_OWNER | PROCESS_QUERY_INFORMATION, false, process_id);
if(!handle && !OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &handle_token))
{
MainWindow::instance()->write("ERROR_ACCESS_DENIED", "console");
return false;
}
MainWindow::instance()->write("START :\n", "console");
DWORD sizep = sizeof(TOKEN_PRIVILEGES);
TOKEN_PRIVILEGES tkp;
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if(!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tkp.Privileges[0].Luid))
{
MainWindow::instance()->write("ERROR in LookupPrivilegeValue", "console");
return FALSE;
}
if (!AdjustTokenPrivileges(handle_token, false, &tkp, sizep, NULL, NULL))//handle_token, FALSE, &tkp, sizeof(tkp), NULL, 0
{
MainWindow::instance()->write((string)"error : " + itoa(GetLastError(), c, 10), "console");
MainWindow::instance()->write("Error in AdjustTokenPrivileges", "console");
return FALSE;
}
else
MainWindow::instance()->write("It works !!!", "console");
}
} |
Partager