private void VerifyCodeBlocks(byte[] allBytes, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
{
//000001=automatic,000002=manual,000003=4wd ????
Tools.Instance.m_codeBlock5ID = 0;
Tools.Instance.m_codeBlock6ID = 0;
Tools.Instance.m_codeBlock7ID = 0;
bool found = true;
int offset = 0;
int defaultCodeBlockLength = 0x10000;
int currentCodeBlockLength = 0;
int prevCodeBlockStart = 0;
while (found)
{
int CodeBlockAddress = Tools.Instance.findSequence(allBytes, offset, new byte[16] { 0x14, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, new byte[16] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
if (CodeBlockAddress > 0)
{
CodeBlock newcodeblock = new CodeBlock();
newcodeblock.StartAddress = CodeBlockAddress +128;
if (prevCodeBlockStart == 0) prevCodeBlockStart = newcodeblock.StartAddress;
else if (currentCodeBlockLength == 0)
{
currentCodeBlockLength = newcodeblock.StartAddress - prevCodeBlockStart;
if (currentCodeBlockLength > 0x10000) currentCodeBlockLength = 0x10000;
}
// find the next occurence of the checksum
newCodeBlocks.Add(newcodeblock);
offset = CodeBlockAddress + 128;
}
else found = false;
}
foreach (CodeBlock cb in newCodeBlocks)
{
if (currentCodeBlockLength != 0) cb.EndAddress = cb.StartAddress + currentCodeBlockLength - 1;
else cb.EndAddress = cb.StartAddress + defaultCodeBlockLength - 1;
}
foreach (CodeBlock cb in newCodeBlocks)
{
CheckCodeBlock(cb.StartAddress, allBytes, newSymbols, newCodeBlocks);
}
}