Beispiel #1
0
        public void Dispose()
        {
            if (m_peFile != null)
            {
                m_peFile.Dispose();
            }

            if (m_modules != null)
            {
                m_modules.Dispose();
            }

            m_modules     = null;
            m_peFile      = null;
            m_assemblyRow = null;
            m_project     = null;
        }
Beispiel #2
0
        private void InitData()
        {
            if (_dataReader == null)
            {
                return;
            }

            if (_pdb != null && _managed != null)
            {
                return;
            }

            PEFile file = null;

            try
            {
                file = PEFile.TryLoad(new ReadVirtualStream(_dataReader, (long)ImageBase, (long)FileSize), true);
                if (file == null)
                {
                    return;
                }

                _managed = file.Header.ComDescriptorDirectory.VirtualAddress != 0;

                if (file.GetPdbSignature(out string pdbName, out Guid guid, out int age))
                {
                    _pdb = new PdbInfo()
                    {
                        FileName = pdbName,
                        Guid     = guid,
                        Revision = age
                    };
                }
            }
            catch
            {
            }
            finally
            {
                if (file != null)
                {
                    file.Dispose();
                }
            }
        }
Beispiel #3
0
        //# Cleans up native resources used by the module collection.
        //# remarks: This will dispose resources for all contained modules, including the manifest module.
        //# It will invalidate the containing assembly and all objects it contains.
        public void Dispose()
        {
            if (m_mainFile != null)
            {
                m_mainFile.Dispose();
            }

            if (m_otherModules != null)
            {
                foreach (var obj in m_otherModules)
                {
                    var peFile = obj as PEFile;
                    if (peFile != null)
                    {
                        peFile.Dispose();
                    }
                }
            }
            m_otherModules = null;
            m_mainFile     = null;
            m_assembly     = null;
        }
Beispiel #4
0
 unsafe void LoadModule(int index)
 {
     if (m_otherModules[index] == null)
     {
         lock (m_lockObject) {
             if (m_otherModules[index] == null)
             {
                 var f = (FileRow *)m_mainFile.GetRow(new ZeroBasedIndex(index), MetadataTable.File);
                 if ((f->Flags & FileAttributes.ContainsNoMetadata) != 0)
                 {
                     m_otherModules[index] = Module.CreateNonMetadataModule(
                         m_assembly,
                         m_mainFile.ReadSystemString(
                             f->GetNameOffset(m_mainFile)
                             )
                         );
                 }
                 else
                 {
                     PEFile peFile = null;
                     try {
                         peFile = new PEFile(m_assembly, m_mainFile.ReadSystemString(f->GetNameOffset(m_mainFile)));
                         m_otherModules[index] = peFile;
                     }
                     catch {
                         if (peFile != null)
                         {
                             peFile.Dispose();
                         }
                         throw;
                     }
                 }
             }
         }
     }
 }
Beispiel #5
0
 public void Dispose()
 {
     PEFile?.Dispose();
 }
Beispiel #6
0
 /// <summary>
 ///     Closes any file handles and cleans up resources.
 /// </summary>
 /// <inheritdoc />
 public void Dispose() => PeFile.Dispose();