From e8127690bb968e0157c1478cdeb295a902017060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Tue, 10 Jan 2017 16:55:15 +0000 Subject: [PATCH] [SETUP][SYSSETUP]: Export a 'InstallWindowsNt' function from syssetup.dll (with Windows-compatible signature) instead of our private 'InstallReactOS' and 'InstallLiveCD', and call it from setup.exe. This allows using our setup.exe on Windows & vice-versa for testing purposes. In syssetup.dll, the choice of installing ReactOS or starting the LiveCD interface is done by checking the command-line given to 'InstallWindowsNt' (using the existing switches). Inspired from Jared's patch in CORE-12615. svn path=/trunk/; revision=73519 --- reactos/base/setup/setup/CMakeLists.txt | 2 +- reactos/base/setup/setup/setup.c | 134 ++++-------------- reactos/dll/win32/syssetup/install.c | 42 +++++- reactos/dll/win32/syssetup/syssetup.spec | 3 +- .../include/reactos/libs/syssetup/syssetup.h | 5 - 5 files changed, 71 insertions(+), 115 deletions(-) diff --git a/reactos/base/setup/setup/CMakeLists.txt b/reactos/base/setup/setup/CMakeLists.txt index 6eae7d22796..985af45fb1e 100644 --- a/reactos/base/setup/setup/CMakeLists.txt +++ b/reactos/base/setup/setup/CMakeLists.txt @@ -1,5 +1,5 @@ add_executable(setup setup.c setup.rc) -set_module_type(setup win32gui UNICODE) +set_module_type(setup win32gui UNICODE ENTRYPOINT wmainCRTStartup) add_importlibs(setup userenv msvcrt kernel32 ntdll) add_cd_file(TARGET setup DESTINATION reactos/system32 FOR all) diff --git a/reactos/base/setup/setup/setup.c b/reactos/base/setup/setup/setup.c index 4c003fe1ed3..59e468dda22 100644 --- a/reactos/base/setup/setup/setup.c +++ b/reactos/base/setup/setup/setup.c @@ -1,21 +1,3 @@ -/* - * ReactOS kernel - * Copyright (C) 2003 ReactOS Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS GUI/console setup @@ -27,124 +9,70 @@ #include #include #include -#include #define NDEBUG #include -typedef DWORD (WINAPI *PINSTALL_REACTOS)(HINSTANCE hInstance); +typedef INT (WINAPI *PINSTALL_REACTOS)(INT argc, WCHAR** argv); /* FUNCTIONS ****************************************************************/ -LPTSTR -lstrchr( - LPCTSTR s, - TCHAR c) -{ - while (*s) - { - if (*s == c) - return (LPTSTR)s; - s++; - } - - if (c == (TCHAR)0) - return (LPTSTR)s; - - return (LPTSTR)NULL; -} - - static -VOID -RunNewSetup( - HINSTANCE hInstance) +INT +RunInstallReactOS(INT argc, WCHAR* argv[]) { + INT RetVal; HMODULE hDll; PINSTALL_REACTOS InstallReactOS; - hDll = LoadLibrary(TEXT("syssetup")); + hDll = LoadLibraryW(L"syssetup.dll"); if (hDll == NULL) { - DPRINT("Failed to load 'syssetup'!\n"); - return; + DPRINT("Failed to load 'syssetup.dll'!\n"); + return GetLastError(); } + DPRINT("Loaded 'syssetup.dll'!\n"); - DPRINT("Loaded 'syssetup'!\n"); - InstallReactOS = (PINSTALL_REACTOS)GetProcAddress(hDll, "InstallReactOS"); + /* Call the standard Windows-compatible export */ + InstallReactOS = (PINSTALL_REACTOS)GetProcAddress(hDll, "InstallWindowsNt"); if (InstallReactOS == NULL) { - DPRINT("Failed to get address for 'InstallReactOS()'!\n"); - FreeLibrary(hDll); - return; + RetVal = GetLastError(); + DPRINT("Failed to get address for 'InstallWindowsNt()'!\n"); + } + else + { + RetVal = InstallReactOS(argc, argv); } - InstallReactOS(hInstance); - FreeLibrary(hDll); + return RetVal; } -static -VOID -RunLiveCD( - HINSTANCE hInstance) +/* Called from wmainCRTStartup */ +INT wmain(INT argc, WCHAR* argv[]) { - HMODULE hDll; - PINSTALL_REACTOS InstallLiveCD; + LPWSTR CmdLine, p; - hDll = LoadLibrary(TEXT("syssetup")); - if (hDll == NULL) - { - DPRINT("Failed to load 'syssetup'!\n"); - return; - } + // NOTE: Temporary, until we correctly use argc/argv. + CmdLine = GetCommandLineW(); + DPRINT("CmdLine: <%S>\n", CmdLine); - DPRINT("Loaded 'syssetup'!\n"); - InstallLiveCD = (PINSTALL_REACTOS)GetProcAddress(hDll, "InstallLiveCD"); - if (InstallLiveCD == NULL) - { - DPRINT("Failed to get address for 'InstallReactOS()'!\n"); - FreeLibrary(hDll); - return; - } - - InstallLiveCD(hInstance); - - FreeLibrary(hDll); -} - - -int -WINAPI -_tWinMain( - HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, - int nShowCmd) -{ - LPTSTR CmdLine; - LPTSTR p; - - CmdLine = GetCommandLine(); - - DPRINT("CmdLine: <%s>\n",CmdLine); - - p = lstrchr(CmdLine, TEXT('-')); + p = wcschr(CmdLine, L'-'); if (p == NULL) - return 0; + return ERROR_INVALID_PARAMETER; + p++; - if (!lstrcmpi(p, TEXT("-newsetup"))) + // NOTE: On Windows, "mini" means "minimal UI", and can be used + // in addition to "newsetup"; these options are not exclusive. + if (_wcsicmp(p, L"newsetup") == 0 || _wcsicmp(p, L"mini") == 0) { - RunNewSetup(hInstance); - } - else if (!lstrcmpi(p, TEXT("-mini"))) - { - RunLiveCD(hInstance); + RunInstallReactOS(argc, argv); } #if 0 - /* Add new setup types here */ + /* Add new setup types here */ else if (...) { diff --git a/reactos/dll/win32/syssetup/install.c b/reactos/dll/win32/syssetup/install.c index 15b9fce0b4d..60b684d7a93 100644 --- a/reactos/dll/win32/syssetup/install.c +++ b/reactos/dll/win32/syssetup/install.c @@ -814,8 +814,9 @@ cleanup: return ret; } -DWORD WINAPI -InstallLiveCD(IN HINSTANCE hInstance) +static +DWORD +InstallLiveCD(VOID) { STARTUPINFOW StartupInfo; PROCESS_INFORMATION ProcessInformation; @@ -1193,9 +1194,9 @@ done: } +static DWORD -WINAPI -InstallReactOS(HINSTANCE hInstance) +InstallReactOS(VOID) { WCHAR szBuffer[MAX_PATH]; HANDLE token; @@ -1353,6 +1354,39 @@ InstallReactOS(HINSTANCE hInstance) } +/* + * Standard Windows-compatible export, which dispatches + * to either 'InstallReactOS' or 'InstallLiveCD'. + */ +INT +WINAPI +InstallWindowsNt(INT argc, WCHAR** argv) +{ + INT i; + PWSTR p; + + for (i = 0; i < argc; ++i) + { + p = argv[i]; + if (*p == L'-') + { + p++; + + // NOTE: On Windows, "mini" means "minimal UI", and can be used + // in addition to "newsetup"; these options are not exclusive. + if (_wcsicmp(p, L"newsetup") == 0) + return (INT)InstallReactOS(); + else if (_wcsicmp(p, L"mini") == 0) + return (INT)InstallLiveCD(); + + /* Add support for other switches */ + } + } + + return 0; +} + + /* * @unimplemented */ diff --git a/reactos/dll/win32/syssetup/syssetup.spec b/reactos/dll/win32/syssetup/syssetup.spec index ed4e0e18724..6f5391db332 100644 --- a/reactos/dll/win32/syssetup/syssetup.spec +++ b/reactos/dll/win32/syssetup/syssetup.spec @@ -22,8 +22,7 @@ @ stub GenerateName @ stdcall HdcClassInstaller(long ptr ptr) @ stdcall InitializeSetupActionLog(long) -@ stdcall InstallLiveCD(ptr) -@ stdcall InstallReactOS(ptr) +@ stdcall InstallWindowsNt(long ptr) @ stub InvokeExternalApplicationEx @ stdcall KeyboardClassInstaller(long ptr ptr) @ stub LegacyDriverPropPageProvider diff --git a/reactos/sdk/include/reactos/libs/syssetup/syssetup.h b/reactos/sdk/include/reactos/libs/syssetup/syssetup.h index 5d888c779f8..03c7c70c5dc 100644 --- a/reactos/sdk/include/reactos/libs/syssetup/syssetup.h +++ b/reactos/sdk/include/reactos/libs/syssetup/syssetup.h @@ -72,11 +72,6 @@ typedef struct _SETUPDATA /* System setup APIs */ -DWORD -WINAPI -InstallReactOS( - HINSTANCE hInstance); - NTSTATUS WINAPI SetAccountsDomainSid(