(Gast)
n/a Beiträge
|
Re: [C] dumpACL
27. Jun 2006, 10:18
Code:
#define WINVER 0x0500
#define _WIN32_WINNT 0x0500
//#define NONAMELESSUNION
//#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <aclapi.h>
#include <sddl.h>
#include <stdio.h>
#include <tchar.h>
void PrintSid( PSID a_pSid )
{
LPTSTR pszStringSid;
if( ConvertSidToStringSid( a_pSid, &pszStringSid ) )
{
_tprintf( TEXT("%s"), pszStringSid );
LocalFree( (HLOCAL)pszStringSid );
}
}
void DumpACL( PACL a_pAcl )
{
ACL_SIZE_INFORMATION Info;
if( GetAclInformation( a_pAcl, &Info, sizeof(ACL_SIZE_INFORMATION), AclSizeInformation ) )
{
DWORD i;
for( i = 0; i < Info.AceCount; i++ )
{
LPVOID pAce;
if( GetAce( a_pAcl, i, &pAce ) )
{
LPCTSTR pszType;
PACE_HEADER pHead = (PACE_HEADER)pAce;
switch( pHead->AceType )
{
case ACCESS_ALLOWED_ACE_TYPE:
pszType = TEXT("allow");
break;
case ACCESS_DENIED_ACE_TYPE:
pszType = TEXT("deny");
break;
case SYSTEM_AUDIT_ACE_TYPE:
pszType = TEXT("audit");
break;
case SYSTEM_ALARM_ACE_TYPE:
pszType = TEXT("alarm");
break;
default:
pszType = TEXT("<unknwon>");
break;
}
PACCESS_ALLOWED_ACE pAccess = (PACCESS_ALLOWED_ACE)pAce;
_tprintf( TEXT("%s %8.8x (flags: %2.2x) to "),
pszType,
pAccess->Mask,
pHead->AceFlags);
PrintSid( (PSID)(&pAccess->SidStart) );
_tprintf( TEXT("\n") );
}
}
}
}
int _tmain(int argc, _TCHAR* argv[])
{
if( 2 == argc )
{
PACL pAcl;
PSECURITY_DESCRIPTOR pSecurityDescriptor;
_tprintf( TEXT("%s\n"), argv[0] );
if( ERROR_SUCCESS == GetNamedSecurityInfo( argv[0],
SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL,
&pAcl, NULL, &pSecurityDescriptor ) )
{
DumpACL( pAcl );
LocalFree( (HLOCAL)pSecurityDescriptor );
}
}
return 0;
}
Zitat von Luckie:
Aber pace.SidStart ist ein Cardinal, wie komme ich denn jetzt an den Namen dran?
SidStart ist das erste DWORD der SID. Demzufolge: (PSID)&pace->SidStart
|
|
Zitat
|