Ejemplo n.º 1
0
        public void IntegrateDriver()
        {
            UpdateTextSetupInformationFileAndCopyFiles(_deviceID);
            var destinationWinntDirectory = _installation.GetDriverDestinationWinntDirectory(_deviceID);

            // hivesft.inf
            _installation.HiveSoftwareInf.RegisterDriverDirectory(destinationWinntDirectory);

            if (_installation.Is64Bit)
            {
                // hivsft32.inf
                _installation.HiveSoftware32Inf.RegisterDriverDirectory(destinationWinntDirectory);
            }
        }
        private void CopyDriverToSetupDriverDirectoryAndRegisterIt(PNPDriverINFFile pnpDriverInf)
        {
            Console.WriteLine();
            Console.WriteLine("Making the driver available to GUI mode setup.");

            // build list of source files:
            var driverFiles = new List <string>();

            foreach (var fileToCopy in DriverFilesToCopy)
            {
                DisableInBoxDeviceDriverFile(_installation.SetupDirectory, fileToCopy.DestinationFileName);

                driverFiles.Add(fileToCopy.RelativeSourceFilePath);
            }

            // make sure the .inf file will be copied too
            driverFiles.Add(pnpDriverInf.FileName);

            if (pnpDriverInf.CatalogFile != string.Empty)
            {
                if (File.Exists(DriverDirectory.Path + pnpDriverInf.CatalogFile))
                {
                    // add the catalog file too (to suppress unsigned driver warning message if the .inf has not been modified)
                    // the catalog file is in the same location as the INF file ( http://msdn.microsoft.com/en-us/library/windows/hardware/ff547502%28v=vs.85%29.aspx )
                    driverFiles.Add(pnpDriverInf.CatalogFile);
                }
            }

            // Note that we may perform some operations on the same directory more than once,
            // the allocate / register methods are supposed to return the previously allocated IDs on subsequent calls,
            // and skip registration of previously registered directories
            foreach (var relativeFilePath in driverFiles)
            {
                var fileName = FileSystemUtils.GetNameFromPath(relativeFilePath);
                var relativeDirectoryPath = relativeFilePath.Substring(0, relativeFilePath.Length - fileName.Length);

                // we need to copy the files to the proper sub-directories
                var sourceDir      = DriverDirectory.Path + relativeDirectoryPath;
                var pathParts      = sourceDir.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
                var destinationDir = pnpDriverInf.ClassName + '\\' + pathParts[pathParts.Length - 1] + relativeDirectoryPath + Path.DirectorySeparatorChar;
                _installation.CopyFileToSetupDriverDirectory(sourceDir + fileName, destinationDir, fileName);

                var sourceDirectoryInMediaRootForm = _installation.GetSourceDriverDirectoryInMediaRootForm(HardwareID + @"\" + relativeDirectoryPath);                 // note that we may violate ISO9660 - & is not allowed
                var sourceDiskID = _installation.TextSetupInf.AllocateSourceDiskID(_installation.ArchitectureIdentifier, sourceDirectoryInMediaRootForm);

                var destinationWinntDirectory   = _installation.GetDriverDestinationWinntDirectory(HardwareID + @"\" + relativeDirectoryPath);
                var destinationWinntDirectoryID = _installation.TextSetupInf.AllocateWinntDirectoryID(destinationWinntDirectory);

                _installation.TextSetupInf.SetSourceDisksFileEntry(_installation.ArchitectureIdentifier, sourceDiskID, destinationWinntDirectoryID, fileName, FileCopyDisposition.AlwaysCopy);

                // dosnet.inf: we add the file to the list of files to be copied to local source directory
                if (!_installation.IsTargetContainsTemporaryInstallation)
                {
                    _installation.DOSNetInf.InstructSetupToCopyFileFromSetupDirectoryToLocalSourceDriverDirectory(
                        sourceDirectoryInMediaRootForm, fileName);
                }

                _installation.HiveSoftwareInf.RegisterDriverDirectory(destinationWinntDirectory);
                if (_installation.Is64Bit)
                {
                    // hivsft32.inf
                    _installation.HiveSoftware32Inf.RegisterDriverDirectory(destinationWinntDirectory);
                }
            }

            // set inf to boot start:
            {
                var sourceDir      = DriverDirectory.Path;
                var pathParts      = sourceDir.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
                var destinationDir = pnpDriverInf.ClassName + '\\' + pathParts[pathParts.Length - 1];

                var setupDriverDirectoryPath = _installation.GetSetupDriverDirectoryPath(destinationDir + Path.DirectorySeparatorChar);
                var installSectionName       = pnpDriverInf.GetDeviceInstallSectionName(HardwareID, _installation.ArchitectureIdentifier, _installation.MinorOSVersion, _installation.ProductType);
                pnpDriverInf.SetServiceToBootStart(installSectionName, _installation.ArchitectureIdentifier, _installation.MinorOSVersion);
                pnpDriverInf.SaveToDirectory(setupDriverDirectoryPath);
                // finished setting inf to boot start
            }
        }