Index: dll/win32/setupapi/install.c
===================================================================
--- dll/win32/setupapi/install.c	(revision 66794)
+++ dll/win32/setupapi/install.c	(working copy)
@@ -2048,113 +2048,142 @@
 BOOL WINAPI SetupInstallServicesFromInfSectionExW( HINF hinf, PCWSTR sectionname, DWORD flags, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PVOID reserved1, PVOID reserved2 )
 {
     struct DeviceInfoSet *list = NULL;
-    BOOL ret = FALSE;
+    struct needs_callback_info needs_info;
+    INFCONTEXT ContextService;
+    LPWSTR ServiceName = NULL;
+    LPWSTR ServiceSection = NULL;
+    INT ServiceFlags;
+    BOOL bNeedReboot = FALSE;
+    BOOL ok, ret = FALSE;
 
     TRACE("%p, %s, 0x%lx, %p, %p, %p, %p\n", hinf, debugstr_w(sectionname),
         flags, DeviceInfoSet, DeviceInfoData, reserved1, reserved2);
 
+    //If sectionname is a NULL
     if (!sectionname)
+    {
         SetLastError(ERROR_INVALID_PARAMETER);
-    else if (flags & ~(SPSVCINST_TAGTOFRONT | SPSVCINST_DELETEEVENTLOGENTRY | SPSVCINST_NOCLOBBER_DISPLAYNAME | SPSVCINST_NOCLOBBER_STARTTYPE | SPSVCINST_NOCLOBBER_ERRORCONTROL | SPSVCINST_NOCLOBBER_LOADORDERGROUP | SPSVCINST_NOCLOBBER_DEPENDENCIES | SPSVCINST_STOPSERVICE))
+        return FALSE;
+    }
+    //If sectionname does not exist
+    if (!(ok = SetupFindFirstLineW( hinf, sectionname, NULL, &ContextService )))
     {
+        SetLastError( ERROR_SECTION_NOT_FOUND );
+        return FALSE;
+    }
+    //If flags are not valid
+    if (flags & ~(SPSVCINST_TAGTOFRONT | SPSVCINST_DELETEEVENTLOGENTRY | SPSVCINST_NOCLOBBER_DISPLAYNAME | SPSVCINST_NOCLOBBER_STARTTYPE | SPSVCINST_NOCLOBBER_ERRORCONTROL | SPSVCINST_NOCLOBBER_LOADORDERGROUP | SPSVCINST_NOCLOBBER_DEPENDENCIES | SPSVCINST_STOPSERVICE))
+    {
         TRACE("Unknown flags: 0x%08lx\n", flags & ~(SPSVCINST_TAGTOFRONT | SPSVCINST_DELETEEVENTLOGENTRY | SPSVCINST_NOCLOBBER_DISPLAYNAME | SPSVCINST_NOCLOBBER_STARTTYPE | SPSVCINST_NOCLOBBER_ERRORCONTROL | SPSVCINST_NOCLOBBER_LOADORDERGROUP | SPSVCINST_NOCLOBBER_DEPENDENCIES | SPSVCINST_STOPSERVICE));
         SetLastError(ERROR_INVALID_FLAGS);
+        return FALSE;
     }
-    else if (DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+    //Invalid DeviceInfoset handle
+    if (DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+    {
         SetLastError(ERROR_INVALID_HANDLE);
-    else if (DeviceInfoSet && (list = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
+        return FALSE;
+    }
+    //Magic device
+    if (DeviceInfoSet && (list = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
+    {
         SetLastError(ERROR_INVALID_HANDLE);
-    else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
+        return FALSE;
+    }
+
+    if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
+    {
         SetLastError(ERROR_INVALID_USER_BUFFER);
-    else if (reserved1 != NULL || reserved2 != NULL)
+        return FALSE;
+    }
+
+    if (reserved1 != NULL || reserved2 != NULL)
+    {
         SetLastError(ERROR_INVALID_PARAMETER);
-    else
-    {
-        struct needs_callback_info needs_info;
-        LPWSTR ServiceName = NULL;
-        LPWSTR ServiceSection = NULL;
-        INT ServiceFlags;
-        INFCONTEXT ContextService;
-        BOOL bNeedReboot = FALSE;
+        return FALSE;
+    }
 
-        /* Parse 'Include' and 'Needs' directives */
-        iterate_section_fields( hinf, sectionname, Include, include_callback, NULL);
-        needs_info.type = 1;
-        needs_info.flags = flags;
-        needs_info.devinfo = DeviceInfoSet;
-        needs_info.devinfo_data = DeviceInfoData;
-        needs_info.reserved1 = reserved1;
-        needs_info.reserved2 = reserved2;
-        iterate_section_fields( hinf, sectionname, Needs, needs_callback, &needs_info);
+    //Param checking ended. Real stuff now:
 
-        if (flags & SPSVCINST_STOPSERVICE)
+    /* Parse 'Include' and 'Needs' directives */
+    iterate_section_fields( hinf, sectionname, Include, include_callback, NULL);
+    needs_info.type = 1;
+    needs_info.flags = flags;
+    needs_info.devinfo = DeviceInfoSet;
+    needs_info.devinfo_data = DeviceInfoData;
+    needs_info.reserved1 = reserved1;
+    needs_info.reserved2 = reserved2;
+    iterate_section_fields( hinf, sectionname, Needs, needs_callback, &needs_info);
+
+    if (flags & SPSVCINST_STOPSERVICE)
+    {
+        FIXME("Stopping the device not implemented\n");
+        /* This may lead to require a reboot */
+        /* bNeedReboot = TRUE; */
+#if 0
+        SERVICE_STATUS ServiceStatus;
+        ret = ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus);
+        if (!ret && GetLastError() != ERROR_SERVICE_NOT_ACTIVE)
+            goto cleanup;
+        if (ServiceStatus.dwCurrentState != SERVICE_STOP_PENDING && ServiceStatus.dwCurrentState != SERVICE_STOPPED)
         {
-            FIXME("Stopping the device not implemented\n");
-            /* This may lead to require a reboot */
-            /* bNeedReboot = TRUE; */
-#if 0
-            SERVICE_STATUS ServiceStatus;
-            ret = ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus);
-            if (!ret && GetLastError() != ERROR_SERVICE_NOT_ACTIVE)
-                goto cleanup;
-            if (ServiceStatus.dwCurrentState != SERVICE_STOP_PENDING && ServiceStatus.dwCurrentState != SERVICE_STOPPED)
-            {
-                SetLastError(ERROR_INSTALL_SERVICE_FAILURE);
-                goto cleanup;
-            }
+            SetLastError(ERROR_INSTALL_SERVICE_FAILURE);
+            goto cleanup;
+        }
 #endif
-            flags &= ~SPSVCINST_STOPSERVICE;
-        }
+        flags &= ~SPSVCINST_STOPSERVICE;
+    }
 
-        ret = SetupFindFirstLineW(hinf, sectionname, AddService, &ContextService);
-        while (ret)
+    ret = SetupFindFirstLineW(hinf, sectionname, AddService, &ContextService);
+    while (ret)
+    {
+        if (!GetStringField(&ContextService, 1, &ServiceName))
+            goto nextservice;
+
+        ret = SetupGetIntField(
+            &ContextService,
+            2, /* Field index */
+            &ServiceFlags);
+        if (!ret)
         {
-            if (!GetStringField(&ContextService, 1, &ServiceName))
-                goto nextservice;
+            /* The field may be empty. Ignore the error */
+            ServiceFlags = 0;
+        }
 
-            ret = SetupGetIntField(
-                &ContextService,
-                2, /* Field index */
-                &ServiceFlags);
-            if (!ret)
-            {
-                /* The field may be empty. Ignore the error */
-                ServiceFlags = 0;
-            }
+        if (!GetStringField(&ContextService, 3, &ServiceSection))
+            goto nextservice;
 
-            if (!GetStringField(&ContextService, 3, &ServiceSection))
-                goto nextservice;
+        ret = InstallOneService(list, hinf, ServiceSection, ServiceName, (ServiceFlags & ~SPSVCINST_ASSOCSERVICE) | flags);
+        if (!ret)
+            goto nextservice;
 
-            ret = InstallOneService(list, hinf, ServiceSection, ServiceName, (ServiceFlags & ~SPSVCINST_ASSOCSERVICE) | flags);
+        if (ServiceFlags & SPSVCINST_ASSOCSERVICE)
+        {
+            ret = SetupDiSetDeviceRegistryPropertyW(DeviceInfoSet, DeviceInfoData, SPDRP_SERVICE, (LPBYTE)ServiceName, (strlenW(ServiceName) + 1) * sizeof(WCHAR));
             if (!ret)
                 goto nextservice;
+        }
 
-            if (ServiceFlags & SPSVCINST_ASSOCSERVICE)
-            {
-                ret = SetupDiSetDeviceRegistryPropertyW(DeviceInfoSet, DeviceInfoData, SPDRP_SERVICE, (LPBYTE)ServiceName, (strlenW(ServiceName) + 1) * sizeof(WCHAR));
-                if (!ret)
-                    goto nextservice;
-            }
-
 nextservice:
-            HeapFree(GetProcessHeap(), 0, ServiceName);
-            HeapFree(GetProcessHeap(), 0, ServiceSection);
-            ServiceName = ServiceSection = NULL;
-            ret = SetupFindNextMatchLineW(&ContextService, AddService, &ContextService);
-        }
-
-        if (bNeedReboot)
-            SetLastError(ERROR_SUCCESS_REBOOT_REQUIRED);
-        else
-            SetLastError(ERROR_SUCCESS);
-        ret = TRUE;
+        HeapFree(GetProcessHeap(), 0, ServiceName);
+        HeapFree(GetProcessHeap(), 0, ServiceSection);
+        ServiceName = ServiceSection = NULL;
+        ret = SetupFindNextMatchLineW(&ContextService, AddService, &ContextService);
     }
 
+    if (bNeedReboot)
+        SetLastError(ERROR_SUCCESS_REBOOT_REQUIRED);
+    else
+        SetLastError(ERROR_SUCCESS);
+    ret = TRUE;
+
+
     TRACE("Returning %d\n", ret);
     return ret;
 }
 
 
+
 /***********************************************************************
  *		SetupCopyOEMInfA  (SETUPAPI.@)
  */
