public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) { if (destType == typeof(string) && value is FlashBlock) { // Cast the value to an Employee type FlashBlock pp = (FlashBlock)value; return(pp.BlockNumber.ToString()); } return(base.ConvertTo(context, culture, value, destType)); }
private void DecodeExtraInfo(string filename) { AddToHeaderLog("DecodeExtraInfo begins for : " + Path.GetFileName(filename)); // get the info that is stored in coded form in blocks from 4000 // read all flashblocks byte[] file_data = readdatafromfile(filename, 0x4000, 0x4000); // example: //44 2A 02 00 00 00 40 CE 00 FF FF FF // info block? //44 2A 01 30 00 00 42 D8 01 00 00 03 * // the last FF FF FF points us to the segment where non coded into is stored like the immo code // the partnumber etc // read that first // @ 0x4004 and 0x6004 there are two 4 byte counters which indicate which block (0x4000 or 0x6000 was last written, so active?) // <*MFS><4bytecounter>FFFFFFFFFF<D*> in which D* indicates the start of the first header int blockNumber = 0; int segmentBlocks = 0; int _lowSegmentCounter = 0; int _highSegmentCounter = 0; _lowSegmentCounter = Convert.ToInt32(file_data[0x0004]) * 256 * 256 * 256; _lowSegmentCounter += Convert.ToInt32(file_data[0x0005]) * 256 * 256; _lowSegmentCounter += Convert.ToInt32(file_data[0x0006]) * 256; _lowSegmentCounter += Convert.ToInt32(file_data[0x0007]); _highSegmentCounter = Convert.ToInt32(file_data[0x2004]) * 256 * 256 * 256; _highSegmentCounter += Convert.ToInt32(file_data[0x2005]) * 256 * 256; _highSegmentCounter += Convert.ToInt32(file_data[0x2006]) * 256; _highSegmentCounter += Convert.ToInt32(file_data[0x2007]); // Thread.Sleep(100); // <to get the debug output correct> // get the addresses of the lower flash blocks int idx = 0x0E; int lowBlkCnt = 0; int lowAddressIdx = 0; for (int t = 0; t < 32; t++) { string descriptor = string.Empty; descriptor += file_data[idx].ToString("X2") + " "; descriptor += file_data[idx + 1].ToString("X2") + " "; descriptor += file_data[idx + 2].ToString("X2") + " "; descriptor += file_data[idx + 3].ToString("X2") + " "; descriptor += file_data[idx + 4].ToString("X2") + " "; descriptor += file_data[idx + 5].ToString("X2") + " "; AddToHeaderLog(descriptor); if (file_data[idx] != 0x44 || file_data[idx+1] != 0x2A) { if (lowBlkCnt == 0) { lowaddress[lowAddressIdx] = Convert.ToInt32(file_data[idx]) * 256 + Convert.ToInt32(file_data[idx + 1]); lowtypes[lowAddressIdx] = Convert.ToInt32(file_data[idx+5]); lowAddressIdx++; } if (lowBlkCnt >= 2) { lowaddress[lowAddressIdx] = Convert.ToInt32(file_data[idx]) * 256 + Convert.ToInt32(file_data[idx +1]); lowtypes[lowAddressIdx] = Convert.ToInt32(file_data[idx + 5]); ; lowAddressIdx++; } lowBlkCnt++; } idx += 6; } int highBlkCnt = 0; int highAddressIdx = 0; idx = 0x200E; for (int t = 0; t < 32; t++) { if (file_data[idx] != 0x44 || file_data[idx + 1] != 0x2A) { if (highBlkCnt == 0) { highaddress[highAddressIdx] = Convert.ToInt32(file_data[idx]) * 256 + Convert.ToInt32(file_data[idx + 1]); hightypes[highAddressIdx] = Convert.ToInt32(file_data[idx + 5]); highAddressIdx++; } if (highBlkCnt >= 2) { highaddress[highAddressIdx] = Convert.ToInt32(file_data[idx]) * 256 + Convert.ToInt32(file_data[idx + 1]); hightypes[highAddressIdx] = Convert.ToInt32(file_data[idx + 5]); ; highAddressIdx++; } highBlkCnt++; } idx += 6; } AddToHeaderLog("Low segment headers"); for (int t = 0; t < 32; t++) { if (lowaddress[t] != 0 && lowaddress[t] != 0xFFFF) { AddToHeaderLog("Found low address: " + lowaddress[t].ToString("X8") + " type: " + lowtypes[t].ToString("X2")); // AddToHeaderLog("Low segment headers address : " + address.ToString("X8") + " type: " + type.ToString("X4")); switch (lowtypes[t]) { case 0x01: // history record pointer, ignore /* debug */ AddToHeaderLog("LOW history record: " + blockNumber.ToString()); FlashBlock fb01 = new FlashBlock(); fb01.BlockType = lowtypes[t]; fb01.BlockAddress = lowaddress[t]; byte[] block_data01 = new byte[0x130]; for (int bt = 0; bt < 0x130; bt++) { block_data01[bt] = file_data[bt + lowaddress[t] - 0x4000]; } fb01.BlockData = block_data01; if (fb01.isValid()) { fb01.BlockNumber = blockNumber; fbc.Add(fb01); blockNumber++; segmentBlocks++; } /* debug */ break; case 0x03: // active record pointer AddToHeaderLog("LOW active record: " + blockNumber.ToString()); FlashBlock fb = new FlashBlock(); fb.BlockType = lowtypes[t]; fb.BlockAddress = lowaddress[t]; byte[] block_data = new byte[0x130]; for (int bt = 0; bt < 0x130; bt++) { block_data[bt] = file_data[bt + lowaddress[t] - 0x4000]; } fb.BlockData = block_data; if (fb.isValid()) { fb.BlockNumber = blockNumber; fbc.Add(fb); blockNumber++; segmentBlocks++; } break; case 0xFF: // information record pointer // read this record and fill immocode etc AddToHeaderLog("LOW 0xFF record: " + blockNumber.ToString()); try { string t_PartNumber = ""; int pc = 0; for (pc = 0; pc < 10; pc++) { t_PartNumber += Convert.ToChar(file_data[lowaddress[t] - 0x4000 + pc]); } m_PartNumber = t_PartNumber.Trim(); // first 10 bytes are serialnumber (but different from PI-area?) // 16 bytes immocode string t_ImmobilizerID = ""; for (pc = 0; pc < 16; pc++) { t_ImmobilizerID += Convert.ToChar(file_data[lowaddress[t] - 0x4000 + pc + 10]); } m_ImmobilizerID = t_ImmobilizerID.Trim(); } catch (Exception E) { AddToHeaderLog("Failed to process low header 0xFF record: " + E.Message); } break; } string dbg = string.Empty; for (int bt = 0; bt < 12; bt++) { dbg += file_data[0x0E + ((t * 24) + bt)].ToString("X2") + " "; } AddToHeaderLog(dbg); } } for (int t = 0; t < 32; t++) { if (highaddress[t] != 0 && highaddress[t] != 0xFFFF) { AddToHeaderLog("Found high address: " + highaddress[t].ToString("X8") + " type: " + hightypes[t].ToString("X2")); switch (hightypes[t]) { case 0x01: // history record pointer, ignore /* debug */ AddToHeaderLog("HIGH history record: " + blockNumber.ToString()); FlashBlock fb01 = new FlashBlock(); fb01.BlockAddress = highaddress[t]; fb01.BlockType = hightypes[t]; byte[] block_data01 = new byte[0x130]; for (int bt = 0; bt < 0x130; bt++) { block_data01[bt] = file_data[bt + highaddress[t] - 0x4000]; } fb01.BlockData = block_data01; if (fb01.isValid()) { fb01.BlockNumber = blockNumber; fbc.Add(fb01); blockNumber++; segmentBlocks++; } /* debug */ break; case 0x03: // active record pointer AddToHeaderLog("HIGH active record: " + blockNumber.ToString()); FlashBlock fb = new FlashBlock(); fb.BlockAddress = highaddress[t]; fb.BlockType = hightypes[t]; byte[] block_data = new byte[0x130]; for (int bt = 0; bt < 0x130; bt++) { block_data[bt] = file_data[bt + highaddress[t] - 0x4000]; } fb.BlockData = block_data; if (fb.isValid()) { fb.BlockNumber = blockNumber; fbc.Add(fb); blockNumber++; segmentBlocks++; } break; case 0xFF: // information record pointer // read this record and fill immocode etc AddToHeaderLog("HIGH 0xFF record: " + blockNumber.ToString()); try { string t_PartNumber = ""; int pc = 0; for (pc = 0; pc < 10; pc++) { t_PartNumber += Convert.ToChar(file_data[highaddress[t] - 0x6000 + pc]); } m_PartNumber = t_PartNumber.Trim(); // first 10 bytes are serialnumber (but different from PI-area?) // 16 bytes immocode string t_ImmobilizerID = ""; for (pc = 0; pc < 16; pc++) { t_ImmobilizerID += Convert.ToChar(file_data[highaddress[t] - 0x6000 + pc + 10]); } m_ImmobilizerID = t_ImmobilizerID.Trim(); } catch (Exception E) { AddToHeaderLog("Failed to process high header 0xFF record: " + E.Message); } break; } string dbg = string.Empty; for (int bt = 0; bt < 12; bt++) { dbg += file_data[0x200E + ((t * 24) + bt)].ToString("X2") + " "; } AddToHeaderLog(dbg); } } // first find 0x78 0x5A 0x84 0xE6... marks the start of this stuff, there are two halves both 0x2000 bytes long // every block = 0x130 bytes so a maximum of 1A blocks. Substract the offset 0x2d8 in each half which means 2 blocks. // That leaves a maximum number of blocks of 0x18 (24) in each half. int iblock = 0; DumpThisData(file_data, @"C:\t8decode\" + Path.GetFileNameWithoutExtension(filename) + "_memdump.bin"); foreach (FlashBlock fbcheck in fbc) { iblock++; string _vin = string.Empty; string _interfacedevice = string.Empty; string _ecudescription = string.Empty; string secretcode = string.Empty; fbcheck.DecodeBlock(out _vin, out _ecudescription, out _interfacedevice, out secretcode); DumpThisData(fbcheck.BlockData, @"C:\T8Decode\flashblock" + iblock.ToString() + ".blk"); AddToHeaderLog("Found (" + fbcheck.BlockNumber.ToString() + ") VIN: " + _vin + " address: " + fbcheck.BlockAddress.ToString("X8")); AddToHeaderLog("Found (" + fbcheck.BlockNumber.ToString() + ") ECU: " + _ecudescription); AddToHeaderLog("Found (" + fbcheck.BlockNumber.ToString() + ") ITF: " + _interfacedevice); AddToHeaderLog("Found (" + fbcheck.BlockNumber.ToString() + ") SEC: " + secretcode); if (m_ChassisID != _vin) m_ChassisID = _vin; if (_interfaceDevice != _interfacedevice) _interfaceDevice = _interfacedevice; if (_ecuDescription != _ecudescription) _ecuDescription = _ecudescription; } _numberOfFlashBlocks = fbc.Count; }
public void Remove(FlashBlock value) { List.Remove(value); }
public bool Contains(FlashBlock value) { // If value is not of type Int16, this will return false. return(List.Contains(value)); }
public int IndexOf(FlashBlock value) { return(List.IndexOf(value)); }
public void Insert(int index, FlashBlock value) { List.Insert(index, value); }
private void DecodeExtraInfo(string filename) { AddToHeaderLog("DecodeExtraInfo begins for : " + Path.GetFileName(filename)); // get the info that is stored in coded form in blocks from 4000 // read all flashblocks byte[] file_data = readdatafromfile(filename, 0x4000, 0x4000); // example: //44 2A 02 00 00 00 40 CE 00 FF FF FF // info block? //44 2A 01 30 00 00 42 D8 01 00 00 03 * // the last FF FF FF points us to the segment where non coded into is stored like the immo code // the partnumber etc // read that first // @ 0x4004 and 0x6004 there are two 4 byte counters which indicate which block (0x4000 or 0x6000 was last written, so active?) // <*MFS><4bytecounter>FFFFFFFFFF<D*> in which D* indicates the start of the first header int blockNumber = 0; int segmentBlocks = 0; int _lowSegmentCounter = 0; int _highSegmentCounter = 0; _lowSegmentCounter = Convert.ToInt32(file_data[0x0004]) * 256 * 256 * 256; _lowSegmentCounter += Convert.ToInt32(file_data[0x0005]) * 256 * 256; _lowSegmentCounter += Convert.ToInt32(file_data[0x0006]) * 256; _lowSegmentCounter += Convert.ToInt32(file_data[0x0007]); _highSegmentCounter = Convert.ToInt32(file_data[0x2004]) * 256 * 256 * 256; _highSegmentCounter += Convert.ToInt32(file_data[0x2005]) * 256 * 256; _highSegmentCounter += Convert.ToInt32(file_data[0x2006]) * 256; _highSegmentCounter += Convert.ToInt32(file_data[0x2007]); // Thread.Sleep(100); // <to get the debug output correct> // get the addresses of the lower flash blocks int idx = 0x0E; int lowBlkCnt = 0; int lowAddressIdx = 0; for (int t = 0; t < 32; t++) { string descriptor = string.Empty; descriptor += file_data[idx].ToString("X2") + " "; descriptor += file_data[idx + 1].ToString("X2") + " "; descriptor += file_data[idx + 2].ToString("X2") + " "; descriptor += file_data[idx + 3].ToString("X2") + " "; descriptor += file_data[idx + 4].ToString("X2") + " "; descriptor += file_data[idx + 5].ToString("X2") + " "; AddToHeaderLog(descriptor); if (file_data[idx] != 0x44 || file_data[idx + 1] != 0x2A) { if (lowBlkCnt == 0) { lowaddress[lowAddressIdx] = Convert.ToInt32(file_data[idx]) * 256 + Convert.ToInt32(file_data[idx + 1]); lowtypes[lowAddressIdx] = Convert.ToInt32(file_data[idx + 5]); lowAddressIdx++; } if (lowBlkCnt >= 2) { lowaddress[lowAddressIdx] = Convert.ToInt32(file_data[idx]) * 256 + Convert.ToInt32(file_data[idx + 1]); lowtypes[lowAddressIdx] = Convert.ToInt32(file_data[idx + 5]);; lowAddressIdx++; } lowBlkCnt++; } idx += 6; } int highBlkCnt = 0; int highAddressIdx = 0; idx = 0x200E; for (int t = 0; t < 32; t++) { if (file_data[idx] != 0x44 || file_data[idx + 1] != 0x2A) { if (highBlkCnt == 0) { highaddress[highAddressIdx] = Convert.ToInt32(file_data[idx]) * 256 + Convert.ToInt32(file_data[idx + 1]); hightypes[highAddressIdx] = Convert.ToInt32(file_data[idx + 5]); highAddressIdx++; } if (highBlkCnt >= 2) { highaddress[highAddressIdx] = Convert.ToInt32(file_data[idx]) * 256 + Convert.ToInt32(file_data[idx + 1]); hightypes[highAddressIdx] = Convert.ToInt32(file_data[idx + 5]);; highAddressIdx++; } highBlkCnt++; } idx += 6; } AddToHeaderLog("Low segment headers"); for (int t = 0; t < 32; t++) { if (lowaddress[t] != 0 && lowaddress[t] != 0xFFFF) { AddToHeaderLog("Found low address: " + lowaddress[t].ToString("X8") + " type: " + lowtypes[t].ToString("X2")); // AddToHeaderLog("Low segment headers address : " + address.ToString("X8") + " type: " + type.ToString("X4")); switch (lowtypes[t]) { case 0x01: // history record pointer, ignore /* debug */ AddToHeaderLog("LOW history record: " + blockNumber.ToString()); FlashBlock fb01 = new FlashBlock(); fb01.BlockType = lowtypes[t]; fb01.BlockAddress = lowaddress[t]; byte[] block_data01 = new byte[0x130]; for (int bt = 0; bt < 0x130; bt++) { block_data01[bt] = file_data[bt + lowaddress[t] - 0x4000]; } fb01.BlockData = block_data01; if (fb01.isValid()) { fb01.BlockNumber = blockNumber; fbc.Add(fb01); blockNumber++; segmentBlocks++; } /* debug */ break; case 0x03: // active record pointer AddToHeaderLog("LOW active record: " + blockNumber.ToString()); FlashBlock fb = new FlashBlock(); fb.BlockType = lowtypes[t]; fb.BlockAddress = lowaddress[t]; byte[] block_data = new byte[0x130]; for (int bt = 0; bt < 0x130; bt++) { block_data[bt] = file_data[bt + lowaddress[t] - 0x4000]; } fb.BlockData = block_data; if (fb.isValid()) { fb.BlockNumber = blockNumber; fbc.Add(fb); blockNumber++; segmentBlocks++; } break; case 0xFF: // information record pointer // read this record and fill immocode etc AddToHeaderLog("LOW 0xFF record: " + blockNumber.ToString()); try { string t_PartNumber = ""; int pc = 0; for (pc = 0; pc < 10; pc++) { t_PartNumber += Convert.ToChar(file_data[lowaddress[t] - 0x4000 + pc]); } m_PartNumber = t_PartNumber.Trim(); // first 10 bytes are serialnumber (but different from PI-area?) // 16 bytes immocode string t_SerialNumber = ""; for (pc = 0; pc < 16; pc++) { t_SerialNumber += Convert.ToChar(file_data[lowaddress[t] - 0x4000 + pc + 10]); } m_SerialNumber = t_SerialNumber.Trim(); } catch (Exception E) { AddToHeaderLog("Failed to process low header 0xFF record: " + E.Message); } break; } string dbg = string.Empty; for (int bt = 0; bt < 12; bt++) { dbg += file_data[0x0E + ((t * 24) + bt)].ToString("X2") + " "; } AddToHeaderLog(dbg); } } for (int t = 0; t < 32; t++) { if (highaddress[t] != 0 && highaddress[t] != 0xFFFF) { AddToHeaderLog("Found high address: " + highaddress[t].ToString("X8") + " type: " + hightypes[t].ToString("X2")); switch (hightypes[t]) { case 0x01: // history record pointer, ignore /* debug */ AddToHeaderLog("HIGH history record: " + blockNumber.ToString()); FlashBlock fb01 = new FlashBlock(); fb01.BlockAddress = highaddress[t]; fb01.BlockType = hightypes[t]; byte[] block_data01 = new byte[0x130]; for (int bt = 0; bt < 0x130; bt++) { block_data01[bt] = file_data[bt + highaddress[t] - 0x4000]; } fb01.BlockData = block_data01; if (fb01.isValid()) { fb01.BlockNumber = blockNumber; fbc.Add(fb01); blockNumber++; segmentBlocks++; } /* debug */ break; case 0x03: // active record pointer AddToHeaderLog("HIGH active record: " + blockNumber.ToString()); FlashBlock fb = new FlashBlock(); fb.BlockAddress = highaddress[t]; fb.BlockType = hightypes[t]; byte[] block_data = new byte[0x130]; for (int bt = 0; bt < 0x130; bt++) { block_data[bt] = file_data[bt + highaddress[t] - 0x4000]; } fb.BlockData = block_data; if (fb.isValid()) { fb.BlockNumber = blockNumber; fbc.Add(fb); blockNumber++; segmentBlocks++; } break; case 0xFF: // information record pointer // read this record and fill immocode etc AddToHeaderLog("HIGH 0xFF record: " + blockNumber.ToString()); try { string t_PartNumber = ""; int pc = 0; for (pc = 0; pc < 10; pc++) { t_PartNumber += Convert.ToChar(file_data[highaddress[t] - 0x6000 + pc]); } m_PartNumber = t_PartNumber.Trim(); // first 10 bytes are serialnumber (but different from PI-area?) // 16 bytes immocode string t_serialNumber = ""; for (pc = 0; pc < 16; pc++) { t_serialNumber += Convert.ToChar(file_data[highaddress[t] - 0x6000 + pc + 10]); } m_SerialNumber = t_serialNumber.Trim(); } catch (Exception E) { AddToHeaderLog("Failed to process high header 0xFF record: " + E.Message); } break; } string dbg = string.Empty; for (int bt = 0; bt < 12; bt++) { dbg += file_data[0x200E + ((t * 24) + bt)].ToString("X2") + " "; } AddToHeaderLog(dbg); } } // first find 0x78 0x5A 0x84 0xE6... marks the start of this stuff, there are two halves both 0x2000 bytes long // every block = 0x130 bytes so a maximum of 1A blocks. Substract the offset 0x2d8 in each half which means 2 blocks. // That leaves a maximum number of blocks of 0x18 (24) in each half. int iblock = 0; DumpThisData(file_data, @"C:\t8decode\" + Path.GetFileNameWithoutExtension(filename) + "_memdump.bin"); foreach (FlashBlock fbcheck in fbc) { iblock++; string _vin = string.Empty; string _interfacedevice = string.Empty; string _ecudescription = string.Empty; string secretcode = string.Empty; fbcheck.DecodeBlock(out _vin, out _ecudescription, out _interfacedevice, out secretcode); DumpThisData(fbcheck.BlockData, @"C:\T8Decode\flashblock" + iblock.ToString() + ".blk"); AddToHeaderLog("Found (" + fbcheck.BlockNumber.ToString() + ") VIN: " + _vin + " address: " + fbcheck.BlockAddress.ToString("X8")); AddToHeaderLog("Found (" + fbcheck.BlockNumber.ToString() + ") ECU: " + _ecudescription); AddToHeaderLog("Found (" + fbcheck.BlockNumber.ToString() + ") ITF: " + _interfacedevice); AddToHeaderLog("Found (" + fbcheck.BlockNumber.ToString() + ") SEC: " + secretcode); if (m_ChassisID != _vin) { m_ChassisID = _vin; } if (_interfaceDevice != _interfacedevice) { _interfaceDevice = _interfacedevice; } if (_ecuDescription != _ecudescription) { _ecuDescription = _ecudescription; } } _numberOfFlashBlocks = fbc.Count; }
public int Add(FlashBlock value) { return(List.Add(value)); }
public bool Contains(FlashBlock value) { // If value is not of type Int16, this will return false. return (List.Contains(value)); }
public int Add(FlashBlock value) { return (List.Add(value)); }
public int IndexOf(FlashBlock value) { return (List.IndexOf(value)); }