[Deny Process] SetKernelObjectSecurity [Deny Access]

closed account (ozUkoG1T)
Hi,

I am going to be releasing many sources and tutorials for some time to help others. Anyway today we are going to deny access to our program using DACLS. This type of software can be very helpful for software to deny access to Standard Users such as Childrens Softwares.

Code:

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
#include <Windows.h>
#include <Aclapi.h>

BOOL DenyAccess()
{

	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;

}

Usage:

1
2
3
4
5
Bool DenyAccess(); //Function Prototype
int main()
{
DenyAccess();
}

Thanks,
Last edited on
Topic archived. No new replies allowed.