Reactos

[SETUPLIB] Add a setuplib_static library, used for the dll and the unit-tests.

Since the setuplib.dll isn't available after installing ReactOS, build
instead a static library that is then used for the dll, and linked into
the setuplib_unittest, so that it can be run in our test-suite.

Addendum to commit d7c1d220.

+58 -31
+7 -3
base/setup/lib/CMakeLists.txt
··· 35 35 setuplib.c 36 36 precomp.h) 37 37 38 + # Static library used for the dll and for setuplib_unittest. 39 + add_library(setuplib_static ${SOURCE}) 40 + add_pch(setuplib_static precomp.h SOURCE) 41 + add_dependencies(setuplib_static xdk) # psdk 42 + 38 43 add_library(setuplib SHARED 39 - ${SOURCE} 44 + main.c 40 45 setuplib.rc 41 46 ${CMAKE_CURRENT_BINARY_DIR}/setuplib.def) 47 + target_link_libraries(setuplib setuplib_static) 42 48 43 - add_pch(setuplib precomp.h SOURCE) 44 49 add_dependencies(setuplib xdk) # psdk 45 - 46 50 set_module_type(setuplib nativedll) 47 51 target_link_libraries(setuplib ext2lib vfatlib btrfslib ${PSEH_LIB}) 48 52 add_importlibs(setuplib ntdll)
+49
base/setup/lib/main.c
··· 1 + /* 2 + * PROJECT: ReactOS Setup Library 3 + * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) 4 + * PURPOSE: DLL Main Routine 5 + * COPYRIGHT: Copyright 2025 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> 6 + */ 7 + 8 + /* INCLUDES ******************************************************************/ 9 + 10 + /* PSDK/NDK Headers */ 11 + #define WIN32_NO_STATUS 12 + #include <windef.h> 13 + #include <winbase.h> 14 + 15 + #define NTOS_MODE_USER 16 + // #include <ndk/umfuncs.h> 17 + #include <ndk/rtlfuncs.h> 18 + 19 + /* GLOBALS *******************************************************************/ 20 + 21 + extern HANDLE ProcessHeap; 22 + 23 + /* ENTRY-POINT ***************************************************************/ 24 + 25 + /* Declared in ndk/umfuncs.h */ 26 + NTSTATUS 27 + NTAPI 28 + LdrDisableThreadCalloutsForDll( 29 + _In_ PVOID BaseAddress); 30 + 31 + BOOL 32 + NTAPI 33 + DllMain( 34 + _In_ HINSTANCE hDll, 35 + _In_ ULONG dwReason, 36 + _In_opt_ PVOID pReserved) 37 + { 38 + UNREFERENCED_PARAMETER(pReserved); 39 + 40 + if (dwReason == DLL_PROCESS_ATTACH) 41 + { 42 + LdrDisableThreadCalloutsForDll(hDll); 43 + ProcessHeap = RtlGetProcessHeap(); 44 + } 45 + 46 + return TRUE; 47 + } 48 + 49 + /* EOF */
-27
base/setup/lib/setuplib.c
··· 1405 1405 return ErrorNumber; 1406 1406 } 1407 1407 1408 - 1409 - /* ENTRY-POINT ***************************************************************/ 1410 - 1411 - /* Declared in ndk/umfuncs.h */ 1412 - NTSTATUS 1413 - NTAPI 1414 - LdrDisableThreadCalloutsForDll( 1415 - _In_ PVOID BaseAddress); 1416 - 1417 - BOOL 1418 - NTAPI 1419 - DllMain( 1420 - _In_ HINSTANCE hDll, 1421 - _In_ ULONG dwReason, 1422 - _In_opt_ PVOID pReserved) 1423 - { 1424 - UNREFERENCED_PARAMETER(pReserved); 1425 - 1426 - if (dwReason == DLL_PROCESS_ATTACH) 1427 - { 1428 - LdrDisableThreadCalloutsForDll(hDll); 1429 - ProcessHeap = RtlGetProcessHeap(); 1430 - } 1431 - 1432 - return TRUE; 1433 - } 1434 - 1435 1408 /* EOF */
+2 -1
modules/rostests/unittests/setuplib/CMakeLists.txt
··· 11 11 precomp.h) 12 12 13 13 add_executable(setuplib_unittest ${SOURCE}) 14 + target_link_libraries(setuplib_unittest setuplib_static ${PSEH_LIB}) 14 15 set_module_type(setuplib_unittest win32cui) 15 - add_importlibs(setuplib_unittest setuplib msvcrt kernel32) 16 + add_importlibs(setuplib_unittest msvcrt kernel32 ntdll) 16 17 #add_pch(setuplib_unittest precomp.h SOURCE) 17 18 add_rostests_file(TARGET setuplib_unittest)