public static MxeEntryType GetEntryType(MxeIndexEntry mie) { int length = BitConverter.ToInt32(mie.TypeCode.GetBytes(), 0); string name = mie.GetVmTitle(); MxeEntryType ret = _other; if (_knownTypes.ContainsKey(name)) { ret = CheckTypeLength(mie, name, ret); } else if (name.StartsWith(VIM_PART)) { string oldName = StripAdditionalName(name); if (_knownTypes.ContainsKey(oldName)) { MxeEntryType newType = new MxeEntryType(name, mie.GetExpectedByteWords()); newType.Headers = _knownTypes[oldName].Headers.ToArray().ToList(); //cheater clone? while (newType.Headers.Count < newType.Length) { newType.Headers.Add(String.Empty); } ConfigDiscovery.AddNewMxeType(newType); _knownTypes.Add(newType.Type1, newType); ret = newType; } } return(ret); }
private static MxeEntryType CheckTypeLength(MxeIndexEntry mie, string name, MxeEntryType ret) { MxeEntryType met = _knownTypes[name]; int indexLength = mie.GetExpectedByteWords(); if (met.Length == indexLength) { ret = met; } else { Console.Out.WriteLine(String.Format(ERROR_FORMAT, name, met.Length, indexLength)); } return(ret); }
public MxeBlockEntry(MxeIndexEntry mie, int position) { _type = MxeEntryType.GetEntryType(mie); _position = position; _entries = new List <MxeWord>(); for (int i = 0; i < _type.Length && _type.Headers != null && _type.Headers.Count > i; i++) { _entries.Add(new MxeWord(position + i * 4, _type.Headers[i])); } if (_type.Equals(MxeEntryType.Other) && _entries.Count < 1) { for (int i = 0; i < mie.GetExpectedByteWords(); i++) { _entries.Add(new MxeWord(position + i * 4, String.Empty)); } } }
public MxeBlockEntry( MxeIndexEntry mie, int position ) { _type = MxeEntryType.GetEntryType(mie); _position = position; _entries = new List<MxeWord>(); for (int i = 0; i < _type.Length && _type.Headers != null && _type.Headers.Count > i; i++) { _entries.Add(new MxeWord(position + i * 4, _type.Headers[i])); } if(_type.Equals(MxeEntryType.Other) && _entries.Count < 1) { for (int i = 0; i < mie.GetExpectedByteWords(); i++) { _entries.Add(new MxeWord(position + i * 4, String.Empty)); } } }
private static MxeEntryType CheckTypeLength(MxeIndexEntry mie, string name, MxeEntryType ret) { MxeEntryType met = _knownTypes[name]; int indexLength = mie.GetExpectedByteWords(); if (met.Length == indexLength) { ret = met; } else { Console.Out.WriteLine(String.Format(ERROR_FORMAT, name, met.Length, indexLength)); } return ret; }
public static MxeEntryType GetEntryType( MxeIndexEntry mie ) { int length = BitConverter.ToInt32(mie.TypeCode.GetBytes(),0); string name = mie.GetVmTitle(); MxeEntryType ret = _other; if (_knownTypes.ContainsKey(name)) { ret = CheckTypeLength(mie, name, ret); } else if(name.StartsWith(VIM_PART)) { string oldName = StripAdditionalName(name); if (_knownTypes.ContainsKey(oldName)) { MxeEntryType newType = new MxeEntryType(name, mie.GetExpectedByteWords()); newType.Headers = _knownTypes[oldName].Headers.ToArray().ToList(); //cheater clone? while (newType.Headers.Count < newType.Length) { newType.Headers.Add(String.Empty); } ConfigDiscovery.AddNewMxeType(newType); _knownTypes.Add(newType.Type1, newType); ret = newType; } } return ret; }
protected override void ReadTableMeta(FileStream stream) { _tableCount = new ByteWord(_tableCountAddr); _tableStart = new ByteWord(_tableStartAddr); _tableCount.ReadFromFile(stream); _tableStart.ReadFromFile(stream); int current = BitConverter.ToInt32( _tableStart.GetBytes(), 0 ); int count = BitConverter.ToInt32( _tableCount.GetBytes(), 0 ); Console.Out.WriteLine("Entry count: " + count); for (int i = 0; i < count; i++) { MxeIndexEntry e = new MxeIndexEntry(GetRealAddress(current)); e.ReadEntry(stream); _indexes.Add(e.GetIndex(), e); current += _tableStart.Length * 4; } Dictionary<string, MxeEntryType> dts = DiscoverTypes(stream); RefreshOtherTypesToDiscoveredType(dts); }