[KERNEL32_APITEST]
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Tue, 17 Jan 2017 19:11:05 +0000 (19:11 +0000)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Tue, 17 Jan 2017 19:11:05 +0000 (19:11 +0000)
- Fix and enable tests for redirection support in LoadLibraryExW.
- Add tests for the default activation context that is active for every process.

svn path=/trunk/; revision=73568

rostests/apitests/kernel32/CMakeLists.txt
rostests/apitests/kernel32/DefaultActCtx.c [new file with mode: 0644]
rostests/apitests/kernel32/LoadLibraryExW.c
rostests/apitests/kernel32/redirptest/CMakeLists.txt
rostests/apitests/kernel32/redirptest/redir2dep.manifest [new file with mode: 0644]
rostests/apitests/kernel32/redirptest/redirtest1.c [new file with mode: 0644]
rostests/apitests/kernel32/redirptest/redirtest2.c [new file with mode: 0644]
rostests/apitests/kernel32/testlist.c

index 0a77394..7c66775 100644 (file)
@@ -1,5 +1,8 @@
 
+add_subdirectory(redirptest)
+
 list(APPEND SOURCE
+    DefaultActCtx.c
     dosdev.c
     FindActCtxSectionStringW.c
     FindFiles.c
@@ -8,6 +11,7 @@ list(APPEND SOURCE
     GetDriveType.c
     GetModuleFileName.c
     interlck.c
+    LoadLibraryExW.c
     lstrcpynW.c
     MultiByteToWideChar.c
     PrivMoveFileIdentityW.c
diff --git a/rostests/apitests/kernel32/DefaultActCtx.c b/rostests/apitests/kernel32/DefaultActCtx.c
new file mode 100644 (file)
index 0000000..17732cf
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Test for the default activation context that is active in every process.
+ *
+ * Copyright 2017 Giannis Adamopoulos
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "wine/test.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+
+START_TEST(DefaultActCtx)
+{
+    DWORD buffer[256];
+    BOOL res;
+    PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION details = (PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION)buffer;
+    PACTIVATION_CONTEXT_DETAILED_INFORMATION info = (PACTIVATION_CONTEXT_DETAILED_INFORMATION)buffer;
+    HANDLE h;
+    DWORD i;
+    ACTCTX_SECTION_KEYED_DATA KeyedData = { 0 };
+    
+    res = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX, 
+                       NULL, 
+                       NULL, 
+                       ActivationContextDetailedInformation,  
+                       &buffer, 
+                       sizeof(buffer), 
+                       NULL);
+    ok(res == TRUE, "\n");
+    ok(info->lpRootManifestPath == NULL, "Expected null lpRootManifestPath, got %S\n", info->lpRootManifestPath);
+    ok(info->lpRootConfigurationPath == NULL, "Expected null lpRootConfigurationPath, got %S\n", info->lpRootConfigurationPath);
+    ok(info->lpAppDirPath == NULL, "Expected null lpAppDirPath, got %S\n", info->lpAppDirPath);
+    ok(info->ulAssemblyCount == 0, "\n");
+    
+    i = 0;
+    res = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX, 
+                       NULL, 
+                       &i, 
+                       AssemblyDetailedInformationInActivationContext,  
+                       &buffer, 
+                       sizeof(buffer), 
+                       NULL);
+    ok(res == TRUE, "\n");
+    ok(details->lpAssemblyEncodedAssemblyIdentity == NULL, "Expected null lpAssemblyEncodedAssemblyIdentity, got %S\n", details->lpAssemblyEncodedAssemblyIdentity);
+    ok(details->lpAssemblyManifestPath == NULL, "Expected null lpAssemblyManifestPath, got %S\n", details->lpAssemblyManifestPath);
+    ok(details->lpAssemblyPolicyPath == NULL, "Expected null lpAssemblyPolicyPath, got %S\n", details->lpAssemblyPolicyPath);
+    ok(details->lpAssemblyDirectoryName == NULL, "Expected null lpAssemblyDirectoryName, got %S\n", details->lpAssemblyDirectoryName);
+    
+    i = 1;
+    res = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX, 
+                       NULL, 
+                       &i, 
+                       AssemblyDetailedInformationInActivationContext,  
+                       &buffer, 
+                       sizeof(buffer), 
+                       NULL);
+    ok(res == TRUE, "\n"); /* This is FALSE in win10 */
+    ok(details->lpAssemblyEncodedAssemblyIdentity == NULL, "Expected null lpAssemblyEncodedAssemblyIdentity, got %S\n", details->lpAssemblyEncodedAssemblyIdentity);
+    ok(details->lpAssemblyManifestPath == NULL, "Expected null lpAssemblyManifestPath, got %S\n", details->lpAssemblyManifestPath);
+    ok(details->lpAssemblyPolicyPath == NULL, "Expected null lpAssemblyPolicyPath, got %S\n", details->lpAssemblyPolicyPath);
+    ok(details->lpAssemblyDirectoryName == NULL, "Expected null lpAssemblyDirectoryName, got %S\n", details->lpAssemblyDirectoryName);
+
+    res = GetCurrentActCtx (&h);
+    ok(res == TRUE, "\n");
+    ok(h == NULL, "\n");
+
+    KeyedData.cbSize = sizeof(KeyedData);
+    res = FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX,
+                                   NULL,
+                                   ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION,
+                                   L"Microsoft.Windows.SysyemCompatible",
+                                   &KeyedData);
+    ok(res == FALSE, "\n");
+
+    KeyedData.cbSize = sizeof(KeyedData);
+    res = FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX,
+                                   NULL,
+                                   ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION,
+                                   L"System Default Context",
+                                   &KeyedData);
+    ok(res == FALSE, "\n");
+    
+    KeyedData.cbSize = sizeof(KeyedData);
+    res = FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX,
+                                   NULL,
+                                   ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION,
+                                   L"Microsoft.Windows.Common-Controls",
+                                   &KeyedData);
+    ok(res == TRUE, "\n");
+    ok(KeyedData.hActCtx == NULL, "Expected null handle for common control context\n");
+    ok(KeyedData.ulAssemblyRosterIndex != 0, "%d\n", KeyedData.ulAssemblyRosterIndex);
+    //ok(wcsstr(details-> , L"SystemCompative"
+    
+}
index 913e5a7..59fc266 100644 (file)
@@ -58,7 +58,11 @@ VOID TestDllRedirection()
     dll1 = LoadLibraryExW(L"kernel32test_versioned.dll",0 , 0);
     ok (dll1 != NULL, "LoadLibraryExW failed\n");
 
-    h = _CreateActCtxFromFile(L"testdata\\redirtest2.manifest", __LINE__);
+    /* redir2dep.manifest defines an assembly with nothing but a dependency on redirtest2 assembly */
+    /* redirtest2.manifest defines an assembly that contains kernel32test_versioned.dll */
+    /* In win10 it is enought to load and activate redirtest2 */
+    /* In win2k3 however the only way to trigger the redirection is to load and activate redir2dep */
+    h = _CreateActCtxFromFile(L"testdata\\redir2dep.manifest", __LINE__);
     _ActivateCtx(h, &cookie, __LINE__);
     dll2 = LoadLibraryExW(L"kernel32test_versioned.dll",0 , 0);
     _DeactivateCtx(cookie, __LINE__);
index 3a7c52a..fa9befa 100644 (file)
@@ -1,25 +1,23 @@
 
 spec2def(redirtest.dll redirtest.spec ADD_IMPORTLIB)
 
-list(APPEND SOURCE
-    redirtest.c
+list(APPEND SOURCE1
+    redirtest1.c
     ${CMAKE_CURRENT_BINARY_DIR}/redirtest_stubs.c
     ${CMAKE_CURRENT_BINARY_DIR}/redirtest.def)
 
-add_definitions(-DTESTVER=1)
+list(APPEND SOURCE2
+    redirtest2.c
+    ${CMAKE_CURRENT_BINARY_DIR}/redirtest_stubs.c
+    ${CMAKE_CURRENT_BINARY_DIR}/redirtest.def)
 
-add_library(redirtest1 SHARED ${SOURCE})
+add_library(redirtest1 SHARED ${SOURCE1})
 set_module_type(redirtest1 win32dll)
 add_importlibs(redirtest1 msvcrt kernel32 ntdll)
-add_rostests_file(TARGET redirtest1 NAME_ON_CD kernel32test_versioned.dll)
+add_rostests_file(TARGET redirtest1 RENAME kernel32test_versioned.dll)
 
-remove_definitions(-DTESTVER=1)
-add_definitions(-DTESTVER=2)
-
-add_library(redirtest2 SHARED ${SOURCE})
+add_library(redirtest2 SHARED ${SOURCE2})
 set_module_type(redirtest2 win32dll)
 add_importlibs(redirtest2 msvcrt kernel32 ntdll)
-add_rostests_file(TARGET redirtest2 SUBDIR testdata NAME_ON_CD kernel32test_versioned.dll)
+add_rostests_file(TARGET redirtest2 SUBDIR testdata RENAME kernel32test_versioned.dll)
 add_rostests_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/redirtest2.manifest" SUBDIR testdata)
-
-remove_definitions(-DTESTVER=2)
\ No newline at end of file
diff --git a/rostests/apitests/kernel32/redirptest/redir2dep.manifest b/rostests/apitests/kernel32/redirptest/redir2dep.manifest
new file mode 100644 (file)
index 0000000..8b20546
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">\r
+  <dependency>\r
+          <dependentAssembly>\r
+              <assemblyIdentity\r
+                  type="win32"\r
+                  name="redirtest2"\r
+                  version="0.2.2.2" \r
+                  processorArchitecture="x86"\r
+                  />\r
+          </dependentAssembly>\r
+  </dependency>  \r
+</assembly>\r
diff --git a/rostests/apitests/kernel32/redirptest/redirtest1.c b/rostests/apitests/kernel32/redirptest/redirtest1.c
new file mode 100644 (file)
index 0000000..e2f1316
--- /dev/null
@@ -0,0 +1,27 @@
+
+#include <windef.h>
+#include <winbase.h>
+
+DWORD WINAPI GetVersion()
+{
+    return 1;
+}
+
+BOOL
+WINAPI
+DllMain(HINSTANCE hinstDll,
+        DWORD dwReason,
+        LPVOID reserved)
+{
+    switch (dwReason)
+    {
+        case DLL_PROCESS_ATTACH:
+            DisableThreadLibraryCalls(hinstDll);
+            break;
+
+        case DLL_PROCESS_DETACH:
+            break;
+    }
+
+   return TRUE;
+}
diff --git a/rostests/apitests/kernel32/redirptest/redirtest2.c b/rostests/apitests/kernel32/redirptest/redirtest2.c
new file mode 100644 (file)
index 0000000..e2c0700
--- /dev/null
@@ -0,0 +1,27 @@
+
+#include <windef.h>
+#include <winbase.h>
+
+DWORD WINAPI GetVersion()
+{
+    return 2;
+}
+
+BOOL
+WINAPI
+DllMain(HINSTANCE hinstDll,
+        DWORD dwReason,
+        LPVOID reserved)
+{
+    switch (dwReason)
+    {
+        case DLL_PROCESS_ATTACH:
+            DisableThreadLibraryCalls(hinstDll);
+            break;
+
+        case DLL_PROCESS_DETACH:
+            break;
+    }
+
+   return TRUE;
+}
index 37e46bc..b78b16f 100644 (file)
@@ -3,6 +3,7 @@
 #define STANDALONE
 #include <apitest.h>
 
+extern void func_DefaultActCtx(void);
 extern void func_dosdev(void);
 extern void func_FindActCtxSectionStringW(void);
 extern void func_FindFiles(void);
@@ -11,6 +12,7 @@ extern void func_GetCurrentDirectory(void);
 extern void func_GetDriveType(void);
 extern void func_GetModuleFileName(void);
 extern void func_interlck(void);
+extern void func_LoadLibraryExW(void);
 extern void func_lstrcpynW(void);
 extern void func_Mailslot(void);
 extern void func_MultiByteToWideChar(void);
@@ -24,6 +26,7 @@ extern void func_WideCharToMultiByte(void);
 
 const struct test winetest_testlist[] =
 {
+    { "DefaultActCtx",               func_DefaultActCtx },
     { "dosdev",                      func_dosdev },
     { "FindActCtxSectionStringW",    func_FindActCtxSectionStringW },
     { "FindFiles",                   func_FindFiles },
@@ -32,6 +35,7 @@ const struct test winetest_testlist[] =
     { "GetDriveType",                func_GetDriveType },
     { "GetModuleFileName",           func_GetModuleFileName },
     { "interlck",                    func_interlck },
+    { "LoadLibraryExW",              func_LoadLibraryExW },
     { "lstrcpynW",                   func_lstrcpynW },
     { "MailslotRead",                func_Mailslot },
     { "MultiByteToWideChar",         func_MultiByteToWideChar },