https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a8755711b986ed1e02cfa…
commit a8755711b986ed1e02cfa2123f57d2e8b61a3d07
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Thu Oct 5 15:40:21 2023 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Oct 5 20:58:57 2023 +0200
[APPHELP_APITEST] Deduplicate the IsUserAdmin() helper.
---
.../rostests/apitests/apphelp/apphelp_apitest.h | 13 ++----------
modules/rostests/apitests/apphelp/db.cpp | 23 ----------------------
modules/rostests/apitests/apphelp/register.cpp | 4 +++-
3 files changed, 5 insertions(+), 35 deletions(-)
diff --git a/modules/rostests/apitests/apphelp/apphelp_apitest.h
b/modules/rostests/apitests/apphelp/apphelp_apitest.h
index 5623c21fd69..58cade256ab 100644
--- a/modules/rostests/apitests/apphelp/apphelp_apitest.h
+++ b/modules/rostests/apitests/apphelp/apphelp_apitest.h
@@ -5,7 +5,6 @@
extern "C" {
#endif
-
/* data.c */
void test_create_db_imp(const WCHAR* name, int win10);
DWORD test_get_db_size();
@@ -21,6 +20,8 @@ void silence_debug_output(void); // Silence output if the
environment var
#define test_create_file (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 :
test_create_file_imp
#define test_create_ne (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 :
test_create_ne_imp
+/* register.cpp */
+BOOL IsUserAdmin();
static DWORD g_WinVersion;
@@ -42,7 +43,6 @@ typedef VOID* HSDB;
typedef INT PATH_TYPE;
-
#define SDB_MAX_SDBS 16
#define SDB_MAX_EXES_VISTA 16
#define SDB_MAX_LAYERS 8
@@ -50,8 +50,6 @@ typedef INT PATH_TYPE;
#define SDBQUERYRESULT_EXPECTED_SIZE_VISTA 456
-
-
typedef struct tagSDBQUERYRESULT_VISTA
{
TAGREF atrExes[SDB_MAX_EXES_VISTA];
@@ -67,7 +65,6 @@ typedef struct tagSDBQUERYRESULT_VISTA
GUID rgGuidDB[SDB_MAX_SDBS];
} SDBQUERYRESULT_VISTA, *PSDBQUERYRESULT_VISTA;
-
#define SDBQUERYRESULT_EXPECTED_SIZE_2k3 344
#define SDB_MAX_EXES_2k3 4
@@ -86,16 +83,10 @@ typedef struct tagSDBQUERYRESULT_2k3
GUID rgGuidDB[SDB_MAX_SDBS];
} SDBQUERYRESULT_2k3, *PSDBQUERYRESULT_2k3;
-
-
-
-
C_ASSERT(sizeof(SDBQUERYRESULT_VISTA) == SDBQUERYRESULT_EXPECTED_SIZE_VISTA);
C_ASSERT(sizeof(SDBQUERYRESULT_2k3) == SDBQUERYRESULT_EXPECTED_SIZE_2k3);
-
-
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/modules/rostests/apitests/apphelp/db.cpp
b/modules/rostests/apitests/apphelp/db.cpp
index 9cebc82506d..7dc5427846b 100644
--- a/modules/rostests/apitests/apphelp/db.cpp
+++ b/modules/rostests/apitests/apphelp/db.cpp
@@ -1189,27 +1189,6 @@ static void test_is_testdb(PDB pdb)
}
}
-static BOOL IsUserAdmin()
-{
- BOOL Result;
- SID_IDENTIFIER_AUTHORITY NtAuthority = { SECURITY_NT_AUTHORITY };
- PSID AdministratorsGroup;
-
- Result = AllocateAndInitializeSid(&NtAuthority, 2,
- SECURITY_BUILTIN_DOMAIN_RID,
- DOMAIN_ALIAS_RID_ADMINS,
- 0, 0, 0, 0, 0, 0,
- &AdministratorsGroup);
- if (Result)
- {
- if (!CheckTokenMembership( NULL, AdministratorsGroup, &Result))
- Result = FALSE;
- FreeSid(AdministratorsGroup);
- }
-
- return Result;
-}
-
template<typename SDBQUERYRESULT_T>
static void check_adwExeFlags(DWORD adwExeFlags_0, SDBQUERYRESULT_T& query, const
char* file, int line, size_t cur)
@@ -1599,8 +1578,6 @@ static void test_MatchApplicationsEx(void)
}
-
-
static void test_TagRef(void)
{
WCHAR tmpdir[MAX_PATH], dbpath[MAX_PATH];
diff --git a/modules/rostests/apitests/apphelp/register.cpp
b/modules/rostests/apitests/apphelp/register.cpp
index 146dc8cf373..647ab6b4a9f 100644
--- a/modules/rostests/apitests/apphelp/register.cpp
+++ b/modules/rostests/apitests/apphelp/register.cpp
@@ -13,6 +13,8 @@
#include <strsafe.h>
#include "wine/test.h"
+#include "apphelp_apitest.h"
+
static const unsigned char rawDB[] =
{
/* Header: Major, Minor, 'sdbf' */
@@ -90,7 +92,7 @@ BOOL IsUserAdmin()
&AdministratorsGroup);
if (Result)
{
- if (!CheckTokenMembership( NULL, AdministratorsGroup, &Result))
+ if (!CheckTokenMembership(NULL, AdministratorsGroup, &Result))
Result = FALSE;
FreeSid(AdministratorsGroup);
}