Module: wine Branch: oldstable Commit: 925b15e28858fe808cd1392ca64cabaf96be4638 URL: https://gitlab.winehq.org/wine/wine/-/commit/925b15e28858fe808cd1392ca64caba...
Author: Alistair Leslie-Hughes leslie_alistair@hotmail.com Date: Mon Jul 11 14:19:41 2022 +1000
ntdll/tests: Add RtlFirstFreeAce tests.
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com (cherry picked from commit d70273363be2e2abc5d5af17341a7e6a31156abb) Conflicts: dlls/ntdll/tests/rtl.c Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/ntdll/tests/rtl.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c index c0168884a0a..5fcf958d3b9 100644 --- a/dlls/ntdll/tests/rtl.c +++ b/dlls/ntdll/tests/rtl.c @@ -3682,6 +3682,54 @@ static void test_RtlDestroyHeap(void) RtlRemoveVectoredExceptionHandler( handler ); }
+static void test_RtlFirstFreeAce(void) +{ + PACL acl; + PACE_HEADER first; + BOOL ret; + DWORD size; + BOOLEAN found; + + size = sizeof(ACL) + (sizeof(ACCESS_ALLOWED_ACE)); + acl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + ret = InitializeAcl(acl, sizeof(ACL), ACL_REVISION); + ok(ret, "InitializeAcl failed with error %d\n", GetLastError()); + + /* AceCount = 0 */ + first = (ACE_HEADER *)0xdeadbeef; + found = RtlFirstFreeAce(acl, &first); + ok(found, "RtlFirstFreeAce failed\n"); + ok(first == (PACE_HEADER)(acl + 1), "Failed to find ACL\n"); + + acl->AclSize = sizeof(ACL) - 1; + first = (ACE_HEADER *)0xdeadbeef; + found = RtlFirstFreeAce(acl, &first); + ok(found, "RtlFirstFreeAce failed\n"); + ok(first == NULL, "Found FirstAce = %p\n", first); + + /* AceCount = 1 */ + acl->AceCount = 1; + acl->AclSize = size; + first = (ACE_HEADER *)0xdeadbeef; + found = RtlFirstFreeAce(acl, &first); + ok(found, "RtlFirstFreeAce failed\n"); + ok(first == (PACE_HEADER)(acl + 1), "Failed to find ACL %p, %p\n", first, (PACE_HEADER)(acl + 1)); + + acl->AclSize = sizeof(ACL) - 1; + first = (ACE_HEADER *)0xdeadbeef; + found = RtlFirstFreeAce(acl, &first); + ok(!found, "RtlFirstFreeAce failed\n"); + ok(first == NULL, "Found FirstAce = %p\n", first); + + acl->AclSize = sizeof(ACL); + first = (ACE_HEADER *)0xdeadbeef; + found = RtlFirstFreeAce(acl, &first); + ok(!found, "RtlFirstFreeAce failed\n"); + ok(first == NULL, "Found FirstAce = %p\n", first); + + HeapFree(GetProcessHeap(), 0, acl); +} + START_TEST(rtl) { InitFunctionPtrs(); @@ -3725,4 +3773,5 @@ START_TEST(rtl) test_LdrRegisterDllNotification(); test_DbgPrint(); test_RtlDestroyHeap(); + test_RtlFirstFreeAce(); }