On 04/03/2013 09:31, Alexey Utkin wrote:
Alan,
Do you agree with
    /**
* Check the access right against the securityInfo in the current thread.
     */
    static boolean checkAccessMask(long securityInfo, int accessMask,
int genericRead, int genericWrite, int genericExecute, int genericAll)
        throws WindowsException
    {
        int privilegies = TOKEN_QUERY;
long hToken = OpenThreadToken(GetCurrentThread(), privilegies, false);
        if (hToken == 0L && processTokenWithDuplicateAccess != 0L)
            hToken = DuplicateTokenEx(processTokenWithDuplicateAccess,
                privilegies);

        boolean hasRight = false;
        if (hToken != 0L) {
            try {
                hasRight = AccessCheck(hToken, securityInfo, accessMask,
genericRead, genericWrite, genericExecute, genericAll);
            } finally {
                CloseHandle(hToken);
            }
        }
        return hasRight;
    }
implementation approach?
Can the handle to the token (hToken) be 0? In my comment I was suggesting:

long hToken = OpenThreadToken(...);
try {
    ...
} finally {
    CloseHandle(hToken);
}

but that doesn't work if OpenThreadToken succeeds with a handle of 0. If 0 is not possible then there are a few other clean-ups that we could do at a later time.

-Alan

Reply via email to