
Ich versuche verzweifelt den Code von folgender Seite nach PB zu übersetzen:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Das hier habe ich:
Code: Alles auswählen
#DACL_SECURITY_INFORMATION = $00000004
#SET_ACCESS = $00000002
#NO_INHERITANCE = $8000000B
#HEAP_ZERO_MEMORY = $00000008
Structure _TRUSTEE
*pMultipleTrustee;
MultipleTrusteeOperation.l
TrusteeForm.l
TrusteeType.l
*ptstrName
EndStructure
Structure EXPLICIT_ACCESS
grfAccessPermissions.l
grfAccessMode.l
grfInheritance.l
Trustee._TRUSTEE
EndStructure
Procedure Modify_DAC(ServiceName.s, AccessGroup.s = "GUEST")
Protected sStatus.SERVICE_STATUS
Protected Result, schSCManager, schService
Protected *psd.SECURITY_DESCRIPTOR, dwBytesNeeded, dwSize, bDaclPresent, *pacl.ACL, bDaclDefaulted
Protected ea.EXPLICIT_ACCESS, dwError, *pNewAcl.ACL, sd.SECURITY_DESCRIPTOR
schSCManager = OpenSCManager_(0, 0, #SC_MANAGER_ALL_ACCESS)
If schSCManager
schService = OpenService_(schSCManager, @ServiceName, #READ_CONTROL | #WRITE_DAC)
If schService
;Get the current security descriptor.
If QueryServiceObjectSecurity_(schService, #DACL_SECURITY_INFORMATION, @*psd, 0, @dwBytesNeeded) = 0
If GetLastError_() = #ERROR_INSUFFICIENT_BUFFER
dwSize = dwBytesNeeded;
*psd = AllocateMemory(dwSize)
If *psd
Result = QueryServiceObjectSecurity_(schService, #DACL_SECURITY_INFORMATION, *psd, dwSize, @dwBytesNeeded)
EndIf
EndIf
EndIf
If Result
Result = 0
;Get the DACL.
If GetSecurityDescriptorDacl_(*psd, @bDaclPresent, @*pacl, @bDaclDefaulted)
;Build the ACE.
BuildExplicitAccessWithName_(@ea, @AccessGroup, #SERVICE_START | #SERVICE_STOP | #READ_CONTROL | #DELETE, #SET_ACCESS, #NO_INHERITANCE)
dwError = SetEntriesInAcl_(1, @ea, *pacl, @*pNewAcl)
If dwError <> #ERROR_SUCCESS
Debug dwError ;<- 87 = Falscher Parameter!
Else
;Initialize a new security descriptor.
If InitializeSecurityDescriptor_(@sd, #SECURITY_DESCRIPTOR_REVISION)
;Set the new DACL in the security descriptor.
If SetSecurityDescriptorDacl_(@sd, #True, *pNewAcl, #False)
;Set the new DACL For the service object.
Result = SetServiceObjectSecurity_(schService, #DACL_SECURITY_INFORMATION, @sd)
EndIf
EndIf
EndIf
EndIf
EndIf
If *psd
FreeMemory(*psd)
EndIf
If *NewAcl
LocalFree_(*NewAcl)
EndIf
CloseServiceHandle_(schService)
EndIf
CloseServiceHandle_(schSCManager)
EndIf
ProcedureReturn Result
EndProcedure
Code: Alles auswählen
dwError = SetEntriesInAcl_(1, @ea, *pacl, @*pNewAcl)
Hat von Euch irgendjemand eine Idee?