Author: gadamopoulos
Date: Fri Jan 13 15:33:38 2017
New Revision: 73538
URL:
http://svn.reactos.org/svn/reactos?rev=73538&view=rev
Log:
[KERNEL32_APITEST] - Add tests for LoadLibraryExW to test its ability to load a redirected
dll. Do not include it in the build until a way is found for it to be compiled properly.
Added:
trunk/rostests/apitests/kernel32/LoadLibraryExW.c (with props)
trunk/rostests/apitests/kernel32/redirptest/
trunk/rostests/apitests/kernel32/redirptest/CMakeLists.txt (with props)
trunk/rostests/apitests/kernel32/redirptest/redirtest.c (with props)
trunk/rostests/apitests/kernel32/redirptest/redirtest.spec (with props)
trunk/rostests/apitests/kernel32/redirptest/redirtest2.manifest (with props)
Added: trunk/rostests/apitests/kernel32/LoadLibraryExW.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/kernel32/LoadLib…
==============================================================================
--- trunk/rostests/apitests/kernel32/LoadLibraryExW.c (added)
+++ trunk/rostests/apitests/kernel32/LoadLibraryExW.c [iso-8859-1] Fri Jan 13 15:33:38
2017
@@ -0,0 +1,90 @@
+/*
+ * 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"
+
+HANDLE _CreateActCtxFromFile(LPCWSTR FileName, int line);
+VOID _ActivateCtx(HANDLE h, ULONG_PTR *cookie, int line);
+VOID _DeactivateCtx(ULONG_PTR cookie, int line);
+
+typedef DWORD (WINAPI *LPGETVERSION)();
+
+VOID _TestVesion(HANDLE dll, DWORD ExpectedVersion, int line)
+{
+ LPGETVERSION proc = (LPGETVERSION)GetProcAddress(dll, "GetVersion");
+ DWORD version = proc();
+ ok_(__FILE__, line)(version == ExpectedVersion, "Got version %d, expected
%d\n", version, ExpectedVersion);
+}
+
+VOID TestDllRedirection()
+{
+ HANDLE dll1, dll2, h;
+ ULONG_PTR cookie;
+
+ /* Try to load the libraries without sxs */
+ dll1 = LoadLibraryExW(L"kernel32test_versioned.dll",0 , 0);
+ ok (dll1 != NULL, "LoadLibraryExW failed\n");
+ dll2 = LoadLibraryExW(L"testdata\\kernel32test_versioned.dll",0 , 0);
+ ok (dll2 != NULL, "LoadLibraryExW failed\n");
+
+ ok (dll1 != dll2, "\n");
+ _TestVesion(dll1, 1, __LINE__);
+ _TestVesion(dll2, 2, __LINE__);
+
+ FreeLibrary(dll1);
+ FreeLibrary(dll2);
+
+ dll1 = LoadLibraryExW(L"kernel32test_versioned.dll",0 , 0);
+ ok (dll1 != NULL, "LoadLibraryExW failed\n");
+
+ h = _CreateActCtxFromFile(L"testdata\\redirtest2.manifest", __LINE__);
+ _ActivateCtx(h, &cookie, __LINE__);
+ dll2 = LoadLibraryExW(L"kernel32test_versioned.dll",0 , 0);
+ _DeactivateCtx(cookie, __LINE__);
+ ok (dll2 != NULL, "LoadLibraryExW failed\n");
+
+ ok (dll1 != dll2, "\n");
+ _TestVesion(dll1, 1, __LINE__);
+ _TestVesion(dll2, 2, __LINE__);
+
+ FreeLibrary(dll1);
+ FreeLibrary(dll2);
+
+ dll1 = LoadLibraryExW(L"comctl32.dll",0 ,0);
+ ok (dll1 != NULL, "LoadLibraryExW failed\n");
+
+ h = _CreateActCtxFromFile(L"comctl32dep.manifest", __LINE__);
+ _ActivateCtx(h, &cookie, __LINE__);
+ dll2 = LoadLibraryExW(L"comctl32.dll",0 , 0);
+ _DeactivateCtx(cookie, __LINE__);
+ ok (dll2 != NULL, "LoadLibraryExW failed\n");
+
+ ok (dll1 != dll2, "\n");
+
+}
+
+START_TEST(LoadLibraryExW)
+{
+ TestDllRedirection();
+}
Propchange: trunk/rostests/apitests/kernel32/LoadLibraryExW.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/apitests/kernel32/redirptest/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/kernel32/redirpt…
==============================================================================
--- trunk/rostests/apitests/kernel32/redirptest/CMakeLists.txt (added)
+++ trunk/rostests/apitests/kernel32/redirptest/CMakeLists.txt [iso-8859-1] Fri Jan 13
15:33:38 2017
@@ -0,0 +1,25 @@
+
+spec2def(redirtest.dll redirtest.spec ADD_IMPORTLIB)
+
+list(APPEND SOURCE
+ redirtest.c
+ ${CMAKE_CURRENT_BINARY_DIR}/redirtest_stubs.c
+ ${CMAKE_CURRENT_BINARY_DIR}/redirtest.def)
+
+add_definitions(-DTESTVER=1)
+
+add_library(redirtest1 SHARED ${SOURCE})
+set_module_type(redirtest1 win32dll)
+add_importlibs(redirtest1 msvcrt kernel32 ntdll)
+add_rostests_file(TARGET redirtest1 NAME_ON_CD kernel32test_versioned.dll)
+
+remove_definitions(-DTESTVER=1)
+add_definitions(-DTESTVER=2)
+
+add_library(redirtest2 SHARED ${SOURCE})
+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(FILE "${CMAKE_CURRENT_SOURCE_DIR}/redirtest2.manifest" SUBDIR
testdata)
+
+remove_definitions(-DTESTVER=2)
Propchange: trunk/rostests/apitests/kernel32/redirptest/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/apitests/kernel32/redirptest/redirtest.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/kernel32/redirpt…
==============================================================================
--- trunk/rostests/apitests/kernel32/redirptest/redirtest.c (added)
+++ trunk/rostests/apitests/kernel32/redirptest/redirtest.c [iso-8859-1] Fri Jan 13
15:33:38 2017
@@ -0,0 +1,27 @@
+
+#include <windef.h>
+#include <winbase.h>
+
+DWORD WINAPI GetVersion()
+{
+ return TESTVER;
+}
+
+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;
+}
Propchange: trunk/rostests/apitests/kernel32/redirptest/redirtest.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/apitests/kernel32/redirptest/redirtest.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/kernel32/redirpt…
==============================================================================
--- trunk/rostests/apitests/kernel32/redirptest/redirtest.spec (added)
+++ trunk/rostests/apitests/kernel32/redirptest/redirtest.spec [iso-8859-1] Fri Jan 13
15:33:38 2017
@@ -0,0 +1 @@
+@ stdcall GetVersion()
Propchange: trunk/rostests/apitests/kernel32/redirptest/redirtest.spec
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/apitests/kernel32/redirptest/redirtest2.manifest
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/kernel32/redirpt…
==============================================================================
--- trunk/rostests/apitests/kernel32/redirptest/redirtest2.manifest (added)
+++ trunk/rostests/apitests/kernel32/redirptest/redirtest2.manifest [iso-8859-1] Fri Jan
13 15:33:38 2017
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
+ <assemblyIdentity type="win32" name="redirtest2"
version="0.2.2.2" processorArchitecture="x86" />
+ <file name="kernel32test_versioned.dll"/>
+</assembly>
+
Propchange: trunk/rostests/apitests/kernel32/redirptest/redirtest2.manifest
------------------------------------------------------------------------------
svn:eol-style = CRLF