Author: ekohl
Date: Tue Jan 20 20:57:58 2015
New Revision: 66069
URL:
http://svn.reactos.org/svn/reactos?rev=66069&view=rev
Log:
[NETCFGX][SYSSETUP]
- Move TCP/IP driver setup code from netcfgx to syssetup.
- Implement SetupStartService().
This installs the TCPIP driver even if no network adapter is available.
CORE-8420 #resolve
Modified:
trunk/reactos/dll/win32/netcfgx/netcfgx.c
trunk/reactos/dll/win32/syssetup/install.c
trunk/reactos/dll/win32/syssetup/syssetup.spec
Modified: trunk/reactos/dll/win32/netcfgx/netcfgx.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netcfgx/netcfgx.…
==============================================================================
--- trunk/reactos/dll/win32/netcfgx/netcfgx.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netcfgx/netcfgx.c [iso-8859-1] Tue Jan 20 20:57:58 2015
@@ -219,106 +219,6 @@
return rc;
}
-/* Install a section of a .inf file
- * Returns TRUE if success, FALSE if failure. Error code can
- * be retrieved with GetLastError()
- */
-static
-BOOL
-InstallInfSection(
- IN HWND hWnd,
- IN LPCWSTR InfFile,
- IN LPCWSTR InfSection OPTIONAL,
- IN LPCWSTR InfService OPTIONAL)
-{
- WCHAR Buffer[MAX_PATH];
- HINF hInf = INVALID_HANDLE_VALUE;
- UINT BufferSize;
- PVOID Context = NULL;
- BOOL ret = FALSE;
-
- /* Get Windows directory */
- BufferSize = MAX_PATH - 5 - wcslen(InfFile);
- if (GetWindowsDirectoryW(Buffer, BufferSize) > BufferSize)
- {
- /* Function failed */
- SetLastError(ERROR_GEN_FAILURE);
- goto cleanup;
- }
- /* We have enough space to add some information in the buffer */
- if (Buffer[wcslen(Buffer) - 1] != '\\')
- wcscat(Buffer, L"\\");
- wcscat(Buffer, L"Inf\\");
- wcscat(Buffer, InfFile);
-
- /* Install specified section */
- hInf = SetupOpenInfFileW(Buffer, NULL, INF_STYLE_WIN4, NULL);
- if (hInf == INVALID_HANDLE_VALUE)
- goto cleanup;
-
- Context = SetupInitDefaultQueueCallback(hWnd);
- if (Context == NULL)
- goto cleanup;
-
- ret = TRUE;
- if (ret && InfSection)
- {
- ret = SetupInstallFromInfSectionW(
- hWnd, hInf,
- InfSection, SPINST_ALL,
- NULL, NULL, SP_COPY_NEWER,
- SetupDefaultQueueCallbackW, Context,
- NULL, NULL);
- }
- if (ret && InfService)
- {
- ret = SetupInstallServicesFromInfSectionW(
- hInf, InfService, 0);
- }
-
-cleanup:
- if (Context)
- SetupTermDefaultQueueCallback(Context);
- if (hInf != INVALID_HANDLE_VALUE)
- SetupCloseInfFile(hInf);
- return ret;
-}
-
-/* Add default services for network cards */
-static
-DWORD
-InstallAdditionalServices(
- IN HWND hWnd)
-{
- BOOL ret;
- UNICODE_STRING TcpipServicePath =
RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Tcpip");
-
- /* Install TCP/IP protocol */
- ret = InstallInfSection(hWnd,
- L"nettcpip.inf",
- L"MS_TCPIP.PrimaryInstall",
- L"MS_TCPIP.PrimaryInstall.Services");
- if (!ret && GetLastError() != ERROR_FILE_NOT_FOUND)
- {
- DPRINT("InstallInfSection() failed with error 0x%lx\n",
GetLastError());
- return GetLastError();
- }
- else if (ret)
- {
- /* Start the TCP/IP driver */
- ret = NtLoadDriver(&TcpipServicePath);
- if (ret)
- {
- /* This isn't really fatal but we want to warn anyway */
- DPRINT1("NtLoadDriver(TCPIP) failed with NTSTATUS 0x%lx\n",
(NTSTATUS)ret);
- }
- }
-
-
- /* You can add here more clients (SMB...) and services (DHCP server...) */
-
- return ERROR_SUCCESS;
-}
static
DWORD
@@ -586,14 +486,6 @@
if (rc != ERROR_SUCCESS)
{
DPRINT("AppendStringToMultiSZ() failed with error 0x%lx\n", rc);
- goto cleanup;
- }
-
- /* Install additionnal services */
- rc = InstallAdditionalServices(NULL);
- if (rc != ERROR_SUCCESS)
- {
- DPRINT("InstallAdditionalServices() failed with error 0x%lx\n", rc);
goto cleanup;
}
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 20 20:57:58 2015
@@ -43,6 +43,9 @@
DWORD WINAPI
CMP_WaitNoPendingInstallEvents(DWORD dwTimeout);
+DWORD WINAPI
+SetupStartService(LPCWSTR lpServiceName, BOOL bWait);
+
/* GLOBALS ******************************************************************/
HINF hSysSetupInf = INVALID_HANDLE_VALUE;
@@ -843,6 +846,72 @@
return TRUE;
}
+/* Install a section of a .inf file
+ * Returns TRUE if success, FALSE if failure. Error code can
+ * be retrieved with GetLastError()
+ */
+static
+BOOL
+InstallInfSection(
+ IN HWND hWnd,
+ IN LPCWSTR InfFile,
+ IN LPCWSTR InfSection OPTIONAL,
+ IN LPCWSTR InfService OPTIONAL)
+{
+ WCHAR Buffer[MAX_PATH];
+ HINF hInf = INVALID_HANDLE_VALUE;
+ UINT BufferSize;
+ PVOID Context = NULL;
+ BOOL ret = FALSE;
+
+ /* Get Windows directory */
+ BufferSize = MAX_PATH - 5 - wcslen(InfFile);
+ if (GetWindowsDirectoryW(Buffer, BufferSize) > BufferSize)
+ {
+ /* Function failed */
+ SetLastError(ERROR_GEN_FAILURE);
+ goto cleanup;
+ }
+ /* We have enough space to add some information in the buffer */
+ if (Buffer[wcslen(Buffer) - 1] != '\\')
+ wcscat(Buffer, L"\\");
+ wcscat(Buffer, L"Inf\\");
+ wcscat(Buffer, InfFile);
+
+ /* Install specified section */
+ hInf = SetupOpenInfFileW(Buffer, NULL, INF_STYLE_WIN4, NULL);
+ if (hInf == INVALID_HANDLE_VALUE)
+ goto cleanup;
+
+ Context = SetupInitDefaultQueueCallback(hWnd);
+ if (Context == NULL)
+ goto cleanup;
+
+ ret = TRUE;
+ if (ret && InfSection)
+ {
+ ret = SetupInstallFromInfSectionW(
+ hWnd, hInf,
+ InfSection, SPINST_ALL,
+ NULL, NULL, SP_COPY_NEWER,
+ SetupDefaultQueueCallbackW, Context,
+ NULL, NULL);
+ }
+ if (ret && InfService)
+ {
+ ret = SetupInstallServicesFromInfSectionW(
+ hInf, InfService, 0);
+ }
+
+cleanup:
+ if (Context)
+ SetupTermDefaultQueueCallback(Context);
+ if (hInf != INVALID_HANDLE_VALUE)
+ SetupCloseInfFile(hInf);
+ return ret;
+}
+
+
DWORD WINAPI
InstallReactOS(HINSTANCE hInstance)
{
@@ -851,6 +920,7 @@
TOKEN_PRIVILEGES privs;
HKEY hKey;
HINF hShortcutsInf;
+ BOOL ret;
InitializeSetupActionLog(FALSE);
LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS");
@@ -893,6 +963,22 @@
_tcscat(szBuffer, _T("system"));
CreateDirectory(szBuffer, NULL);
}
+
+ /* Hack: Install TCP/IP protocol driver */
+ ret = InstallInfSection(NULL,
+ L"nettcpip.inf",
+ L"MS_TCPIP.PrimaryInstall",
+ L"MS_TCPIP.PrimaryInstall.Services");
+ if (!ret && GetLastError() != ERROR_FILE_NOT_FOUND)
+ {
+ DPRINT("InstallInfSection() failed with error 0x%lx\n",
GetLastError());
+ }
+ else
+ {
+ /* Start the TCP/IP protocol driver */
+ SetupStartService(L"Tcpip", FALSE);
+ }
+
if (!CommonInstall())
return 0;
@@ -1039,3 +1125,48 @@
{
return SetupChangeLocaleEx(hWnd, Lcid, NULL, 0, 0, 0);
}
+
+
+DWORD
+WINAPI
+SetupStartService(
+ LPCWSTR lpServiceName,
+ BOOL bWait)
+{
+ SC_HANDLE hManager = NULL;
+ SC_HANDLE hService = NULL;
+ DWORD dwError = ERROR_SUCCESS;
+
+ hManager = OpenSCManagerW(NULL,
+ NULL,
+ SC_MANAGER_ALL_ACCESS);
+ if (hManager == NULL)
+ {
+ dwError = GetLastError();
+ goto done;
+ }
+
+ hService = OpenServiceW(hManager,
+ lpServiceName,
+ SERVICE_START);
+ if (hService == NULL)
+ {
+ dwError = GetLastError();
+ goto done;
+ }
+
+ if (!StartService(hService, 0, NULL))
+ {
+ dwError = GetLastError();
+ goto done;
+ }
+
+done:
+ if (hService != NULL)
+ CloseServiceHandle(hService);
+
+ if (hManager != NULL)
+ CloseServiceHandle(hManager);
+
+ return dwError;
+}
Modified: trunk/reactos/dll/win32/syssetup/syssetup.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/syssetu…
==============================================================================
--- trunk/reactos/dll/win32/syssetup/syssetup.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/syssetup.spec [iso-8859-1] Tue Jan 20 20:57:58 2015
@@ -72,7 +72,7 @@
@ stub SetupSetRegisteredOsComponentsOrder
@ stub SetupSetSetupInfo
@ stub SetupShellSettings
-@ stub SetupStartService
+@ stdcall SetupStartService(wstr long)
@ stub SetupUnregisterOsComponent
@ stub StorageCoInstaller
@ stub SystemUpdateUserProfileDirectory