Megatron, thats the declare he already is using
rspangl's declare:
Quote:
Code:
Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (lpdest As Any, lpsrc As Any, ByVal length As Long)
Megatron's declare (and the one I use too):
Quote:
Code:
Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (dest As Any, src As Any, ByVal length As Long)
The actual problem is in the call to CopyMem. Now I have not run this code, just read through it and I am not familiar with the API's in use. But it seems to me that:
Code:
CopyMem p_atypExplicitAccess(0), ByVal p_lngListExplicitEntries, Len(p_atypExplicitAccess(0)) * p_lngCountExplicitEntries
is intended to copy array elements from a block of memory pointed at by the value contained in p_lngListExplicitEntries into the VB array starting at the memory address of p_atypExplicitAccess(0).
This looks reasonable to me. I assume that the values of p_lngCountExplicitEntries and p_lngListExplicitEntries are being set by GetExplicitEntriesFromAcl correctly? I am not familiar with your calling convention to GetExplicitEntriesFromAcl so I assume it is the same as:
Code:
p_lngRtn = GetExplicitEntriesFromAcl(
p_lngPtrDACL, p_lngCountExplicitEntries, p_lngListExplicitEntries)
So I am left to conclude that the error is more to do with what GetExplicitEntriesFromAcl is returning. I will check the MFC for GetExplicitEntriesFromAcl and see what my interpretation of the declare should be.
Cheers
GetExplicitEntriesFromAcl
Quote:
Code:
GetExplicitEntriesFromAcl
The GetExplicitEntriesFromAcl function retrieves an array of EXPLICIT_ACCESS structures that describe the access-control entries (ACEs) in an access-control list (ACL).
DWORD GetExplicitEntriesFromAcl(
PACL pacl, // pointer to the ACL from which to get entries
PULONG pcCountOfExplicitEntries,
// receives number of entries in the list
PEXPLICIT_ACCESS *pListOfExplicitEntries
// receives pointer to list of entries
);
Parameters
pacl
Pointer to an ACL from which to get ACE information.
pcCountOfExplicitEntries
Pointer to a variable that receives the number of EXPLICIT_ACCESS structures returned in the pListOfExplicitEntries array.
pListOfExplicitEntries
Pointer to a variable that receives a pointer to an array of EXPLICIT_ACCESS structures that describe the ACEs in the ACL. If the function succeeds, you must call the LocalFree function to free the returned buffer.
Return Values
If the function succeeds, the return value is ERROR_SUCCESS.
If the function fails, the return value is a nonzero error code defined in WINERROR.H.
Remarks
Each entry in the array of EXPLICIT_ACCESS structures describes access control information from an ACE for a trustee. A trustee can be a user, group, or program (such as a Win32 service).
Each EXPLICIT_ACCESS structure specifies a set of access rights and an access mode flag that indicates whether the ACE allows, denies, or audits the specified rights.
For a discretionary ACL (DACL), the access mode flag can be one of the following values from the ACCESS_MODE enumeration.
I would write the Declare:
Code:
Public Declare Function GetExplicitEntriesFromAcl Lib "advapi32.dll" Alias "GetExplicitEntriesFromAclA" _
(ByRef pACL As Long, ByRef pcCountOfExplicitEntries As Long, _
ByRef pListOfExplicitEntries As Long)
Based on the difference in the above declare to your existing declare, the follow-on problems would cause your error if for example pcCountOfExplicitEntries was negative.
All this guesswork and obviously you'll need to check out the MFC for yourself to make sure you trust my judgement. If I am worng (highly likely - I'm no guru...) then let me know where I went wrong so I too can learn from my mistakes :)
Cheers
Hmm, I already explained my reasoning...
Changing the CopyMem emulated the fix I recommended.
Your decalre for GetExplicitEntriesFromAcl is wrong I
believe so it's up to you if you want to take another look
again or not.
I already researched this to give my first reply so I'm
sticking to it :)
LIke you said though, if it works, then it's hard to
argue. Personally, I don't like things working unless they
are working the way they are meant to :)
Cheers