@@ -1122,6 +1122,7 @@ type OBJECTS_AND_NAME struct {
1122
1122
//sys SetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) = advapi32.SetSecurityInfo
1123
1123
//sys getNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) = advapi32.GetNamedSecurityInfoW
1124
1124
//sys SetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) = advapi32.SetNamedSecurityInfoW
1125
+ //sys getExplicitEntriesFromAclW(acl *ACL, countAccessEntries *uint32, accessEntries **EXPLICIT_ACCESS) (ret error) = advapi32.GetExplicitEntriesFromAclW
1125
1126
1126
1127
//sys buildSecurityDescriptor(owner *TRUSTEE, group *TRUSTEE, countAccessEntries uint32, accessEntries *EXPLICIT_ACCESS, countAuditEntries uint32, auditEntries *EXPLICIT_ACCESS, oldSecurityDescriptor *SECURITY_DESCRIPTOR, sizeNewSecurityDescriptor *uint32, newSecurityDescriptor **SECURITY_DESCRIPTOR) (ret error) = advapi32.BuildSecurityDescriptorW
1127
1128
//sys initializeSecurityDescriptor(absoluteSD *SECURITY_DESCRIPTOR, revision uint32) (err error) = advapi32.InitializeSecurityDescriptor
@@ -1374,6 +1375,29 @@ func GetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, security
1374
1375
return winHeapSD .copySelfRelativeSecurityDescriptor (), nil
1375
1376
}
1376
1377
1378
+ // GetExplicitEntriesFromAcl queries the explicit entries from a given ACL
1379
+ func GetExplicitEntriesFromAcl (acl * ACL ) ([]EXPLICIT_ACCESS , error ) {
1380
+ var entries * EXPLICIT_ACCESS
1381
+ var size uint32
1382
+ err := getExplicitEntriesFromAclW (
1383
+ acl ,
1384
+ & size ,
1385
+ & entries ,
1386
+ )
1387
+ if err != nil {
1388
+ return nil , err
1389
+ }
1390
+
1391
+ defer LocalFree (Handle (unsafe .Pointer (entries )))
1392
+ var accesses []EXPLICIT_ACCESS
1393
+ for i := 0 ; i < int (size ); i ++ {
1394
+ accesses = append (accesses , * entries )
1395
+ entries = (* EXPLICIT_ACCESS )(unsafe .Pointer ((uintptr (unsafe .Pointer (entries )) + unsafe .Sizeof (* entries ))))
1396
+ }
1397
+
1398
+ return accesses , nil
1399
+ }
1400
+
1377
1401
// BuildSecurityDescriptor makes a new security descriptor using the input trustees, explicit access lists, and
1378
1402
// prior security descriptor to be merged, any of which can be nil, returning the self-relative security descriptor
1379
1403
// result on the Go heap.
0 commit comments