Francois Gouget : atl100/tests: Skip the test_regcat() tests if we don' t have elevated privileges.

Alexandre Julliard julliard at winehq.org
Mon Feb 17 13:45:15 CST 2014


Module: wine
Branch: master
Commit: 9eaf355130df56d2d47948c64b87bc6e2f637650
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9eaf355130df56d2d47948c64b87bc6e2f637650

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Mon Feb 17 17:13:02 2014 +0100

atl100/tests: Skip the test_regcat() tests if we don't have elevated privileges.

---

 dlls/atl100/tests/atl.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/dlls/atl100/tests/atl.c b/dlls/atl100/tests/atl.c
index 383dbe4..96abf57 100644
--- a/dlls/atl100/tests/atl.c
+++ b/dlls/atl100/tests/atl.c
@@ -43,6 +43,32 @@ static const GUID CATID_CatTest2 =
     {0x178fc163,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x46}};
 #define CATID_CATTEST2_STR "178fc163-0000-0000-0000-000000000246"
 
+static BOOL is_process_limited(void)
+{
+    static BOOL (WINAPI *pOpenProcessToken)(HANDLE, DWORD, PHANDLE) = NULL;
+    HANDLE token;
+
+    if (!pOpenProcessToken)
+    {
+        HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
+        pOpenProcessToken = (void*)GetProcAddress(hadvapi32, "OpenProcessToken");
+        if (!pOpenProcessToken)
+            return FALSE;
+    }
+
+    if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
+    {
+        BOOL ret;
+        TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
+        DWORD size;
+
+        ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
+        CloseHandle(token);
+        return (ret && type == TokenElevationTypeLimited);
+    }
+    return FALSE;
+}
+
 static void test_winmodule(void)
 {
     _AtlCreateWndData create_data[3];
@@ -148,6 +174,12 @@ static void test_regcat(void)
         {_ATL_CATMAP_ENTRY_END}
     };
 
+    if (is_process_limited())
+    {
+        skip("process is limited\n");
+        return;
+    }
+
     hres = AtlRegisterClassCategoriesHelper(&CLSID_Test, catmap, TRUE);
     ok(hres == S_OK, "AtlRegisterClassCategoriesHelper failed: %08x\n", hres);
 




More information about the wine-cvs mailing list