Search in sources :

Example 1 with TRUSTEE

use of jnc.platform.win32.TRUSTEE in project judge by zjnu-acm.

the class RestrictedToken method addSidToDacl.

private static void addSidToDacl(long pSid, long oldDacl, ACCESS_MODE accessMode, int access, AddressByReference newDacl) {
    EXPLICIT_ACCESS newAccess = new EXPLICIT_ACCESS();
    newAccess.setAccessMode(accessMode);
    newAccess.setAccessPermissions(access);
    newAccess.setInheritance(NO_INHERITANCE);
    TRUSTEE trustee = newAccess.getTrustee();
    trustee.setMultipleTrustee(0);
    trustee.setMultipleTrusteeOperation(NO_MULTIPLE_TRUSTEE);
    trustee.setTrusteeForm(TRUSTEE_IS_SID);
    trustee.setName(pSid);
    int error = Advapi32.INSTANCE.SetEntriesInAclW(1, newAccess, oldDacl, newDacl);
    if (error != ERROR_SUCCESS) {
        throw new Win32Exception(error);
    }
}
Also used : NO_MULTIPLE_TRUSTEE(com.github.zhanhb.jnc.platform.win32.MULTIPLE_TRUSTEE_OPERATION.NO_MULTIPLE_TRUSTEE) TRUSTEE(com.github.zhanhb.jnc.platform.win32.TRUSTEE) EXPLICIT_ACCESS(com.github.zhanhb.jnc.platform.win32.EXPLICIT_ACCESS) Win32Exception(com.github.zhanhb.jnc.platform.win32.Win32Exception)

Example 2 with TRUSTEE

use of jnc.platform.win32.TRUSTEE in project judge by zjnu-acm.

the class RestrictedToken method addSidToDacl.

private static void addSidToDacl(Pointer pSid, Pointer oldDacl, ACCESS_MODE accessMode, int access, PointerByReference newDacl) {
    EXPLICIT_ACCESS newAccess = new EXPLICIT_ACCESS();
    newAccess.setAccessMode(accessMode);
    newAccess.setAccessPermissions(access);
    newAccess.setInheritance(NO_INHERITANCE);
    TRUSTEE trustee = newAccess.getTrustee();
    trustee.setMultipleTrustee(0);
    trustee.setMultipleTrusteeOperation(NO_MULTIPLE_TRUSTEE);
    trustee.setTrusteeForm(TRUSTEE_IS_SID);
    trustee.setTrusteeType(TRUSTEE_IS_UNKNOWN);
    trustee.setName(pSid);
    if (log.isDebugEnabled()) {
        log.debug("addSidToDacl: {} {}", accessMode, SID.toString(pSid));
    }
    int error = Advapi32.INSTANCE.SetEntriesInAclW(1, newAccess, oldDacl, newDacl);
    if (error != ERROR_SUCCESS) {
        throw new Win32Exception(error);
    }
}
Also used : NO_MULTIPLE_TRUSTEE(jnc.platform.win32.MULTIPLE_TRUSTEE_OPERATION.NO_MULTIPLE_TRUSTEE) TRUSTEE(jnc.platform.win32.TRUSTEE) EXPLICIT_ACCESS(jnc.platform.win32.EXPLICIT_ACCESS) Win32Exception(jnc.platform.win32.Win32Exception)

Aggregations

EXPLICIT_ACCESS (com.github.zhanhb.jnc.platform.win32.EXPLICIT_ACCESS)1 NO_MULTIPLE_TRUSTEE (com.github.zhanhb.jnc.platform.win32.MULTIPLE_TRUSTEE_OPERATION.NO_MULTIPLE_TRUSTEE)1 TRUSTEE (com.github.zhanhb.jnc.platform.win32.TRUSTEE)1 Win32Exception (com.github.zhanhb.jnc.platform.win32.Win32Exception)1 EXPLICIT_ACCESS (jnc.platform.win32.EXPLICIT_ACCESS)1 NO_MULTIPLE_TRUSTEE (jnc.platform.win32.MULTIPLE_TRUSTEE_OPERATION.NO_MULTIPLE_TRUSTEE)1 TRUSTEE (jnc.platform.win32.TRUSTEE)1 Win32Exception (jnc.platform.win32.Win32Exception)1