public void Integrate() { PNPDriverINFFile pnpDriverInf; var installSectionName = DriverDirectory.GetDeviceInstallSectionName(HardwareID, _installation.ArchitectureIdentifier, _installation.MinorOSVersion, _installation.ProductType, out pnpDriverInf); ProcessInstallSection(pnpDriverInf, installSectionName, string.Empty); // We don't care about the classInstanceID because we don't populate the registry ProcessCoInstallersSection(pnpDriverInf, installSectionName); CopyDriverToSetupDriverDirectoryAndRegisterIt(pnpDriverInf); }
public void IntegrateDriver() { PNPDriverINFFile pnpDriverInf; var installSectionName = DriverDirectory.GetDeviceInstallSectionName(HardwareID, _installation.ArchitectureIdentifier, _installation.MinorOSVersion, _installation.ProductType, out pnpDriverInf); if (installSectionName == string.Empty) { Console.WriteLine("Unable to locate InstallSectionName in INF file"); Program.Exit(); } _classInstanceID = _installation.SetupRegistryHive.AllocateClassInstanceID(pnpDriverInf.ClassGUID); ProcessInstallSection(pnpDriverInf, installSectionName, _classInstanceID); ProcessInstallServicesSection(pnpDriverInf, installSectionName); // this.DeviceServices is now populated if (DeviceServices.Count == 0) { Console.WriteLine("Error: driver does not have an associated service, IntegrateDrv will not proceed."); Program.Exit(); } PrepareToPreventTextModeDriverNameCollision(DeviceServices); foreach (var deviceService in DeviceServices) { InstructToLoadTextModeDeviceService(deviceService); RegisterDeviceService(_installation.SetupRegistryHive, pnpDriverInf, deviceService); RegisterDeviceService(_installation.HiveSystemInf, pnpDriverInf, deviceService); } CopyDriverFiles(DeviceServices); // register the device: if (PNPDriverINFFile.IsRootDevice(HardwareID)) { // installing virtual device: (this is critical for some services such as iScsiPrt) var virtualDeviceInstanceID = _installation.AllocateVirtualDeviceInstanceID(pnpDriverInf.ClassName); if (DeviceServices.Count > 0) { var deviceService = DeviceServices[0]; PreconfigureDeviceInstance(pnpDriverInf, "Root", pnpDriverInf.ClassName.ToUpper(), virtualDeviceInstanceID, deviceService); } } else // physical device { RegisterPhysicalDevice(pnpDriverInf); // GUI-Mode setup will scan all of the directories listed under "DevicePath" directories, // if it will find multiple matches, it will use the .inf file that has the best match. // Microsoft does not define exactly how matching drivers are ranked, observations show that: // 1. When both .inf have the exact same hardwareID, and one of the .inf is signed and the other is not, the signed .inf will qualify as the best match. // 2. When both .inf have the exact same hardwareID, and both of the .inf files are unsigned, the .inf with the most recent version / date will qualify as the best match. // 3. When both .inf have the exact same hardwareID, and both of the .inf files are unsigned, and both has the same version / date, the .inf from the first directory listed under "DevicePath" will qualify as the best match. // We have to disable the device drivers included in windows to qualify the newly integrated drivers as best match: PNPDriverGUIModeIntegrator.DisableInBoxDeviceDrivers(_installation.SetupDirectory, _installation.ArchitectureIdentifier, _installation.MinorOSVersion, _installation.ProductType, HardwareID); } // Network Device: // We want to make the NIC driver accessible to windows GUI mode setup, otherwise no 'Network Connection' will be installed and TCP/IP configuration // for the NIC will be deleted. (and as a result, the NIC would not have TCP/IP bound to it) // Devices in general: // Windows will clear all existing Enum and / or Control\Class entries of devices that have no matching driver available during GUI-mode setup // (it will be done near the very end of GUI-mode setup) // So we let Windows GUI-Mode install the device. // Note: the driver will be modified for boot start var guiModeIntegrator = new PNPDriverGUIModeIntegrator(DriverDirectory, _installation, HardwareID); guiModeIntegrator.Integrate(); }