mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 15:52:57 +00:00
[ADVAPI32_APITEST]
- Add a test for calling RegQueryInfoKey with different access rights CORE-9719 svn path=/trunk/; revision=67848
This commit is contained in:
parent
ac3616d42c
commit
9600755aaa
3 changed files with 80 additions and 1 deletions
|
@ -6,6 +6,7 @@ list(APPEND SOURCE
|
||||||
LockDatabase.c
|
LockDatabase.c
|
||||||
QueryServiceConfig2.c
|
QueryServiceConfig2.c
|
||||||
RegEnumValueW.c
|
RegEnumValueW.c
|
||||||
|
RegQueryInfoKey.c
|
||||||
RtlEncryptMemory.c
|
RtlEncryptMemory.c
|
||||||
SaferIdentifyLevel.c
|
SaferIdentifyLevel.c
|
||||||
testlist.c)
|
testlist.c)
|
||||||
|
|
76
rostests/apitests/advapi32/RegQueryInfoKey.c
Normal file
76
rostests/apitests/advapi32/RegQueryInfoKey.c
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS api tests
|
||||||
|
* LICENSE: LGPLv2.1+ - See COPYING.Lib in the top level directory
|
||||||
|
* PURPOSE: Test for RegQueryInfoKey
|
||||||
|
* PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <apitest.h>
|
||||||
|
|
||||||
|
#define WIN32_NO_STATUS
|
||||||
|
#include <winreg.h>
|
||||||
|
|
||||||
|
#define TestKeyAccess(da, er, es) TestKeyAccess_(__FILE__, __LINE__, da, er, es)
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
TestKeyAccess_(
|
||||||
|
_In_ PCSTR File,
|
||||||
|
_In_ INT Line,
|
||||||
|
_In_ REGSAM DesiredAccess,
|
||||||
|
_In_ LONG ExpectedReturn,
|
||||||
|
_In_ BOOLEAN ExpectSd)
|
||||||
|
{
|
||||||
|
DWORD cbSd;
|
||||||
|
HKEY hKey;
|
||||||
|
LONG ret;
|
||||||
|
|
||||||
|
ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software", 0, DesiredAccess, &hKey);
|
||||||
|
ok_(File, Line)(ret == NO_ERROR, "RegOpenKeyEx returned %ld\n", ret);
|
||||||
|
if (ret == NO_ERROR)
|
||||||
|
{
|
||||||
|
cbSd = 0x55555555;
|
||||||
|
ret = RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &cbSd, NULL);
|
||||||
|
ok_(File, Line)(ret == ExpectedReturn, "RegQueryInfoKeyW returned %ld\n", ret);
|
||||||
|
if (ExpectSd)
|
||||||
|
ok_(File, Line)(cbSd != 0 && cbSd != 0x55555555, "RegQueryInfoKeyW - cbSd = %lu\n", cbSd);
|
||||||
|
else
|
||||||
|
ok_(File, Line)(cbSd == 0, "RegQueryInfoKeyW - cbSd = %lu\n", cbSd);
|
||||||
|
|
||||||
|
cbSd = 0x55555555;
|
||||||
|
ret = RegQueryInfoKeyA(hKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &cbSd, NULL);
|
||||||
|
ok_(File, Line)(ret == ExpectedReturn, "RegQueryInfoKeyA returned %ld\n", ret);
|
||||||
|
if (ExpectSd)
|
||||||
|
ok_(File, Line)(cbSd != 0 && cbSd != 0x55555555, "RegQueryInfoKeyA - cbSd = %lu\n", cbSd);
|
||||||
|
else
|
||||||
|
ok_(File, Line)(cbSd == 0, "RegQueryInfoKeyA - cbSd = %lu\n", cbSd);
|
||||||
|
ret = RegCloseKey(hKey);
|
||||||
|
ok_(File, Line)(ret == NO_ERROR, "RegCloseKey returned %ld\n", ret);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skip_(File, Line)("No key handle\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(RegQueryInfoKey)
|
||||||
|
{
|
||||||
|
/* 0 access just fails the open */
|
||||||
|
if (0)
|
||||||
|
TestKeyAccess(0, ERROR_ACCESS_DENIED, FALSE);
|
||||||
|
/* Without KEY_QUERY_VALUE we can't query anything */
|
||||||
|
TestKeyAccess(READ_CONTROL, ERROR_ACCESS_DENIED, FALSE);
|
||||||
|
/* Without READ_CONTROL we'll get success but SD size will yield 0 */
|
||||||
|
TestKeyAccess(KEY_QUERY_VALUE, NO_ERROR, FALSE);
|
||||||
|
/* With the two combined we get everything */
|
||||||
|
TestKeyAccess(KEY_QUERY_VALUE | READ_CONTROL, NO_ERROR, TRUE);
|
||||||
|
/* Write rights give us everything too */
|
||||||
|
TestKeyAccess(KEY_SET_VALUE, NO_ERROR, TRUE);
|
||||||
|
TestKeyAccess(KEY_CREATE_SUB_KEY, NO_ERROR, TRUE);
|
||||||
|
TestKeyAccess(KEY_CREATE_LINK, NO_ERROR, TRUE);
|
||||||
|
TestKeyAccess(DELETE, NO_ERROR, TRUE);
|
||||||
|
TestKeyAccess(WRITE_DAC, NO_ERROR, TRUE);
|
||||||
|
TestKeyAccess(WRITE_OWNER, NO_ERROR, TRUE);
|
||||||
|
/* But these return nothing */
|
||||||
|
TestKeyAccess(KEY_ENUMERATE_SUB_KEYS, ERROR_ACCESS_DENIED, FALSE);
|
||||||
|
TestKeyAccess(KEY_NOTIFY, ERROR_ACCESS_DENIED, FALSE);
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ extern void func_HKEY_CLASSES_ROOT(void);
|
||||||
extern void func_LockDatabase(void);
|
extern void func_LockDatabase(void);
|
||||||
extern void func_QueryServiceConfig2(void);
|
extern void func_QueryServiceConfig2(void);
|
||||||
extern void func_RegEnumValueW(void);
|
extern void func_RegEnumValueW(void);
|
||||||
|
extern void func_RegQueryInfoKey(void);
|
||||||
extern void func_RtlEncryptMemory(void);
|
extern void func_RtlEncryptMemory(void);
|
||||||
extern void func_SaferIdentifyLevel(void);
|
extern void func_SaferIdentifyLevel(void);
|
||||||
|
|
||||||
|
@ -19,7 +20,8 @@ const struct test winetest_testlist[] =
|
||||||
{ "HKEY_CLASSES_ROOT", func_HKEY_CLASSES_ROOT },
|
{ "HKEY_CLASSES_ROOT", func_HKEY_CLASSES_ROOT },
|
||||||
{ "LockDatabase" , func_LockDatabase },
|
{ "LockDatabase" , func_LockDatabase },
|
||||||
{ "QueryServiceConfig2", func_QueryServiceConfig2 },
|
{ "QueryServiceConfig2", func_QueryServiceConfig2 },
|
||||||
{ "RegEnumValueW", func_RegEnumValueW},
|
{ "RegEnumValueW", func_RegEnumValueW },
|
||||||
|
{ "RegQueryInfoKey", func_RegQueryInfoKey },
|
||||||
{ "RtlEncryptMemory", func_RtlEncryptMemory },
|
{ "RtlEncryptMemory", func_RtlEncryptMemory },
|
||||||
{ "SaferIdentifyLevel", func_SaferIdentifyLevel },
|
{ "SaferIdentifyLevel", func_SaferIdentifyLevel },
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue