Added test for com.sun.jna.platform.win32.Advapi32.AccessCheck and updated changelog markup
Esse commit está contido em:
+1
-1
@@ -18,7 +18,7 @@ Features
|
||||
* [#250](https://github.com/twall/jna/pull/250): Added `com.sun.jna.platform.win32.Kernel32.GetPrivateProfileSection`, `GetPrivateProfileSectionNames` and `WritePrivateProfileSection` and corresponding `Kernel32Util` helpers - [@quipsy-karg](https://github.com/quipsy-karg).
|
||||
* [#287](https://github.com/twall/jna/pull/287): Added `DBTF_MEDIA` and `DBTF_NET` to `com.sun.jna.platform.win32.DBT` - [@daifei4321](https://github.com/daifei4321).
|
||||
* [#295](https://github.com/twall/jna/pull/295): Added `com.sun.jna.platform.win32.Kernel32.ResetEvent` - [@manithree](https://github.com/manithree).
|
||||
* [#301](https://github.com/twall/jna/pull/301): Added `com.sun.jna.platform.win32.Advapi32Util.accessCheck` and supporting classes/methods to verify file permissions - [@BusyByte] (https://github.com/BusyByte/jna).
|
||||
* [#301](https://github.com/twall/jna/pull/301): Added `accessCheck` to `com.sun.jna.platform.win32.Advapi32Util`, `MapGenericMask` and `AccessCheck` to `com.sun.jna.platform.win32.Advapi32`, `PRIVILEGE_SET` and `GENERIC_MAPPING` to `com.sun.jna.platform.win32.WinNT` - [@BusyByte](https://github.com/BusyByte).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
@@ -885,4 +885,25 @@ public class Advapi32Test extends TestCase {
|
||||
assertTrue(GENERIC_ALL != (rights.getValue().intValue() & GENERIC_ALL));
|
||||
}
|
||||
|
||||
public void testAccessCheck() {
|
||||
final WinNT.GENERIC_MAPPING mapping = new WinNT.GENERIC_MAPPING();
|
||||
mapping.genericRead = new DWORD(FILE_GENERIC_READ);
|
||||
mapping.genericWrite = new DWORD(FILE_GENERIC_WRITE);
|
||||
mapping.genericExecute = new DWORD(FILE_GENERIC_EXECUTE);
|
||||
mapping.genericAll = new DWORD(FILE_ALL_ACCESS);
|
||||
final Memory securityDescriptorMemoryPointer = new Memory(1);
|
||||
|
||||
final PRIVILEGE_SET privileges = new PRIVILEGE_SET(1);
|
||||
privileges.PrivilegeCount = new DWORD(0);
|
||||
final DWORDByReference privilegeLength = new DWORDByReference(new DWORD(privileges.size()));
|
||||
final DWORDByReference grantedAccess = new DWORDByReference();
|
||||
final BOOLByReference result = new BOOLByReference();
|
||||
|
||||
final boolean status = Advapi32.INSTANCE.AccessCheck(securityDescriptorMemoryPointer, null, new DWORD(FILE_GENERIC_READ), mapping, privileges, privilegeLength, grantedAccess, result);
|
||||
assertFalse(status);
|
||||
assertFalse(result.getValue().booleanValue());
|
||||
|
||||
assertEquals("The handle is invalid.", Kernel32Util.formatMessage(W32Errors.HRESULT_FROM_WIN32(Kernel32.INSTANCE.GetLastError())));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário