[0.4.7][USETUP][MBEDTLS] Port back some cleanup

by picking:
0.4.9-dev-884-g 7b618314c2 [USETUP] Remove now-unneeded file.
0.4.9-dev-849-g 7c3cff3a68 [USETUP] Remove the WIN32 support because usetup is a native-only application
0.4.9-dev-847-g 1b323ff2f4 [USETUP] Remove unused VolumeLabel and FileSystemName from the PARTENTRY type
partially 0.4.9-dev-843-g 3bf2f30cf2 [USETUP] only the Cleanup-part in consup.c, **not** the part which improved on the keys for CORE13975

0.4.8-dev-979-g 25bca520f5 [MBEDTLS] Don't link with zlib, we don't use it. CORE-14290
0.4.8-dev-978-g dc51b419c7 [USETUP] Use the smaller zlib_solo instead of the full zlib. CORE-14290
partially 0.4.8-dev-271-g 5633423086 [USETUP] Silence some clang-cl warnings. (only the [USETUP]-part)
partially 0.4.8-dev-107-g f0e6c11bba [USETUP] NtWriteFile() calls: Remove unused 'ByteOffset = 0',

In sum:
0.4.9 usetup binary size RosBEWin2.1.6 GCC4.7.2dbg == 849.920bytes
0.4.8 usetup binary size RosBEWin2.1.6 GCC4.7.2dbg shrinks from 847.872bytes -> 846.848bytes
0.4.7 usetup binary size RosBEWin2.1.6 GCC4.7.2dbg shrinks from 853.504bytes ->	845.312bytes
This commit is contained in:
Joachim Henze 2023-06-13 01:04:25 +02:00
parent c41493fcf9
commit e4f0ba5cae
22 changed files with 22 additions and 289 deletions

View file

@ -8,14 +8,11 @@ include_directories(
${REACTOS_SOURCE_DIR}/sdk/include/reactos/drivers)
list(APPEND SOURCE
native/utils/keytrans.c
native/utils/console.c
native/fslist.c
native/console.c
bootsup.c
cabinet.c
chkdsk.c
cmdcons.c
console.c
consup.c
devinst.c
drivesup.c
@ -26,6 +23,7 @@ list(APPEND SOURCE
genlist.c
inffile.c
inicache.c
keytrans.c
mui.c
partlist.c
progress.c
@ -34,13 +32,13 @@ list(APPEND SOURCE
usetup.c
usetup.h)
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
#FIXME: Investigate Clang "illegal character encoding in string literal" warning
set_property(SOURCE mui.c APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-invalid-source-encoding")
add_executable(usetup ${SOURCE} usetup.rc)
if(USE_CLANG_CL)
add_target_compile_flags(usetup "-Wno-invalid-source-encoding")
endif()
add_executable(usetup ${SOURCE} usetup.rc)
target_link_libraries(usetup zlib inflib ext2lib vfatlib)
target_link_libraries(usetup zlib_solo inflib ext2lib vfatlib)
set_module_type(usetup nativecui)
add_importlibs(usetup ntdll)
add_pch(usetup usetup.h SOURCE)

View file

@ -941,7 +941,6 @@ InstallFat16BootCodeToFile(
return Status;
}
FileOffset.QuadPart = 0ULL;
Status = NtWriteFile(FileHandle,
NULL,
NULL,
@ -1001,7 +1000,6 @@ InstallFat32BootCodeToFile(
return Status;
}
FileOffset.QuadPart = 0ULL;
Status = NtReadFile(FileHandle,
NULL,
NULL,
@ -1103,7 +1101,6 @@ InstallFat32BootCodeToFile(
return Status;
}
FileOffset.QuadPart = 0ULL;
Status = NtWriteFile(FileHandle,
NULL,
NULL,
@ -2252,7 +2249,6 @@ InstallFatBootcodeToPartition(
PUNICODE_STRING DestinationArcPath,
UCHAR PartitionType)
{
#ifdef __REACTOS__
NTSTATUS Status;
BOOLEAN DoesFreeLdrExist;
WCHAR SrcPath[MAX_PATH];
@ -2497,9 +2493,6 @@ InstallFatBootcodeToPartition(
}
return STATUS_SUCCESS;
#else
return STATUS_NOT_IMPLEMENTED;
#endif
}
static
@ -2510,7 +2503,6 @@ InstallExt2BootcodeToPartition(
PUNICODE_STRING DestinationArcPath,
UCHAR PartitionType)
{
#ifdef __REACTOS__
NTSTATUS Status;
BOOLEAN DoesFreeLdrExist;
WCHAR SrcPath[MAX_PATH];
@ -2616,9 +2608,6 @@ InstallExt2BootcodeToPartition(
}
return STATUS_SUCCESS;
#else
return STATUS_NOT_IMPLEMENTED;
#endif
}
@ -2669,7 +2658,6 @@ InstallFatBootcodeToFloppy(
PUNICODE_STRING SourceRootPath,
PUNICODE_STRING DestinationArcPath)
{
#ifdef __REACTOS__
NTSTATUS Status;
UNICODE_STRING FloppyDevice = RTL_CONSTANT_STRING(L"\\Device\\Floppy0");
WCHAR SrcPath[MAX_PATH];
@ -2728,9 +2716,6 @@ InstallFatBootcodeToFloppy(
}
return STATUS_SUCCESS;
#else
return STATUS_NOT_IMPLEMENTED;
#endif
}
/* EOF */

View file

@ -10,6 +10,7 @@
#include "usetup.h"
#define Z_SOLO
#include <zlib.h>
#define NDEBUG

View file

@ -19,7 +19,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup
* FILE: base/setup/usetup/native/utils/console.c
* FILE: base/setup/usetup/console.c
* PURPOSE: Console support functions
* PROGRAMMER: Eric Kohl
*/

View file

@ -19,7 +19,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup
* FILE: base/setup/usetup/native/utils/console.h
* FILE: base/setup/usetup/console.h
* PURPOSE: Console support functions
* PROGRAMMER: Eric Kohl
*/
@ -124,7 +124,6 @@ WriteConsoleOutputCharacterW(
BOOL
WINAPI
SetConsoleOutputCP(
IN UINT wCodePageID
);
IN UINT wCodePageID);
/* EOF */

View file

@ -46,7 +46,7 @@ CONSOLE_Init(
VOID)
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (!HOST_InitConsole())
if (!AllocConsole())
return FALSE;
StdInput = GetStdHandle(STD_INPUT_HANDLE);
@ -334,20 +334,12 @@ CONSOLE_SetInputTextXY(
&Written);
coPos.X += Length;
FillConsoleOutputCharacterA(
StdOutput,
'_',
1,
coPos,
&Written);
if (len > Length + 1)
if (len > Length)
{
coPos.X++;
FillConsoleOutputCharacterA(
StdOutput,
' ',
len - Length - 1,
len - Length,
coPos,
&Written);
}

View file

@ -238,7 +238,6 @@ SetupCopyFile(
SIZE_T SourceSectionSize = 0;
LARGE_INTEGER ByteOffset;
#ifdef __REACTOS__
RtlInitUnicodeString(&FileName,
SourceFileName);
@ -259,20 +258,6 @@ SetupCopyFile(
DPRINT1("NtOpenFile failed: %x, %wZ\n", Status, &FileName);
goto done;
}
#else
FileHandleSource = CreateFileW(SourceFileName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);
if (FileHandleSource == INVALID_HANDLE_VALUE)
{
Status = STATUS_UNSUCCESSFUL;
goto done;
}
#endif
Status = NtQueryInformationFile(FileHandleSource,
&IoStatusBlock,
@ -409,7 +394,7 @@ done:
return Status;
}
#ifdef __REACTOS__
NTSTATUS
SetupExtractFile(
PWCHAR CabinetFileName,
@ -487,7 +472,7 @@ SetupExtractFile(
return STATUS_SUCCESS;
}
#endif
BOOLEAN
DoesFileExist(

View file

@ -33,7 +33,7 @@
/* FUNCTIONS ****************************************************************/
VOID
FS_AddProvider(
AddProvider(
IN OUT PFILE_SYSTEM_LIST List,
IN LPCWSTR FileSystemName,
IN FORMATEX FormatFunc,
@ -175,12 +175,12 @@ CreateFileSystemList(
List->Selected = NULL;
InitializeListHead(&List->ListHead);
HOST_CreateFileSystemList(List);
AddProvider(List, L"FAT", VfatFormat, VfatChkdsk);
if (!ForceFormat)
{
/* Add 'Keep' provider */
FS_AddProvider(List, NULL, NULL, NULL);
AddProvider(List, NULL, NULL, NULL);
}
/* Search for ForceFileSystem in list */

View file

@ -1,31 +0,0 @@
#ifdef __REACTOS__
#include "native/host_native.h"
#define HOST_InitConsole NATIVE_InitConsole
#define HOST_InitMemory NATIVE_InitMemory
#define HOST_CreateFileSystemList NATIVE_CreateFileSystemList
#else
#include "win32/host_win32.h"
#define HOST_InitConsole WIN32_InitConsole
#define HOST_InitMemory WIN32_InitMemory
#define HOST_CreateFileSystemList WIN32_CreateFileSystemList
#endif
BOOLEAN
HOST_InitConsole(VOID);
BOOLEAN
HOST_InitMemory(VOID);
BOOLEAN
HOST_CreateFileSystemList(
IN PFILE_SYSTEM_LIST List);
BOOLEAN
HOST_FormatPartition(
IN PFILE_SYSTEM_ITEM FileSystem,
IN PCUNICODE_STRING DriveRoot,
IN PFMIFSCALLBACK Callback);

View file

@ -33,8 +33,6 @@
/* FUNCTIONS *****************************************************************/
#ifdef __REACTOS__
BOOL
WINAPI
InfpFindFirstLineW(
@ -81,7 +79,6 @@ InfpOpenInfFileW(
return hInf;
}
#endif /* __REACTOS__ */
BOOLEAN
@ -90,54 +87,7 @@ INF_GetData(
OUT PWCHAR *Key,
OUT PWCHAR *Data)
{
#ifdef __REACTOS__
return InfGetData(Context, Key, Data);
#else
static PWCHAR pLastCallData[4] = { NULL, NULL, NULL, NULL };
static DWORD currentIndex = 0;
DWORD dwSize, i;
BOOL ret;
currentIndex ^= 2;
if (Key)
*Key = NULL;
if (Data)
*Data = NULL;
if (SetupGetFieldCount(Context) != 1)
return FALSE;
for (i = 0; i <= 1; i++)
{
ret = SetupGetStringFieldW(Context,
i,
NULL,
0,
&dwSize);
if (!ret)
return FALSE;
HeapFree(GetProcessHeap(), 0, pLastCallData[i + currentIndex]);
pLastCallData[i + currentIndex] = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
ret = SetupGetStringFieldW(Context,
i,
pLastCallData[i + currentIndex],
dwSize,
NULL);
if (!ret)
return FALSE;
}
if (Key)
*Key = pLastCallData[0 + currentIndex];
if (Data)
*Data = pLastCallData[1 + currentIndex];
return TRUE;
#endif /* !__REACTOS__ */
}
@ -147,38 +97,7 @@ INF_GetDataField(
IN ULONG FieldIndex,
OUT PWCHAR *Data)
{
#ifdef __REACTOS__
return InfGetDataField(Context, FieldIndex, Data);
#else
static PWCHAR pLastCallsData[] = { NULL, NULL, NULL };
static DWORD NextIndex = 0;
DWORD dwSize;
BOOL ret;
*Data = NULL;
ret = SetupGetStringFieldW(Context,
FieldIndex,
NULL,
0,
&dwSize);
if (!ret)
return FALSE;
HeapFree(GetProcessHeap(), 0, pLastCallsData[NextIndex]);
pLastCallsData[NextIndex] = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
ret = SetupGetStringFieldW(Context,
FieldIndex,
pLastCallsData[NextIndex],
dwSize,
NULL);
if (!ret)
return FALSE;
*Data = pLastCallsData[NextIndex];
NextIndex = (NextIndex + 1) % (sizeof(pLastCallsData) / sizeof(pLastCallsData[0]));
return TRUE;
#endif /* !__REACTOS__ */
}
@ -191,7 +110,6 @@ INF_OpenBufferedFileA(
IN LCID LocaleId,
OUT PUINT ErrorLine)
{
#ifdef __REACTOS__
HINF hInf = NULL;
ULONG ErrorLineUL;
NTSTATUS Status;
@ -206,9 +124,6 @@ INF_OpenBufferedFileA(
return INVALID_HANDLE_VALUE;
return hInf;
#else
return INVALID_HANDLE_VALUE;
#endif /* !__REACTOS__ */
}
/* EOF */

View file

@ -26,12 +26,6 @@
#pragma once
#ifndef __REACTOS__
#include <setupapi.h>
#else /* __REACTOS__ */
#include <infcommon.h>
#define SetupFindFirstLineW InfpFindFirstLineW
@ -69,8 +63,6 @@ InfpOpenInfFileW(
IN LCID LocaleId,
OUT PUINT ErrorLine);
#endif /* __REACTOS__ */
BOOLEAN
INF_GetData(
IN PINFCONTEXT Context,

View file

@ -19,7 +19,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup
* FILE: base/setup/usetup/native/utils/keytrans.c
* FILE: base/setup/usetup/keytrans.c
* PURPOSE: Console support functions: keyboard translation
* PROGRAMMER: Tinus
*

View file

@ -18,7 +18,7 @@
*/
/* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup
* FILE: base/setup/usetup/native/utils/keytrans.h
* FILE: base/setup/usetup/keytrans.h
* PURPOSE: Keyboard translation functionality
* PROGRAMMER: Tinus
*/

View file

@ -1,7 +0,0 @@
#include <usetup.h>
BOOLEAN
NATIVE_InitConsole(VOID)
{
return (BOOLEAN)AllocConsole();
}

View file

@ -1,31 +0,0 @@
#include <usetup.h>
BOOLEAN
NATIVE_CreateFileSystemList(
IN PFILE_SYSTEM_LIST List)
{
FS_AddProvider(List, L"FAT", VfatFormat, VfatChkdsk);
#if 0
FS_AddProvider(List, L"EXT2", Ext2Format, Ext2Chkdsk);
FS_AddProvider(List, L"NTFS", NtfsFormat, NtfsChkdsk);
#endif
return TRUE;
}
BOOLEAN
NATIVE_FormatPartition(
IN PFILE_SYSTEM_ITEM FileSystem,
IN PCUNICODE_STRING DriveRoot,
IN PFMIFSCALLBACK Callback)
{
NTSTATUS Status;
Status = FileSystem->FormatFunc((PUNICODE_STRING)DriveRoot,
FMIFS_HARDDISK, /* MediaFlag */
NULL, /* Label */
FileSystem->QuickFormat, /* QuickFormat */
0, /* ClusterSize */
Callback); /* Callback */
return NT_SUCCESS(Status);
}

View file

@ -1,5 +0,0 @@
#pragma once
#define SetupInitDefaultQueueCallback(a) NULL
#define SetupDefaultQueueCallbackW(a, b, c, d) TRUE
#define SetupTermDefaultQueueCallback(a)

View file

@ -63,8 +63,6 @@ typedef struct _PARTENTRY
ULONG PartitionIndex;
CHAR DriveLetter;
CHAR VolumeLabel[17];
CHAR FileSystemName[9];
BOOLEAN LogicalPartition;

View file

@ -31,7 +31,6 @@
#define NDEBUG
#include <debug.h>
#ifdef __REACTOS__
#define FLG_ADDREG_BINVALUETYPE 0x00000001
#define FLG_ADDREG_NOCLOBBER 0x00000002
#define FLG_ADDREG_DELVAL 0x00000004
@ -45,7 +44,6 @@
#define FLG_ADDREG_TYPE_DWORD (0x00010000 | FLG_ADDREG_BINVALUETYPE)
#define FLG_ADDREG_TYPE_NONE (0x00020000 | FLG_ADDREG_BINVALUETYPE)
#define FLG_ADDREG_TYPE_MASK (0xFFFF0000 | FLG_ADDREG_BINVALUETYPE)
#endif
#ifdef _M_IX86
#define Architecture L"x86"
@ -324,16 +322,12 @@ do_reg_operation(HANDLE KeyHandle,
DPRINT("setting dword %wZ to %lx\n", ValueName, dw);
#ifdef __REACTOS__
NtSetValueKey (KeyHandle,
ValueName,
0,
Type,
(PVOID)&dw,
sizeof(ULONG));
#else
RegSetValueExW(KeyHandle, ValueName, 0, Type, (const UCHAR*)&dw, sizeof(ULONG));
#endif
}
else
{
@ -341,29 +335,21 @@ do_reg_operation(HANDLE KeyHandle,
if (Str)
{
#ifdef __REACTOS__
NtSetValueKey (KeyHandle,
ValueName,
0,
Type,
(PVOID)Str,
Size * sizeof(WCHAR));
#else
RegSetValueExW(KeyHandle, ValueName, 0, Type, (const UCHAR*)Str, Size * sizeof(WCHAR));
#endif
}
else
{
#ifdef __REACTOS__
NtSetValueKey (KeyHandle,
ValueName,
0,
Type,
(PVOID)&EmptyStr,
sizeof(WCHAR));
#else
RegSetValueExW(KeyHandle, ValueName, 0, Type, (const UCHAR*)&EmptyStr, sizeof(WCHAR));
#endif
}
}
RtlFreeHeap (ProcessHeap, 0, Str);
@ -385,16 +371,12 @@ do_reg_operation(HANDLE KeyHandle,
SetupGetBinaryField (Context, 5, Data, Size, NULL);
}
#ifdef __REACTOS__
NtSetValueKey (KeyHandle,
ValueName,
0,
Type,
(PVOID)Data,
Size);
#else
RegSetValueExW(KeyHandle, ValueName, 0, Type, (const UCHAR*)Data, Size);
#endif
RtlFreeHeap (ProcessHeap, 0, Data);
}
@ -402,7 +384,6 @@ do_reg_operation(HANDLE KeyHandle,
return TRUE;
}
#ifdef __REACTOS__
NTSTATUS
CreateNestedKey (PHANDLE KeyHandle,
ACCESS_MASK DesiredAccess,
@ -494,7 +475,6 @@ CreateNestedKey (PHANDLE KeyHandle,
return Status;
}
#endif
/***********************************************************************
* registry_callback
@ -543,7 +523,6 @@ registry_callback(HINF hInf, PCWSTR Section, BOOLEAN Delete)
DPRINT("Flags: %lx\n", Flags);
#ifdef __REACTOS__
RtlInitUnicodeString (&Name,
Buffer);
@ -575,26 +554,6 @@ registry_callback(HINF hInf, PCWSTR Section, BOOLEAN Delete)
continue;
}
}
#else
if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY))
{
LONG rc = RegOpenKeyW(NULL, Buffer, &KeyHandle);
if (rc != ERROR_SUCCESS)
{
DPRINT("RegOpenKeyW(%S) failed (error %lu)\n", Buffer, rc);
continue; /* ignore if it doesn't exist */
}
}
else
{
LONG rc = RegCreateKeyW(NULL, Buffer, &KeyHandle);
if (rc != ERROR_SUCCESS)
{
DPRINT("RegCreateKeyW(%S) failed (error %lu)\n", Buffer, rc);
continue;
}
}
#endif
/* get value name */
if (SetupGetStringFieldW (&Context, 3, Buffer, MAX_INF_STRING_LENGTH, NULL))
@ -615,9 +574,7 @@ registry_callback(HINF hInf, PCWSTR Section, BOOLEAN Delete)
return FALSE;
}
#ifdef __REACTOS__
NtClose (KeyHandle);
#endif
}
}

View file

@ -3760,7 +3760,6 @@ PrepareCopyPage(PINPUT_RECORD Ir)
wcscat(PathBuffer, L"\\");
wcscat(PathBuffer, KeyValue);
#ifdef __REACTOS__
CabinetInitialize();
CabinetSetEventHandlers(NULL, NULL, NULL);
CabinetSetCabinetName(PathBuffer);
@ -3803,7 +3802,6 @@ PrepareCopyPage(PINPUT_RECORD Ir)
/* FIXME: show an error dialog */
return QUIT_PAGE;
}
#endif
} while (SetupFindNextLine(&CabinetsContext, &CabinetsContext));
return FILE_COPY_PAGE;
@ -4834,8 +4832,6 @@ RunUSetup(VOID)
}
#ifdef __REACTOS__
VOID NTAPI
NtProcessStartup(PPEB Peb)
{
@ -4845,6 +4841,5 @@ NtProcessStartup(PPEB Peb)
InfSetHeap(ProcessHeap);
RunUSetup();
}
#endif /* __REACTOS__ */
/* EOF */

View file

@ -63,17 +63,14 @@
#include "inffile.h"
#include "inicache.h"
#include "progress.h"
#ifdef __REACTOS__
#include "infros.h"
#include "filequeue.h"
#endif
#include "registry.h"
#include "fslist.h"
#include "partlist.h"
#include "cabinet.h"
#include "filesup.h"
#include "genlist.h"
#include "host.h"
#include "mui.h"
#include "errorcode.h"
@ -84,8 +81,6 @@ extern UNICODE_STRING SourcePath;
extern BOOLEAN IsUnattendedSetup;
extern PWCHAR SelectedLanguageId;
#ifdef __REACTOS__
extern VOID InfSetHeap(PVOID Heap);
extern VOID InfCloseFile(HINF InfHandle);
extern BOOLEAN InfFindNextLine(PINFCONTEXT ContextIn,
@ -112,8 +107,6 @@ extern BOOLEAN InfGetStringField(PINFCONTEXT Context,
#define SetupGetMultiSzFieldW InfGetMultiSzField
#define SetupGetStringFieldW InfGetStringField
#endif /* __REACTOS__ */
#ifndef _PAGE_NUMBER_DEFINED
#define _PAGE_NUMBER_DEFINED
typedef enum _PAGE_NUMBER

View file

@ -1,6 +1,4 @@
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Setup"
#define REACTOS_STR_INTERNAL_NAME "usetup"
#define REACTOS_STR_ORIGINAL_FILENAME "usetup.dll"
#ifdef __REACTOS__
#define REACTOS_STR_ORIGINAL_FILENAME "usetup.exe"
#include <reactos/version.rc>
#endif

View file

@ -84,7 +84,6 @@ add_library(mbedtls SHARED
${CMAKE_CURRENT_BINARY_DIR}/mbedtls.def)
set_module_type(mbedtls win32dll)
target_link_libraries(mbedtls zlib)
add_importlibs(mbedtls advapi32 msvcrt kernel32 ntdll)
# to use `_vsnprintf_s` looks like we have to define MINGW_HAS_SECURE_API