void removeMemberItem_Click(object sender, EventArgs e) { if (tablesTree.SelectedNode != null && tablesTree.SelectedNode.Tag is MetaDataMember) { MetaDataMember member = tablesTree.SelectedNode.Tag as MetaDataMember; currentTablesHeap.GetTable(member.TableType, false).RemoveMember(member); tablesTree.SelectedNode.Remove(); } }
private void CacheMethodBodies(TablesHeap tablesHeap) { Constructor.Log("Caching .NET method bodies."); foreach (MethodDefinition methodDef in tablesHeap.GetTable(MetaDataTableType.Method).Members) { if (methodDef.HasBody) { // check if valid rva. if (!Constructor.OriginalAssembly.Image.ContainsOffset(Offset.FromRva(methodDef.RVA, Constructor.OriginalAssembly).FileOffset)) { Constructor.Log("Failed to read method body.", LogMessageType.Error, new ArgumentException("Invalid method RVA.")); } // cache instructions. methodDef.Body.LoadCache(); } } }
internal void RemoveEmptyTables() { ulong validMask = 0; for (int i = 0; i < 45; i++) { if (tablesHeap.HasTable((MetaDataTableType)i)) { MetaDataTable table = tablesHeap.GetTable((MetaDataTableType)i); if (table.Members.Length > 0) { validMask |= ((ulong)1 << i); } else { tablesHeap.tables[i] = null; } } } tablesHeap.MaskValid = validMask; }
private void CollectMembers(TablesHeap tablesHeap, Workspace workspace) { Constructor.Log("Collecting .NET metadata members."); for (int i = 0; i < tablesHeap._tables.Length; i++) { MetaDataTableType tableType = (MetaDataTableType)i; if (tablesHeap.HasTable(tableType)) { MetaDataTable table = tablesHeap.GetTable(tableType); if (table.Members.Count != 0) { MetaDataMemberInfo[] subMembers = new MetaDataMemberInfo[table.Members.Count]; for (int j = 0; j < subMembers.Length; j++) { subMembers[j] = new MetaDataMemberInfo(table.Members[j]); } workspace.Members.Add(tableType, subMembers); } } } }