#define _WIN32_WINNT 0x0500
#define
UNICODE
#include "G:\Programme\Microsoft
SDK\include\windows.h"
#include "G:\Programme\Microsoft
SDK\include\Sddl.h"
#include "G:\Programme\Microsoft
SDK\include\Aclapi.h"
#include <stdio.h>
void _printSid(void* psid) {
wchar_t* psz;
if (ConvertSidToStringSid(psid, &psz)) {
wprintf(psz);
LocalFree(psz);
}
}
void _dumpDacl(
ACL* pdacl) {
ACL_SIZE_INFORMATION sizeInfo;
DWORD i;
const wchar_t* pszGrantOrDeny;
GetAclInformation(pdacl, &sizeInfo, sizeof sizeInfo, AclSizeInformation);
for (i = 0; i < sizeInfo.AceCount; ++i) {
ACCESS_ALLOWED_ACE* pace;
GetAce(pdacl, i, (void**)&pace);
switch (pace->Header.AceType) {
case ACCESS_ALLOWED_ACE_TYPE:
pszGrantOrDeny = L"grant";
break;
case ACCESS_DENIED_ACE_TYPE:
pszGrantOrDeny = L"deny";
break;
default:
pszGrantOrDeny = L"<<unexpected ace type>>";
break;
}
wprintf(L"%s 0x%08 (inh: %X) to ", pszGrantOrDeny, pace->Mask, pace->Header.AceFlags);
_printSid(&pace->SidStart);
wprintf(L"\n");
}
}
#pragma argsused
int main(int argc, char* argv[])
{
PACL* dacl;
PSECURITY_DESCRIPTOR* ppSecurityDescriptor;
wprintf(L"%s", argv[0]);
GetNamedSecurityInfo(argv[0], SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, dacl, NULL, ppSecurityDescriptor);
_dumpDacl(dacl);
return 0;
}