public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) { if (destType == typeof(string) && value is MNemonicHelper) { // Cast the value to an Employee type MNemonicHelper pp = (MNemonicHelper)value; return(pp.Mnemonic + ", " + pp.Address.ToString("X8")); } return(base.ConvertTo(context, culture, value, destType)); }
private void AddLabel(long trgaddr) { if (trgaddr < 0xF00000) { MNemonicHelper label = new MNemonicHelper(); label.Address = trgaddr; label.Mnemonic = "LBL_" + trgaddr.ToString("X8") + ":"; if (!_passOne) { if (!LabelPresent(trgaddr)) { labels.Add(label); } } else { if (!AddressInLabelList(trgaddr)) { _labels.Add(label); } } } }
private void TranslateLabels(MNemonicHelper mnemonic) { if (AddressInLabelList(mnemonic.Mnemonic)) { foreach (MNemonicHelper label in _labels) { if (mnemonic.Mnemonic.Contains("JSR") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); break; } else if (mnemonic.Mnemonic.Contains("BEQ") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); break; } else if (mnemonic.Mnemonic.Contains("BRA") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); break; } else if (mnemonic.Mnemonic.Contains("BLS") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); break; } else if (mnemonic.Mnemonic.Contains("BNE") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); break; } else if (mnemonic.Mnemonic.Contains("BHI") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); break; } else if (mnemonic.Mnemonic.Contains("BCS") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); break; } else if (mnemonic.Mnemonic.Contains("BCC") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); break; } else if (mnemonic.Mnemonic.Contains("BGE") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); break; } else if (mnemonic.Mnemonic.Contains("BLT") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); break; } else if (mnemonic.Mnemonic.Contains("BGT") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); break; } else if (mnemonic.Mnemonic.Contains("BLE") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); break; } } } }
private void LoadLabels(long addr, FileStream fs, BinaryReader br, long offset) { MNemonicHelper label = new MNemonicHelper(); MNemonicCollection functionList = new MNemonicCollection(); label.Mnemonic = "Function_" + addr.ToString("X8") + ":"; label.Address = addr; if (AddressInLabelList(addr)) { return; } long offaddr = 0; if (addr == 0) return; if (addr > offset) { fs.Position = addr - offset; } else { fs.Position = addr; } bool endsub = false; bool issub = false; bool isjump = false; string str; while (!endsub) { byte ch1 = br.ReadByte(); byte ch2 = br.ReadByte(); uint i = (uint)((ch1 << 8) + ch2); uint seg = (uint)(((addr + offaddr) & 0xffff0000) >> 16); uint adr = (uint)(((addr + offaddr) & 0xffff)); uint t = disasm(out str, addr, ch1, ch2, offaddr, br, out endsub, out issub, out isjump); if (str != "") { MNemonicHelper mnhelper = new MNemonicHelper(); mnhelper.Mnemonic = str; mnhelper.Address = addr; //realAddr = fs.Position + offset; //mnhelper.Address = realAddr; functionList.Add(mnhelper); } if (t > 5) t = 5; //addr += t; switch (t) { case 0: case 1: addr += 2L; break; case 2: addr += 4L; break; case 3: addr += 6L; break; case 4: addr += 8L; break; case 5: addr += 10L; break; } if (issub) { if (trgdata != 0) { if (!AddressInLabelList(trgdata)) { if (trgdata < 0x00F00000) { long position = fs.Position; LoadLabels(trgdata, fs, br, offset); fs.Position = position; // reset to previous position } } } } if (endsub) { } } // assign a meaningful name to the function if we can // we know what the rom->ram copy routine looks like bool _has_Rom_IgnitionMap = false; bool _has_Ram_IgnitionMap = false; bool _has_Rom_FuelMap = false; bool _has_Ram_FuelMap = false; bool _has_KontrollOrd = false; bool _has_Da_insp = false; bool _has_Tq = false; bool _has_EB = false; bool _has_IdleNeutral = false; string _functionName = string.Empty; foreach (MNemonicHelper functionHelper in functionList) { //Console.WriteLine(functionHelper.Address.ToString("X8") + " " + functionHelper.Mnemonic); if (functionHelper.Mnemonic.Contains("ROM_Ign_map_0!")) _has_Rom_IgnitionMap = true; if (functionHelper.Mnemonic.Contains("RAM_Ign_map_0!")) _has_Ram_IgnitionMap = true; if (functionHelper.Mnemonic.Contains("RAM_Insp_mat!")) _has_Ram_FuelMap = true; if (functionHelper.Mnemonic.Contains("ROM_Insp_mat!")) _has_Rom_FuelMap = true; if (functionHelper.Mnemonic.Contains("#ABCD")) _has_KontrollOrd = true; if (functionHelper.Mnemonic.Contains("Da_insp")) _has_Da_insp = true; if (functionHelper.Mnemonic.Contains("#EB")) _has_EB = true; if (functionHelper.Mnemonic.Contains("Tq")) _has_Tq = true; if (functionHelper.Mnemonic.Contains("Idle_rpm_offNeutral")) _has_IdleNeutral = true; //Idle_rpm_offNeutral } if (_has_Ram_IgnitionMap && _has_Rom_IgnitionMap) _functionName = "CopyIgnitionRomToRam:"; else if (_has_Ram_FuelMap && _has_Rom_FuelMap) _functionName = "CopyFuelRomToRam:"; else if (_has_Ram_IgnitionMap) _functionName = "CalculateIgnitionAngle:"; else if (_has_Ram_FuelMap && !_has_Rom_FuelMap) _functionName = "CalculateInjectionDuration:"; else if (_has_KontrollOrd) _functionName = "CheckSRAMIntegrity:"; else if (_has_Da_insp) _functionName = "CalcInjectionForCylinder:"; else if (_has_EB && _has_Tq) _functionName = "CalculateTorque:"; else if (_has_IdleNeutral) _functionName = "DetermineIdleStatus:"; if (_functionName != string.Empty) { label.Mnemonic = _functionName; } _labels.Add(label); }
public bool Contains(MNemonicHelper value) { // If value is not of type Int16, this will return false. return(List.Contains(value)); }
public void Insert(int index, MNemonicHelper value) { List.Insert(index, value); }
public void Remove(MNemonicHelper value) { List.Remove(value); }
public int Add(MNemonicHelper value) { return(List.Add(value)); }
public int IndexOf(MNemonicHelper value) { return(List.IndexOf(value)); }
public bool Contains(MNemonicHelper value) { // If value is not of type Int16, this will return false. return (List.Contains(value)); }
public int Add(MNemonicHelper value) { return (List.Add(value)); }
public int IndexOf(MNemonicHelper value) { return (List.IndexOf(value)); }