Search in sources :

Example 6 with SECURITY_DESCRIPTOR

use of com.sun.jna.platform.win32.WinNT.SECURITY_DESCRIPTOR in project jna by java-native-access.

the class Advapi32Test method testSetGetSecurityDescriptorControl.

public void testSetGetSecurityDescriptorControl() {
    SECURITY_DESCRIPTOR sd = new SECURITY_DESCRIPTOR(64 * 1024);
    assertTrue(Advapi32.INSTANCE.InitializeSecurityDescriptor(sd, WinNT.SECURITY_DESCRIPTOR_REVISION));
    assertTrue(Advapi32.INSTANCE.SetSecurityDescriptorControl(sd, (short) WinNT.SE_DACL_PROTECTED, (short) WinNT.SE_DACL_PROTECTED));
    ShortByReference pControl = new ShortByReference();
    IntByReference lpdwRevision = new IntByReference();
    assertTrue(Advapi32.INSTANCE.GetSecurityDescriptorControl(sd, pControl, lpdwRevision));
    assertTrue(pControl.getValue() == WinNT.SE_DACL_PROTECTED);
    assertTrue(lpdwRevision.getValue() == WinNT.SECURITY_DESCRIPTOR_REVISION);
}
Also used : IntByReference(com.sun.jna.ptr.IntByReference) ShortByReference(com.sun.jna.ptr.ShortByReference) SECURITY_DESCRIPTOR(com.sun.jna.platform.win32.WinNT.SECURITY_DESCRIPTOR)

Example 7 with SECURITY_DESCRIPTOR

use of com.sun.jna.platform.win32.WinNT.SECURITY_DESCRIPTOR in project jna by java-native-access.

the class Advapi32Test method testMakeSelfRelativeSD.

public void testMakeSelfRelativeSD() {
    SECURITY_DESCRIPTOR absolute = new SECURITY_DESCRIPTOR(64 * 1024);
    assertTrue(Advapi32.INSTANCE.InitializeSecurityDescriptor(absolute, WinNT.SECURITY_DESCRIPTOR_REVISION));
    SECURITY_DESCRIPTOR_RELATIVE relative = new SECURITY_DESCRIPTOR_RELATIVE(64 * 1024);
    IntByReference lpdwBufferLength = new IntByReference(64 * 1024);
    assertTrue(Advapi32.INSTANCE.MakeSelfRelativeSD(absolute, relative, lpdwBufferLength));
    assertEquals(WinNT.SECURITY_DESCRIPTOR_REVISION, relative.Revision);
}
Also used : IntByReference(com.sun.jna.ptr.IntByReference) SECURITY_DESCRIPTOR_RELATIVE(com.sun.jna.platform.win32.WinNT.SECURITY_DESCRIPTOR_RELATIVE) SECURITY_DESCRIPTOR(com.sun.jna.platform.win32.WinNT.SECURITY_DESCRIPTOR)

Aggregations

SECURITY_DESCRIPTOR (com.sun.jna.platform.win32.WinNT.SECURITY_DESCRIPTOR)7 IntByReference (com.sun.jna.ptr.IntByReference)6 PSID (com.sun.jna.platform.win32.WinNT.PSID)4 BOOLByReference (com.sun.jna.platform.win32.WinDef.BOOLByReference)3 ACL (com.sun.jna.platform.win32.WinNT.ACL)2 PSIDByReference (com.sun.jna.platform.win32.WinNT.PSIDByReference)2 SECURITY_DESCRIPTOR_RELATIVE (com.sun.jna.platform.win32.WinNT.SECURITY_DESCRIPTOR_RELATIVE)2 BOOL (com.sun.jna.platform.win32.WinDef.BOOL)1 ACCESS_ALLOWED_ACE (com.sun.jna.platform.win32.WinNT.ACCESS_ALLOWED_ACE)1 PACLByReference (com.sun.jna.platform.win32.WinNT.PACLByReference)1 PointerByReference (com.sun.jna.ptr.PointerByReference)1 ShortByReference (com.sun.jna.ptr.ShortByReference)1 File (java.io.File)1