mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 14:37:45 +00:00
[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 svn path=/trunk/; revision=66069
This commit is contained in:
parent
caae20ea25
commit
acf84c8854
|
@ -219,106 +219,6 @@ cleanup:
|
||||||
return rc;
|
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
|
static
|
||||||
DWORD
|
DWORD
|
||||||
|
@ -589,14 +489,6 @@ InstallNetDevice(
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Install additionnal services */
|
|
||||||
rc = InstallAdditionalServices(NULL);
|
|
||||||
if (rc != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
DPRINT("InstallAdditionalServices() failed with error 0x%lx\n", rc);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ERROR_SUCCESS;
|
rc = ERROR_SUCCESS;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
|
@ -43,6 +43,9 @@
|
||||||
DWORD WINAPI
|
DWORD WINAPI
|
||||||
CMP_WaitNoPendingInstallEvents(DWORD dwTimeout);
|
CMP_WaitNoPendingInstallEvents(DWORD dwTimeout);
|
||||||
|
|
||||||
|
DWORD WINAPI
|
||||||
|
SetupStartService(LPCWSTR lpServiceName, BOOL bWait);
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
HINF hSysSetupInf = INVALID_HANDLE_VALUE;
|
HINF hSysSetupInf = INVALID_HANDLE_VALUE;
|
||||||
|
@ -843,6 +846,72 @@ SetSetupType(DWORD dwSetupType)
|
||||||
return TRUE;
|
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
|
DWORD WINAPI
|
||||||
InstallReactOS(HINSTANCE hInstance)
|
InstallReactOS(HINSTANCE hInstance)
|
||||||
{
|
{
|
||||||
|
@ -851,6 +920,7 @@ InstallReactOS(HINSTANCE hInstance)
|
||||||
TOKEN_PRIVILEGES privs;
|
TOKEN_PRIVILEGES privs;
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
HINF hShortcutsInf;
|
HINF hShortcutsInf;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
InitializeSetupActionLog(FALSE);
|
InitializeSetupActionLog(FALSE);
|
||||||
LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS");
|
LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS");
|
||||||
|
@ -894,6 +964,22 @@ InstallReactOS(HINSTANCE hInstance)
|
||||||
CreateDirectory(szBuffer, NULL);
|
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())
|
if (!CommonInstall())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1039,3 +1125,48 @@ SetupChangeLocale(HWND hWnd, LCID Lcid)
|
||||||
{
|
{
|
||||||
return SetupChangeLocaleEx(hWnd, Lcid, NULL, 0, 0, 0);
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
@ stub SetupSetRegisteredOsComponentsOrder
|
@ stub SetupSetRegisteredOsComponentsOrder
|
||||||
@ stub SetupSetSetupInfo
|
@ stub SetupSetSetupInfo
|
||||||
@ stub SetupShellSettings
|
@ stub SetupShellSettings
|
||||||
@ stub SetupStartService
|
@ stdcall SetupStartService(wstr long)
|
||||||
@ stub SetupUnregisterOsComponent
|
@ stub SetupUnregisterOsComponent
|
||||||
@ stub StorageCoInstaller
|
@ stub StorageCoInstaller
|
||||||
@ stub SystemUpdateUserProfileDirectory
|
@ stub SystemUpdateUserProfileDirectory
|
||||||
|
|
Loading…
Reference in a new issue