I've tried to protect a process in c++ windows, the code is:
#include <iostream>
#include <Aclapi.h>
#include <iostream>
#include <windows.h>
#include <sddl.h>
#include <stdio.h>
using namespace std;
BOOL DenyAccess()
{
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = FALSE;
SetKernelObjectSecurity(hProcess, DACL_SECURITY_INFORMATION, sa.lpSecurityDescriptor);
return TRUE;
}
int main()
{
while(DenyAccess());
return 0;
}
But I can kill process from task manager! what's wrong ?