[SYSSETUP][NETCFGX][INF] Install the TCPIP protocol driver properly
[reactos.git] / dll / win32 / syssetup / install.c
index fa1d52b..7ce1aaa 100644 (file)
@@ -734,70 +734,6 @@ Exit:
     return bResult;
 }
 
-/* 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 = ARRAYSIZE(Buffer) - 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;
-}
-
 static
 DWORD
 InstallLiveCD(VOID)
@@ -806,14 +742,14 @@ InstallLiveCD(VOID)
     PROCESS_INFORMATION ProcessInformation;
     BOOL bRes;
 
-    /* Hack: Install TCP/IP protocol driver */
-    bRes = InstallInfSection(NULL,
-                             L"nettcpip.inf",
-                             L"MS_TCPIP.PrimaryInstall",
-                             L"MS_TCPIP.PrimaryInstall.Services");
+    if (!CommonInstall())
+        goto error;
+
+    /* Install the TCP/IP protocol driver */
+    bRes = InstallNetworkComponent(L"MS_TCPIP");
     if (!bRes && GetLastError() != ERROR_FILE_NOT_FOUND)
     {
-        DPRINT("InstallInfSection() failed with error 0x%lx\n", GetLastError());
+        DPRINT("InstallNetworkComponent() failed with error 0x%lx\n", GetLastError());
     }
     else
     {
@@ -822,9 +758,6 @@ InstallLiveCD(VOID)
         SetupStartService(L"Dhcp", FALSE);
     }
 
-    if (!CommonInstall())
-        goto error;
-
     /* Register components */
     _SEH2_TRY
     {
@@ -1327,14 +1260,14 @@ InstallReactOS(VOID)
 
     hHotkeyThread = CreateThread(NULL, 0, HotkeyThread, NULL, 0, NULL);
 
-    /* Hack: Install TCP/IP protocol driver */
-    ret = InstallInfSection(NULL,
-                            L"nettcpip.inf",
-                            L"MS_TCPIP.PrimaryInstall",
-                            L"MS_TCPIP.PrimaryInstall.Services");
+    if (!CommonInstall())
+        return 0;
+
+    /* Install the TCP/IP protocol driver */
+    ret = InstallNetworkComponent(L"MS_TCPIP");
     if (!ret && GetLastError() != ERROR_FILE_NOT_FOUND)
     {
-        DPRINT("InstallInfSection() failed with error 0x%lx\n", GetLastError());
+        DPRINT("InstallNetworkComponent() failed with error 0x%lx\n", GetLastError());
     }
     else
     {
@@ -1343,10 +1276,6 @@ InstallReactOS(VOID)
         SetupStartService(L"Dhcp", FALSE);
     }
 
-
-    if (!CommonInstall())
-        return 0;
-
     InstallWizard();
 
     InstallSecurity();