一個非常酷的功能:PYTHON |停止用戶查殺過程這裏提到
Prevent user process from being killed with "End Process" from Process Explorer
有誰知道如何翻譯這個C++代碼到Python(或重新編輯,使其至少在C/C編譯++假設這是它是):
static const bool ProtectProcess()
{
HANDLE hProcess = GetCurrentProcess();
EXPLICIT_ACCESS denyAccess = {0};
DWORD dwAccessPermissions = GENERIC_WRITE|PROCESS_ALL_ACCESS|WRITE_DAC|DELETE|WRITE_OWNER|READ_CONTROL;
BuildExplicitAccessWithName(&denyAccess, _T("CURRENT_USER"), dwAccessPermissions, DENY_ACCESS, NO_INHERITANCE);
PACL pTempDacl = NULL;
DWORD dwErr = 0;
dwErr = SetEntriesInAcl(1, &denyAccess, NULL, &pTempDacl);
// check dwErr...
dwErr = SetSecurityInfo(hProcess, SE_KERNEL_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, pTempDacl, NULL);
// check dwErr...
LocalFree(pTempDacl);
CloseHandle(hProcess);
return dwErr == ERROR_SUCCESS;
}
爲什麼要讓用戶難以終止進程? –
@DavidHeffernan - 天網:) – Rook
你是什麼意思編輯它,使它編譯爲C++。它不會編譯?看起來像通過ctypes Pythin的一個非常容易的端口。 –