public void TestFieldsMapfiles() { string error; const string parentsPath = @"D:\Jerzy\WinDbgStuff\dumps\DumpSearch\DumpSearch.exe_160711_121816.map\DumpSearch.exe_160711_121816.FIELDPARENTINSTANCES[0].map"; const string offsetsPath = @"D:\Jerzy\WinDbgStuff\dumps\DumpSearch\DumpSearch.exe_160711_121816.map\DumpSearch.exe_160711_121816.FIELDPARENTOFFSETS[0].map"; ulong fldAddr = 0x00000002488cc8; var fieldInfos = FieldDependency.GetFieldOffsets(offsetsPath, out error); ulong[] fldAddresses = fieldInfos.Item1; long[] parentOffsets = fieldInfos.Item2; var ndx = Array.BinarySearch(fldAddresses, fldAddr); Assert.IsTrue(ndx >= 0); Assert.IsNull(error); using (var mmf = FieldDependency.GetFieldParentMap(parentsPath, "ParentInstances", out error)) { KeyValuePair <ulong, int>[] parents = FieldDependency.GetFieldParents(mmf, parentOffsets[ndx], parentOffsets[ndx + 1], out error); Assert.IsNull(error); } }
private FieldDependency[] GetFieldDependencies(Type type) { FieldInfo[] fieldInfos = type.GetFields(DEPENDENCY_VARIABLE_FLAGS) .Where(f => f.GetCustomAttributes(typeof (Inject), true).Length > 0).ToArray(); FieldDependency[] fieldDependencies = new FieldDependency[fieldInfos.Length]; for (int i = 0; i < fieldInfos.Length; i++) { Type fieldType = fieldInfos[i].FieldType; if (fieldType == type) { throw new InjectToSelfException(type.FullName); } fieldDependencies[i] = new FieldDependency(fieldInfos[i], GetDependency(fieldType)); } return fieldDependencies; }