Ejemplo n.º 1
0
        public void ParseAssembly(string path)
        {
            ReaderHelper.LoadOpCodes();

            _types.Clear();
            _namespaces.Clear();

            try
            {
                //Load Assembly an extract all types
                Assembly assembly = Assembly.LoadFile(path);

                OnProgressChanged("Assembly loaded successfully");

                foreach (Type type in assembly.GetTypes())
                {
                    ParseType(type);
                }

                //Es müssen erst alle Methoden erzeugt sein um dann die entsprechende Aufrufe zu finden
                foreach (Method method in _methods.Values)
                {
                    if (method.ParentType is Class)
                    {
                        method.BodyReader.GenerateInstructions();

                        foreach (Instruction instruction in method.BodyReader.Instructions)
                        {
                            ParseInstruction(instruction);
                        }
                    }
                }
            }
            catch (FileNotFoundException ex)
            {
                throw new ArgumentException("The File \"" + ex.FileName + "\" does not exist.", ex);
            }
            catch (BadImageFormatException ex)
            {
                throw new ArgumentException("The File \"" + Path.GetFileName(path) + "\" is not a valid .NET-Assembly.", ex);
            }
        }