Ejemplo n.º 1
0
        /// <summary>
        /// firmware or regular driver will still call this to do the actual installation
        /// </summary>
        /// <param name="infName"></param>
        /// <param name="line"></param>
        /// <param name="installer"></param>
        /// <param name="installArgs"></param>
        /// <param name="InputTestFilePath"></param>
        /// <param name="rebootRequired"></param>
        /// <param name="hardwareID"></param>
        /// SafeNativeMethods.InstallUninstallCall(seedIndex, rebootRequired, infName, line, installer, InputTestFilePath);
        internal static void InstallUninstallCall(int seedIndex, bool rebootRequired, string infName, string line, string installer, string InputTestFilePath)
        {
            try
            {
                Logger.FunctionEnter();
                string expectedDriverVersion = GetData.GetDriverVersion(line);
                string infNameToTest         = Path.GetFileNameWithoutExtension(line);
                string expectedDriverDate    = GetData.GetDriverDate(line);
                string infPath = Path.GetDirectoryName(line);
                string installArgs;
                string friendlyDriverName = XMLReader.GetFriendlyDriverName(InputTestFilePath, line);
                Console.WriteLine(line + " and " + seedIndex);
                Console.WriteLine("RemoveXMLElement now");
                XMLWriter.RemoveXMLElemnt(Program.InputTestFilePath, line, seedIndex);
                Console.WriteLine("check the xml please..");
                string hardwareID  = GetData.FirmwareInstallGetHID(line);
                bool   isInstalled = CheckWhatInstalled.CheckInstalled(line, hardwareID, friendlyDriverName, infNameToTest, expectedDriverVersion, expectedDriverDate);
                if (isInstalled)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("----------------------------------------------------------");
                    Console.WriteLine("THIS PnP DRIVER VERSION IS INSTALLED UN-INSTALLING NOW....");
                    Console.WriteLine(infName);
                    Console.WriteLine("----------------------------------------------------------");
                    Console.ForegroundColor = ConsoleColor.White;

                    Logger.Comment("rebootRequired is showing as : " + rebootRequired);
                    installArgs = " /C /U " + line + " /Q /D";
                    Install_Inf(line, installer, installArgs, seedIndex);
                    Logger.Comment("Operation should be complete: " + line);

                    string classGUID = GetData.GetClassGUID(line);
                    GetDataFromReg.GetOEMinfNameFromReg(infName, hardwareID, classGUID);

                    if (RegCheck.IsRebootPending())
                    {
                        Logger.Comment("there is a pending reboot...");
                        RebootAndContinue.RebootCmd(true);
                    }
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("---------------------------------------------------------------");
                    Console.WriteLine("THIS PnP DRIVER VERSION WAS NOT INSTALLED YET INSTALLING NOW...");
                    Console.WriteLine(infName);
                    Console.WriteLine("---------------------------------------------------------------");
                    Console.ForegroundColor = ConsoleColor.White;

                    Logger.Comment("rebootRequired is showing as : " + rebootRequired);
                    installArgs = " /C /A /Q /SE /F /PATH " + infPath;
                    Install_Inf(line, installer, installArgs, seedIndex);
                    string classGUID = GetData.GetClassGUID(line);
                    XMLWriter.SetLastInstalled(line);

                    //can we check registry simiarly to firmware for PnP drivers?
                    Logger.Comment("Operation should be complete: " + line);

                    if (RegCheck.IsRebootPending())
                    {
                        Logger.Comment("there is a pending reboot...");
                        RebootAndContinue.RebootCmd(true);
                    }
                }
                Logger.FunctionLeave();
            }
            catch (Exception ex)
            {
                GetData.GetExceptionMessage(ex);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// this is called when installing firmware to perform the extra actions needed such as regkey writes and reboot
        /// </summary>
        /// <param name="infName"></param>
        /// <param name="infFileContent"></param>
        /// <param name="hardwareID"></param>
        /// <param name="rebootRequired"></param>
        /// <param name="rollBackLine"></param>
        /// <param name="installer"></param>
        /// <param name="installArgs"></param>
        /// <param name="InputTestFilePath"></param>
        internal static void RollbackInstall(int seedIndex, string line, string infName, string infFileContent, string hardwareID, bool rebootRequired, string InputTestFilePath)
        {
            Logger.FunctionEnter();
            string installArgs;
            string fullRollBackFile   = string.Empty;
            string fullRollBackDIR    = string.Empty;
            string fullRollBackDIRdir = string.Empty;

            try
            {
                XMLWriter.RemoveXMLElemnt(Program.InputTestFilePath, line, seedIndex);
                RegCheck.CreatePolicyRegKeyAndSetValue(hardwareID, rebootRequired.Equals(true));

                fullRollBackDIR = GetData.CheckRollbacksExist(line, infName);

                if (string.IsNullOrEmpty(fullRollBackDIR))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("should i even be trying to rollback at all???");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    fullRollBackDIRdir = Path.GetDirectoryName(fullRollBackDIR);
                }

                installArgs = " /C /U " + line + " /Q /D";
                string tmpfileName = string.Empty;
                string tmpVersion  = GetData.GetDriverVersion(line);
                var    binsList    = Directory.EnumerateFiles(@"C:\Windows\Firmware\");
                foreach (string binFileToDelete in binsList)
                {
                    tmpfileName = Path.GetFileNameWithoutExtension(binFileToDelete);
                    tmpVersion  = tmpVersion.TrimEnd('0').TrimEnd('0').TrimEnd('.');
                    if (Regex.Match(tmpfileName, tmpVersion).Success)
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine("binFileToDelete exists : " + tmpfileName);
                        File.Delete(tmpfileName);
                        Console.ForegroundColor = ConsoleColor.White;
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                Install_Inf(line, Program.installer, installArgs, seedIndex);
                Logger.Comment("Uninstall Operation should be complete: " + line);
                installArgs = " /C /A /Q /SE /F /PATH " + fullRollBackDIRdir;
                Logger.Comment("start rollback...");
                XMLWriter.SetLastInstalled(fullRollBackDIR);
                Install_Inf(line, Program.installer, installArgs, seedIndex);
                string classGUID             = GetData.GetClassGUID(line);
                string expectedDriverVersion = GetData.GetDriverVersion(line);
                GetDataFromReg.GetOEMinfNameFromReg(infName, hardwareID, classGUID);
                if (RegCheck.IsRebootPending())
                {
                    Logger.Comment("there is a pending reboot...");
                    RebootAndContinue.RebootCmd(true);
                }
            }
            catch (Exception ex)
            {
                GetData.GetExceptionMessage(ex);
            }
            Logger.FunctionLeave();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// logPath will be the location or the DPINST.LOG
        /// </summary>
        /// ParseForResults.ParseFromdpinstLog(logPath);
        /// <param name="logPath"></param>
        internal static void ParseFromdpinstLog(string logPath)
        {
            List <string> infsPathsList = GetData.GetInfPathsList(Program.dirName);
            string        line          = string.Empty;
            string        dumpExist     = string.Empty;
            string        logString     = string.Empty;
            string        lineContains  = string.Empty;
            string        dumpFilePath  = string.Empty;

            try
            {
                using (FileStream fs = File.Open(logPath, FileMode.Open, FileAccess.Read, FileShare.Inheritable))
                    using (BufferedStream bs = new BufferedStream(fs))
                        using (StreamReader sr = new StreamReader(bs))
                        {
                            while ((line = sr.ReadLine()) != null)
                            {
                                foreach (string infPathTMP in infsPathsList)
                                {
                                    string inNameTMP = Path.GetFileNameWithoutExtension(infPathTMP).ToLower();
                                    if (line.Contains(inNameTMP.ToLower()))
                                    {
                                        switch (lineContains)
                                        {
                                        case string errorResult when line.Contains(errorCode):
                                            errorCount++;

                                            break;

                                        case string successUninstallResult when line.Contains(successUninstallResults):
                                            successUninstallCount++;

                                            break;

                                        case string failedResult when line.Contains(failedResults):
                                            failedCount++;

                                            break;

                                        case string successinstallResult when line.Contains(successinstallResults):
                                            successInstallCount++;

                                            break;
                                        }
                                    }
                                }

                                if (line.Contains(rollbackCheck))
                                {
                                    switch (lineContains)
                                    {
                                    case string errorResult when line.Contains(errorCode):
                                        rollBackErrorCount++;

                                        break;

                                    case string successinstallResult when line.Contains(successinstallResults):
                                        rollBackSuccessCount++;

                                        break;

                                    case string failedResult when line.Contains(failedResults):
                                        rollBackFailedCount++;

                                        break;
                                    }
                                }
                            }

                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("failedCount : " + failedCount);
                            Console.WriteLine("successInstallCount : " + successInstallCount);
                            Console.WriteLine("successUninstallCount : " + successUninstallCount);
                            Console.WriteLine("errorCount  : " + errorCount);
                            Console.WriteLine("rollBackFailedCount : " + rollBackFailedCount);
                            Console.WriteLine("rollBackSuccessInstallCount : " + (rollBackSuccessCount - successInstallCount));
                            Console.WriteLine("rollBackErrorCount  : " + rollBackErrorCount);
                            Console.ForegroundColor = ConsoleColor.White;
                        }

                foreach (var dmpFileTest in Directory.EnumerateDirectories(Program.dirName, ".dmp", SearchOption.AllDirectories))
                {
                    dumpExist    = "True";
                    dumpFilePath = dmpFileTest;
                }
                XMLWriter.LogResults(Program.InputTestFilePathBAK, errorCount.ToString(), failedCount.ToString(), successInstallCount.ToString(), successUninstallCount.ToString(),
                                     rollBackErrorCount.ToString(), rollBackFailedCount.ToString(), rollBackSuccessCount.ToString(), dumpExist, logString, dumpFilePath);
            }

            catch (Exception ex)
            {
                GetData.GetExceptionMessage(ex);
            }
        }