Beispiel #1
0
        public InfFileInstructions(String FileName, InfSection infs)
        {
            this.FileName = FileName;
            curInfSection = infs;

            ProcessFileSection();
        }
Beispiel #2
0
        public List <InfFileInstructions> CreateFileListFromSection(InfSection InfFileSection)
        {
            List <InfFileInstructions> ifi = new List <InfFileInstructions>();

            //The section should already be specified for the InfSectionOpNode if it isn't there was an error
            foreach (String infline in InfFileSection.GetInfSectionLines())
            {
                //if this line is a hook then you should add it to the section list
                //this url specifies the line syntax:
                //http://msdn.microsoft.com/library/default.asp?url=/workshop/delivery/download/overview/overview.asp

                //check if there is an equals sign
                string[] s = infline.Split('=');

                if (s.Length == 2)
                {
                    if (MainBinFileName == null)
                    {
                        MainBinFileName = s[0];
                    }

                    ifi.Add(new InfFileInstructions(s[0], ReturnNamedSection(s[1])));
                }
                else
                {
                    Console.WriteLine("Exception: this line is busted: {0}", infline);
                    throw new System.IO.InvalidDataException();
                }
            }

            return(ifi);
        }
Beispiel #3
0
        public void InterpretInfToOpTree()
        {
            //this is implemented because the ICD spec includes a check in the
            //CheckHookEnablement();

            //if (!HooksEnabled)
            //{
            //    Console.WriteLine("Exception: Hooks aren't enabled for this install - this is unusual.");
            //}


            //Get the [Setup Hooks] and [Add.Code] or [DefaultInstall] sections to check to see where to start processing
            //If none of these exist then bomb out the install with an invalid format error.
            InfSection SetupHooks     = ReturnNamedSection("Setup Hooks");
            InfSection AddCode        = ReturnNamedSection("Add.Code");
            InfSection DefaultInstall = ReturnNamedSection("DefaultInstall");

            //Currently we only support installs with only Add.Code sections.
            //if either section exists then we'll throw an exception.
            if (AddCode != null)
            {
                //This datastructure is currently replaced -
                //if there were multiple sections with files you'd want to add them InfFiles
                InfFiles = CreateFileListFromSection(AddCode);
            }


            //Because this is an ActiveX Inf file, we should be building the op tree starting with the
            if (SetupHooks != null || DefaultInstall != null)
            {
                //BUGBUG remove the exception...
                throw new System.IO.InvalidDataException();
            }
        }
Beispiel #4
0
        /// <summary>
        /// This function will take the inf and parse it into InfSection's.
        ///
        /// The sections can then be ordered to create an execution order.
        /// </summary>
        public void ParseIntoSections( )
        {
            String       InfLine;
            StreamReader InfReader = new StreamReader(InfPath);

            InfSection CurrentSection = null;

            while ((InfLine = InfReader.ReadLine()) != null)
            {
                InfLine = InfLine.Trim();

                if (InfLine.Length == 0)
                {
                    //Add the current section to the list of sections.
                    if (CurrentSection != null)
                    {
                        InfSections.Add(CurrentSection);
                        CurrentSection = null;
                    }

                    continue;
                }

                if (InfLine[0] == '[')
                {
                    //if there can be sections without whitespace between them
                    //the code above to add the current section to InfSections must be added
                    CurrentSection = new InfSection(InfLine.Substring(1, InfLine.IndexOf(']') - 1));
                }
                else if (InfLine[0] == ';')
                {
                    continue;
                }
                else
                {
                    CurrentSection.AddLine(InfLine);
                }
            }


            if (CurrentSection != null)
            {
                //there was no whitespace after the last section
                //add the section to the list
                InfSections.Add(CurrentSection);
            }

            InfReader.Close();
        }
Beispiel #5
0
        /// <summary>
        /// This function will probably need to be rewritten.
        ///
        /// It just verifies the version section of the inf.
        /// </summary>
        public void CheckHookEnablement()
        {
            //Get the version section and check to see if this is an Internet Component Download inf
            //If it isn't bomb out the install with an invalid error issue.
            InfSection versect = ReturnNamedSection("version");

            if (versect == null)
            {
                Console.WriteLine("Exception: This is an invalid inf file with no version section.");
                HooksEnabled = false;
            }


            //TODO: this is fragile code.  "AdvancedINF=2.0" should be replaced by a set of language keywords.
            bool AdvInf  = false;
            bool Chicago = false;

            foreach (String sline in versect.GetInfSectionLines())
            {
                if (sline == "AdvancedINF=2.0")
                {
                    AdvInf = true;
                }

                if (sline == "Signature=\"$CHICAGO$\"")
                {
                    Chicago = true;
                }
            }

            if (AdvInf && Chicago)
            {
                HooksEnabled = true;
            }
            else
            {
                HooksEnabled = false;
            }

            return;
        }