private T CreateDiaTable <T>() where T : class { IDiaEnumTables enumTables = null; try { this.session.getEnumTables(out enumTables); if (enumTables == null) { return(null); } // GetEnumerator() fails in netcoreapp2.0--need to iterate without foreach. for (int i = 0; i < enumTables.Count; i++) { IDiaTable table = enumTables.Item(i); if (!(table is T result)) { Marshal.ReleaseComObject(table); } else { return(result); } }
public int Enum(string arg) { IDiaEnumSymbols EnumSymbols = null; IDiaSymbol Master = null; IDiaEnumTables tables = null; int level = 2; uint compileFetched = 0; //DebugHelp.SymFindDebugInfoFile(hCurrentProcess, SymPath, arg, ) var foo = new Dia2Lib.DiaSource(); foo.loadDataForExe(arg, SymPath, null); //foo.loadDataFromPdb(arg); foo.openSession(out Session); if (Session == null) { return(-1); } Session.loadAddress = 0; uint rva = 0; //do //{ // try // { // Session.findChildren(Session.globalScope, SymTagEnum.SymTagNull, null, 0, out EnumSymbols); // var tot1 = EnumSymbols.count; // uint curr1 = 0; // do // { // EnumSymbols.Next(1, out Master, out compileFetched); // if (Master == null) // continue; // ForegroundColor = ConsoleColor.White; // foreach (var pr in typeof(IDiaSymbol).LinqPublicProperties()) // { // WriteLine($"{pr.Name} = {pr.GetValue(Master)}"); // } // //foreach (var fn in typeof(IDiaSymbol).LinqPublicFunctions()) // //{ // // //if (fn.Name.Contains("get")) // // WriteLine($"{fn.Name} = {fn.Invoke(Master, null)}"); // //} // // DumpSymbol<IDiaSymbol>(Master, ref level); // } while (curr1++ < tot1); // //foreach (var pr in typeof(IDiaSymbol).LinqPublicProperties()) // // WriteLine($"{pr.Name} = {pr.GetValue(Master)}"); // } // catch { } // finally // { // if (Master != null) // rva += (uint)(Master.length == 0 ? 1 : Master.length); // } //} while (Master != null); var GlobalScope = Session.globalScope; IDiaEnumDebugStreams DebugStreams; Session.getEnumDebugStreams(out DebugStreams); for (int i = 0; i < DebugStreams.count; i++) { var ds = DebugStreams.Item(i); foreach (var pr in typeof(IDiaEnumDebugStreamData).LinqPublicProperties()) { WriteLine($"{pr.Name} = {pr.GetValue(ds)}"); } } Session.getEnumTables(out tables); for (int i = 0; i < tables.count; i++) { var ds = tables.Item(i); foreach (var pr in typeof(IDiaTable).LinqPublicProperties()) { WriteLine($"{pr.Name} = {pr.GetValue(ds)}"); } } GlobalScope.findChildren(SymTagEnum.SymTagNull, null, 0, out EnumSymbols); var tot = EnumSymbols.count; var curr = 0; do { EnumSymbols.Next(1, out Master, out compileFetched); if (Master == null) { continue; } ForegroundColor = ConsoleColor.White; //foreach (var pr in typeof(IDiaSymbol).LinqPublicProperties()) //WriteLine($"{pr.Name} = {pr.GetValue(Master)}"); DumpSymbol <IDiaSymbol>(Master, level); } while (curr++ < tot); return(0); }