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; }
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(); } } }
//# 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; }
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; } } } } } }
public void Dispose() { PEFile?.Dispose(); }
/// <summary> /// Closes any file handles and cleans up resources. /// </summary> /// <inheritdoc /> public void Dispose() => PeFile.Dispose();