Skip to content

Written modern c++ wrapper for win32 acl methods on windows directories - can be expanded to support more objects on windows system.

License

Notifications You must be signed in to change notification settings

JakeAbo/WindowsAclWrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Windows Acl Wrapper

Written modern c++ wrapper for win32 acl methods on windows directories - can be expanded to support more objects on windows system.

The project is basically written for change Dacl/Owner of Directories - You can expand it and change also Sacl/PrimaryGroup for directories or other objects (files, namedpipes, process etc.)

This is just example project.


Author: Jack Abulafia

Dependencies

Aclapi.h (Win32) Windows OS.

Getting Started

Take a look at source.cpp Create an instance of ProtectedDirectory (you may expanded to support more windows os objects):

	ProtectedDirectory myDir{ L"C:\\ProgramData\\0003" };

Now you may modifiy your dacl/owner:

	if (myDir.ChangeDirectoryOwner(Owner(Trustee::BuiltinAdministrators)/*WinBuiltinAdministratorsSid*//*WinLocalSystemSid*/))
	{
		std::cout << "success to change to system owner" << std::endl;
	}
	const auto dacl = Dacl()
		.AddAceEntry(
			AceEntry(
				AceType::AccessDenied,
				AceFlag::ObjectInherit | AceFlag::ContainerInherit,
				Permissions::GenericAll,
				Trustee::BuiltinGuests))
		.AddAceEntry(
			AceEntry(
				AceType::AccessDenied,
				AceFlag::ObjectInherit | AceFlag::ContainerInherit,
				Permissions::GenericAll,
				Trustee::AnonymousLogon))
		.AddAceEntry(
			AceEntry(
				AceType::AccessAllowed,
				AceFlag::ObjectInherit | AceFlag::ContainerInherit,
				Permissions::GenericAll,
				Trustee::LocalSystem))
		.AddAceEntry(
			AceEntry(
				AceType::AccessAllowed,
				AceFlag::ObjectInherit | AceFlag::ContainerInherit,
				Permissions::GenericAll,
				Trustee::BuiltinAdministrators));

	if (myDir.ChangeDirectoryDacl(dacl))
	{
		std::cout << "success to change dacl" << std::endl;
	}

For more information: https://docs.microsoft.com/en-us/windows/win32/secauthz/security-descriptor-string-format https://docs.microsoft.com/en-us/windows/win32/api/aclapi/nf-aclapi-setsecurityinfo

About

Written modern c++ wrapper for win32 acl methods on windows directories - can be expanded to support more objects on windows system.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages