Skip to content

Commit d7c1d22

Browse files
committed
[SETUPLIB][REACTOS][USETUP] Turn setuplib into a DLL shared between TUI and GUI 1st-stage setups (reactos#7523)
CORE-13525 Notes: - Most of the exported functions have been turned from default cdecl to explicit stdcall / "NTAPI". - The two InitializeSetup() phases have been collapsed to make the initialization simpler. Average reductions (percentages; see PR reactos#7523 for actual numbers): x86 Debug builds: reactos.exe: 35.1% smss.exe : 39.8% Total (including setuplib.dll): 17.9% x86 Release builds: reactos.exe: 22.3% smss.exe : 25.0% Total (including setuplib.dll): 10.6% x64 Debug builds: reactos.exe: 40.6% smss.exe : 41.6% Total (including setuplib.dll): 20.0% x64 Release builds: reactos.exe: 22.8% smss.exe : 22.3% Total (including setuplib.dll): 10.1%
1 parent e51e5de commit d7c1d22

35 files changed

+459
-259
lines changed

base/setup/lib/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ add_definitions(${I18N_DEFS})
33
if(_WINKD_)
44
add_definitions(-D_WINKD_)
55
endif()
6+
add_definitions(-D_SETUPLIB_)
67

78
include_directories(spapisup utils)
89

10+
spec2def(setuplib.dll setuplib.spec ADD_IMPORTLIB)
11+
912
list(APPEND SOURCE
1013
spapisup/fileqsup.c
1114
spapisup/infsupp.c
@@ -32,6 +35,15 @@ list(APPEND SOURCE
3235
setuplib.c
3336
precomp.h)
3437

35-
add_library(setuplib ${SOURCE})
38+
add_library(setuplib SHARED
39+
${SOURCE}
40+
setuplib.rc
41+
${CMAKE_CURRENT_BINARY_DIR}/setuplib.def)
42+
3643
add_pch(setuplib precomp.h SOURCE)
3744
add_dependencies(setuplib xdk) # psdk
45+
46+
set_module_type(setuplib nativedll)
47+
target_link_libraries(setuplib ext2lib vfatlib btrfslib ${PSEH_LIB})
48+
add_importlibs(setuplib ntdll)
49+
add_cd_file(TARGET setuplib DESTINATION reactos/system32 NO_CAB FOR bootcd regtest)

base/setup/lib/bootsup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "bootcode.h"
2020
#include "fsutil.h"
2121

22-
#include "setuplib.h" // HAXX for IsUnattendedSetup!!
22+
#include "setuplib.h" // HACK for IsUnattendedSetup
2323

2424
#include "bootsup.h"
2525

@@ -1658,6 +1658,7 @@ GetDeviceInfo(
16581658
* @return An NTSTATUS code indicating success or failure.
16591659
**/
16601660
NTSTATUS
1661+
NTAPI
16611662
InstallBootManagerAndBootEntries(
16621663
_In_ ARCHITECTURE_TYPE ArchType,
16631664
_In_ PCUNICODE_STRING SystemRootPath,
@@ -1813,6 +1814,7 @@ InstallBootManagerAndBootEntries(
18131814
}
18141815

18151816
NTSTATUS
1817+
NTAPI
18161818
InstallBootcodeToRemovable(
18171819
_In_ ARCHITECTURE_TYPE ArchType,
18181820
_In_ PCUNICODE_STRING RemovableRootPath,

base/setup/lib/bootsup.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#pragma once
99

1010
NTSTATUS
11+
NTAPI
1112
InstallBootManagerAndBootEntries(
1213
_In_ ARCHITECTURE_TYPE ArchType,
1314
_In_ PCUNICODE_STRING SystemRootPath,
@@ -16,6 +17,7 @@ InstallBootManagerAndBootEntries(
1617
_In_ ULONG_PTR Options);
1718

1819
NTSTATUS
20+
NTAPI
1921
InstallBootcodeToRemovable(
2022
_In_ ARCHITECTURE_TYPE ArchType,
2123
_In_ PCUNICODE_STRING RemovableRootPath,

base/setup/lib/fsutil.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ static FILE_SYSTEM RegisteredFileSystems[] =
179179

180180
/** QueryAvailableFileSystemFormat() **/
181181
BOOLEAN
182+
NTAPI
182183
GetRegisteredFileSystems(
183184
IN ULONG Index,
184185
OUT PCWSTR* FileSystemName)
@@ -241,6 +242,7 @@ GetFileSystemByName(
241242

242243
/** ChkdskEx() **/
243244
NTSTATUS
245+
NTAPI
244246
ChkdskFileSystem_UStr(
245247
_In_ PUNICODE_STRING DriveRoot,
246248
_In_ PCWSTR FileSystemName,
@@ -284,6 +286,7 @@ ChkdskFileSystem_UStr(
284286
}
285287

286288
NTSTATUS
289+
NTAPI
287290
ChkdskFileSystem(
288291
_In_ PCWSTR DriveRoot,
289292
_In_ PCWSTR FileSystemName,
@@ -308,6 +311,7 @@ ChkdskFileSystem(
308311

309312
/** FormatEx() **/
310313
NTSTATUS
314+
NTAPI
311315
FormatFileSystem_UStr(
312316
_In_ PUNICODE_STRING DriveRoot,
313317
_In_ PCWSTR FileSystemName,
@@ -373,6 +377,7 @@ FormatFileSystem_UStr(
373377
}
374378

375379
NTSTATUS
380+
NTAPI
376381
FormatFileSystem(
377382
_In_ PCWSTR DriveRoot,
378383
_In_ PCWSTR FileSystemName,
@@ -754,6 +759,7 @@ InstallNtfsBootCode(
754759
//
755760

756761
NTSTATUS
762+
NTAPI
757763
ChkdskVolume(
758764
_In_ PVOLINFO Volume,
759765
_In_ BOOLEAN FixErrors,
@@ -778,6 +784,7 @@ ChkdskVolume(
778784
}
779785

780786
NTSTATUS
787+
NTAPI
781788
ChkdskPartition(
782789
_In_ PPARTENTRY PartEntry,
783790
_In_ BOOLEAN FixErrors,
@@ -801,6 +808,7 @@ ChkdskPartition(
801808
}
802809

803810
NTSTATUS
811+
NTAPI
804812
FormatVolume(
805813
_In_ PVOLINFO Volume,
806814
_In_ PCWSTR FileSystemName,
@@ -839,6 +847,7 @@ FormatVolume(
839847
}
840848

841849
NTSTATUS
850+
NTAPI
842851
FormatPartition(
843852
_In_ PPARTENTRY PartEntry,
844853
_In_ PCWSTR FileSystemName,
@@ -1084,6 +1093,7 @@ GetNextUnformattedVolume(
10841093
}
10851094

10861095
BOOLEAN
1096+
NTAPI
10871097
FsVolCommitOpsQueue(
10881098
_In_ PPARTLIST PartitionList,
10891099
_In_ PVOLENTRY SystemVolume,

base/setup/lib/fsutil.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212

1313
/** QueryAvailableFileSystemFormat() **/
1414
BOOLEAN
15+
NTAPI
1516
GetRegisteredFileSystems(
1617
IN ULONG Index,
1718
OUT PCWSTR* FileSystemName);
1819

1920

2021
/** ChkdskEx() **/
2122
NTSTATUS
23+
NTAPI
2224
ChkdskFileSystem_UStr(
2325
_In_ PUNICODE_STRING DriveRoot,
2426
_In_ PCWSTR FileSystemName,
@@ -29,6 +31,7 @@ ChkdskFileSystem_UStr(
2931
_In_opt_ PFMIFSCALLBACK Callback);
3032

3133
NTSTATUS
34+
NTAPI
3235
ChkdskFileSystem(
3336
_In_ PCWSTR DriveRoot,
3437
_In_ PCWSTR FileSystemName,
@@ -41,6 +44,7 @@ ChkdskFileSystem(
4144

4245
/** FormatEx() **/
4346
NTSTATUS
47+
NTAPI
4448
FormatFileSystem_UStr(
4549
_In_ PUNICODE_STRING DriveRoot,
4650
_In_ PCWSTR FileSystemName,
@@ -51,6 +55,7 @@ FormatFileSystem_UStr(
5155
_In_opt_ PFMIFSCALLBACK Callback);
5256

5357
NTSTATUS
58+
NTAPI
5459
FormatFileSystem(
5560
_In_ PCWSTR DriveRoot,
5661
_In_ PCWSTR FileSystemName,
@@ -109,6 +114,7 @@ InstallNtfsBootCode(
109114
//
110115

111116
NTSTATUS
117+
NTAPI
112118
ChkdskPartition(
113119
_In_ PPARTENTRY PartEntry,
114120
_In_ BOOLEAN FixErrors,
@@ -118,6 +124,7 @@ ChkdskPartition(
118124
_In_opt_ PFMIFSCALLBACK Callback);
119125

120126
NTSTATUS
127+
NTAPI
121128
FormatPartition(
122129
_In_ PPARTENTRY PartEntry,
123130
_In_ PCWSTR FileSystemName,
@@ -200,6 +207,7 @@ typedef FSVOL_OP
200207
_In_ ULONG_PTR Param2);
201208

202209
BOOLEAN
210+
NTAPI
203211
FsVolCommitOpsQueue(
204212
_In_ PPARTLIST PartitionList,
205213
_In_ PVOLENTRY SystemVolume,

base/setup/lib/install.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "filesup.h"
1414
#include "infsupp.h"
1515

16-
#include "setuplib.h" // HAXX for USETUP_DATA!!
16+
#include "setuplib.h" // HACK for USETUP_DATA
1717

1818
#include "install.h"
1919

@@ -681,6 +681,7 @@ PrepareCopyInfFile(
681681
// #define USE_CABINET_INF
682682

683683
BOOLEAN // ERROR_NUMBER
684+
NTAPI
684685
PrepareFileCopy(
685686
IN OUT PUSETUP_DATA pSetupData,
686687
IN PFILE_COPY_STATUS_ROUTINE StatusRoutine OPTIONAL)
@@ -823,6 +824,7 @@ PrepareFileCopy(
823824
}
824825

825826
BOOLEAN
827+
NTAPI
826828
DoFileCopy(
827829
IN OUT PUSETUP_DATA pSetupData,
828830
IN PSP_FILE_CALLBACK_W MsgHandler,

base/setup/lib/install.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ PrepareCopyInfFile(
2727
#endif
2828

2929
BOOLEAN // ERROR_NUMBER
30+
NTAPI
3031
PrepareFileCopy(
3132
IN OUT PUSETUP_DATA pSetupData,
3233
IN PFILE_COPY_STATUS_ROUTINE StatusRoutine OPTIONAL);
3334

3435
BOOLEAN
36+
NTAPI
3537
DoFileCopy(
3638
IN OUT PUSETUP_DATA pSetupData,
3739
IN PSP_FILE_CALLBACK_W MsgHandler,

base/setup/lib/precomp.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@
2929

3030
#include <ntstrsafe.h>
3131

32-
3332
/* Filesystem headers */
3433
#include <reactos/rosioctl.h> // For extra partition IDs
3534

35+
36+
#ifndef SPLIBAPI
37+
#define SPLIBAPI
38+
#endif
39+
3640
//
3741
///* Internal Headers */
3842
//#include "interface/consup.h"
@@ -51,7 +55,6 @@
5155
//#include "filesup.h"
5256
//#include "genlist.h"
5357

54-
5558
extern HANDLE ProcessHeap;
5659

5760
#include "errorcode.h"

0 commit comments

Comments
 (0)