Delphi & Win32 Security API

Hi!

I have two questions about WIN32 Security API functions
in Windows NT 4.0.

1. LookupSecurityDescriptorParts is defined in aclapi.h with
   PTTRUSTEE_A and PEXPLICIT_ACCESS_A defined in accctrl.h this way:

DWORD WINAPI LookupSecurityDescriptorPartsA(OUT PTRUSTEE_A *pOwner,
  OUT PTRUSTEE_A *pGroup,OUT PULONG cCountOfAccessEntries,
  OUT PEXPLICIT_ACCESS_A *pListOfAccessEntries,
  OUT PULONG cCountOfAuditEntries,
  OUT PEXPLICIT_ACCESS_A * pListOfAuditEntries,
  IN  PSECURITY_DESCRIPTOR pSD);

typedef struct _TRUSTEE_A
{
    struct _TRUSTEE_A          *pMultipleTrustee;
    MULTIPLE_TRUSTEE_OPERATION  MultipleTrusteeOperation;
    TRUSTEE_FORM                TrusteeForm;
    TRUSTEE_TYPE                TrusteeType;
    LPSTR                       ptstrName;

Quote
} TRUSTEE_A, *PTRUSTEE_A, TRUSTEEA, *PTRUSTEEA;

typedef struct _EXPLICIT_ACCESS_A
{
    DWORD        grfAcces{*word*237}issions;
    ACCESS_MODE  grfAccessMode;
    DWORD        grfInheritance;
    TRUSTEE_A    Trustee;
Quote
} EXPLICIT_ACCESS_A, *PEXPLICIT_ACCESS_A, EXPLICIT_ACCESSA,

*PEXPLICIT_ACCESSA;

How do I translate this in Delphi4.0 ?

I tried like this:

interface
function LookupSecurityDescriptorParts(pOwner:PTrustee;pGroup:PTrustee;
  cCountOfAccessEntries:PULONG;pListOfAccessEntries:AExplicitAccess;
  cCountOfAuditEntries:PULONG;pListOfAuditEntries:AExplicitAccess;
  pSD:PSECURITY_DESCRIPTOR):DWORD;stdcall;

implementation
function LookupSecurityDescriptorParts; external "advapi32.dll" name
  'LookupSecurityDescriptorPartsA';

This is how I called this function from code:

var
  SecDscrptr:PSECURITY_DESCRIPTOR;
  OwnerTrustee,GroupTrustee:PTrustee;
  resLSDP:DWORD;
begin
{I got SecDscrptr from GetNamedSecurityInfo }
{...}

resLSDP:=LookupSecurityDescriptorParts(@OwnerTrustee,@GroupTrustee,
  nil,nil,Nil,Nil,SecDscrptr);

LocalFree(Cardinal(OwnerTrustee));// de{*word*81} error
{...}
end;

In win32.hlp writes that i have to LocalFree OwnerTrustee and
GroupTrustee. When I do this it returns in IDE and when I look in
EventLog I see this:
"ODS: Heap block at 13a908 modified at 13a930 past requested size of 20  
Process ID: $000000B2."
On address 13a908 is OwnerTrustee.
OwnerTrustee has Name:PChar and on address 13a930 is #0 character from
OwnerTrustee.Name.
I assumed that API function did not allocated enough memory for #0
character. Is this BUG in Windows NT4 ServicePack 5 or I am doing
something wrong.

2. If API function is returning array of records like previous
   function
  OUT PEXPLICIT_ACCESS_A *pListOfAccessEntries //in C
how should I write it in Delphi4.0 and how to call it from code?
Can I use dinamic arrays?

Thanks for any help.

p.s. Sorry for my bad english
--
+-------------------------------+
  Rodiger Dejan,                
  dejan.virusrodi...@ck.tel.hr  
  Remove virus from e-mail      
+-------------------------------+