Author: hbelusca Date: Tue Jan 10 16:55:15 2017 New Revision: 73519
URL: http://svn.reactos.org/svn/reactos?rev=73519&view=rev Log: [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.
Modified: trunk/reactos/base/setup/setup/CMakeLists.txt trunk/reactos/base/setup/setup/setup.c trunk/reactos/dll/win32/syssetup/install.c trunk/reactos/dll/win32/syssetup/syssetup.spec trunk/reactos/sdk/include/reactos/libs/syssetup/syssetup.h
Modified: trunk/reactos/base/setup/setup/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/setup/CMakeLists... ============================================================================== --- trunk/reactos/base/setup/setup/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/setup/setup/CMakeLists.txt [iso-8859-1] Tue Jan 10 16:55:15 2017 @@ -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)
Modified: trunk/reactos/base/setup/setup/setup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/setup/setup.c?re... ============================================================================== --- trunk/reactos/base/setup/setup/setup.c [iso-8859-1] (original) +++ trunk/reactos/base/setup/setup/setup.c [iso-8859-1] Tue Jan 10 16:55:15 2017 @@ -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 <stdarg.h> #include <windef.h> #include <winbase.h> -#include <tchar.h>
#define NDEBUG #include <debug.h>
-typedef DWORD (WINAPI *PINSTALL_REACTOS)(HINSTANCE hInstance); +typedef INT (WINAPI *PINSTALL_REACTOS)(INT argc, WCHAR** argv);
/* FUNCTIONS ****************************************************************/
-LPTSTR -lstrchr( - LPCTSTR s, - TCHAR c) +static +INT +RunInstallReactOS(INT argc, WCHAR* argv[]) { - while (*s) + INT RetVal; + HMODULE hDll; + PINSTALL_REACTOS InstallReactOS; + + hDll = LoadLibraryW(L"syssetup.dll"); + if (hDll == NULL) { - if (*s == c) - return (LPTSTR)s; - s++; + DPRINT("Failed to load 'syssetup.dll'!\n"); + return GetLastError(); + } + DPRINT("Loaded 'syssetup.dll'!\n"); + + /* Call the standard Windows-compatible export */ + InstallReactOS = (PINSTALL_REACTOS)GetProcAddress(hDll, "InstallWindowsNt"); + if (InstallReactOS == NULL) + { + RetVal = GetLastError(); + DPRINT("Failed to get address for 'InstallWindowsNt()'!\n"); + } + else + { + RetVal = InstallReactOS(argc, argv); }
- if (c == (TCHAR)0) - return (LPTSTR)s; - - return (LPTSTR)NULL; + FreeLibrary(hDll); + return RetVal; }
-static -VOID -RunNewSetup( - HINSTANCE hInstance) +/* Called from wmainCRTStartup */ +INT wmain(INT argc, WCHAR* argv[]) { - HMODULE hDll; - PINSTALL_REACTOS InstallReactOS; + LPWSTR CmdLine, p;
- hDll = LoadLibrary(TEXT("syssetup")); - if (hDll == NULL) + // NOTE: Temporary, until we correctly use argc/argv. + CmdLine = GetCommandLineW(); + DPRINT("CmdLine: <%S>\n", CmdLine); + + p = wcschr(CmdLine, L'-'); + if (p == NULL) + return ERROR_INVALID_PARAMETER; + 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 || _wcsicmp(p, L"mini") == 0) { - DPRINT("Failed to load 'syssetup'!\n"); - return; - } - - DPRINT("Loaded 'syssetup'!\n"); - InstallReactOS = (PINSTALL_REACTOS)GetProcAddress(hDll, "InstallReactOS"); - if (InstallReactOS == NULL) - { - DPRINT("Failed to get address for 'InstallReactOS()'!\n"); - FreeLibrary(hDll); - return; - } - - InstallReactOS(hInstance); - - FreeLibrary(hDll); -} - - -static -VOID -RunLiveCD( - HINSTANCE hInstance) -{ - HMODULE hDll; - PINSTALL_REACTOS InstallLiveCD; - - hDll = LoadLibrary(TEXT("syssetup")); - if (hDll == NULL) - { - DPRINT("Failed to load 'syssetup'!\n"); - return; - } - - 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('-')); - if (p == NULL) - return 0; - - if (!lstrcmpi(p, TEXT("-newsetup"))) - { - 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 (...) {
Modified: trunk/reactos/dll/win32/syssetup/install.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/install.... ============================================================================== --- trunk/reactos/dll/win32/syssetup/install.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/syssetup/install.c [iso-8859-1] Tue Jan 10 16:55:15 2017 @@ -814,8 +814,9 @@ return ret; }
-DWORD WINAPI -InstallLiveCD(IN HINSTANCE hInstance) +static +DWORD +InstallLiveCD(VOID) { STARTUPINFOW StartupInfo; PROCESS_INFORMATION ProcessInformation; @@ -1193,9 +1194,9 @@ }
+static DWORD -WINAPI -InstallReactOS(HINSTANCE hInstance) +InstallReactOS(VOID) { WCHAR szBuffer[MAX_PATH]; HANDLE token; @@ -1349,6 +1350,39 @@ }
ExitWindowsEx(EWX_REBOOT, 0); + return 0; +} + + +/* + * 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; }
Modified: trunk/reactos/dll/win32/syssetup/syssetup.spec URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/syssetup... ============================================================================== --- trunk/reactos/dll/win32/syssetup/syssetup.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/syssetup/syssetup.spec [iso-8859-1] Tue Jan 10 16:55:15 2017 @@ -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
Modified: trunk/reactos/sdk/include/reactos/libs/syssetup/syssetup.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/reactos/libs/sy... ============================================================================== --- trunk/reactos/sdk/include/reactos/libs/syssetup/syssetup.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/reactos/libs/syssetup/syssetup.h [iso-8859-1] Tue Jan 10 16:55:15 2017 @@ -72,11 +72,6 @@
/* System setup APIs */
-DWORD -WINAPI -InstallReactOS( - HINSTANCE hInstance); - NTSTATUS WINAPI SetAccountsDomainSid(