コード例 #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;
        }
コード例 #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();
                }
            }
        }
コード例 #3
0
ファイル: ModuleCollection.cs プロジェクト: dbremner/tiny
        //# 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;
        }
コード例 #4
0
ファイル: ModuleCollection.cs プロジェクト: dbremner/tiny
 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;
                     }
                 }
             }
         }
     }
 }
コード例 #5
0
 public void Dispose()
 {
     PEFile?.Dispose();
 }
コード例 #6
0
ファイル: PeFileAdapter.cs プロジェクト: tysmithnet/mortician
 /// <summary>
 ///     Closes any file handles and cleans up resources.
 /// </summary>
 /// <inheritdoc />
 public void Dispose() => PeFile.Dispose();