Skip to content

Instantly share code, notes, and snippets.

@puppis42
Created May 28, 2023 13:39
Show Gist options
  • Save puppis42/eedb32b5b56048ba6e9b5de241267786 to your computer and use it in GitHub Desktop.
Save puppis42/eedb32b5b56048ba6e9b5de241267786 to your computer and use it in GitHub Desktop.
#include <Windows.h>
#include "aclapi.h"
#include <chrono>
#include <thread>
DWORD ProtectProcess(void)
{
HANDLE hProcess = GetCurrentProcess();
PACL pEmptyDacl;
DWORD dwErr;
pEmptyDacl = (PACL)malloc(sizeof(ACL));
if (!InitializeAcl(pEmptyDacl, sizeof(ACL), ACL_REVISION))
{
dwErr = GetLastError();
}
else
{
dwErr = SetSecurityInfo(hProcess, SE_KERNEL_OBJECT,
DACL_SECURITY_INFORMATION, NULL, NULL, pEmptyDacl, NULL);
}
free(pEmptyDacl);
return dwErr;
}
int main()
{
ShowWindow(GetConsoleWindow(), SW_HIDE);
ProtectProcess();
while (true) {
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment