[C++] Protect Process 05-31-2015, 09:00 PM
#1
First you need to include (Visual Studio IDE):Â
#include "stdafx.h"
#include <Windows.h>
#include <Aclapi.h>
#include <Sddl.h>
Here is the code:
Just simply call: ProtectProcess() in your main.
NOTE: Admin accounts will be able to bypass this.
#include "stdafx.h"
#include <Windows.h>
#include <Aclapi.h>
#include <Sddl.h>
Here is the code:
Code:
BOOL ProtectProcess()
{
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
SECURITY_ATTRIBUTES sa;
TCHAR * szSD = TEXT("D:P") Â ;
 TEXT("(D;OICI;GA;;;BG)");   // Deny access toÂ
                   // built-in guests
    TEXT("(D;OICI;GA;;;AN)") ;  // Deny access toÂ
                   // anonymous logon
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = FALSE;
if (!ConvertStringSecurityDescriptorToSecurityDescriptor(szSD, SDDL_REVISION_1, &(sa.lpSecurityDescriptor), NULL))
return FALSE;
if (!SetKernelObjectSecurity(hProcess, DACL_SECURITY_INFORMATION, sa.lpSecurityDescriptor))
return FALSE;
return TRUE;
}NOTE: Admin accounts will be able to bypass this.
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)