[SETUPLIB][REACTOS][USETUP] Turn setuplib into a DLL shared between TUI and GUI 1st-stage setups (#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 #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%
This commit is contained in:
Hermès Bélusca-Maïto 2024-11-22 21:45:06 +01:00
parent e51e5de1f8
commit d7c1d220b5
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
35 changed files with 462 additions and 262 deletions

View file

@ -20,15 +20,6 @@
* These externs should be defined by the user of this library.
* They are kept there for reference and ease of usage.
*/
#if 0
pSpFileQueueOpen SpFileQueueOpen = NULL;
pSpFileQueueClose SpFileQueueClose = NULL;
pSpFileQueueCopy SpFileQueueCopy = NULL;
pSpFileQueueDelete SpFileQueueDelete = NULL;
pSpFileQueueRename SpFileQueueRename = NULL;
pSpFileQueueCommit SpFileQueueCommit = NULL;
#endif
SPFILE_EXPORTS SpFileExports = {NULL};
/* EOF */

View file

@ -51,7 +51,7 @@
#define FILEOP_NEWPATH 4
/* TYPES ********************************************************************/
/* TYPES *********************************************************************/
typedef PVOID HSPFILEQ;
@ -72,21 +72,17 @@ typedef UINT (CALLBACK* PSP_FILE_CALLBACK_W)(
#endif
/* FUNCTIONS ****************************************************************/
/* FUNCTIONS *****************************************************************/
// #define SetupOpenFileQueue
typedef HSPFILEQ
(WINAPI* pSpFileQueueOpen)(VOID);
extern pSpFileQueueOpen SpFileQueueOpen;
// #define SetupCloseFileQueue
typedef BOOL
(WINAPI* pSpFileQueueClose)(
IN HSPFILEQ QueueHandle);
extern pSpFileQueueClose SpFileQueueClose;
// #define SetupQueueCopyW
typedef BOOL
(WINAPI* pSpFileQueueCopy)(
@ -101,8 +97,6 @@ typedef BOOL
IN PCWSTR TargetFileName OPTIONAL,
IN ULONG CopyStyle);
extern pSpFileQueueCopy SpFileQueueCopy;
// #define SetupQueueDeleteW
typedef BOOL
(WINAPI* pSpFileQueueDelete)(
@ -110,8 +104,6 @@ typedef BOOL
IN PCWSTR PathPart1,
IN PCWSTR PathPart2 OPTIONAL);
extern pSpFileQueueDelete SpFileQueueDelete;
// #define SetupQueueRenameW
typedef BOOL
(WINAPI* pSpFileQueueRename)(
@ -121,8 +113,6 @@ typedef BOOL
IN PCWSTR TargetPath OPTIONAL,
IN PCWSTR TargetFileName);
extern pSpFileQueueRename SpFileQueueRename;
// #define SetupCommitFileQueueW
typedef BOOL
(WINAPI* pSpFileQueueCommit)(
@ -131,6 +121,23 @@ typedef BOOL
IN PSP_FILE_CALLBACK_W MsgHandler,
IN PVOID Context OPTIONAL);
extern pSpFileQueueCommit SpFileQueueCommit;
typedef struct _SPFILE_EXPORTS
{
pSpFileQueueOpen SpFileQueueOpen;
pSpFileQueueClose SpFileQueueClose;
pSpFileQueueCopy SpFileQueueCopy;
pSpFileQueueDelete SpFileQueueDelete;
pSpFileQueueRename SpFileQueueRename;
pSpFileQueueCommit SpFileQueueCommit;
} SPFILE_EXPORTS, *PSPFILE_EXPORTS;
extern /*SPLIBAPI*/ SPFILE_EXPORTS SpFileExports;
#define SpFileQueueOpen (SpFileExports.SpFileQueueOpen)
#define SpFileQueueClose (SpFileExports.SpFileQueueClose)
#define SpFileQueueCopy (SpFileExports.SpFileQueueCopy)
#define SpFileQueueDelete (SpFileExports.SpFileQueueDelete)
#define SpFileQueueRename (SpFileExports.SpFileQueueRename)
#define SpFileQueueCommit (SpFileExports.SpFileQueueCommit)
/* EOF */

View file

@ -21,20 +21,7 @@
* These externs should be defined by the user of this library.
* They are kept there for reference and ease of usage.
*/
#if 0
pSpInfCloseInfFile SpInfCloseInfFile = NULL;
pSpInfFindFirstLine SpInfFindFirstLine = NULL;
pSpInfFindNextLine SpInfFindNextLine = NULL;
pSpInfGetFieldCount SpInfGetFieldCount = NULL;
pSpInfGetBinaryField SpInfGetBinaryField = NULL;
pSpInfGetIntField SpInfGetIntField = NULL;
pSpInfGetMultiSzField SpInfGetMultiSzField = NULL;
pSpInfGetStringField SpInfGetStringField = NULL;
pSpInfGetField SpInfGetField = NULL;
pSpInfOpenInfFile SpInfOpenInfFile = NULL;
#endif
SPINF_EXPORTS SpInfExports = {NULL};
/* HELPER FUNCTIONS **********************************************************/

View file

@ -29,6 +29,8 @@ typedef struct _INFCONTEXT
#endif
C_ASSERT(sizeof(INFCONTEXT) == 2 * sizeof(HINF) + 2 * sizeof(UINT));
/* Lower the MAX_INF_STRING_LENGTH value in order to avoid too much stack usage */
#undef MAX_INF_STRING_LENGTH
#define MAX_INF_STRING_LENGTH 1024 // Still larger than in infcommon.h
@ -41,27 +43,14 @@ typedef struct _INFCONTEXT
#define INF_STYLE_WIN4 0x00000002
#endif
#if 0
typedef PVOID HINF;
typedef struct _INFCONTEXT
{
HINF Inf;
HINF CurrentInf;
UINT Section;
UINT Line;
} INFCONTEXT, *PINFCONTEXT;
#endif
C_ASSERT(sizeof(INFCONTEXT) == 2 * sizeof(HINF) + 2 * sizeof(UINT));
/* FUNCTIONS *****************************************************************/
// #define SetupCloseInfFile InfCloseFile
typedef VOID
(WINAPI* pSpInfCloseInfFile)(
IN HINF InfHandle);
extern pSpInfCloseInfFile SpInfCloseInfFile;
// #define SetupFindFirstLineW InfpFindFirstLineW
typedef BOOL
(WINAPI* pSpInfFindFirstLine)(
@ -70,23 +59,17 @@ typedef BOOL
IN PCWSTR Key,
IN OUT PINFCONTEXT Context);
extern pSpInfFindFirstLine SpInfFindFirstLine;
// #define SetupFindNextLine InfFindNextLine
typedef BOOL
(WINAPI* pSpInfFindNextLine)(
IN PINFCONTEXT ContextIn,
OUT PINFCONTEXT ContextOut);
extern pSpInfFindNextLine SpInfFindNextLine;
// #define SetupGetFieldCount InfGetFieldCount
typedef ULONG
(WINAPI* pSpInfGetFieldCount)(
IN PINFCONTEXT Context);
extern pSpInfGetFieldCount SpInfGetFieldCount;
// #define SetupGetBinaryField InfGetBinaryField
typedef BOOL
(WINAPI* pSpInfGetBinaryField)(
@ -96,8 +79,6 @@ typedef BOOL
IN ULONG ReturnBufferSize,
OUT PULONG RequiredSize);
extern pSpInfGetBinaryField SpInfGetBinaryField;
// #define SetupGetIntField InfGetIntField
typedef BOOL
(WINAPI* pSpInfGetIntField)(
@ -105,8 +86,6 @@ typedef BOOL
IN ULONG FieldIndex,
OUT INT *IntegerValue); // PINT
extern pSpInfGetIntField SpInfGetIntField;
// #define SetupGetMultiSzFieldW InfGetMultiSzField
typedef BOOL
(WINAPI* pSpInfGetMultiSzField)(
@ -116,8 +95,6 @@ typedef BOOL
IN ULONG ReturnBufferSize,
OUT PULONG RequiredSize);
extern pSpInfGetMultiSzField SpInfGetMultiSzField;
// #define SetupGetStringFieldW InfGetStringField
typedef BOOL
(WINAPI* pSpInfGetStringField)(
@ -127,16 +104,12 @@ typedef BOOL
IN ULONG ReturnBufferSize,
OUT PULONG RequiredSize);
extern pSpInfGetStringField SpInfGetStringField;
// #define pSetupGetField
typedef PCWSTR
(WINAPI* pSpInfGetField)(
IN PINFCONTEXT Context,
IN ULONG FieldIndex);
extern pSpInfGetField SpInfGetField;
/* A version of SetupOpenInfFileW with support for a user-provided LCID */
// #define SetupOpenInfFileExW InfpOpenInfFileW
typedef HINF
@ -147,8 +120,32 @@ typedef HINF
IN LCID LocaleId,
OUT PUINT ErrorLine);
extern pSpInfOpenInfFile SpInfOpenInfFile;
typedef struct _SPINF_EXPORTS
{
pSpInfCloseInfFile SpInfCloseInfFile;
pSpInfFindFirstLine SpInfFindFirstLine;
pSpInfFindNextLine SpInfFindNextLine;
pSpInfGetFieldCount SpInfGetFieldCount;
pSpInfGetBinaryField SpInfGetBinaryField;
pSpInfGetIntField SpInfGetIntField;
pSpInfGetMultiSzField SpInfGetMultiSzField;
pSpInfGetStringField SpInfGetStringField;
pSpInfGetField SpInfGetField;
pSpInfOpenInfFile SpInfOpenInfFile;
} SPINF_EXPORTS, *PSPINF_EXPORTS;
extern /*SPLIBAPI*/ SPINF_EXPORTS SpInfExports;
#define SpInfCloseInfFile (SpInfExports.SpInfCloseInfFile)
#define SpInfFindFirstLine (SpInfExports.SpInfFindFirstLine)
#define SpInfFindNextLine (SpInfExports.SpInfFindNextLine)
#define SpInfGetFieldCount (SpInfExports.SpInfGetFieldCount)
#define SpInfGetBinaryField (SpInfExports.SpInfGetBinaryField)
#define SpInfGetIntField (SpInfExports.SpInfGetIntField)
#define SpInfGetMultiSzField (SpInfExports.SpInfGetMultiSzField)
#define SpInfGetStringField (SpInfExports.SpInfGetStringField)
#define SpInfGetField (SpInfExports.SpInfGetField)
#define SpInfOpenInfFile (SpInfExports.SpInfOpenInfFile)
/* HELPER FUNCTIONS **********************************************************/