[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

@ -17,6 +17,7 @@
/* FUNCTIONS ****************************************************************/
PGENERIC_LIST
NTAPI
CreateGenericList(VOID)
{
PGENERIC_LIST List;
@ -33,6 +34,7 @@ CreateGenericList(VOID)
}
VOID
NTAPI
DestroyGenericList(
IN OUT PGENERIC_LIST List,
IN BOOLEAN FreeData)
@ -59,6 +61,7 @@ DestroyGenericList(
}
BOOLEAN
NTAPI
AppendGenericListEntry(
IN OUT PGENERIC_LIST List,
IN PVOID Data,
@ -84,6 +87,7 @@ AppendGenericListEntry(
}
VOID
NTAPI
SetCurrentListEntry(
IN PGENERIC_LIST List,
IN PGENERIC_LIST_ENTRY Entry)
@ -94,6 +98,7 @@ SetCurrentListEntry(
}
PGENERIC_LIST_ENTRY
NTAPI
GetCurrentListEntry(
IN PGENERIC_LIST List)
{
@ -101,6 +106,7 @@ GetCurrentListEntry(
}
PGENERIC_LIST_ENTRY
NTAPI
GetFirstListEntry(
IN PGENERIC_LIST List)
{
@ -111,6 +117,7 @@ GetFirstListEntry(
}
PGENERIC_LIST_ENTRY
NTAPI
GetNextListEntry(
IN PGENERIC_LIST_ENTRY Entry)
{
@ -123,6 +130,7 @@ GetNextListEntry(
}
PVOID
NTAPI
GetListEntryData(
IN PGENERIC_LIST_ENTRY Entry)
{
@ -137,6 +145,7 @@ GetListEntryUiData(
}
ULONG
NTAPI
GetNumberOfListEntries(
IN PGENERIC_LIST List)
{

View file

@ -24,37 +24,45 @@ typedef struct _GENERIC_LIST
PGENERIC_LIST
NTAPI
CreateGenericList(VOID);
VOID
NTAPI
DestroyGenericList(
IN OUT PGENERIC_LIST List,
IN BOOLEAN FreeData);
BOOLEAN
NTAPI
AppendGenericListEntry(
IN OUT PGENERIC_LIST List,
IN PVOID Data,
IN BOOLEAN Current);
VOID
NTAPI
SetCurrentListEntry(
IN PGENERIC_LIST List,
IN PGENERIC_LIST_ENTRY Entry);
PGENERIC_LIST_ENTRY
NTAPI
GetCurrentListEntry(
IN PGENERIC_LIST List);
PGENERIC_LIST_ENTRY
NTAPI
GetFirstListEntry(
IN PGENERIC_LIST List);
PGENERIC_LIST_ENTRY
NTAPI
GetNextListEntry(
IN PGENERIC_LIST_ENTRY Entry);
PVOID
NTAPI
GetListEntryData(
IN PGENERIC_LIST_ENTRY Entry);
@ -63,6 +71,7 @@ GetListEntryUiData(
IN PGENERIC_LIST_ENTRY Entry);
ULONG
NTAPI
GetNumberOfListEntries(
IN PGENERIC_LIST List);

View file

@ -209,12 +209,16 @@ EnumerateInstallations(
return STATUS_SUCCESS;
}
/*
* FindSubStrI(PCWSTR str, PCWSTR strSearch) :
* Searches for a sub-string 'strSearch' inside 'str', similarly to what
* wcsstr(str, strSearch) does, but ignores the case during the comparisons.
*/
PCWSTR FindSubStrI(PCWSTR str, PCWSTR strSearch)
/**
* @brief
* Finds the first occurrence of a sub-string 'strSearch' inside 'str',
* using case-insensitive comparisons.
**/
PCWSTR
NTAPI
FindSubStrI(
_In_ PCWSTR str,
_In_ PCWSTR strSearch)
{
PCWSTR cp = str;
PCWSTR s1, s2;
@ -760,6 +764,7 @@ FindNTOSInstallations(
**/
// EnumerateNTOSInstallations
PGENERIC_LIST
NTAPI
CreateNTOSInstallationsList(
_In_ PPARTLIST PartList)
{

View file

@ -30,14 +30,14 @@ typedef struct _NTOS_INSTALLATION
// EnumerateNTOSInstallations
PGENERIC_LIST
NTAPI
CreateNTOSInstallationsList(
_In_ PPARTLIST PartList);
/*
* FindSubStrI(PCWSTR str, PCWSTR strSearch) :
* Searches for a sub-string 'strSearch' inside 'str', similarly to what
* wcsstr(str, strSearch) does, but ignores the case during the comparisons.
*/
PCWSTR FindSubStrI(PCWSTR str, PCWSTR strSearch);
PCWSTR
NTAPI
FindSubStrI(
_In_ PCWSTR str,
_In_ PCWSTR strSearch);
/* EOF */

View file

@ -16,7 +16,7 @@ typedef struct _MBR_PARTITION_TYPE
} MBR_PARTITION_TYPE, *PMBR_PARTITION_TYPE;
#define NUM_MBR_PARTITION_TYPES 153
extern const MBR_PARTITION_TYPE MbrPartitionTypes[NUM_MBR_PARTITION_TYPES];
extern SPLIBAPI const MBR_PARTITION_TYPE MbrPartitionTypes[NUM_MBR_PARTITION_TYPES];
/* GPT PARTITION TYPES ******************************************************/
@ -27,6 +27,6 @@ typedef struct _GPT_PARTITION_TYPE
} GPT_PARTITION_TYPE, *PGPT_PARTITION_TYPE;
#define NUM_GPT_PARTITION_TYPES 177
extern const GPT_PARTITION_TYPE GptPartitionTypes[NUM_GPT_PARTITION_TYPES];
extern SPLIBAPI const GPT_PARTITION_TYPE GptPartitionTypes[NUM_GPT_PARTITION_TYPES];
/* EOF */

View file

@ -1984,6 +1984,7 @@ GetActiveDiskPartition(
}
PPARTLIST
NTAPI
CreatePartitionList(VOID)
{
PPARTLIST List;
@ -2069,6 +2070,7 @@ CreatePartitionList(VOID)
}
VOID
NTAPI
DestroyPartitionList(
IN PPARTLIST List)
{
@ -2288,6 +2290,7 @@ SelectPartition(
}
PPARTENTRY
NTAPI
GetNextPartition(
IN PPARTLIST List,
IN PPARTENTRY CurrentPart OPTIONAL)
@ -2380,6 +2383,7 @@ GetNextPartition(
}
PPARTENTRY
NTAPI
GetPrevPartition(
IN PPARTLIST List,
IN PPARTENTRY CurrentPart OPTIONAL)
@ -2783,6 +2787,7 @@ UpdateDiskLayout(
* @return The adjacent unpartitioned region, if it exists, or NULL.
**/
PPARTENTRY
NTAPI
GetAdjUnpartitionedEntry(
_In_ PPARTENTRY PartEntry,
_In_ BOOLEAN Direction)
@ -2872,6 +2877,7 @@ MBRPartitionCreateChecks(
}
ERROR_NUMBER
NTAPI
PartitionCreateChecks(
_In_ PPARTENTRY PartEntry,
_In_opt_ ULONGLONG SizeBytes,
@ -2900,6 +2906,7 @@ PartitionCreateChecks(
// (see VDS::CREATE_PARTITION_PARAMETERS and PPARTITION_INFORMATION_MBR/GPT for example)
// So far we only use it as the optional type of the partition to create.
BOOLEAN
NTAPI
CreatePartition(
_In_ PPARTLIST List,
_Inout_ PPARTENTRY PartEntry,
@ -2990,6 +2997,7 @@ DismountPartition(
}
BOOLEAN
NTAPI
DeletePartition(
_In_ PPARTLIST List,
_In_ PPARTENTRY PartEntry,

View file

@ -283,9 +283,11 @@ IsPartitionActive(
IN PPARTENTRY PartEntry);
PPARTLIST
NTAPI
CreatePartitionList(VOID);
VOID
NTAPI
DestroyPartitionList(
IN PPARTLIST List);
@ -323,27 +325,32 @@ SelectPartition(
_In_ ULONG PartitionNumber);
PPARTENTRY
NTAPI
GetNextPartition(
IN PPARTLIST List,
IN PPARTENTRY CurrentPart OPTIONAL);
PPARTENTRY
NTAPI
GetPrevPartition(
IN PPARTLIST List,
IN PPARTENTRY CurrentPart OPTIONAL);
PPARTENTRY
NTAPI
GetAdjUnpartitionedEntry(
_In_ PPARTENTRY PartEntry,
_In_ BOOLEAN Direction);
ERROR_NUMBER
NTAPI
PartitionCreateChecks(
_In_ PPARTENTRY PartEntry,
_In_opt_ ULONGLONG SizeBytes,
_In_opt_ ULONG_PTR PartitionInfo);
BOOLEAN
NTAPI
CreatePartition(
_In_ PPARTLIST List,
_Inout_ PPARTENTRY PartEntry,
@ -351,6 +358,7 @@ CreatePartition(
_In_opt_ ULONG_PTR PartitionInfo);
BOOLEAN
NTAPI
DeletePartition(
_In_ PPARTLIST List,
_In_ PPARTENTRY PartEntry,