Big Plug-and-Play patch for ReactOS:
- Install drivers for devices at first boot
- Remove now useless entries in hivesys.inf
At the moment, driver installation only uses .inf files in ReactOS\Inf
directory, and the needed files have to be in ReactOS\Inf or their final
location (ReactOS\system32 or ReactOS\system32\drivers) + the user can't
provide a custom driver
Plug-and-Plays devices are only USB controllers (OHCI and UHCI) and
serial ports now.
Modified: trunk/reactos/bootdata/hivesys.inf
Modified: trunk/reactos/ntoskrnl/io/driver.c
Modified: trunk/reactos/services/umpnpmgr/umpnpmgr.c
_____
Modified: trunk/reactos/bootdata/hivesys.inf
--- trunk/reactos/bootdata/hivesys.inf 2005-10-14 18:14:19 UTC (rev
18447)
+++ trunk/reactos/bootdata/hivesys.inf 2005-10-14 18:24:19 UTC (rev
18448)
@@ -594,47 +594,6 @@
HKLM,"SYSTEM\CurrentControlSet\Enum\Root\PCI\0000","ClassGUID",0x0000000
0,"{4D36E966-E325-11CE-BFC1-08002BE10318}"
HKLM,"SYSTEM\CurrentControlSet\Enum\Root\PCI\0000","ParentIdPrefix",0x00
00000,"0000"
-;USB UHCI Driver
-HKLM,"SYSTEM\CurrentControlSet\Services\usbuhci","Type",0x00010001,0x00
000001
-HKLM,"SYSTEM\CurrentControlSet\Services\usbuhci","ErrorControl",0x00010
001,0x00000001
-HKLM,"SYSTEM\CurrentControlSet\Services\usbuhci","Start",0x00010001,0x0
0000003
-HKLM,"SYSTEM\CurrentControlSet\Services\usbuhci","Group",0x00000000,"Ba
se"
-HKLM,"SYSTEM\CurrentControlSet\Services\usbuhci","ImagePath",0x00020000
,"System32\DRIVERS\usbuhci.sys"
-HKLM,"SYSTEM\CurrentControlSet\Services\usbuhci","Tag",0x00010001,0x000
0000f
-HKLM,"SYSTEM\CurrentControlSet\Services\usbuhci","DisplayName",0x000000
00,"ReactOS USB UHCI controller miniport driver"
-;hard coded values for VMWARE
-HKLM,"SYSTEM\CurrentControlSet\Services\usbuhci\Enum","0",0x00000000,"P
CI\VEN_8086&DEV_7112&SUBSYS_197615AD&REV_00\0000"
-HKLM,"SYSTEM\CurrentControlSet\Services\usbuhci\Enum","Count",0x0001000
1,0x00000001
-HKLM,"SYSTEM\CurrentControlSet\Services\usbuhci\Enum","NextInstance",0x
00010001,0x00000001
-HKLM,"SYSTEM\CurrentControlSet\Enum\PCI\VEN_8086&DEV_7112&SUBSYS_197615
AD&REV_00\0000","Service",0x0000000,"usbuhci"
-HKLM,"SYSTEM\CurrentControlSet\Enum\PCI\VEN_8086&DEV_7112&SUBSYS_197615
AD&REV_00\0000","ParentIdPrefix",0x0000000,"0000"
-
-;USB OHCI Driver (Cromwell), especially the same name as windows OHCI
miniport
-HKLM,"SYSTEM\CurrentControlSet\Services\usbohci","Type",0x00010001,0x00
000001
-HKLM,"SYSTEM\CurrentControlSet\Services\usbohci","ErrorControl",0x00010
001,0x00000001
-HKLM,"SYSTEM\CurrentControlSet\Services\usbohci","Start",0x00010001,0x0
0000003
-HKLM,"SYSTEM\CurrentControlSet\Services\usbohci","Group",0x00000000,"Ba
se"
-HKLM,"SYSTEM\CurrentControlSet\Services\usbohci","ImagePath",0x00020000
,"System32\drivers\usbohci.sys"
-HKLM,"SYSTEM\CurrentControlSet\Services\usbohci","Tag",0x00010001,0x000
0000f
-HKLM,"SYSTEM\CurrentControlSet\Services\usbohci","DisplayName",0x000000
00,"ReactOS USB OHCI cromwell-type driver"
-;hard coded values for Virtual PC 6/7 (Mac)
-HKLM,"SYSTEM\CurrentControlSet\Services\usbohci\Enum","0",0x00000000,"P
CI\VEN_2955&DEV_6E61&SUBSYS_6E612955&REV_11\0000"
-HKLM,"SYSTEM\CurrentControlSet\Services\usbohci\Enum","Count",0x0001000
1,0x00000001
-HKLM,"SYSTEM\CurrentControlSet\Services\usbohci\Enum","NextInstance",0x
00010001,0x00000001
-HKLM,"SYSTEM\CurrentControlSet\Enum\PCI\VEN_2955&DEV_6E61&SUBSYS_6E6129
55&REV_11\0000","Service",0x0000000,"usbohci"
-
-;USB Hub driver
-HKLM,"SYSTEM\CurrentControlSet\Services\usbhub","Type",0x00010001,0x000
00001
-HKLM,"SYSTEM\CurrentControlSet\Services\usbhub","ErrorControl",0x000100
01,0x00000001
-HKLM,"SYSTEM\CurrentControlSet\Services\usbhub","Start",0x00010001,0x00
000003
-HKLM,"SYSTEM\CurrentControlSet\Services\usbhub","Group",0x00000000,"Bas
e"
-HKLM,"SYSTEM\CurrentControlSet\Services\usbhub","ImagePath",0x00020000,
"System32\drivers\usbhub.sys"
-HKLM,"SYSTEM\CurrentControlSet\Services\usbhub","Tag",0x00010001,0x0000
0011
-HKLM,"SYSTEM\CurrentControlSet\Services\usbhub","DisplayName",0x0000000
0,"ReactOS USB HUB cromwell-type driver"
-;hard coded values
-HKLM,"SYSTEM\CurrentControlSet\Enum\USB\ROOT_HUB\0000","Service",0x0000
000,"usbhub"
-HKLM,"SYSTEM\CurrentControlSet\Enum\USB\ROOT_HUB20\0000","Service",0x00
00000,"usbhub"
-
; ReactOS PCNet NIC driver
; To use the AMD supplied driver change the driver name to pcntn5m.sys
;
@@ -699,23 +658,12 @@
HKLM,"SYSTEM\CurrentControlSet\Services\Null","Start",0x00010001,0x00000
001
HKLM,"SYSTEM\CurrentControlSet\Services\Null","Type",0x00010001,0x000000
01
-; Serial device driver
-HKLM,"SYSTEM\CurrentControlSet\Enum\ACPI\PNP0501\1","ClassGUID",0x00000
000,"{4D36E978-E325-11CE-BFC1-08002BE10318}"
-HKLM,"SYSTEM\CurrentControlSet\Enum\ACPI\PNP0501\1","Service",0x0000000
0,"serial"
-HKLM,"SYSTEM\CurrentControlSet\Enum\ACPI\PNP0501\1","UpperFilters",0x00
010000,"serenum"
-HKLM,"SYSTEM\CurrentControlSet\Enum\ACPI\PNP0501\2","ClassGUID",0x00000
000,"{4D36E978-E325-11CE-BFC1-08002BE10318}"
-HKLM,"SYSTEM\CurrentControlSet\Enum\ACPI\PNP0501\2","Service",0x0000000
0,"serial"
-HKLM,"SYSTEM\CurrentControlSet\Enum\ACPI\PNP0501\2","UpperFilters",0x00
010000,"serenum"
-
; Packet driver
HKLM,"SYSTEM\CurrentControlSet\Services\Packet","ErrorControl",0x0001000
1,0x00000001
HKLM,"SYSTEM\CurrentControlSet\Services\Packet","Group",0x00000000,"PNP_
TDI"
HKLM,"SYSTEM\CurrentControlSet\Services\Packet","ImagePath",0x00020000,"
system32\drivers\packet.sys"
HKLM,"SYSTEM\CurrentControlSet\Services\Packet","Start",0x00010001,0x000
00004
HKLM,"SYSTEM\CurrentControlSet\Services\Packet","Type",0x00010001,0x0000
0001
-; NOTE: These settings should be added by the network setup
-HKLM,"SYSTEM\CurrentControlSet\Services\Packet\Linkage","Bind",0x000100
00,"\Device\Ne20001"
-HKLM,"SYSTEM\CurrentControlSet\Services\Packet\Linkage","Export",0x0001
0000,"\Device\packet"
; Plug and Play manager
HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","ErrorControl",0x00010
001,0x00000000
@@ -737,16 +685,6 @@
HKLM,"SYSTEM\CurrentControlSet\Services\Scsiport","Start",0x00010001,0x0
0000000
HKLM,"SYSTEM\CurrentControlSet\Services\Scsiport","Type",0x00010001,0x00
000001
-; Serial mouse driver
-HKLM,"SYSTEM\CurrentControlSet\Services\Sermouse","ErrorControl",0x0001
0001,0x00000000
-HKLM,"SYSTEM\CurrentControlSet\Services\Sermouse","Group",0x00000000,"P
ointer Port"
-HKLM,"SYSTEM\CurrentControlSet\Services\Sermouse","ImagePath",0x0002000
0,"system32\drivers\sermouse.sys"
-HKLM,"SYSTEM\CurrentControlSet\Services\Sermouse","Start",0x00010001,0x
00000003
-HKLM,"SYSTEM\CurrentControlSet\Services\Sermouse","Type",0x00010001,0x0
0000001
-;hard coded values for some serial mice
-HKLM,"SYSTEM\CurrentControlSet\Enum\Serenum\Mouse\0000","Service",0x000
0000,"sermouse"
-HKLM,"SYSTEM\CurrentControlSet\Enum\Serenum\Mouse\0000","ClassGUID",0x0
000000,"{4D36E96F-E325-11CE-BFC1-08002BE10318}"
-
; TCP/IP driver
HKLM,"SYSTEM\CurrentControlSet\Services\Tcpip","ErrorControl",0x00010001
,0x00000001
HKLM,"SYSTEM\CurrentControlSet\Services\Tcpip","Group",0x00000000,"PNP_T
DI"
_____
Modified: trunk/reactos/ntoskrnl/io/driver.c
--- trunk/reactos/ntoskrnl/io/driver.c 2005-10-14 18:14:19 UTC (rev
18447)
+++ trunk/reactos/ntoskrnl/io/driver.c 2005-10-14 18:24:19 UTC (rev
18448)
@@ -529,6 +529,9 @@
break;
}
}
+ if (!NT_SUCCESS(Status))
+ /* Try to load it. It may just have been installed by PnP
manager */
+ Status = LdrLoadModule(&ServiceImagePath, ModuleObject);
}
/*
_____
Modified: trunk/reactos/services/umpnpmgr/umpnpmgr.c
--- trunk/reactos/services/umpnpmgr/umpnpmgr.c 2005-10-14 18:14:19 UTC
(rev 18447)
+++ trunk/reactos/services/umpnpmgr/umpnpmgr.c 2005-10-14 18:24:19 UTC
(rev 18448)
@@ -22,6 +22,7 @@
* FILE: services/umpnpmgr/umpnpmgr.c
* PURPOSE: User-mode Plug and Play manager
* PROGRAMMER: Eric Kohl
+ * HervÚ Poussineau (hpoussin(a)reactos.org)
*/
/* INCLUDES
*****************************************************************/
@@ -874,7 +875,52 @@
return ret;
}
+typedef BOOL (*PDEV_INSTALL_W)(HWND, HINSTANCE, LPCWSTR, INT);
+static BOOL
+InstallDevice(PCWSTR DeviceInstance)
+{
+ PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData;
+ HMODULE hNewDev = NULL;
+ PDEV_INSTALL_W DevInstallW;
+ NTSTATUS Status;
+ BOOL DeviceInstalled = FALSE;
+
+ RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
+ DeviceInstance);
+ PlugPlayData.Operation = 0; /* Get status */
+
+ /* Get device status */
+ Status = NtPlugPlayControl(PlugPlayControlDeviceStatus,
+ (PVOID)&PlugPlayData,
+ sizeof(PLUGPLAY_CONTROL_STATUS_DATA));
+ if (!NT_SUCCESS(Status))
+ return FALSE;
+
+ if (PlugPlayData.DeviceStatus & DNF_STARTED ||
PlugPlayData.DeviceStatus & DNF_START_FAILED)
+ /* Device is already started, or disabled due to some problem.
Don't install it */
+ return TRUE;
+
+ /* Install device */
+ SetEnvironmentVariable(L"USERPROFILE", L"."); /* FIXME: why is
it
needed? */
+ hNewDev = LoadLibraryW(L"newdev.dll");
+ if (!hNewDev)
+ goto cleanup;
+ DevInstallW = (PDEV_INSTALL_W)GetProcAddress(hNewDev,
(LPCSTR)"DevInstallW");
+ if (!DevInstallW)
+ goto cleanup;
+ if (!DevInstallW(NULL, NULL, DeviceInstance, SW_SHOWNOACTIVATE))
+ goto cleanup;
+
+ DeviceInstalled = TRUE;
+
+cleanup:
+ if (hNewDev != NULL)
+ FreeLibrary(hNewDev);
+
+ return DeviceInstalled;
+}
+
static DWORD WINAPI
PnpEventThread(LPVOID lpParameter)
{
@@ -915,6 +961,7 @@
if (UuidEqual(&PnpEvent->EventGuid,
(UUID*)&GUID_DEVICE_ARRIVAL, &RpcStatus))
{
DPRINT("Device arrival event: %S\n",
PnpEvent->TargetDevice.DeviceIds);
+ InstallDevice(PnpEvent->TargetDevice.DeviceIds);
}
else
{