diff --git a/BoschHelper.cpp b/BoschHelper.cpp new file mode 100644 index 0000000..cf9c2b9 --- /dev/null +++ b/BoschHelper.cpp @@ -0,0 +1,868 @@ +// BoschHelper.cpp: implementation of the BoschHelper class. +// +////////////////////////////////////////////////////////////////////// +//Standard Defs +typedef int BOOL; +#define FALSE 0 +#define TRUE 1 +#define NULL 0 + +#include +#include //str2reg() +#include +#include +#include +#include +#include +#include +#include +#include //SetDefaultRegisterValue() +#include // processor instructions +#include //get_func() +#include //for enumerations +#include // for showaddr + +#include "BoschHelper.h" +//#include "FunctionSigs.h" + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +BoschHelper::BoschHelper() +{ + mSelector = 1; + +} + +BoschHelper::~BoschHelper() +{ + +} + + +////////////////////////////////////////////////////////////////////// +// Helpers +////////////////////////////////////////////////////////////////////// + +// Loops through the binary and makes disassembled code +bool BoschHelper::CreateDissCode(ea_t eaStartAddr, ea_t eaEndAddr) +{ + msg("Creating disassembly from 0x%x through to 0x%x\n", eaStartAddr, eaEndAddr); + + ea_t eaAddr, eaLenOfGeneratedCode; + int iCount, iReturns; + ushort uWord; + + eaAddr = eaStartAddr; + eaLenOfGeneratedCode = 1; + iCount = iReturns = 1; + + show_wait_box("Creating disassembly..."); + for (eaAddr; eaAddr(get_16bit(eaAddr));//read the word at the current location + + if(uWord == 0xffff) + { +// msg("0xffff read at 0x%x\n", eaAddr); + doWord(eaAddr, 4);//Convert to data word + eaAddr+=1;//skip these bytes + } + else if(uWord == 0x0000) + { +// msg("0x0000 read at 0x%x\n", eaAddr); + doWord(eaAddr, 4);//Convert to data word + eaAddr+=1;//skip these bytes + } + else if(uWord == 0x8000) + { +// msg("0x8000 read at 0x%x\n", eaAddr); + doWord(eaAddr, 4);//Convert to data word + eaAddr+=1;//skip these bytes + } + else + { + //attempt to disassemble the next code + eaLenOfGeneratedCode = create_insn(eaAddr);//create the disassembled code and return the length of it + //msg("Code created at 0x%X\n", eaAddr); + if(eaLenOfGeneratedCode == 0) + {//guard against nothing happening + eaLenOfGeneratedCode++; + } + else if(iCount >= 0x200) + { + iCount=0; + msg("."); + } + else if(iReturns >= 0x4000) + { + iReturns=0; + msg("\n"); + } + } + } + msg("\n"); + hide_wait_box(); + + msg("Looking through code to make subroutines....\n"); + // + // Look for subroutines within the code + // + + eaAddr = eaStartAddr; + eaLenOfGeneratedCode = 1; + iCount = iReturns = 1; + + // Instructions we know that subroutines don't start with. + int instrs[] = { C166_jmps, C166_jmpr, C166_ret, C166_reti, C166_retp, C166_rets, C166_rol, C166_add, C166_shr, C166_xor, C166_xorb, 0 }; + char mnem[MAXSTR]; + const char *res; + bool bFound; + + show_wait_box("Making subroutines..."); + for (eaAddr; eaAddrendEA - func->startEA); + } + else + { + eaAddr++; + } + } + else + { + eaAddr++; + } + } + else + { + eaAddr++; + } + } + hide_wait_box(); + return true; +} + +// Loops through the binary and searches for where DTC flags are being set. +bool BoschHelper::EnumDTCflags(ea_t eaStartAddr, ea_t eaEndAddr) +{ + msg("Searching for DTC setting flags from 0x%x through to 0x%x\n", eaStartAddr, eaEndAddr); + + // Instructions we know that DTC setting is done by. + char mnem[MAXSTR]; + const char *res; +// uval_t uvalOp1Value, uvalOp2Value; + + ea_t eaAddr; + + eaAddr = eaStartAddr;// sets the start + + show_wait_box("Searching for DTCs..."); + for (eaAddr; eaAddr> 4;// divide by 16 + msg("Creating segment at para %x, start address %x, end address %x, name %s, selector 0x%x\n", eaParagraph, eaStartAddr, eaEndAddr, cBuf, mSelector); + set_selector(mSelector, eaParagraph); +// set_selector(mSelector, 0); + mSelector++; + msg("Adding new segments\n"); + add_segm(eaParagraph, eaStartAddr, eaEndAddr, cBuf, sclass); + + //Set the default register values for this segment + msg("Setting DPPs\n"); + SetC16xRegs("dpp0", dpp0); + SetC16xRegs("dpp1", dpp1); + SetC16xRegs("dpp2", dpp2); + SetC16xRegs("dpp3", dpp3); + msg("BoschHelper::CreateC16xSmallBoschSegments Finished\n"); + return 1; +} + +// Creates the correct Bosch segments and default registers +bool BoschHelper::CreateC16xBoschSegments(ea_t eaParagraph, unsigned int iNumSegsToCreate, const char *sclass, sel_t dpp0, sel_t dpp1, sel_t dpp2, sel_t dpp3) +{ + sel_t selSelector = 0; + ea_t eaStartAddr, eaEndAddr; + int iDPPNum; + char cBuf[20]; + + msg("\nBoschHelper::CreateC16xBoschSegments Started\n"); + for(selSelector; selSelector\n", eaAddr); + msg(" Op0: n = %d type = %d reg = %d value = %a addr = %a\n", + cmd.Operands[0].n, + cmd.Operands[0].type, + cmd.Operands[0].reg, + cmd.Operands[0].value, + cmd.Operands[0].addr); + msg(" Op1: n = %d type = %d reg = %d value = %a addr = %a\n", + cmd.Operands[1].n, + cmd.Operands[1].type, + cmd.Operands[1].reg, + cmd.Operands[1].value, + cmd.Operands[1].addr); +*/ + // Is the instruction Memory Reg [Base Reg + Index Reg + Displacement] phrase+addr? + // If so, then these need converting into offset addresses + if(cmd.Operands[0].type == o_displ) + { + //r0 is a special register and should not be offsetted + if(cmd.Operands[0].reg!= 0) + if(cmd.Operands[0].addr >= 0x00ff) + MakeC166Offset(eaAddr, 0); + } + else if(cmd.Operands[1].type == o_displ) + { + //r0 is a special register and should not be offsetted + if(cmd.Operands[1].reg!= 0) + if(cmd.Operands[1].addr >= 0x00ff) + MakeC166Offset(eaAddr, 1); + } + } + } + eaAddr++; + } + hide_wait_box(); + return 1; +} + +//Makes C166 offsets utilising the correct DPP value +// eaAddr = Address of the instruction +// nOp = Operand Number +void BoschHelper::MakeC166Offset(ea_t eaAddr, int nOp) +{ + //Translate the address we get into a real address + int iReg; + ea_t eaDpp; + sel_t selSelector; + + //Find out what DPP the address we've found lives in. + //The DPP selector is the top two bits + eaDpp = (cmd.Operands[1].addr & 0xc000) >> 14; + if(eaDpp == 0) + { + iReg = str2reg("DPP0"); + } + else if (eaDpp==1) + { + iReg = str2reg("DPP1"); + } + else if (eaDpp==2) + { + iReg = str2reg("DPP2"); + } + else + { + iReg = str2reg("DPP3"); + } + //Get the value of the selected register + //Don't ask me why but the register needs to be multiplied by 16 to become the base + selSelector = get_segreg(eaAddr, iReg) << 4; + ea_t eaOffsetBase = get_offbase(eaAddr, nOp);//For information, not used + msg("**** At address 0x%x DPP number 0x%x for Register 0x%x, is 0x%x. Op is 0x%x. Offset base is 0x%x\n", eaAddr, eaDpp, iReg, selSelector, nOp, eaOffsetBase); + //Create the offset + if(op_offset(eaAddr, nOp, REF_OFF16, BADADDR, selSelector) == 0) + { + msg("op_offset failed\n"); + } +} + +// Loops through the binary and tries to make code offsets from implicit references +// e.g. movb [r5+0E0A4h], rl4 = movb [r5+word_E0A4], rl4 +//mov r4, #0F9F6h ; Move Word <- Here's the address +//mov r5, #0 ; Move Word <- Here's the segment +//movbz r2, rl6 ; Move Byte Zero Extend +//shl r2, #1 ; Shift Left +//mov r3, #0 ; Move Word +//add r4, r2 ; Integer Addition +//addc r5, r3 ; Integer Addition with Carry +//exts r5, #1 ; Begin Extended Segment Sequence <- This requires a segment +//mov r12, [r4] ; Move Word with phrase <- This requires an address +bool BoschHelper::FindAndCreateImplicitOffsets(ea_t eaStartAddr, ea_t eaEndAddr) +{ + msg("Finding implicit offsets and trying to create them from 0x%x through to 0x%x\n", eaStartAddr, eaEndAddr); + + ea_t eaAddr, eaLenOfGeneratedCode; + int iCount, iReturns; + + // + // Look for known function that will contain offsets within the code + // + + eaAddr = eaStartAddr; + eaLenOfGeneratedCode = 1; + iCount = iReturns = 1; + + // Instructions we know that contain addresses. + int instrs[] = { C166_mov, 0 }; + char mnem[MAXSTR]; + const char *res; + bool bFound; + + show_wait_box("Searching for implicit offsets..."); + + for (eaAddr; eaAddr\n", eaAddr); + msg(" Op0: n = %d type = %d reg = %d value = %a addr = %a\n", + cmd.Operands[0].n, + cmd.Operands[0].type, + cmd.Operands[0].reg, + cmd.Operands[0].value, + cmd.Operands[0].addr); + msg(" Op1: n = %d type = %d reg = %d value = %a addr = %a\n", + cmd.Operands[1].n, + cmd.Operands[1].type, + cmd.Operands[1].reg, + cmd.Operands[1].value, + cmd.Operands[1].addr); + + // Is the instruction a Memory Ref [Base Reg + Index Reg] and not r0? + // If so, then we need to back track and see when it's loaded with an immediate + // Need to do this for cmd.Operands[0] and cmd.Operands[1] + // Also backtrack one instruction and see if there's a "exts" + if((cmd.Operands[1].type == o_phrase) & (cmd.Operands[1].reg != 0)) + { + msg("We're at a phrase and need to look for where r%a was immediate loaded.\n", cmd.Operands[1].reg); + // We need to backtrack & find where this register was loaded immediate at op1 + + //r0 is a special register and should not be offsetted +// if(cmd.Operands[1].reg!= 0) +// if(cmd.Operands[1].addr >= 0x00ff) +// MakeC166Offset(eaAddr, 1); + } + } + } + eaAddr++; + } + hide_wait_box(); + return 1; +} + +////////////////////////////////////////////////////////////////////// +// Implementation +////////////////////////////////////////////////////////////////////// + +//Automatically disassembles the code and tries to make subroutines +void BoschHelper::MakeDissCode(string sECU) +{ + if(sECU == "bNewME711") + { + CreateDissCode(0x00000, 0xdfff); + CreateDissCode(0x10000, 0xcffff); + //CreateDissCode(0x800014, 0x803422); + CreateDissCode(0x800014, 0x8fffff); + //CreateDissCode(0x800014, 0x80ffff); + //RAM is @ 0x380000 - 0x383fff - size 0x4000 + //Data is @0x8 + CreateDissCode(0x81e28c, 0x81ea40); + } + else if (sECU == "ME761Astra") + { + CreateDissCode(0x0000, 0x3fff); + CreateDissCode(0x4000, 0x7fff); + CreateDissCode(0x10000, 0xaffff); + CreateDissCode(0xc0000, 0xcff00); + } + else + { + CreateDissCode(0x00000, 0x1ff); + CreateDissCode(0x700, 0x7fff); + CreateDissCode(0x800000, 0x810000); + CreateDissCode(0x830000, 0x8fff00); + } +} + +//No longer used +//void BoschHelper::MakeSubroutines(void) +//{ +// ea_t eaResult=0, eaLast=0; +// +// add_func(eaResult, BADADDR); +// +// while(eaResult != BADADDR) +// { +// eaResult = find_unknown(eaLast, SEARCH_DOWN); +// if(add_func(eaResult, BADADDR)) +// msg("Function created at %x\n", eaResult); +// +// if( (eaResult > MAP_AREA_START) & (eaResult < MAP_AREA_FINISH) ) +// { +// msg("Ignoring data - within MAP area\n"); +// eaResult = MAP_AREA_FINISH; +// } +// if(eaResult == BADADDR) +// msg("End of Auto-Disassemble analysis loop\n"); +// +// eaLast = eaResult; +// } +// +//} + +//Makes the segments of the disassembly +//void BoschHelper::MakeSegments(BOOL bNewME711) +void BoschHelper::MakeSegments(string sECU) +{ + //bool BoschHelper::CreateC16xBoschSegments(ea_t eaParagraph, unsigned int iNumSegsToCreate, const char *sclass, sel_t dpp0, sel_t dpp1, sel_t dpp2, sel_t dpp3) + if(sECU == "bNewME711") + { + //CreateC16xBoschSegments(0x0000, 4, "ABS", 0x0, 0x1, 2, 3); + CreateC16xSmallBoschSegments(0x0000, 0x8000, "MEM_EXT", "CODE", 0x23f, 0x3c, 0x0e0, 3); + //SFR + CreateC16xSmallBoschSegments(0x8000, 0xE000, "MEM_EXT", "CODE", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xSmallBoschSegments(0xE000, 0xE800, "XRAM", "DATA", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xSmallBoschSegments(0xE800, 0xEf00, "RESERVED", "BSS", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xSmallBoschSegments(0xEf00, 0xf000, "CAN1", "DATA", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xSmallBoschSegments(0xf000, 0xf200, "E_SFR", "DATA", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xSmallBoschSegments(0xf200, 0xf600, "RESERVED", "BSS", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xSmallBoschSegments(0xf600, 0xfE00, "IRAM", "CODE", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xSmallBoschSegments(0xfe00, 0x10000, "SFR", "DATA", 0x23f, 0x3c, 0x0e0, 3); + + //MPU ROM + CreateC16xBoschSegments(0x1000, 4, "MPUCODE", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xBoschSegments(0x2000, 4, "MPUCODE", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xBoschSegments(0x3000, 4, "MPUCODE", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xBoschSegments(0x4000, 4, "MPUCODE", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xBoschSegments(0x5000, 4, "MPUCODE", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xBoschSegments(0x6000, 4, "MPUCODE", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xBoschSegments(0x7000, 4, "MPUCODE", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xBoschSegments(0x8000, 4, "MPUCODE", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xBoschSegments(0x9000, 4, "MPUCODE", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xBoschSegments(0xa000, 4, "MPUCODE", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xBoschSegments(0xb000, 4, "DATA", 0x23f, 0x3c, 0x0e0, 3); + CreateC16xBoschSegments(0xc000, 4, "DATA", 0x23f, 0x3c, 0x0e0, 3); + + //RAM + CreateC16xBoschSegments(0xe000, 4, "CODERAM", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0xf000, 4, "CODERAM", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x38000, 4, "DATARAM", 0x23f, 0x3c, 0xe0, 3); + + //ROM + CreateC16xBoschSegments(0x80000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x81000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x82000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x83000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x84000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x85000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x86000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x87000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x88000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x89000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x8a000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x8b000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x8c000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x8d000, 4, "CODE", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x8e000, 4, "DATA", 0x23f, 0x3c, 0xe0, 3); + CreateC16xBoschSegments(0x8f000, 4, "DATA", 0x23f, 0x3c, 0xe0, 3); + } + else if (sECU == "ME761Astra") + { + CreateC16xSmallBoschSegments(0x0000, 0x8000, "MEM_EXT", "CODE", 0x0, 0x1, 0x2, 0x3); + //SFR + CreateC16xSmallBoschSegments(0x8000, 0xE000, "MEM_EXT", "CODE", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xE000, 0xE800, "XRAM", "DATA", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xE800, 0xEf00, "RESERVED", "BSS", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xEf00, 0xf000, "CAN1", "DATA", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xf000, 0xf200, "E_SFR", "DATA", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xf200, 0xf600, "RESERVED", "BSS", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xf600, 0xfE00, "IRAM", "CODE", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xfe00, 0x10000, "SFR", "DATA", 0x0, 0x1, 0x2, 0x3); + //RAM + CreateC16xBoschSegments(0xf000, 4, "DATA" , 0x2c, 0x2d, 0x3c, 3); + //ROM + CreateC16xBoschSegments(0x1000, 4, "CODE", 0x2c, 0x2d, 0x3c, 3); + CreateC16xBoschSegments(0x2000, 4, "CODE", 0x2c, 0x2d, 0x3c, 3); + CreateC16xBoschSegments(0x3000, 4, "CODE", 0x2c, 0x2d, 0x3c, 3); + CreateC16xBoschSegments(0x4000, 4, "CODE", 0x2c, 0x2d, 0x3c, 3); + CreateC16xBoschSegments(0x5000, 4, "CODE", 0x2c, 0x2d, 0x3c, 3); + CreateC16xBoschSegments(0x6000, 4, "CODE", 0x2c, 0x2d, 0x3c, 3); + CreateC16xBoschSegments(0x7000, 4, "CODE", 0x2c, 0x2d, 0x3c, 3); + CreateC16xBoschSegments(0x8000, 4, "CODE", 0x2c, 0x2d, 0x3c, 3); + CreateC16xBoschSegments(0x9000, 4, "CODE", 0x2c, 0x2d, 0x3c, 3); + CreateC16xBoschSegments(0xa000, 4, "CODE", 0x2c, 0x2d, 0x3c, 3); + CreateC16xBoschSegments(0xb000, 4, "DATA", 0x2c, 0x2d, 0x3c, 3); + CreateC16xBoschSegments(0xc000, 4, "CODE", 0x2c, 0x2d, 0x3c, 3); + CreateC16xBoschSegments(0xd000, 4, "CODE", 0x2c, 0x2d, 0x3c, 3); + } + else + { + CreateC16xSmallBoschSegments(0x0000, 0x8000, "MEM_EXT", "CODE", 0x0, 0x1, 0x2, 0x3); + //SFR + CreateC16xSmallBoschSegments(0x8000, 0xE000, "MEM_EXT", "CODE", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xE000, 0xE800, "XRAM", "DATA", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xE800, 0xEf00, "RESERVED", "BSS", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xEf00, 0xf000, "CAN1", "DATA", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xf000, 0xf200, "E_SFR", "DATA", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xf200, 0xf600, "RESERVED", "BSS", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xf600, 0xfE00, "IRAM", "CODE", 0x0, 0x1, 0x2, 0x3); + CreateC16xSmallBoschSegments(0xfe00, 0x10000, "SFR", "DATA", 0x0, 0x1, 0x2, 0x3); + //RAM + CreateC16xBoschSegments(0x38000, 2, "DATA" , 0x204, 0x205, 0xe0, 3); + //ROM + CreateC16xBoschSegments(0x80000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x81000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x82000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x83000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x84000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x85000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x86000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x87000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x88000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x89000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x8a000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x8b000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x8c000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x8d000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x8e000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + CreateC16xBoschSegments(0x8f000, 4, "CODE", 0x204, 0x205, 0xe0, 3); + } +} + +//Looks for signatures of commonly known functions and set their name. +//Test routine! +//void BoschHelper::SearchForFuncSigs(BOOL bNewME711) +//{ +// //No longer used +// const uchar test[]={0xfa, 0x82, 0xd8, 0x00, 0xfa, 0xff, 0xDC, 0x00}; +// ea_t eaFound; +// +// eaFound = FindBinaryWithDontCare((uchar*)test, 8, 0x800000, 0x80ffff); +// if(eaFound != BADADDR) +// msg("Found Sig at 0x%x\n", eaFound); +// else +// msg("Sig not found\n"); +//} + +//Looks for Bosch DTC setting fields. +void BoschHelper::SearchForDTCFlagSetting(string sECU) +{ + //Create the enum constants first + enum_t enumtID; + + //The DTC enum for low bits + enumtID = add_enum(BADADDR, "DTCLBit", 0x1100000);//Create the enum + set_enum_bf(enumtID, 1);//Set the enum to a bitfield + //Now fill the enum structure + add_enum_member(enumtID,"DTCBit_L0", 0x1, 0x1); + add_enum_member(enumtID,"DTCBit_L1", 0x2, 0x2); + add_enum_member(enumtID,"DTCBit_L2", 0x4, 0x4); + add_enum_member(enumtID,"DTCBit_L3", 0x8, 0x8); + add_enum_member(enumtID,"DTCBit_L4", 0x10, 0x10); + add_enum_member(enumtID,"DTCBit_L5", 0x20, 0x20); + add_enum_member(enumtID,"DTCBit_L6", 0x40, 0x40); + add_enum_member(enumtID,"DTCBit_L7", 0x80, 0x80); + + //The DTC enum for high bits + enumtID = add_enum(BADADDR, "DTCHBit", 0x1100000);//Create the enum + set_enum_bf(enumtID, 1);//Set the enum to a bitfield + //Now fill the enum structure + add_enum_member(enumtID,"DTCFieldA_H0", 0x1, 0x1); + set_enum_cmt(get_const(enumtID, 0x1, NULL, 0x1),"Select DTC Group A",1); + //set_enum_cmt(get_const(enumtID, 0x1, NULL, 0x1), "Select DTC Group A", 1); + add_enum_member(enumtID, "DTCFieldB_H1", 0x2, 0x2); + set_enum_cmt(get_const(enumtID, 0x2, NULL, 0x2),"Select DTC Group B",1); + add_enum_member(enumtID,"DTCFieldC_H2", 0x4, 0x4); + set_enum_cmt(get_const(enumtID, 0x4, NULL, 0x4),"Select DTC Group C",1); + add_enum_member(enumtID,"DTCFieldD_H3", 0x8, 0x8); + set_enum_cmt(get_const(enumtID, 0x8, NULL, 0x8),"Select DTC Group D",1); + add_enum_member(enumtID,"DTCBit_H4", 0x10, 0x10); + add_enum_member(enumtID,"DTCBit_H5", 0x20, 0x20); + add_enum_member(enumtID,"DTCBit_H6", 0x40, 0x40); + add_enum_member(enumtID,"DTCBit_H7", 0x80, 0x80); + + //Search the disassembly for enum flag setting + if(sECU == "bNewME711") + { + EnumDTCflags(0x00000, 0xffffff); + } + else if (sECU == "ME761Astra") + { + EnumDTCflags(0x10000, 0xff000); + } + else + { + EnumDTCflags(0x820000, 0x8ff000); + } +} + +//Looks for specific binary patterns and then makes a subroutine and comments it +void BoschHelper::SearchForFuncSigsAndThenCmt(string sECU) +{ + if (sECU == "ME761Astra") + { + msg("*** ME761Astra 1st pass\n"); + functionsigsclass.FindFuncSigsAndComment(0x0, 0x3fff); + msg("*** ME761Astra 2nd pass\n"); + functionsigsclass.FindFuncSigsAndComment(0x4000, 0x7fff); + msg("*** ME761Astra 3rd pass\n"); + functionsigsclass.FindFuncSigsAndComment(0x8000, 0xdfff); + msg("*** ME761Astra 4th pass\n"); + functionsigsclass.FindFuncSigsAndComment(0x10000, 0xdffff); + } + else + { + msg("Everything Else\n"); + functionsigsclass.FindFuncSigsAndComment(0x0, 0xffffff); + } + +// FindFuncSigsAndComment(0x8de4b4, 0x8de566); +} + +//Looks for instructions that will probably contain an offset. When found it creates them. +void BoschHelper::SearchForArrayOffsetsAndThenCreate(string sECU) +{ + if(sECU == "bNewME711") + { + FindAndCreateArrayOffsets(0x0, 0xffffff); + } + else if (sECU == "ME761Astra") + { + FindAndCreateArrayOffsets(0x0, 0x3fff); + FindAndCreateArrayOffsets(0x4000, 0x7fff); + FindAndCreateArrayOffsets(0x8000, 0xdfff); + FindAndCreateArrayOffsets(0x10000, 0xdffff); + } + else + { + FindAndCreateArrayOffsets(0x0, 0x8fffff); + } +// FindAndCreateImplicitOffsets(0x8694b4, 0x8694ce); +} diff --git a/BoschHelper.h b/BoschHelper.h new file mode 100644 index 0000000..a02f120 --- /dev/null +++ b/BoschHelper.h @@ -0,0 +1,52 @@ +// BoschHelper.h: interface for the BoschHelper class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_BOSCHHELPER_H__9F97668B_19D4_4904_923E_1C391DF3A947__INCLUDED_) +#define AFX_BOSCHHELPER_H__9F97668B_19D4_4904_923E_1C391DF3A947__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "FunctionSigs.h" +#include + +using namespace std; + +#define ROM_START 0x800000 +#define MAP_AREA_START 0x810000 +#define MAP_AREA_FINISH 0x822000 + +class BoschHelper : public FunctionSigs +{ +public: + BoschHelper(); + virtual ~BoschHelper(); + + FunctionSigs functionsigsclass; + sel_t mSelector;// Used to count the selector + + //helper functions +protected: + bool CreateDissCode(ea_t eaStartAddr, ea_t eaEndAddr);// Loops through the binary and makes disassembled code + bool BoschHelper::EnumDTCflags(ea_t eaStartAddr, ea_t eaEndAddr);// Loops through the binary and searches for where DTC flags are being set. + bool SetC16xRegs(const char *RegName, sel_t value);// Sets the default register values on the C16x CPU + bool CreateC16xSmallBoschSegments(ea_t eaStartAddr, ea_t eaEndAddr, char* cName, const char *sclass, sel_t dpp0, sel_t dpp1, sel_t dpp2, sel_t dpp3);// Creates a Bosch segment and default registers + bool CreateC16xBoschSegments(ea_t eaParagraph, unsigned int iNumSegsToCreate, const char *sclass, sel_t dpp0, sel_t dpp1, sel_t dpp2, sel_t dpp3);// Creates the correct Bosch segments and default registers + bool FindAndCreateArrayOffsets(ea_t eaStartAddr, ea_t eaEndAddr);// Loops through the binary and tries to make code offsets + void MakeC166Offset(ea_t eaAddr, int nOp);//Makes C166 offsets utilising the correct DPP value + bool FindAndCreateImplicitOffsets(ea_t eaStartAddr, ea_t eaEndAddr); + + //implementation +public: + void MakeDissCode(string sECU);//Automatically disassembles the code and tries to make subroutines + //void MakeSubroutines(void);//No longer used + void MakeSegments(string sECU);//Makes the segments of the disassembly + //void SearchForFuncSigs(BOOL bNewME711);//Looks for signatures of commonly known functions and set their name. + void SearchForDTCFlagSetting(string sECU);//Looks for Bosch DTC setting fields. + void SearchForFuncSigsAndThenCmt(string sECU);//Looks for specific binary patterns and then makes a subroutine and comments it + void SearchForArrayOffsetsAndThenCreate(string sECU);//Looks for instructions that will probably contain an offset. When found it creates them. +}; + +#endif // !defined(AFX_BOSCHHELPER_H__9F97668B_19D4_4904_923E_1C391DF3A947__INCLUDED_) diff --git a/Explain Offset Problem.txt b/Explain Offset Problem.txt new file mode 100644 index 0000000..43189de --- /dev/null +++ b/Explain Offset Problem.txt @@ -0,0 +1,26 @@ +I'm been pulling my hair out with trying to figure out how to create an offset with the IDA SDK. + +Here's a snippet of code: + +Seg0x200@800000:2818 loc_802818: ; CODE XREF: sub_80274E+E0.j +Seg0x200@800000:2818 movbz r12, rl6 +Seg0x200@800000:281A shl r12, #1 +Seg0x200@800000:281C extp #0, #1 +Seg0x200@800000:2820 mov r4, [r12+430h] +Seg0x200@800000:2824 mov [r12+0E210h], r4 + +If I select the offset and press "O", IDA correctly creates the offset. + +Seg0x200@800000:2818 loc_802818: ; CODE XREF: sub_80274E+E0.j +Seg0x200@800000:2818 movbz r12, rl6 +Seg0x200@800000:281A shl r12, #1 +Seg0x200@800000:281C extp #0, #1 +Seg0x200@800000:2820 mov r4, [r12+word_430] +Seg0x200@800000:2824 mov [r12+word_E210], r4 + +If I execute an IDC script with this code: + +OpOff(0x802820, 1, 0x800000); +OpOff(0x802824, 0, 0x800000); + +This works great... however, I cannot get the same working in the sdk :confused: diff --git a/FunctionSigs.cpp b/FunctionSigs.cpp new file mode 100644 index 0000000..27137b1 --- /dev/null +++ b/FunctionSigs.cpp @@ -0,0 +1,1271 @@ +#include +// FunctionSigs.cpp: implementation of the FunctionSigs class. +// +////////////////////////////////////////////////////////////////////// + +//Standard Defs +typedef int BOOL; +#define FALSE 0 +#define TRUE 1 +#define NULL 0 + +#include +#include +#include +#include +#include +#include + +#include "FunctionSigs.h"//Has all the function signatures stored within it + +//Defines if the following data is a function or a data array +#define FUNC 1 +#define DATA 2 + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// +#define NUM_FUNC_SIGS 107 + +unsigned char fs_functionnames[NUM_FUNC_SIGS][255] = + { + { "CRC32_MainRoutine" }, + {"Do_CRC32"}, + {"StackJumpR5R4"}, + {"Crc32_ME711" }, + {"MulitpointChksum" }, + {"CopyROMtoRAM"}, + {"WLookup2D_Spark"}, + {"WLookup1D_CTS"}, + {"WLookup2D_BoostAndFuel"}, + {"WLookup1D_RPM"}, + {"BLookup2D_Fuel"}, + {"ParseDTCME71a"}, + {"SetDTCME71a"}, + { "CopyBuffer"}, + { "CRCSub0"}, + { "CRCSub1"}, + { "CRC32Calc"}, + { "MultitaskCRC32"}, + { "ReadADC3"}, + { "CANStuff1"}, + { "CANWriteToMsgController"}, + { "CANStuff0"}, + { "EnableADC"}, + { "ReadADC2"}, + { "SetupADC"}, + { "ReadADC1"}, + { "IRRFiltLoPass16bit_16bitRes0"}, + { "IRRFilt16bit_32bitRes1"}, + { "IRRFilt16bit_32bitRes0"}, + { "TableScaler32by16bit_16bitRes"}, + { "UnsDiv32by16bit_16bitRes"}, + { "UnsDiv16bit_16bitRes"}, + { "SignedMult16bitNegativeA_32bitRes"}, + { "SignedMult16bit_32bitRes"}, + { "UnsMult16bit_16bitHiRes"}, + { "UnsMult16bit_32bitRes"}, + { "UnsMult16bit_16bitRes"}, + { "Signed32bitSubtract"}, + { "Signed8bitSubtract"}, + { "Uns8bitSubtract"}, + { "Signed16bitSubtract"}, + { "Uns16bitSubtract"}, + { "ServiceWatchdog"}, + { "ConditionalMultiply"}, + { "Write32bitValue"}, + { "Read32bitValue"}, + { "ME71VAGseedkey_routine0"}, + { "ME71VAGseedkey_routine1"}, + { "kwp2000_27_SecurityAccess"}, + { "kwp2000_27_SecurityAccessOpel_01"}, + { "kwp2000_27_SecurityAccessOpel_02"}, + { "ME761OPELseedkey_routine0"}, + { "LookupA" }, + { "LookupB" }, + { "LookupC" }, + { "LookupD" }, + { "LookupE" }, + { "LookupF" }, + { "LookupG" }, + { "LookupH" }, + { "LookupI" }, + { "LookupJ" }, + { "LookupK" }, + { "LookupL" }, + { "LookupM" }, + { "LookupN" }, + { "LookupO" }, + { "LookupP" }, + { "LookupQ" }, + { "LookupR" }, + { "LookupS" }, + { "LookupT" }, + { "LookupU" }, + { "LookupV" }, + { "WLookup1DIAT" }, + { "LookupX" }, + { "LookupY" }, + { "LookupZ" }, + { "LookupAA" }, + { "WLookup2DBoost" }, + { "LookupAC" }, + { "LookupAD" }, + { "LookupAE" }, + { "LookupAF" }, + { "CRC8Sub" }, + { "CRC8ME75" }, + {"RSACallingSub"}, + {"CRC32ME71Sub"}, + {"CRC32ME75Sub"}, + {"CRC32ME75"}, + {"TestSub"}, + {"SetDTCME75"}, + {"SetDTCME75"}, + {"SetDTCME75"}, + {"SetDTCME71"}, + {"SetDTCME75"}, + {"SetDTCME75"}, + {"SetDTCME761"}, + {"Reset_Handler"}, + {"Reset_Handler"}, + {"Chksum803c"}, + {"Chksum803c"}, + {"Chksum803c"}, + {"Chksum803c"}, + {"ValidateROMChksum"}, + {"MainROMChksum"}, + {"MainROMChksum"} + }; + +unsigned char fs_functioncomments[NUM_FUNC_SIGS][255] = + { + { "Main routine to perform the ROM Wide CRC32 checks" }, + {"CRC32 Hash Lookup"}, + {"Jumps to the address R5:R4"}, + {"CRC32 ME711 Routine - Golf R32" }, + {"Multipoint Chksum Routine"}, + {"Copies ROM Code to RAM Area\nProbably for FLASH programming"}, + {"2D Lookup Word Arguments usually Spark related\n\nr12= Main Table map address\nr13= Column Table Addr\nr14= Y\nr15= X"}, + {"1D Lookup Word Arguments usually CTS related\n\nr12= Map address, 1st byte height\nr13= X"}, + {"2D Lookup Word Arguments usually Boost and Fuel related\n\nr12= Map address, 1st byte width, 2nd byte height\nr13= Y\nr14= X"}, + {"1D Lookup Word Arguments usually RPM related\n\nr12= Map address, 1st byte height\nr13= X"}, + {"2D Lookup Byte Arguments usually Fuel related\n\nr12= Map address, 1st byte width, 2nd byte height\nr13= Y\nr14= X"}, + {"Parses the Diagnostic Trouble Code\nr12 = ErrorCode"}, + {"Sets the Diagnostic Trouble Code\nr12 = ErrorCode"}, + {"Copies a buffer\n\nr12:AddrFrom\nr13:Segment\nr14:AddrTo\nr15:Length\n"}, + {"Calculates a CRC Checksum\n\nr12: Addr\nr13: Length\n"}, + {"Calculates a CRC Checksum\n\nr12: AddrFromLo\nr13: AddrFromHi\nr14: AddrToLo\nr15: AddrToHi"}, + {"Calculates CRC32 Checksum\n\nr12: AddrFromLo\nr13: AddrFromHi\nr14: AddrToLo\nr15: AddrToHi"}, + {"Calculates CRC32 Chksums but multitasks\n\nr12: AddrFromLo\nr13: AddrFromHi\nr14: AddrToLo\nr15: AddrToHi"}, + {"Read ADC - 16 bit result into an array"}, + {"CAN Stuff"}, + {"CAN Write To Msg Controller"}, + {"CAN Stuff"}, + {"Enable ADC"}, + {"Read ADC2 - 16 bit result into an array\nr12 = ADC Channel\nr13 = Address to write ADC result"}, + {"Setup ADC - Sets up various variables for the ADC"}, + {"Read ADC1 - 16 bit result into an array"}, + {"16bit analogue IRR Lowpass Filter - 16 bit result"}, + {"16bit analogue IRR Filter - 32 bit result"}, + {"16bit analogue IRR Filter - 32 bit result"}, + {"Table Scaler 32bit by 16bit Unsigned Divide - 16 bit result"}, + {"32bit by 16bit Unsigned Divide - 16 bit result"}, + {"16bit Unsigned Divide - 16 bit result"}, + {"16bit Signed Multiply With Negative Handling - 32 bit result\n\nr13 with r12\nResult r4:r5"}, + {"16bit Signed Multiply - 32 bit result\n\nr13 with r12\nResult r4:r5"}, + {"16bit Unsigned Multiply - 16 bit high byte result\n\nr13 with r12\nResult r4"}, + {"16bit Unsigned Multiply - 32 bit result\n\nr13 with r12\nResult r4:r5"}, + {"16bit Unsigned Multiply - 16 bit result\n\nr13 with r12\nResult r4"}, + {"Signed 32bit Subtraction\n\nr13:r12 with r15:r14\nResult r4:r5"}, + {"Signed 8bit Subtraction"}, + {"Unsigned 8bit Subtraction"}, + {"Signed 16bit Subtraction"}, + {"Unsigned 16bit Subtraction"}, + {"Service The Watchdog"}, + {"Conditional Multiply\nr5\nr4\nr10\nr11\n\nreturns 32 bit result r5:r6"}, + {"Write 32 Bit Value\nr5 - DPP\nr4 - Addr\n\nr11 - High Data\nr12 - Low Data"}, + {"Read 32 Bit Value\nr5 - DPP\nr4 - Addr\n\nreturns 32 bit result r11:r12"}, + {"Seedkey Routine\nIN:\nr14,r15=seedLo,seedHi\nr12=xorTable offset\nr13=byte_E240 (loop counter?)\n\nOUT: r4 - 0=key bad, 1=key matches..."}, + {"Seedkey Routine\nIN: r14,r15=seedLo,seedHi\nr12=xorTable offset\nr13=byte_E240 (loop counter?)\n\nOUT: r4 - 0=key bad, 1=key matches..."}, + {"kwp2000_27_SecurityAccess"}, + {"kwp2000_27_SecurityAccessOpel 01"}, + {"kwp2000_27_SecurityAccessOpel 02"}, + {"Seedkey Routine\nIN: r14,r15=seedLo,seedHi\nr12=xorTable offset\nr13=Length (loop counter)\n\nOUT: r4 - 0=key bad, 1=key matches..."}, + {"References a lookupA table"}, + {"References a lookupB table"}, + {"References a lookupC table"}, + {"References a lookupD table"}, + {"References a lookupE table"}, + {"References a lookupF table"}, + {"References a lookupG table"}, + {"References a lookupH table"}, + {"References a lookupI table"}, + {"References a lookupJ table"}, + {"References a lookupK table"}, + {"References a lookupL table"}, + {"References a lookupM table"}, + {"References a lookupN table"}, + {"References a lookupO table"}, + {"References a lookupP table"}, + {"References a lookupQ table"}, + {"References a lookupR table"}, + {"References a lookupS table"}, + {"References a lookupT table"}, + {"References a lookupU table"}, + {"References a lookupV table"}, + {"1D Lookup Word Argument usually IAT related\n\nr12= Map address, 1st byte height\nr13= Map DPP\nr14= X"}, + {"References a lookupX table"}, + {"References a lookupY table"}, + {"References a lookupZ table"}, + {"References a lookupAA table"}, + {"References a lookupAB table"}, + {"2D Lookup Word Arguments usually Boost related\n\nr4 = X\nr5 = Y\nr12= Main Table map address\nr13= Main Table map DPP\nr14= Column Table Addr\nr15= Column Table DPP"}, + {"References a lookup tableAD"}, + {"References a lookup tableAE"}, + {"References a lookup tableAF"}, + {"Calculates a basic CRC8 checksum\n\nr12= Addr\nr13= Seg\nr14= number of bytes"}, + {"Calculates a basic CRC8 checksum\n\nr12= Addr\nr13= Seg\nr14= number of bytes"}, + {"Deals with the RSA checking"}, + {"Calculates the CRC32 checksum\n\nr12: AddrFromLo\nr13: AddrFromHi\nr14: Length"}, + {"Calculates the CRC32 checksum\n\nr12: AddrFromLo\nr13: AddrFromHi\nr14: Length"}, + {"Calculates the CRC32 checksum\n\nr12: AddrFromLo\nr13: AddrFromHi\nr14: Length"}, + {"Test Subroutine"}, + {"Sets the Diagnostic Trouble Code\nr12 = ErrorCode"}, + {"Sets the Diagnostic Trouble Code\nr12 = ErrorCode"}, + {"Sets the Diagnostic Trouble Code\nr12 = ErrorCode"}, + {"Sets the Diagnostic Trouble Code\nr12 = ErrorCode"}, + {"Sets the Diagnostic Trouble Code\nr12 = ErrorCode"}, + {"Sets the Diagnostic Trouble Code\nr12 = ErrorCode"}, + {"Sets the Diagnostic Trouble Code (ME761)\nr12 = ErrorCode"}, + {"Reset Handler (ME7.1)"}, + {"Reset Handler (ME7.6.2)"}, + {"Does the 8038 and 803c checksum"}, + {"Does the 8038 and 803c checksum (ME7.6.1)"}, + {"Does the 8038 and 803c checksum"}, + {"Does the 8038 and 803c checksum (ME7.1.1)"}, + {"Main ROM chksum validate during ECU boot"}, + {"Main ROM chskum during runtime"}, + {"Main ROM chskum during runtime"} + }; +unsigned char fs_sigs[NUM_FUNC_SIGS][310] = { + //CRC32_MainRoutine + { 0x88,0x90,0x88,0x80,0x88,0x70,0x88,0x60,0x28,0x06 }, + //CRC32 ME75 + {0x88,0x60,0x28,0x04,0xc2,0xf4,0x43,0x89,0x68}, + //StackJumpR5R4 Jump to R4:R5 + {0xEC, 0x0F5, 0x0EC, 0x0F4, 0x0DB, 0x00}, //len (6) + //ME711 Golf R32 CRC32 + { 0x28, 0x04, 0xf3, 0xf2, 0xd4, 0x46, 0x8a, 0xf1, 0x02, 0x00, 0xea, 0x00, 0x82, 0x56, 0xd7, 0x40, + 0x3d, 0x00, 0xf3, 0xf4, 0x52, 0x00, 0x9a, 0xf2, 0x02, 0x00, 0xea, 0x00, 0x82, 0x56, 0xf3, 0xf6, + 0xd3, 0x46, 0x9a, 0xf3, 0x02, 0x10, 0xea, 0x00, 0x82, 0x56, 0xf3, 0xf8, 0xf0, 0x56, 0x49, 0x81, + 0xea, 0x30, 0xe0, 0x55, 0x0d, 0x28, 0xf2, 0xfc, 0xfc, 0x56, 0xf2, 0xfd, 0xfe, 0x56, 0xdc, 0x0d }, //len 64 + //RS4 Multipoint Chksum + {0x88, 0x60, 0xf2, 0xf4, 0xff, 0xff, 0x66, 0xf4, 0x00, 0x80, 0x2d, 0x29, 0xe6, 0xf4, 0xff, 0xff, + 0x74, 0xf4, 0xff, 0xff, 0x9a, 0x89, 0x03, 0xa0, 0xf6, 0x8e, 0xff, 0xff, 0x0d, 0x03, 0xe0, 0x24, + 0xf6, 0xf4, 0xff, 0xff, 0xda, 0xff, 0xff, 0xff, 0xf2, 0xf4, 0xff, 0xff, 0x5c, 0x44, 0xf2, 0xfa, + 0xff, 0xff, 0xf2, 0xfb, 0xff, 0xff, 0x00, 0xa4, 0xdc, 0x5b, 0x98, 0x4a, 0xa8, 0x5a}, // len 62 + //RAM Copier probably for FLASH Programming + {0x88, 0x90, 0x88, 0x80, 0xf2, 0xf4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd7, 0x40, 0xe0, 0x00, + 0xf6, 0xff, 0xff, 0xff, 0xd7, 0x40, 0xe1, 0x00, 0xf6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xdc, 0x09, 0xa8, 0x48, 0xdc, 0x0e, 0xb8, 0x4d, 0xf0, 0x4d, 0xf0, 0x5e, + 0x08, 0xd2, 0x18, 0xe0, 0xdc, 0x05, 0xa8, 0x24, 0xf0, 0x48, 0xf0, 0x59, 0x08, 0x82, 0x18, 0x90, + 0xdc, 0x05, 0xa8, 0x34, 0x40, 0x23, 0x2d, 0x04}, + //2d Lookup + {0xa9, 0x4d, 0xc0, 0x4d, 0xf0, 0x1e, 0xc0, 0x31, 0x1b, 0x1d, 0xf2, 0xf1, 0x0e, 0xfe, 0x00, 0xc1, + 0xf0, 0x1f, 0xc0, 0x31, 0x00, 0xc1, 0xa9, 0x4c, 0xd0, 0x42, 0x5c, 0x8f, 0x7c, 0x1f, 0x2d, 0x09, + 0xf4, 0x6c, 0x01, 0x00, 0xd0, 0x63, 0x20, 0x32, 0x5c, 0x13, 0x0b, 0x3f, 0xf2, 0xf3, 0x0c, 0xfe, + 0x00, 0x23, 0xf0, 0x42, 0x5c, 0x8e, 0x7c, 0x1e, 0x2d, 0x13, 0x00, 0xcd, 0x99, 0x4c, 0xd0, 0x42, + 0x78, 0xf0, 0x2d, 0x08, 0xa9, 0x6c, 0xd0, 0x63, 0x20, 0x32, 0x5c, 0x13, 0x0b, 0x3f, 0xf2, 0xf3, + 0x0c, 0xfe, 0x00, 0x23, 0x20, 0x24, 0x5c, 0x12, 0x0b, 0x2e, 0xf2, 0xf2, 0x0c, 0xfe, 0x00, 0x42, + 0xdb, 0x00}, + //1d lookup + {0xe0, 0x04, 0xf0, 0x3d, 0x99, 0x2c, 0xc0, 0x21, 0xf0, 0x2c, 0x49, 0x6a, 0xfd, 0x15, 0x00, 0x21, + 0x28, 0x21, 0x49, 0x6a, 0x9d, 0x0f, 0x08, 0x21, 0x28, 0x21, 0x49, 0x6a, 0x8d, 0xfd, 0x29, 0x6a, + 0x5c, 0x83, 0xf6, 0xf3, 0x0e, 0xfe, 0xf4, 0x62, 0x01, 0x00, 0x29, 0x6a, 0xc0, 0x63, 0x5b, 0x33, + 0xf2, 0xf4, 0x0e, 0xfe, 0x20, 0x2c, 0xf1, 0x94, 0xdb, 0x00}, + //2d lookup + {0x98, 0xbc, 0x66, 0xfb, 0xff, 0x00, 0x5c, 0x1b, 0x08, 0xc2, 0xe0, 0x04, 0xe0, 0x05, 0xe0, 0x01, + 0xf0, 0x2c, 0x48, 0xda, 0xff, 0xff, 0xff, 0x2b, 0x28, 0x22, 0x48, 0xda, 0xff, 0xff, 0xff, 0x22, + 0x28, 0x22, 0x48, 0xda, 0xff, 0xff, 0xff, 0x4d, 0x28, 0x4a, 0xd4, 0x52, 0x02, 0x00, 0x28, 0x5a, + 0x20, 0x2c, 0x7c, 0x12, 0xf0, 0x12, 0xf0, 0xa5, 0x28, 0xc2, 0x98, 0xdc, 0x66, 0xfd, 0xff, 0x00, + 0x5c, 0x1d, 0x00, 0xcb, 0xf0, 0xb4, 0xe0, 0x04, 0xe0, 0x05, 0xe0, 0x0f, 0xf0, 0x2c, 0x48, 0xea, + 0xfd, 0x10, 0x00, 0x2d, 0x28, 0x22, 0x48, 0xea, 0x9d, 0x09, 0x08, 0x22, 0x28, 0x22, 0x48, 0xea, + 0x8d, 0xfd, 0xf0, 0x4e, 0x28, 0x4a, 0xd4, 0x52, 0x02, 0x00, 0x28, 0x5a, 0x20, 0x2c, 0x7c, 0x12, + 0xf0, 0xf2, 0xf0, 0xe4, 0x5c, 0x1f, 0x00, 0xcd, 0x1b, 0x1d, 0xf2, 0xf1, 0x0e, 0xfe, 0x00, 0xc1, + 0x00, 0xcf, 0x98, 0x4c, 0x48, 0xe0, 0x2d, 0x11, 0xa8, 0x3c, 0x40, 0x43, 0xed, 0x07, 0x20, 0x34, + 0x1b, 0x3e, 0x7b, 0x55, 0xf2, 0xf3, 0x0e, 0xfe, 0x00, 0x43, 0x0d, 0x07, 0xf0, 0x24, 0x20, 0x23, + 0x1b, 0x2e, 0x7b, 0x55, 0xf2, 0xf2, 0x0e, 0xfe, 0x20, 0x42, 0x48, 0xb0, 0x2d, 0x26, 0x28, 0xc2, + 0x00, 0xcd, 0x98, 0x3c, 0x48, 0xe0, 0x2d, 0x11, 0xa8, 0x2c, 0x40, 0x32, 0xed, 0x07, 0x20, 0x23, + 0x1b, 0x2e, 0x7b, 0x55, 0xf2, 0xf2, 0x0e, 0xfe, 0x00, 0x32, 0x0d, 0x07, 0xf0, 0x13, 0x20, 0x12, + 0x1b, 0x1e, 0x7b, 0x55, 0xf2, 0xf1, 0x0e, 0xfe, 0x20, 0x31, 0x40, 0x43, 0xed, 0x07, 0x20, 0x34, + 0x1b, 0x3b, 0x7b, 0xaa, 0xf2, 0xf3, 0x0e, 0xfe, 0x00, 0x43, 0x0d, 0x07, 0xf0, 0x24, 0x20, 0x23, + 0x1b, 0x2b, 0x7b, 0xaa, 0xf2, 0xf2, 0x0e, 0xfe, 0x20, 0x42, 0xdb, 0x00}, + //1d Lookup + {0xf0, 0xed, 0x98, 0xdc, 0xe0, 0x04, 0xe0, 0x05, 0xe0, 0x0f, 0xf0, 0x1d, 0x66, 0xf1, 0xff, 0x00, + 0x5c, 0x11, 0xf0, 0x2c, 0x48, 0xea, 0xbd, 0x10, 0x00, 0x21, 0x28, 0x22, 0x48, 0xea, 0xdd, 0x09, + 0x48, 0xea, 0xdd, 0x02, 0x28, 0x22, 0x0d, 0xfc, 0xf0, 0x4e, 0x28, 0x4a, 0xd4, 0x52, 0x02, 0x00, + 0x28, 0x5a, 0x20, 0x2c, 0x7c, 0x12, 0xf0, 0xf2, 0x5c, 0x1d, 0x5c, 0x1f, 0x00, 0xcd, 0x00, 0xcf, + 0xf0, 0x24, 0x98, 0x4c, 0x48, 0x20, 0x2d, 0x11, 0xa8, 0x3c, 0x40, 0x43, 0xad, 0x07, 0x20, 0x34, + 0x0b, 0x32, 0x6b, 0x55, 0xf2, 0xf3, 0x0e, 0xfe, 0x00, 0x43, 0x0d, 0x07, 0xf0, 0x14, 0x20, 0x13, + 0x0b, 0x12, 0x6b, 0x55, 0xf2, 0xf3, 0x0e, 0xfe, 0x20, 0x43, 0xdb, 0x00}, + //2d Lookup + {0x99, 0x6c, 0xc0, 0x6b, 0x08, 0xc1, 0xe0, 0x04, 0xe0, 0x05, 0xe0, 0x01, 0x66, 0xfd, 0xff, 0x00, + 0xf0, 0x3d, 0xf0, 0x2c, 0x49, 0x6a, 0xfd, 0x10, 0x00, 0x2b, 0x28, 0x21, 0x49, 0x6a, 0x9d, 0x0a, + 0x08, 0x21, 0x28, 0x21, 0x49, 0x6a, 0x8d, 0xfd, 0x29, 0x6a, 0xc0, 0x64, 0xf4, 0x62, 0x01, 0x00, + 0x29, 0x6a, 0xc0, 0x65, 0x20, 0x2c, 0xf0, 0x12, 0xf0, 0xa5, 0x28, 0xc1, 0x99, 0x6c, 0x00, 0xcb, + 0xc0, 0x6d, 0xf0, 0xb4, 0xe0, 0x04, 0xe0, 0x05, 0xe0, 0x0f, 0x66, 0xfe, 0xff, 0x00, 0xf0, 0x3e, + 0xf0, 0x2c, 0x49, 0x6a, 0xfd, 0x10, 0x00, 0x2d, 0x28, 0x21, 0x49, 0x6a, 0x9d, 0x0a, 0x08, 0x21, + 0x28, 0x21, 0x49, 0x6a, 0x8d, 0xfd, 0x29, 0x6a, 0xc0, 0x64, 0xf4, 0x62, 0x01, 0x00, 0x29, 0x6a, + 0xc0, 0x65, 0x20, 0x2c, 0xf0, 0xf2, 0xf0, 0xe4, 0x00, 0xcd, 0x1b, 0x1d, 0xf2, 0xf1, 0x0e, 0xfe, + 0x00, 0xc1, 0x00, 0xcf, 0x99, 0x8c, 0xc0, 0x84, 0x48, 0xe0, 0x2d, 0x08, 0xa9, 0x6c, 0xc0, 0x63, + 0x20, 0x34, 0x0b, 0x3e, 0x6b, 0x55, 0xf2, 0xf3, 0x0e, 0xfe, 0x00, 0x43, 0x48, 0xb0, 0x2d, 0x14, + 0x28, 0xc1, 0x00, 0xcd, 0x99, 0x6c, 0xc0, 0x63, 0x48, 0xe0, 0x2d, 0x08, 0xa9, 0x4c, 0xc0, 0x42, + 0x20, 0x23, 0x0b, 0x2e, 0x6b, 0x55, 0xf2, 0xf2, 0x0e, 0xfe, 0x00, 0x32, 0x20, 0x34, 0x0b, 0x3b, + 0x6b, 0xaa, 0xf2, 0xf3, 0x0e, 0xfe, 0x00, 0x43, 0xdb, 0x00}, + //Parses the DTC Code + {0x88, 0xc0, 0x88, 0x90, 0x88, 0x80, 0x88, 0x70, 0x88, 0x60, 0xe6, 0xf4, 0xff, 0xff, 0x64, 0xf4, 0xff, 0xff, 0xf3, 0xf8, 0xff, 0xff, 0x49, 0x83, 0xea, 0x30, 0x28, 0x84, 0xf2, 0xf4, 0xff, 0xff, 0xf4, 0xa4, 0x01, 0x00, 0xc0, 0xa9, 0x5c, 0x89, 0x66, 0xf9, 0x00, 0xff, 0xf4, 0xa4, 0x02, 0x00, 0xc0, 0xa5, 0x66, 0xf5, 0xff, 0x00, 0x70, 0x95, 0x2d, 0x03, 0x46, 0xf9, 0x00, 0xff, 0x3d, 0x15}, + //Set DTC Peugeot + {0x88, 0x60, 0xf0, 0x6c, 0xd4, 0x40, 0x02, 0x00, 0x9a, 0xf4, 0x1f, 0x00, 0xe6, 0xf5, 0xff, 0xff, 0xc0, 0xc2, 0x5c, 0x12, 0x00, 0x52, 0xa8, 0x25, 0x9a, 0xf2, 0x02, 0x00, 0x8a, 0xf4, 0x15, 0xc0, 0xd4, 0x40, 0x02, 0x00, 0x88, 0x40, 0xc0, 0xcc}, + //Copy Buffer + {0x88, 0x90, 0xf0, 0x9e, 0x00, 0x9f, 0x0d, 0x06, 0xdc, 0x0d, 0xa9, 0x8c, 0xb9, 0x8e, 0x08, 0xe1, 0x08, 0xc1, 0x18, 0xd0, 0x40, 0xe9, 0x8d, 0xf8, 0x98, 0x90, 0xdb, 0x00}, + //CRC Sub + {0x88, 0x60, 0xe6, 0xfe, 0xff, 0xff, 0x0d, 0x0d, 0xa9, 0x8c, 0xf0, 0x6e, 0x51, 0xc8, 0x7c, 0x8e, 0xc0, 0xc4, 0x5c, 0x14, 0xd7, 0x50, 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0xcc, 0x00, 0x50, 0xe5, 0x08, 0xc1, 0x40, 0xcd, 0xfd, 0xf1, 0xf0, 0x4e, 0x98, 0x60, 0xdb, 0x00}, + //CRC Sub + {0x88, 0x90, 0x88, 0x60, 0xe6, 0xf9, 0xff, 0xff, 0x0d, 0x0f, 0xdc, 0x0d, 0xa9, 0x8c, 0xf0, 0x69, 0x51, 0xc8, 0x7c, 0x89, 0xc0, 0xc4, 0x5c, 0x14, 0xd7, 0x50, 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0xcc, 0x00, 0x50, 0x95, 0x08, 0xc1, 0x18, 0xd0, 0xf0, 0x4c, 0xf0, 0x5d, 0x20, 0x4e, 0x30, 0x5f, 0xfd, 0xec, 0xf0, 0x49, 0x98, 0x60, 0x98, 0x90, 0xdb, 0x00}, + //Peugeot CRC32 Sub + {0x88, 0x90, 0x88, 0x80, 0x88, 0x60, 0xf4, 0x80, 0x0a, 0x00, 0xc0, 0x84, 0x68, 0x41, 0x2d, 0x05, 0xe6, 0xf8, 0xff, 0xff, 0xe6, 0xf9, 0xff, 0xff, 0x0d, 0x1b, 0xd4, 0x80, 0x06, 0x00, 0xd4, 0x90, 0x08, 0x00, 0x0d, 0x16, 0xdc, 0x0d, 0xa9, 0x8c, 0xf0, 0x68, 0x51, 0xc8, 0xf0, 0x49, 0x7c, 0x88, 0x7c, 0x89, 0x5c, 0x84, 0x70, 0x84, 0xc0, 0xc4, 0x5c, 0x24, 0xd7, 0x60, 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcc, 0x00, 0x50, 0x8a, 0x50, 0x9b, 0x08, 0xc1, 0x18, 0xd0, 0xf0, 0x4c, 0xf0, 0x5d, 0x20, 0x4e, 0x30, 0x5f, 0xfd, 0xe5, 0xf4, 0x80, 0x0a, 0x00, 0xc0, 0x84, 0x68, 0x42, 0x2d, 0x04, 0x56, 0xf8, 0xff, 0xff, 0x56, 0xf9, 0xff, 0xff, 0xf0, 0x48, 0xf0, 0x59, 0x98, 0x60, 0x98, 0x80, 0x98, 0x90, 0xdb, 0x00}, + //CRC32 Multitasking Calcs + {0x88, 0xf0, 0x88, 0xe0, 0x88, 0xd0, 0x88, 0xc0, 0x88, 0x90, 0x88, 0x80, 0x88, 0x70, 0x88, 0x60, 0x28, 0x04, 0xd4, 0x40, 0x1e, 0x00, 0x42, 0xf4, 0xdc, 0xfc, 0xea, 0xf0, 0x6e, 0xda, 0xff, 0xff, 0xff, 0xfc, 0xe0, 0x05, 0xf1, 0xba, 0xf1, 0xa9, 0x5c, 0x84, 0xd4, 0x80, 0x0c, 0x00, 0xd4, 0x90, 0x0e, 0x00, 0x00, 0x84, 0x10, 0x95, 0xe6, 0xf4, 0xff, 0xff, 0xe0, 0x05, 0x00, 0x48, 0x10, 0x59, 0xb8, 0x40, 0xc4, 0x50, 0x02, 0x00, 0xf2, 0xf2, 0xdc, 0xfc, 0x3d, 0x02, 0xe1, 0x1c, 0x0d, 0x01, 0xe1, 0x0c, 0x24, 0x8f, 0xdc, 0xfc, 0xd4, 0x40, 0x16, 0x00, 0xd4, 0x50, 0x18, 0x00, 0xd4, 0xa0, 0x0c, 0x00, 0xd4, 0xb0, 0x0e, 0x00, 0x20, 0xa4, 0x30, 0xb5, 0xea, 0x20, 0x3c, 0xda, 0xff, 0xff, 0xff, 0x00, 0x42, 0xf2, 0xdc, 0xfc, 0x3d, 0x27, 0xc0, 0xc3, 0x88, 0x30, 0xf2, 0xf4, 0xd8, 0xfc, 0xf2, 0xf5, 0xda, 0xff, 0xff, 0xff, 0x88, 0x40, 0xf0, 0xc8, 0xf0, 0xd9, 0xd4, 0xe0, 0x16, 0x00, 0xd4, 0xf0, 0x18, 0x00, 0x28, 0xe1}, + //ADC 16 read + {0x88, 0x60, 0xe6, 0xd0, 0xff, 0xff, 0x9a, 0xcc, + 0xfe, 0x70, 0x7e, 0xcc, 0xf2, 0xf4, 0xa0, 0xfe, + 0x66, 0xf4, 0xff, 0x03, 0xb8, 0x4c, 0xe6, 0xd0, + 0xff, 0xff, 0xe7, 0xfc, 0x10, 0x00, 0x9a, 0xcc, + 0xfe, 0x70, 0x7e, 0xcc, 0xf2, 0xf4, 0xa0, 0xfe, + 0x66, 0xf4, 0xff, 0x03, 0xf0, 0x5c, 0x28, 0x52, + 0xc0, 0xc2, 0x5c, 0x12, 0x00, 0x52, 0xb8, 0x45, + 0x29, 0xc1, 0x49, 0xc0, 0xed, 0xf0, 0x98, 0x60, 0xdb, 0x00}, + //CAN Stuff + {0xe7, 0xf8, 0x55, 0x00, 0xe6, 0xf5, 0xff, 0xff, 0xb9, 0x85, 0xe6, 0xf4, 0xff, 0xff, 0xb8, 0xe4, 0xe7, 0xf8, 0x55, 0x00, 0xe6, 0xf5, 0xff, 0xff, 0xb9, 0x85, 0xe6, 0xff, 0xff, 0xef, 0xb9, 0x85, 0xf0, 0x4d, 0xc0, 0x84, 0x5c, 0x44, 0xe6, 0xf5, 0xff, 0xff, 0xb9, 0x85, 0xf0, 0x4c, 0x7c, 0x34, 0xe6, 0xf5, 0xff, 0xff, 0xb9, 0x85, 0xf0, 0x4c, 0x5c, 0x54, 0xe6, 0xf5, 0xff, 0xff, 0xb9, 0x85, 0xe7, 0xf8, 0xff, 0x00, 0xe6, 0xf5, 0xff, 0xff, 0xb9, 0x85, 0xe7, 0xf8, 0xf8, 0x00, 0xe6, 0xf5, 0xff, 0xff, 0xb9, 0x85, 0xe7, 0xf8, 0x95, 0x00, 0xe6, 0xf5, 0xff, 0xff, 0xb9, 0x85, 0xdb, 0x00}, + //CAN Write To Msg Controller + {0x88, 0x90, 0x88, 0x80, 0xf0, 0x4c, 0xc0, 0x84, 0x5c, 0x44, 0xe6, 0xf8, 0xff, 0xff, 0x00, 0x84, 0xf0, 0x4f, 0xc0, 0x89, 0x5c, 0x49, 0xf0, 0x4e, 0x49, 0x80, 0x2d, 0x02, 0x76, 0xf9, 0x08, 0x00, 0xf0, 0x49, 0xe4, 0x88, 0x06, 0x00, 0xf0, 0x4d, 0x7c, 0x34, 0xe4, 0x88, 0x02, 0x00, 0xf0, 0x4d, 0x5c, 0x54, 0xe4, 0x88, 0x03, 0x00, 0xe7, 0xf8, 0xff, 0x00, 0xe4, 0x88, 0x04, 0x00, 0xe7, 0xf8, 0xf8, 0x00, 0xe4, 0x88, 0x05, 0x00, 0xe7, 0xf8, 0x55, 0x00, 0xe4, 0x88, 0x01, 0x00, 0xe7, 0xf8, 0x95, 0x00, 0xb9, 0x88, 0x98, 0x80, 0x98, 0x90}, + //CAN Stuff + {0xe6, 0xf2, 0xff, 0xff, 0xf6, 0xf2, 0x90, 0x8d, 0xe6, 0xf2, 0xff, 0xff, 0xf6, 0xf2, 0x92, 0x8d, 0xdb, 0x00, 0xe6, 0xf4, 0xff, 0xff, 0xf6, 0xf4, 0x82, 0x8d, 0xe6, 0xf5, 0xff, 0xff, 0xf6, 0xf5, 0x84, 0x8d, 0xe6, 0xf2, 0xff, 0xff, 0xf6, 0xf2, 0x86, 0x8d, 0xe0, 0x03, 0xf6, 0xf3, 0x88, 0x8d, 0xe0, 0x01, 0xf6, 0xf1, 0x8a, 0x8d, 0xe6, 0xf2, 0xff, 0xff, 0xf6, 0xf2, 0x8c, 0x8d, 0xe0, 0x02, 0xf6, 0xf2, 0x8e, 0x8d, 0xe6, 0xf2, 0xff, 0xff, 0xf6, 0xf2, 0x90, 0x8d, 0xe6, 0xf2, 0xff, 0xff, 0xf6, 0xf2, 0x92, 0x8d, 0xdb, 0x00, 0xd1, 0x20, 0x1a, 0x88, 0xf0, 0xf8, 0xe6, 0xbb, 0xff, 0xff, 0xe6, 0xba, 0xff, 0xff, 0xe6, 0xb9, 0xff, 0xff, 0xe6, 0xcd, 0xff, 0xff}, + //Enable ADC + {0x6e, 0xcd, 0x7f, 0xd0, 0xfb, 0x88}, + //ADC 2 read + {0x9a, 0xd0, 0x04, 0xb0, 0x8a, 0xd0, 0xfe, 0xb0, 0xf2, 0xfe, 0xa0, 0xf0, 0xf0, 0x4c, 0x5c, 0xc4, 0xf6, 0xf4, 0xa0, 0xf0, 0xbf, 0xd0, 0xe1, 0x08, 0x4a, 0xd0, 0xf4, 0xb0, 0x49, 0x81, 0x2d, 0xfb, 0xf2, 0xf4, 0xa0, 0xf0, 0x66, 0xf4, 0xff, 0x03, 0xb8, 0x4d, 0xf6, 0xfe, 0xa0, 0xf0, 0xdb, 0x00}, + //ADC Setup + {0xda, 0xff, 0xff, 0xff, 0xe6, 0xf4, 0xff, 0xff, 0xf6, 0xf4, 0xec, 0xfc, 0xe6, 0xf4, 0xff, 0xff, 0xf6, 0xf4, 0xee, 0xfc, 0xe6, 0x63, 0xff, 0xff, 0xe6, 0xcc, 0xff, 0xff, 0xe6, 0xcd, 0xff, 0xff, 0xe6, 0xd0, 0xff, 0xff, 0xbe, 0xd0, 0xdb, 0x00}, + //ADC 1 read + {0xe6, 0xd0, 0xff, 0xff, 0x9a, 0xcc, 0xfe, 0x70, 0x7e, 0xcc, 0xf6, 0x50, 0xd2, 0xf7, 0xe6, 0xd0, 0xff, 0xff, 0xe0, 0x0c, 0x9a, 0xcc, 0xfe, 0x70, 0x7e, 0xcc, 0xf2, 0xf4, 0xa0, 0xfe, 0xf0, 0x5c, 0x5c, 0x15, 0xc4, 0x45, 0xff, 0xff, 0x08, 0xc1, 0x46, 0xfc, 0x10, 0x00, 0x8d, 0xf3, 0xdb, 0x00}, + //16 bit analogue IRR lowpass filter + {0x5c, 0x8d, 0x40, 0xde, 0x8d, 0x0f, 0x3d, 0x02, 0xf0, 0x4e, 0xdb, 0x00, 0xf0, 0x1d, 0x20, 0x1e, 0x1b, 0xc1, 0xf2, 0xf4, 0x0c, 0xfe, 0x3d, 0x01, 0xe0, 0x14, 0x00, 0x4e, 0x9d, 0x0e, 0xf2, 0xf4, 0x1e, 0xff, 0xdb, 0x00, 0xf0, 0x4e, 0xf0, 0x2e, 0x20, 0x2d, 0x1b, 0xc2, 0xf2, 0xf1, 0x0c, 0xfe, 0x3d, 0x01, 0xe0, 0x11, 0x20, 0x41, 0x9d, 0x01, 0xe0, 0x04, 0xdb, 0x00, 0xdb, 0x00}, + //16 bit analogue IRR filter + {0xe0, 0x01, 0x40, 0xde, 0xad, 0x19, 0x3d, 0x05, 0x40, 0x1f, 0x8d, 0x03, 0xf0, 0x5e, 0xf0, 0x4f, 0xdb, 0x00, 0xf0, 0x4e, 0xf0, 0x3f, 0x20, 0x4d, 0x1b, 0xc4, 0xf2, 0xfd, 0x0c, 0xfe, 0x2d, 0x03, 0xf2, 0xf1, 0x0e, 0xfe, 0x0d, 0x04, 0xf2, 0xf1, 0x0e, 0xfe, 0x3d, 0x01, 0xe0, 0x11, 0xf0, 0x5e, 0xf0, 0x4f, 0x20, 0x41, 0x30, 0x5d, 0xdb, 0x00, 0xf0, 0x4d, 0xe0, 0x03, 0x20, 0x3f, 0x30, 0x4e, 0x1b, 0xc4, 0xf2, 0xf5, 0x0c, 0xfe, 0x2d, 0x03, 0xf2, 0xf4, 0x0e, 0xfe, 0x0d, 0x04, 0xf2, 0xf4, 0x0e, 0xfe, 0x3d, 0x01, 0xe0, 0x14, 0x00, 0x4f, 0x10, 0x5e, 0xdb, 0x00}, + //16 bit analogue IRR filter + {0xe0, 0x03, 0x40, 0xde, 0xed, 0x1c, 0x3d, 0x05, 0x40, 0x3f, 0x8d, 0x03, 0xf0, 0x5e, 0xf0, 0x4f, 0xdb, 0x00, 0xf0, 0x4e, 0xf0, 0x3f, 0x20, 0x4d, 0x1b, 0xc4, 0xf2, 0xfd, 0x0c, 0xfe, 0x2d, 0x03, 0xf2, 0xf1, 0x0e, 0xfe, 0x0d, 0x04, 0xf2, 0xf1, 0x0e, 0xfe, 0x3d, 0x01, 0xe0, 0x11, 0xf0, 0x5e, 0xf0, 0x4f, 0x20, 0x41, 0x30, 0x5d, 0x9d, 0x19, 0xe0, 0x04, 0xe0, 0x05, 0xdb, 0x00, 0xf0, 0x4d, 0x20, 0x3f, 0x30, 0x4e, 0x1b, 0xc4, 0xf2, 0xfd, 0x0c, 0xfe, 0x2d, 0x03, 0xf2, 0xf1, 0x0e, 0xfe, 0x0d, 0x04, 0xf2, 0xf1, 0x0e, 0xfe, 0x3d, 0x01, 0xe0, 0x11, 0xf0, 0x5e, 0xf0, 0x4f, 0x00, 0x41, 0x10, 0x5d, 0x9d, 0x03, 0xf2, 0xf4, 0x1e, 0xff, 0xf0, 0x54, 0xdb, 0x00}, + //16 bit table scaler + {0x1b, 0xcd, 0x7b, 0xee, 0x4d, 0x03, 0xf2, 0xf4, 0x0e, 0xfe, 0xdb, 0x00, 0xe6, 0xf4, 0xff, 0xff, 0xdb, 0x00}, + //16 bit divide - 8 bit byte result + {0xf6, 0xfc, 0x0c, 0xfe, 0xf6, 0xfd, 0x0e, 0xfe, 0x7b, 0xee, 0x4d, 0x03, 0xf2, 0xf4, 0x0e, 0xfe, 0xdb, 0x00, 0xe6, 0xf4, 0xff, 0xff, 0xdb, 0x00}, + //16 bit divide - 8 bit byte result + {0xf6, 0xfc, 0x0e, 0xfe, 0x5b, 0xdd, 0x4d, 0x03, 0xf2, 0xf4, 0x0e, 0xfe, 0xdb, 0x00, 0xe6, 0xf4, 0xff, 0xff, 0xdb, 0x00}, + //16 bit multiply with negative handling - 32 bit byte result + {0xf0, 0x4d, 0x6d, 0x06, 0x0b, 0xcd, 0xf2, 0xf5, 0x0c, 0xfe, 0xf2, 0xf4, 0x0e, 0xfe, 0xdb, 0x00, 0x66, 0xfd, 0xff, 0x7f, 0x0b, 0xcd, 0xf2, 0xf4, 0x0e, 0xfe, 0xf2, 0xf5, 0x0c, 0xfe, 0xe0, 0x0d, 0x4a, 0xfc, 0xfd, 0x0f, 0xbc, 0x1c, 0x00, 0x4d, 0x10, 0x5c, 0xdb, 0x00}, + //16 bit multiply - 32 bit byte result + {0x0b, 0xcd, 0xf2, 0xf5, 0x0c, 0xfe, 0xf2, 0xf4, 0x0e, 0xfe, 0xdb, 0x00}, + //16 bit multiply - 16 bit high byte result + {0x1b, 0xcd, 0xf2, 0xf4, 0x0c, 0xfe, 0xdb, 0x00}, + //16 bit multiply - 32 bit result + {0x1b, 0xcd, 0xf2, 0xf5, 0x0c, 0xfe, 0xf2, 0xf4, 0x0e, 0xfe, 0xdb, 0x00}, + //16 bit multiply - 16 bit result + {0x1b, 0xcd, 0x4d, 0x03, 0xf2, 0xf4, 0x0e, 0xfe, 0xdb, 0x00, 0xe6, 0xf4, 0xff, 0xff, 0xdb, 0x00}, + //Signed 32bit subtract + {0xf0, 0x4d, 0xf0, 0x5c, 0x20, 0x4f, 0x30, 0x5e, 0x4d, 0x01, 0xdb, 0x00, 0x9d, 0x05, 0xe6, 0xf4, 0xff, 0xff, 0xe6, 0xf5, 0xff, 0xff, 0xdb, 0x00, 0xe0, 0x04, 0xe6, 0xf5, 0xff, 0xff, 0xdb, 0x00, 0xdb, 0x00}, + //Signed 8bit subtract + {0xf0, 0x4c, 0xf0, 0x3d, 0x21, 0x86, 0x8d, 0x02, 0x6d, 0x03, 0xdb, 0x00, 0x7d, 0x04, 0xdb, 0x00, 0xe7, 0xf8, 0x7f, 0x00, 0xdb, 0x00, 0xe7, 0xf8, 0x80, 0x00, 0xdb, 0x00}, + //Unsigned 8bit subtract (14) + {0xf0, 0x4c, 0xf0, 0x3d, 0x21, 0x86, 0x8d, 0x01, 0xdb, 0x00, 0xe0, 0x04, 0xdb, 0x00}, + //Signed 16bit subtract (26) + {0xf0, 0x4c, 0x20, 0x4d, 0x8d, 0x02, 0x6d, 0x03, 0xdb, 0x00, 0x7d, 0x04, 0xdb, 0x00, 0xe6, 0xf4, 0xff, 0xff, 0xdb, 0x00, 0xe6, 0xf4, 0xff, 0xff, 0xdb, 0x00}, + //Unsigned 16bit subtract (12) + {0xf0, 0x4c, 0x20, 0x4d, 0x8d, 0x01, 0xdb, 0x00, 0xe0, 0x04, 0xdb, 0x00}, + //Service Watchdog (10) + {0xf6, 0xfc, 0xae, 0xff, 0xa7, 0x58, 0xa7, 0xa7, 0xdb, 0x00}, + //Conditional Multiply (32) + {0x70, 0x55, 0x2d, 0x03, 0x1b, 0x5a, 0xf2, 0xf5, 0x0e, 0xfe, 0x70, 0xbb, 0x2d, 0x03, 0x1b, 0xb4, + 0x02, 0xf5, 0x0e, 0xfe, 0x1b, 0x4a, 0x02, 0xf5, 0x0c, 0xfe, 0xf2, 0xf4, 0x0e, 0xfe, 0xdb, 0x00}, + //Write 32 bit value (14) + {0xdc, 0x05, 0xb8, 0xa4, 0x08, 0x42, 0x18, 0x50, 0xdc, 0x05, 0xb8, 0xb4, 0xdb, 0x00}, + //Read 32 bit value (14) + {0xdc, 0x05, 0xa8, 0xa4, 0x08, 0x42, 0x18, 0x50, 0xdc, 0x05, 0xa8, 0xb4, 0xdb, 0x00}, + //seedkey_routine - exact copy of VAG ME7.1 (106) + {0x88, 0x60, 0xf0, 0x4d, 0x07, 0xf8, 0x23, 0x00, 0xf0, 0xd4, 0x47, 0xf8, 0x23, 0x00, 0x9d, 0x02, 0xe6, 0xfd, 0xff, 0xff, 0xe1, 0x0c, 0x0d, 0x1a, 0x46, 0xff, 0x00, 0x80, 0x3d, 0x01, 0x48, 0xe0, 0x8d, 0x12, 0xf0, 0x4c, 0xc0, 0x84, 0x5c, 0x24, 0xd7, 0x50, 0x00, 0x00, 0xd4, 0xa4, 0x8c, 0x05, 0xd4, 0xb4, 0x8e, 0x05, 0xf0, 0x4e, 0xf0, 0x5f, 0x00, 0x44, 0x10, 0x55, 0x50, 0x4a, 0x50, 0x5b, 0xf0, 0xe4, 0xf0, 0xf5, 0x0d, 0x02, 0x00, 0xee, 0x10, 0xff, 0x09, 0xc1, 0xf0, 0x4d, 0x41, 0xc8, 0x8d, 0xe3, 0xd4, 0x40, 0x02, 0x00, 0xd4, 0x50, 0x04, 0x00, 0x20, 0x4e, 0x30, 0x5f, 0x3d, 0x02, 0xe0, 0x14, 0x0d, 0x01, 0xe0, 0x04, 0x98, 0x60, 0xdb, 0x00}, + //seedkey_routine - generic copy of VAG ME7.1 (106) + {0x88, 0x60, 0xf0, 0x4d, 0x07, 0xf8, 0x23, 0x00, 0xf0, 0xd4, 0x47, 0xf8, 0x23, 0x00, 0x9d, 0x02, 0xe6, 0xfd, 0xff, 0xff, 0xe1, 0x0c, 0x0d, 0x1a, 0x46, 0xff, 0x00, 0x80, 0x3d, 0x01, 0x48, 0xe0, 0x8d, 0x12, 0xf0, 0x4c, 0xc0, 0x84, 0x5c, 0x24, 0xd7, 0x50, 0x00, 0x00, 0xd4, 0xa4, 0xff, 0xff, 0xd4, 0xb4, 0xff, 0xff, 0xf0, 0x4e, 0xf0, 0x5f, 0x00, 0x44, 0x10, 0x55, 0x50, 0x4a, 0x50, 0x5b, 0xf0, 0xe4, 0xf0, 0xf5, 0x0d, 0x02, 0x00, 0xee, 0x10, 0xff, 0x09, 0xc1, 0xf0, 0x4d, 0x41, 0xc8, 0x8d, 0xe3, 0xd4, 0x40, 0x02, 0x00, 0xd4, 0x50, 0x04, 0x00, 0x20, 0x4e, 0x30, 0x5f, 0x3d, 0x02, 0xe0, 0x14, 0x0d, 0x01, 0xe0, 0x04, 0x98, 0x60, 0xdb, 0x00}, + // kwp2000_27_SecurityAccess (150) + {0x88, 0x90, 0x88, 0x70, 0x88, 0x60, 0xf0, 0x9c, 0xf2, 0xf4, 0xff, 0xff, 0x9a, 0xf4, 0x07, 0xff, 0xc2, 0xfc, 0xff, 0xff, 0xf0, 0xd9, 0xda, 0xff, 0xff, 0xff, 0xf1, 0xc8, 0x0d, 0x37, 0xf3, 0xf8, 0xff, 0xff, 0x49, 0x82, 0x8d, 0x2b, 0xf2, 0xf4, 0xff, 0xff, 0xf4, 0xa4, 0x01, 0x00, 0xf7, 0xfa, 0xff, 0xff, 0xc0, 0xa5, 0x08, 0x51, 0xbc, 0x15, 0xf1, 0xea, 0xc0, 0xe5, 0x46, 0xf5, 0x3c, 0x00, 0xcd, 0x10, 0x47, 0xfe, 0x40, 0x00, 0xed, 0x0d, 0x88, 0x90, 0xc2, 0xfc, 0xff, 0xff, 0xc0, 0xed, 0xe6, 0xfe, 0xff, 0xff, 0xe6, 0xff, 0xff, 0xff, 0xda, 0xff, 0xff, 0xff, 0x08, 0x02, 0xf1, 0xc8, 0x0d, 0x15, 0xe6, 0xf4, 0xff, 0xff, 0x64, 0xf4, 0xff, 0xff, 0xe6, 0xfc, 0xff, 0xff, 0xe6, 0xfd, 0xff, 0xff, 0xf0, 0xe9, 0xda, 0xff, 0xff, 0xff, 0xf1, 0xc8, 0x0d, 0x08, 0xe6, 0xfc, 0xff, 0xff, 0xe6, 0xfd, 0xff, 0xff, 0xf0, 0xe9, 0xda, 0xff, 0xff, 0xff, 0xf1, 0xc8, 0xf1, 0x8c, 0x98, 0x60, 0x98, 0x70, 0x98, 0x90, 0xdb, 0x00}, + // kwp2000_27_SecurityAccessOpel 1(64) + {0x88, 0x80, 0x88, 0x70, 0x88, 0x60, 0x26, 0xF0, 0x10, 0x00, 0xF0, 0x7C, 0xD4, 0x80, 0x16, 0x00, + 0xE1, 0x0C, 0xF1, 0x2E, 0x69, 0x21, 0x49, 0x21, 0x2D, 0x05, 0x49, 0x20, 0xEA, 0x20, 0x7A, 0x2A, + 0xEA, 0x00, 0xff, 0xff, 0xF2, 0xF6, 0xff, 0xff, 0x9A, 0xF6, 0xff, 0xff, 0xF6, 0x8E, 0xff, 0xff, + 0xF6, 0x8E, 0xff, 0xff, 0xEA, 0xff, 0xff, 0xff, 0xDA, 0xff, 0xff, 0xff, 0xF0, 0xC4, 0xF0, 0xD5}, + // kwp2000_27_SecurityAccessOpel 2(62) + {0x88, 0x90, 0x88, 0x80, 0x88, 0x70, 0x88, 0x60, 0x26, 0xF0, 0x10, 0x00, 0xF0, 0x9E, 0xF0, 0x7C, + 0xD4, 0x80, 0x18, 0x00, 0xE1, 0x0C, 0xF1, 0x2E, 0x69, 0x21, 0x49, 0x21, 0x2D, 0x05, 0x49, 0x20, + 0xEA, 0xff, 0xff, 0xff, 0xEA, 0xff, 0xff, 0xff, 0xF2, 0xF6, 0xff, 0xff, 0x9A, 0xF6, 0x0A, 0x00, + 0xF6, 0x8E, 0xff, 0xff, 0xF6, 0x8E, 0xff, 0xff, 0xE6, 0xF9, 0x00, 0x10, 0x74, 0xF9}, + // Opel Seed Key (42) + {0x88, 0x70, 0x88, 0x60, 0xF0, 0x6D, 0x07, 0xFC, 0x23, 0x00, 0x47, 0xFC, 0x23, 0x00, 0x9D, 0x02, + 0xE7, 0xFC, 0xFF, 0x00, 0xE1, 0x0E, 0x0D, 0x17, 0xF0, 0xDE, 0xF0, 0x1F, 0x28, 0xD0, 0x36, 0xF1, + 0x00, 0x80, 0x8D, 0x0E, 0xF0, 0x1C, 0xC0, 0x2D, 0x5C, 0x2D}, + //Lookup (64) + {0xE0,0x04,0xF0,0x3F,0xF0,0x2C,0xDC,0x4D,0x49,0x6A,0xFD,0x19,0x00,0x2E,0x28,0x21, + 0xDC,0x4D,0x49,0x6A,0x9D,0x12,0x08,0x21,0x28,0x21,0xDC,0x4D,0x49,0x6A,0x8D,0xFC, + 0xDC,0x4D,0x29,0x6A,0x5C,0x83,0xF6,0xF3,0x0E,0xFE,0xDC,0x5D,0xF4,0x62,0x01,0x00, + 0x29,0x6A,0xC0,0x63,0x5B,0x33,0xF2,0xF4,0x0E,0xFE,0x20,0x2C,0xF1,0x94,0xDB,0x00}, + //Lookup (64) + {0xE0,0x04,0xF0,0x3F,0xF0,0x2C,0xDC,0x4D,0x49,0x6A,0xBD,0x19,0x00,0x2E,0x28,0x21, + 0xDC,0x4D,0x49,0x6A,0xDD,0x12,0xDC,0x4D,0x49,0x6A,0xDD,0x02,0x28,0x21,0x0D,0xFB, + 0xDC,0x4D,0x29,0x6A,0x5C,0x83,0xF6,0xF3,0x0E,0xFE,0xDC,0x5D,0xF4,0x62,0x01,0x00, + 0x29,0x6A,0xC0,0x63,0x5B,0x33,0xF2,0xF4,0x0E,0xFE,0x20,0x2C,0xF1,0x94,0xDB,0x00}, + //WideLookup (72) + {0xE0,0x04,0x5C,0x1E,0xF0,0x2C,0xDC,0x4D,0x48,0xFA,0xFD,0x1D,0x00,0x2E,0x28,0x22, + 0xDC,0x4D,0x48,0xFA,0x9D,0x15,0x08,0x22,0x28,0x22,0xDC,0x4D,0x48,0xFA,0x8D,0xFC, + 0xDC,0x4D,0x28,0xFA,0xF0,0x4F,0x5C,0x8F,0x7C,0x84,0xF6,0xF4,0x0C,0xFE,0xF6,0xFF, + 0x0E,0xFE,0xDC,0x5D,0xD4,0xF2,0x02,0x00,0x28,0xFA,0x7B,0xFF,0xF2,0xF4,0x0E,0xFE, + 0x20,0x2C,0x7C,0x12,0xF1,0x94,0xDB,0x00}, + //WideLookup (72) + {0xE0,0x04,0x5C,0x1E,0xF0,0x2C,0xDC,0x4D,0x48,0xFA,0xBD,0x1D,0x00,0x2E,0x28,0x22, + 0xDC,0x4D,0x48,0xFA,0xDD,0x15,0xDC,0x4D,0x48,0xFA,0xDD,0x02,0x28,0x22,0x0D,0xFB, + 0xDC,0x4D,0x28,0xFA,0xF0,0x4F,0x5C,0x8F,0x7C,0x84,0xF6,0xF4,0x0C,0xFE,0xF6,0xFF, + 0x0E,0xFE,0xDC,0x5D,0xD4,0xF2,0x02,0x00,0x28,0xFA,0x7B,0xFF,0xF2,0xF4,0x0E,0xFE, + 0x20,0x2C,0x7C,0x12,0xF1,0x94,0xDB,0x00}, + //lookup (74) + {0xF0,0x3E,0xDC,0x4D,0x99,0x8C,0xF0,0x1C,0xF0,0x2C,0x7C,0x8F,0x00,0x1F,0xDC,0x4D, + 0x49,0x6D,0x8D,0x1B,0xC0,0x84,0x28,0x41,0x00,0x24,0xDC,0x4D,0x49,0x6E,0x9D,0x2D, + 0x20,0x24,0xDC,0x4D,0x49,0x6D,0x9D,0xFD,0x28,0x12,0xDC,0x4D,0x29,0x69,0x5C,0x83, + 0xF6,0xF3,0x0E,0xFE,0xDC,0x5D,0xF4,0x61,0x01,0x00,0x29,0x69,0xC0,0x63,0x5B,0x33, + 0xF2,0xF4,0x0E,0xFE,0x20,0x1C,0xF1,0x92,0xDB,0x00}, + //Widelookup (140) + {0xDC,0x4D,0x98,0x4C,0xF0,0x1C,0xF0,0x2C,0x7C,0x8F,0x5C,0x1F,0x00,0x1F,0xDC,0x4D, + 0x48,0xED,0x8D,0x20,0xC0,0x84,0x28,0x41,0x5C,0x14,0x00,0x24,0xDC,0x4D,0x48,0xEE, + 0x9D,0x35,0x20,0x24,0xDC,0x4D,0x48,0xED,0x9D,0xFD,0x28,0x14,0xDC,0x4D,0x28,0xE9, + 0xF0,0x4E,0x5C,0x8E,0x7C,0x84,0xF6,0xFE,0x0E,0xFE,0xF6,0xF4,0x0C,0xFE,0xDC,0x5D, + 0xD4,0xE1,0x02,0x00,0x28,0xE9,0x7B,0xEE,0xF2,0xF4,0x0E,0xFE,0x20,0x1C,0x7C,0x11, + 0xF1,0x92,0xDB,0x00,0xDC,0x4D,0x48,0xEA,0xFD,0x1B,0x28,0x14,0xDC,0x4D,0x48,0xED, + 0x8D,0xFC,0x28,0x12,0xDC,0x4D,0x28,0xE9,0xF0,0x4E,0x5C,0x8E,0x7C,0x84,0xF6,0xFE, + 0x0E,0xFE,0xF6,0xF4,0x0C,0xFE,0xDC,0x5D,0xD4,0xE1,0x02,0x00,0x28,0xE9,0x7B,0xEE, + 0xF2,0xF4,0x0E,0xFE,0x20,0x1C,0x7C,0x11,0xF1,0x92,0xDB,0x00}, + //Lookup (122) + {0xF0,0x3E,0xDC,0x4D,0x99,0x8C,0xF0,0x1C,0xF0,0x2C,0x7C,0x8F,0x00,0x1F,0xDC,0x4D, + 0x49,0x6D,0xCD,0x1B,0xC0,0x84,0x28,0x41,0x00,0x24,0xDC,0x4D,0x49,0x6E,0xDD,0x2D, + 0x20,0x24,0xDC,0x4D,0x49,0x6D,0xDD,0xFD,0x28,0x12,0xDC,0x4D,0x29,0x69,0x5C,0x83, + 0xF6,0xF3,0x0E,0xFE,0xDC,0x5D,0xF4,0x61,0x01,0x00,0x29,0x69,0xC0,0x63,0x5B,0x33, + 0xF2,0xF4,0x0E,0xFE,0x20,0x1C,0xF1,0x92,0xDB,0x00,0xDC,0x4D,0x49,0x6A,0xBD,0x17, + 0x28,0x12,0xDC,0x4D,0x49,0x6D,0xCD,0xFC,0x28,0x11,0xDC,0x4D,0x29,0x69,0x5C,0x83, + 0xF6,0xF3,0x0E,0xFE,0xDC,0x5D,0xF4,0x61,0x01,0x00,0x29,0x69,0xC0,0x63,0x5B,0x33, + 0xF2,0xF4,0x0E,0xFE,0x20,0x1C,0xF1,0x92,0xDB,0x00}, + //WideLookup (84) + {0xDC,0x4D,0x98,0x4C,0xF0,0x1C, + 0xF0,0x2C,0x7C,0x8F,0x5C,0x1F,0x00,0x1F,0xDC,0x4D,0x48,0xED,0xCD,0x20,0xC0,0x84, + 0x28,0x41,0x5C,0x14,0x00,0x24,0xDC,0x4D,0x48,0xEE,0xDD,0x35,0x20,0x24,0xDC,0x4D, + 0x48,0xED,0xDD,0xFD,0x28,0x14,0xDC,0x4D,0x28,0xE9,0xF0,0x4E,0x5C,0x8E,0x7C,0x84, + 0xF6,0xFE,0x0E,0xFE,0xF6,0xF4,0x0C,0xFE,0xDC,0x5D,0xD4,0xE1,0x02,0x00,0x28,0xE9, + 0x7B,0xEE,0xF2,0xF4,0x0E,0xFE,0x20,0x1C,0x7C,0x11,0xF1,0x92,0xDB,0x00}, + //lookup (100) + {0xF0,0x3E,0xDC,0x4D,0x99,0x2C,0xF0,0x2C,0xC0,0x21,0xE0,0x04,0xE0,0x05,0xE0,0x0F, + 0xDC,0x4D,0x49,0x6A,0xFD,0x13,0x00,0x21,0x28,0x21,0xDC,0x4D,0x49,0x6A,0x9D,0x0C, + 0x08,0x21,0x28,0x21,0xDC,0x4D,0x49,0x6A,0x8D,0xFC,0xDC,0x7D,0x29,0x6A,0xC0,0x64, + 0xF4,0x62,0x01,0x00,0x29,0x6A,0xC0,0x65,0x20,0x2C,0xF0,0xF2,0x00,0xC1,0x00,0xCF, + 0xF0,0x24,0xDC,0x4D,0x99,0x8C,0xC0,0x84,0x48,0x20,0x2D,0x13,0xDC,0x4D,0xA9,0x6C, + 0xC0,0x63,0x40,0x43,0xED,0x07,0x20,0x34,0x1B,0x32,0x5B,0x55,0xF2,0xF3,0x0E,0xFE, + 0x00,0x43,0xDB,0x00}, + //WideLookup (122) + {0xF0,0xAE,0xDC,0x4D,0x98,0xEC,0xE0,0x04,0xE0,0x05,0xE0,0x0F,0xF0,0x1E,0x66,0xF1, + 0xFF,0x00,0x5C,0x11,0xF0,0x2C,0xDC,0x4D,0x48,0xAA,0xFD,0x13,0x00,0x21,0x28,0x22, + 0xDC,0x4D,0x48,0xAA,0x9D,0x0B,0x08,0x22,0x28,0x22,0xDC,0x4D,0x48,0xAA,0x8D,0xFC, + 0xF0,0x4A,0xDC,0x6D,0x28,0x4A,0xD4,0x52,0x02,0x00,0x28,0x5A,0x20,0x2C,0x7C,0x12, + 0xF0,0xF2,0x5C,0x1E,0x5C,0x1F,0x00,0xCE,0x00,0xCF,0xF0,0x24,0xDC,0x4D,0x98,0x4C, + 0x48,0x20,0x2D,0x12,0xDC,0x4D,0xA8,0x3C,0x40,0x43,0xED,0x07,0x20,0x34,0x1B,0x32, + 0x7B,0x55,0xF2,0xF3,0x0E,0xFE,0x00,0x43,0x0D,0x07,0xF0,0x14,0x20,0x13,0x1B,0x12, + 0x7B,0x55,0xF2,0xF3,0x0E,0xFE,0x20,0x43,0xDB,0x00}, + //Lookup (120) + {0xF0,0xAE,0xDC,0x4D,0x99,0x6C,0xC0,0x6E,0xE0,0x04,0xE0,0x05,0xE0,0x0F,0xF0,0x3A, + 0xF0,0x1E,0xF0,0x2C,0xDC,0x4D,0x49,0x6A,0xBD,0x13,0x00,0x21,0x28,0x21,0xDC,0x4D, + 0x49,0x6A,0xDD,0x0C,0xDC,0x4D,0x49,0x6A,0xDD,0x02,0x28,0x21,0x0D,0xFB,0xDC,0x7D, + 0x29,0x6A,0xC0,0x64,0xF4,0x62,0x01,0x00,0x29,0x6A,0xC0,0x65,0x20,0x2C,0xF0,0xF2, + 0x00,0xCE,0x00,0xCF,0xF0,0x24,0xDC,0x4D,0x99,0x8C,0xD0,0x84,0x48,0x20,0x2D,0x13, + 0xDC,0x4D,0xA9,0x6C,0xD0,0x63,0x40,0x43,0xAD,0x07,0x20,0x34,0x1B,0x32,0x5B,0x55, + 0xF2,0xF3,0x0E,0xFE,0x00,0x43,0x0D,0x07,0xF0,0x14,0x20,0x13,0x1B,0x12,0x5B,0x55, + 0xF2,0xF1,0x0E,0xFE,0x20,0x41,0xDB,0x00}, + //Lookup (122) + {0xF0,0xAE,0xDC,0x4D,0x98,0xEC,0xE0,0x04,0xE0,0x05,0xE0,0x0F,0xF0,0x1E,0x66,0xF1, + 0xFF,0x00,0x5C,0x11,0xF0,0x2C,0xDC,0x4D,0x48,0xAA,0xBD,0x13,0x00,0x21,0x28,0x22, + 0xDC,0x4D,0x48,0xAA,0xDD,0x0B,0xDC,0x4D,0x48,0xAA,0xDD,0x02,0x28,0x22,0x0D,0xFB, + 0xF0,0x4A,0xDC,0x6D,0x28,0x4A,0xD4,0x52,0x02,0x00,0x28,0x5A,0x20,0x2C,0x7C,0x12, + 0xF0,0xF2,0x5C,0x1E,0x5C,0x1F,0x00,0xCE,0x00,0xCF,0xF0,0x24,0xDC,0x4D,0x98,0x4C, + 0x48,0x20,0x2D,0x12,0xDC,0x4D,0xA8,0x3C,0x40,0x43,0xAD,0x07,0x20,0x34,0x0B,0x32, + 0x6B,0x55,0xF2,0xF3,0x0E,0xFE,0x00,0x43,0x0D,0x07,0xF0,0x14,0x20,0x13,0x0B,0x12, + 0x6B,0x55,0xF2,0xF3,0x0E,0xFE,0x20,0x43,0xDB,0x00}, + //Lookup (234) + {0x88,0x90,0xDC,0x4D,0x99,0x6C,0xC0,0x6B,0x08,0xC1,0xE0,0x04,0xE0,0x05,0xE0,0x01, + 0x66,0xFE,0xFF,0x00,0xF0,0x3E,0xF0,0x2C,0xDC,0x4D,0x49,0x6A,0xFD,0x13,0x00,0x2B, + 0x28,0x21,0xDC,0x4D,0x49,0x6A,0x9D,0x0C,0x08,0x21,0x28,0x21,0xDC,0x4D,0x49,0x6A, + 0x8D,0xFC,0xDC,0x7D,0x29,0x6A,0xC0,0x64,0xF4,0x62,0x01,0x00,0x29,0x6A,0xC0,0x65, + 0x20,0x2C,0xF0,0x12,0xF0,0xA5,0x28,0xC1,0xDC,0x4D,0x99,0x6C,0x00,0xCB,0xC0,0x6E, + 0xF0,0xB4,0xE0,0x04,0xE0,0x05,0xE0,0x09,0x66,0xFF,0xFF,0x00,0xF0,0x3F,0xF0,0x2C, + 0xDC,0x4D,0x49,0x6A,0xFD,0x13,0x00,0x2E,0x28,0x21,0xDC,0x4D,0x49,0x6A,0x9D,0x0C, + 0x08,0x21,0x28,0x21,0xDC,0x4D,0x49,0x6A,0x8D,0xFC,0xDC,0x7D,0x29,0x6A,0xC0,0x64, + 0xF4,0x62,0x01,0x00,0x29,0x6A,0xC0,0x65,0x20,0x2C,0xF0,0x92,0xF0,0xF4,0x00,0xCE, + 0x1B,0x1E,0xF2,0xF1,0x0E,0xFE,0x00,0xC1,0x00,0xC9,0xDC,0x4D,0x99,0x8C,0xC0,0x84, + 0x48,0xF0,0x2D,0x09,0xDC,0x4D,0xA9,0x6C,0xC0,0x63,0x20,0x34,0x0B,0x3F,0x6B,0x55, + 0xF2,0xF3,0x0E,0xFE,0x00,0x43,0x48,0xB0,0x2D,0x16,0x28,0xC1,0x00,0xCE,0xDC,0x4D, + 0x99,0x6C,0xC0,0x63,0x48,0xF0,0x2D,0x09,0xDC,0x4D,0xA9,0x4C,0xC0,0x42,0x20,0x23, + 0x0B,0x2F,0x6B,0x55,0xF2,0xF2,0x0E,0xFE,0x00,0x32,0x20,0x34,0x0B,0x3B,0x6B,0xAA, + 0xF2,0xF3,0x0E,0xFE,0x00,0x43,0x98,0x90,0xDB,0x00}, + //Lookup (284) + {0x88,0x90,0xDC,0x4D,0x98,0xBC,0x66,0xFB,0xFF,0x00,0x5C,0x1B,0x08,0xC2,0xE0,0x04, + 0xE0,0x05,0xE0,0x01,0xF0,0x2C,0xDC,0x4D,0x48,0xEA,0xFD,0x13,0x00,0x2B,0x28,0x22, + 0xDC,0x4D,0x48,0xEA,0x9D,0x0B,0x08,0x22,0x28,0x22,0xDC,0x4D,0x48,0xEA,0x8D,0xFC, + 0xF0,0x4E,0xDC,0x6D,0x28,0x4A,0xD4,0x52,0x02,0x00,0x28,0x5A,0x20,0x2C,0x7C,0x12, + 0xF0,0x12,0xF0,0xA5,0x28,0xC2,0xDC,0x4D,0x98,0xEC,0x66,0xFE,0xFF,0x00,0x5C,0x1E, + 0x00,0xCB,0xF0,0xB4,0xE0,0x04,0xE0,0x05,0xE0,0x09,0xF0,0x2C,0xDC,0x4D,0x48,0xFA, + 0xFD,0x13,0x00,0x2E,0x28,0x22,0xDC,0x4D,0x48,0xFA,0x9D,0x0B,0x08,0x22,0x28,0x22, + 0xDC,0x4D,0x48,0xFA,0x8D,0xFC,0xF0,0x4F,0xDC,0x6D,0x28,0x4A,0xD4,0x52,0x02,0x00, + 0x28,0x5A,0x20,0x2C,0x7C,0x12,0xF0,0x92,0xF0,0xF4,0x5C,0x19,0x00,0xCE,0x1B,0x1E, + 0xF2,0xF1,0x0E,0xFE,0x00,0xC1,0x00,0xC9,0xDC,0x4D,0x98,0x4C,0x48,0xF0,0x2D,0x12, + 0xDC,0x4D,0xA8,0x3C,0x40,0x43,0xED,0x07,0x20,0x34,0x1B,0x3F,0x7B,0x55,0xF2,0xF3, + 0x0E,0xFE,0x00,0x43,0x0D,0x07,0xF0,0x24,0x20,0x23,0x1B,0x2F,0x7B,0x55,0xF2,0xF2, + 0x0E,0xFE,0x20,0x42,0x48,0xB0,0x2D,0x28,0x28,0xC2,0x00,0xCE,0xDC,0x4D,0x98,0x3C, + 0x48,0xF0,0x2D,0x12,0xDC,0x4D,0xA8,0x2C,0x40,0x32,0xED,0x07,0x20,0x23,0x1B,0x2F, + 0x7B,0x55,0xF2,0xF2,0x0E,0xFE,0x00,0x32,0x0D,0x07,0xF0,0x13,0x20,0x12,0x1B,0x1F, + 0x7B,0x55,0xF2,0xF1,0x0E,0xFE,0x20,0x31,0x40,0x43,0xED,0x07,0x20,0x34,0x1B,0x3B, + 0x7B,0xAA,0xF2,0xF3,0x0E,0xFE,0x00,0x43,0x0D,0x07,0xF0,0x24,0x20,0x23,0x1B,0x2B, + 0x7B,0xAA,0xF2,0xF2,0x0E,0xFE,0x20,0x42,0x98,0x90,0xDB,0x00}, + //Lookup (70) + {0xE0,0x04,0xF0,0x3E,0xDC,0x4D,0x99,0x2C,0xC0,0x21,0xF0,0x2C,0xDC,0x4D,0x49,0x6A, + 0xFD,0x19,0x00,0x21,0x28,0x21,0xDC,0x4D,0x49,0x6A,0x9D,0x12,0x08,0x21,0x28,0x21, + 0xDC,0x4D,0x49,0x6A,0x8D,0xFC,0xDC,0x4D,0x29,0x6A,0x5C,0x83,0xF6,0xF3,0x0E,0xFE, + 0xDC,0x5D,0xF4,0x62,0x01,0x00,0x29,0x6A,0xC0,0x63,0x5B,0x33,0xF2,0xF4,0x0E,0xFE, + 0x20,0x2C,0xF1,0x94,0xDB,0x00}, + //Lookup (70) + {0xE0,0x04,0xF0,0x3E,0xDC,0x4D,0x99,0x2C,0xC0,0x21,0xF0,0x2C,0xDC,0x4D,0x49,0x6A, + 0xBD,0x19,0x00,0x21,0x28,0x21,0xDC,0x4D,0x49,0x6A,0xDD,0x12,0xDC,0x4D,0x49,0x6A, + 0xDD,0x02,0x28,0x21,0x0D,0xFB,0xDC,0x4D,0x29,0x6A,0x5C,0x83,0xF6,0xF3,0x0E,0xFE, + 0xDC,0x5D,0xF4,0x62,0x01,0x00,0x29,0x6A,0xC0,0x63,0x5B,0x33,0xF2,0xF4,0x0E,0xFE, + 0x20,0x2C,0xF1,0x94,0xDB,0x00}, + //lookup (78) + {0xE0,0x04,0xDC,0x4D,0x98,0x1C,0xC0,0x21,0x5C,0x11,0xF0,0x2C,0xDC,0x4D,0x48,0xEA, + 0xFD,0x1D,0x00,0x21,0x28,0x22,0xDC,0x4D,0x48,0xEA,0x9D,0x15,0x08,0x22,0x28,0x22, + 0xDC,0x4D,0x48,0xEA,0x8D,0xFC,0xDC,0x4D,0x28,0xEA,0xF0,0x4E,0x5C,0x8E,0x7C,0x84, + 0xF6,0xF4,0x0C,0xFE,0xF6,0xFE,0x0E,0xFE,0xDC,0x5D,0xD4,0xE2,0x02,0x00,0x28,0xEA, + 0x7B,0xEE,0xF2,0xF4,0x0E,0xFE,0x20,0x2C,0x7C,0x12,0xF1,0x94,0xDB,0x00}, + //Lookup (78) + {0xE0,0x04,0xDC,0x4D,0x98,0x1C,0xC0,0x21,0x5C,0x11,0xF0,0x2C,0xDC,0x4D,0x48,0xEA, + 0xBD,0x1D,0x00,0x21,0x28,0x22,0xDC,0x4D,0x48,0xEA,0xDD,0x15,0xDC,0x4D,0x48,0xEA, + 0xDD,0x02,0x28,0x22,0x0D,0xFB,0xDC,0x4D,0x28,0xEA,0xF0,0x4E,0x5C,0x8E,0x7C,0x84, + 0xF6,0xF4,0x0C,0xFE,0xF6,0xFE,0x0E,0xFE,0xDC,0x5D,0xD4,0xE2,0x02,0x00,0x28,0xEA, + 0x7B,0xEE,0xF2,0xF4,0x0E,0xFE,0x20,0x2C,0x7C,0x12,0xF1,0x94,0xDB,0x00}, + //Lookup (38) + {0xF0,0x3E,0xC0,0x72,0x00,0xC2,0xDC,0x4D,0x99,0x8C,0xC0,0x84,0x5C,0x8E,0x7C,0x1E, + 0x2D,0x09,0xDC,0x4D,0xA9,0x6C,0xC0,0x63,0x20,0x34,0x5C,0x13,0x0B,0xE3,0xF2,0xF3, + 0x0C,0xFE,0x00,0x43,0xDB,0x00}, + //Lookup (13) + {0xF0,0x3E,0xC0,0x72,0x00,0xC2,0xDC,0x4D,0xA9,0x8C,0xDB,0x00,0xDB}, + //Lookup (14) + {0xF0,0x3E,0xC0,0x72,0x5C,0x12,0x00,0x2C,0xDC,0x4D,0xA8,0x42,0xDB,0x00}, + //lookup (12) + {0xF0,0x3D,0xC0,0x72,0x5C,0x12,0x00,0x2C,0xA8,0x42,0xDB,0x00}, + //lookup (38) + {0xF0,0x3E,0xC0,0x72,0x00,0xC2,0xDC,0x4D,0x99,0x8C,0xD0,0x84,0x5C,0x8E,0x7C,0x1E, + 0x2D,0x09,0xDC,0x4D,0xA9,0x6C,0xD0,0x63,0x20,0x34,0x5C,0x13,0x0B,0xE3,0xF2,0xF3, + 0x0C,0xFE,0x00,0x43,0xDB,0x00}, + //lookup (36) + {0xF0,0x3E,0xC0,0x72,0x5C,0x12,0x00,0xC2,0xDC,0x4D,0x98,0x4C,0x5C,0x8E,0x2D,0x10, + 0xDC,0x4D,0xA8,0x3C,0x40,0x43,0xED,0x06,0x20,0x34,0x1B,0xE3,0xF2,0xF2,0x0C,0xFE, + 0x00,0x42,0xDB,0x00}, + //LookupZ (48) + {0xF0,0x3E, + 0xC0,0x72,0x5C,0x12,0x00,0xC2,0xDC,0x4D,0x98,0x4C,0x5C,0x8E,0x2D,0x10,0xDC,0x4D, + 0xA8,0x3C,0x40,0x43,0xAD,0x06,0x20,0x34,0x1B,0xE3,0xF2,0xF2,0x0C,0xFE,0x00,0x42, + 0x0D,0x06,0xF0,0x24,0x20,0x23,0x1B,0xE2,0xF2,0xF2,0x0C,0xFE,0x20,0x42,0xDB,0x00}, + //LookupAA (116) + {0xD4,0xA0,0x00,0x00,0xD4,0xB0,0x02,0x00,0xDC,0x4F,0xA9,0x4E,0xC0,0x4E,0xF0,0x1A, + 0xC0,0x31,0x1B,0x1E,0xF2,0xF1,0x0E,0xFE,0x00,0xC1,0xF0,0x1B,0xC0,0x31,0x00,0xC1, + 0xDC,0x4D,0xA9,0x4C,0xC0,0x42,0x5C,0x8B,0x7C,0x1B,0x2D,0x0A,0xDC,0x4D,0xF4,0x6C, + 0x01,0x00,0xC0,0x63,0x20,0x32,0x5C,0x13,0x0B,0x3B,0xF2,0xF3,0x0C,0xFE,0x00,0x23, + 0xF0,0x42,0x5C,0x8A,0x7C,0x1A,0x2D,0x15,0x00,0xCE,0xDC,0x4D,0x99,0x4C,0xC0,0x42, + 0x78,0xB0,0x2D,0x09,0xDC,0x4D,0xA9,0x6C,0xC0,0x63,0x20,0x32,0x5C,0x13,0x0B,0x3B, + 0xF2,0xF3,0x0C,0xFE,0x00,0x23,0x20,0x24,0x5C,0x12,0x0B,0x2A,0xF2,0xF2,0x0C,0xFE, + 0x00,0x42,0xDB,0x00}, + //Lookup (144) + {0xD4,0xA0,0x00,0x00,0xD4,0xB0,0x02,0x00,0xDC,0x4F,0xA9,0x2E,0xC0,0x2E,0xF0,0x1A, + 0xC0,0x31,0x1B,0x1E,0xF2,0xF1,0x0E,0xFE,0xF0,0x2B,0xC0,0x52,0x00,0x21,0x5C,0x12, + 0x00,0xC2,0xDC,0x4D,0xA8,0x2C,0x5C,0x8B,0x2D,0x11,0xDC,0x4D,0xD4,0x3C,0x02,0x00, + 0x40,0x32,0xED,0x07,0xF0,0x12,0x20,0x13,0x1B,0x1B,0xF2,0xF3,0x0C,0xFE,0x20,0x23, + 0x0D,0x05,0x20,0x32,0x1B,0x3B,0xF2,0xF3,0x0C,0xFE,0x00,0x23,0xF0,0x42,0x5C,0x8A, + 0x2D,0x24,0x5C,0x1E,0x00,0xCE,0xDC,0x4D,0x98,0x2C,0x78,0xB0,0x2D,0x10,0xDC,0x4D, + 0xA8,0x3C,0x40,0x32,0xED,0x07,0xF0,0x12,0x20,0x13,0x1B,0x1B,0xF2,0xF3,0x0C,0xFE, + 0x20,0x23,0x0D,0x05,0x20,0x32,0x1B,0x3B,0xF2,0xF3,0x0C,0xFE,0x00,0x23,0x40,0x24, + 0xED,0x07,0xF0,0x14,0x20,0x12,0x1B,0x1A,0xF2,0xF2,0x0C,0xFE,0x20,0x42,0xDB,0x00}, + //Lookup (156) + {0xD4,0xA0,0x00,0x00, + 0xD4,0xB0,0x02,0x00,0xDC,0x4F,0xA9,0x2E,0xC0,0x2E,0xF0,0x1A,0xC0,0x31,0x1B,0x1E, + 0xF2,0xF1,0x0E,0xFE,0xF0,0x2B,0xC0,0x52,0x00,0x21,0x5C,0x12,0x00,0xC2,0xDC,0x4D, + 0xA8,0x2C,0x5C,0x8B,0x2D,0x11,0xDC,0x4D,0xD4,0x3C,0x02,0x00,0x40,0x32,0xAD,0x07, + 0xF0,0x12,0x20,0x13,0x1B,0x1B,0xF2,0xF3,0x0C,0xFE,0x20,0x23,0x0D,0x05,0x20,0x32, + 0x1B,0x3B,0xF2,0xF3,0x0C,0xFE,0x00,0x23,0xF0,0x42,0x5C,0x8A,0x2D,0x24,0x5C,0x1E, + 0x00,0xCE,0xDC,0x4D,0x98,0x2C,0x78,0xB0,0x2D,0x10,0xDC,0x4D,0xA8,0x3C,0x40,0x32, + 0xAD,0x07,0xF0,0x12,0x20,0x13,0x1B,0x1B,0xF2,0xF3,0x0C,0xFE,0x20,0x23,0x0D,0x05, + 0x20,0x32,0x1B,0x3B,0xF2,0xF3,0x0C,0xFE,0x00,0x23,0x40,0x24,0xAD,0x07,0xF0,0x14, + 0x20,0x12,0x1B,0x1A,0xF2,0xF2,0x0C,0xFE,0x20,0x42,0xDB,0x00,0x20,0x24,0x1B,0x2A, + 0xF2,0xF2,0x0C,0xFE,0x00,0x42,0xDB,0x00}, + //Lookup (48) + {0xF0,0x3E,0xC0,0x63,0xDC,0x4D,0x99,0x4C,0xC0,0x41,0xF0,0x2C,0xDC,0x4D,0x49,0x6A, + 0xFD,0x0A,0x00,0x21,0x28,0x21,0xDC,0x4D,0x49,0x6A,0x9D,0x05,0x08,0x21,0x28,0x21, + 0xDC,0x4D,0x49,0x6A,0x8D,0xFC,0x00,0x21,0xDC,0x4D,0xA9,0x82,0xC0,0x84,0xDB,0x00}, + //Lookup (48) + {0xDC,0x4D,0x98,0x3C,0xF0,0x13,0x66,0xF1,0xFF,0x00,0x5C,0x11,0xF0,0x2C,0xDC,0x4D, + 0x48,0xEA,0xFD,0x0A,0x00,0x21,0x28,0x22,0xDC,0x4D,0x48,0xEA,0x9D,0x05,0x08,0x22, + 0x28,0x22,0xDC,0x4D,0x48,0xEA,0x8D,0xFC,0x00,0x21,0xDC,0x4D,0xA8,0x42,0xDB,0x00}, + //Lookup (112) + {0xF0,0x3E,0xDC,0x4D,0x99,0x4C,0xC0,0x41,0xF0,0xEF,0xDC,0x4D,0x99,0x4C,0xC0,0x4F, + 0x66,0xF3,0xFF,0x00,0xF0,0x2C,0xDC,0x4D,0x49,0x6A,0xFD,0x0A,0x00,0x21,0x28,0x21, + 0xDC,0x4D,0x49,0x6A,0x9D,0x05,0x08,0x21,0x28,0x21,0xDC,0x4D,0x49,0x6A,0x8D,0xFC, + 0x20,0x2C,0xF0,0x42,0x00,0xC1,0x66,0xFE,0xFF,0x00,0xF0,0x3E,0xF0,0x1F,0xF0,0x2C, + 0xDC,0x4D,0x49,0x6A,0xFD,0x0A,0x00,0x21,0x28,0x21,0xDC,0x4D,0x49,0x6A,0x9D,0x05, + 0x08,0x21,0x28,0x21,0xDC,0x4D,0x49,0x6A,0x8D,0xFC,0x20,0x2C,0x00,0xC1,0x1B,0x41, + 0xF2,0xF1,0x0E,0xFE,0x00,0xC1,0x00,0xC2,0xDC,0x4D,0xA9,0x8C,0xC0,0x84,0xDB,0x00}, + //Lookup (20) + {0xD4,0xA0,0x00,0x00,0xD4,0xB0,0x02,0x00,0xDC,0x4F,0xA9,0x8E,0xC0,0x84,0x7C,0x8A, + 0x7C,0x8B,0x1B,0x4A,0xF2,0xF4,0x0E,0xFE,0x00,0x4B,0x00,0xC4,0xDC,0x4D,0xA9,0x8C, + 0xC0,0x84,0xDB,0x00}, + + //CRC8 (118) + {0x88,0x90,0x88,0x80,0x88,0x70,0x88,0x60,0x28,0x04,0xc2,0xf4,0xff,0xff,0xc2,0xf5, + 0xff,0xff,0x1b,0x45,0xf2,0xf4,0x0e,0xfe,0xc2,0xf2,0xff,0xff,0x1b,0x42,0xf2,0xf5, + 0x0c,0xfe,0xf2,0xf4,0x0e,0xfe,0x26,0xf4,0x98,0xf3,0x36,0xf5,0x28,0x00,0x3d,0x04, + 0x8a,0xff,0x02,0xff,0xea,0x00,0xff,0xff,0xf2,0xf4,0xff,0xff,0x66,0xf4,0x00,0x80, + 0x2d,0x1d,0x84,0x00,0xff,0xff,0xa8,0x40,0x66,0xf4,0x00,0x0f,0x46,0xf4,0x00,0x01, + 0x2d,0x15,0xa8,0x40,0x0a,0xf4,0x02,0x02,0xb8,0x40,0xa8,0x50,0x1a,0xf5,0x20,0x20, + 0xb8,0x50,0xa8,0x40,0x0a,0xf4,0x01,0x01,0xb8,0x40,0xa8,0x50,0x1a,0xf5,0x01,0x0f, + 0xb8,0x50,0x88,0x50,0xe0,0x1c}, + + //CRC8 Porsche (66) + {0x88, 0x90, 0x88, 0x80, 0xe0, 0x0f, 0xf0, 0x8c, 0xf0, 0x9d, 0x0d, 0x10, 0xdc, + 0x09, 0xa9, 0x88, 0xc0, 0x8a, 0xe0, 0x0b, 0xd4, 0x40, 0x04, 0x00, 0xd4, 0x50, + 0x06, 0x00, 0x00, 0x4a, 0x10, 0x5b, 0xc4, 0x40, 0x04, 0x00, 0xc4, 0x50, 0x06, + 0x00, 0x08, 0x81, 0x18, 0x90, 0xf0, 0x4f, 0x08, 0xf1, 0x40, 0x4e, 0x8d, 0xec, + 0xd4, 0x40, 0x04, 0x00, 0xd4, 0x50, 0x06, 0x00, 0x98, 0x80, 0x98, 0x90, 0xdb, 0x00}, + + //RSA,Calling,Sub (52) + {0x8a,0xff,0x52,0xff,0xda,0xff,0xff,0xff,0xf3,0xf8,0xff,0xff,0x2d,0x27,0x25,0x8f, + 0xff,0xff,0xf3,0xfa,0xff,0xff,0x49,0xa5,0xfd,0x19,0xff,0xff,0xff,0xff,0xe6,0xfc, + 0xff,0xff,0xe0,0x0d,0xe6,0xfe,0xff,0xff,0xda,0xff,0xff,0xff,0xe6,0xfc,0xff,0xff, + 0xe0,0x0d,0xe6,0xfe}, + //CRC32,ME71,Sub (118) + {0x88,0x90,0x88,0x80,0x88,0x70,0x88,0x60,0x28,0x06,0xc2,0xf4,0xff,0xff,0xc2,0xf5, + 0xff,0xff,0x1b,0x45,0xf2,0xf4,0x0e,0xfe,0xc2,0xf2,0xff,0xff,0x1b,0x42,0xf2,0xf5, + 0x0c,0xfe,0xf2,0xf4,0x0e,0xfe,0x26,0xf4,0x98,0xf3,0x36,0xf5,0x28,0x00,0xea,0x20, + 0xff,0xff,0xf3,0xf8,0xff,0xbd,0x47,0xf8,0x33,0x00,0xea,0x30,0xff,0xff,0xf3,0xfa, + 0xff,0xbd,0x47,0xfa,0x33,0x00,0xea,0x30,0xff,0xff,0xff,0xff,0xf3,0xf6,0xff,0xff, + 0xea,0x30,0xff,0xff,0xf3,0xf4,0xff,0xff,0x47,0xf4,0x33,0x00,0xea,0x30,0xff,0xff, + 0xe1,0x12,0xf7,0xf2,0xff,0xff,0xe1,0x28,0xf7,0xf8,0xff,0xff,0xf3,0xf8,0xff,0xbd, + 0xf7,0xf8,0xff,0xff,0xf7,0xfa}, + //CRC32,ME75,Sub (118) + {0x88,0x90,0x88,0x80,0x88,0x70,0x88,0x60,0x28,0x06,0xc2,0xf4,0xff,0xa8,0xc2,0xf5, + 0xff,0xa8,0x1b,0x45,0xf2,0xf4,0x0e,0xfe,0xc2,0xf2,0xff,0xa8,0x1b,0x42,0xf2,0xf5, + 0x0c,0xfe,0xf2,0xf4,0x0e,0xfe,0x26,0xf4,0x98,0xf3,0x36,0xf5,0x28,0x00,0xea,0x20, + 0xff,0xff,0xf3,0xf8,0x7a,0xbb,0x47,0xf8,0x33,0x00,0xea,0x30,0xff,0xff,0xf3,0xfa, + 0x8a,0xbb,0x47,0xfa,0x33,0x00,0xea,0x30,0xff,0xff,0x4f,0xff,0xf3,0xf6,0xff,0xa8, + 0xea,0x30,0xff,0xff,0xf3,0xf4,0xff,0xa8,0x47,0xf4,0x33,0x00,0xea,0x30,0xff,0xff, + 0xe1,0x12,0xf7,0xf2,0xff,0xa8,0xe1,0x28,0xf7,0xf8,0xff,0xa8,0xf3,0xf8,0x7a,0xbb, + 0xf7,0xf8,0xff,0xa8,0xf7,0xfa}, + //CRC32, ME75 Porsche Sub (len 110) + {0x88, 0x90, 0x88, 0x80, 0x88, 0x70, 0x88, 0x60, 0x28, 0x02, 0xe0, 0x0f, 0xf2, + 0xf6, 0xff, 0xff, 0xf2, 0xf7, 0xff, 0xff, 0xf0, 0x8c, 0xf0, 0x9d, 0x0d, 0x1e, + 0xdc, 0x09, 0xa9, 0x88, 0xf0, 0x56, 0x51, 0xa8, 0xb9, 0xa0, 0xe6, 0xf4, 0xff, + 0xff, 0xe6, 0xf5, 0xff, 0xff, 0xa9, 0x60, 0xc0, 0x62, 0x5c, 0x22, 0xe0, 0x03, + 0x00, 0x42, 0x10, 0x53, 0xda, 0xff, 0xff, 0xff, 0xe6, 0x00, 0xff, 0xff, 0xf0, + 0x46, 0xf0, 0x57, 0xf1, 0x89, 0xf1, 0x9a, 0x7c, 0x85, 0x50, 0x4a, 0x50, 0x5b, + 0xf0, 0x64, 0xf0, 0x75, 0x08, 0x81, 0x18, 0x90, 0xf0, 0x4f, 0x08, 0xf1, 0x40, + 0x4e, 0x8d, 0xde, 0xf0, 0x46, 0xf0, 0x57, 0x08, 0x02, 0x98, 0x60, 0x98, 0x70, + 0x98, 0x80, 0x98, 0x90, 0xdb, 0x00}, + //Test,Sub (len 59) + {0x88,0xD0,0x88,0xC0,0x88,0x90,0x88,0x80,0x88,0x70,0x88,0x60,0x26,0xF0,0x0A,0x00, + 0xE0,0x04,0xC4,0x40,0x08,0x00,0xE0,0x06,0xE0,0x07,0xE0,0x08,0xE0,0x09,0xD4,0x40, + 0x12,0x00,0xD4,0x50,0x14,0x00,0xB8,0x40,0xC4,0x50,0x02,0x00,0xDC,0x55,0x98,0xA4, + 0xA8,0xB4,0xC4,0xA0,0x04,0x00,0xC4,0xB0,0x06,0x00,0x0D}, + //SetDTCme75 (len 99) + {0x88,0x60,0xF0,0x6C,0xD4,0x40,0x02,0x00,0x9A,0xF4,0x1F,0x00,0xE6,0xF5,0xff,0xff, + 0xC0,0xC2,0x5C,0x12,0x00,0x52,0xA8,0x25,0x9A,0xF2,0x02,0x00,0x8A,0xF4,0x15,0xC0, + 0xD4,0x40,0x02,0x00,0x88,0x40,0xC0,0xCC,0xDA,0xff,0xff,0xff,0x08,0x02,0xC0,0xC4, + 0x5C,0x14,0xD4,0x54,0xff,0xff,0x9A,0xF5,0x3C,0xC0,0xD4,0x40,0x02,0x00,0x1A,0xF4, + 0x10,0x10,0xC4,0x40,0x02,0x00,0xEA,0x00,0xff,0xff,0xD4,0x40,0x02,0x00,0x8A,0xF4, + 0x0C,0x00,0xC0,0xC5,0x5C,0x15,0xD4,0x25,0xff,0xff,0x9A,0xF2,0x06,0x00,0x88,0x40, + 0xC0,0xCC,0xDA,0xff,0xff,0xff,0x08,0x02,0x0D,0x24,0xD4,0x40,0x02,0x00,0x9A,0xF4, + 0x09,0x10,0xC0,0xC5,0x5C,0x15,0xD4,0x25,0xff,0xff,0x8A,0xF2,0x03,0x10,0xC0,0xCC, + 0xDA,0xff,0xff,0xff,0xC0,0xC4,0x5C,0x14,0xD4,0x54,0xff,0xff,0x7C,0x85,0x66,0xF5, + 0x0F,0x00,0xD4,0x40,0x02,0x00,0x7C,0x84,0x66,0xF4,0x0F,0x00,0x40,0x45,0x2D,0x09, + 0xD4,0x40,0x02,0x00,0x9A,0xF4,0x05,0x00,0x88,0x40,0xC0,0xCC,0xDA,0xff,0xff,0xff, + 0x08,0x02,0xD4,0x40,0x02,0x00,0xE6,0xF5,0xff,0xff,0xC0,0xC2,0x5C,0x12,0x00,0x52, + 0xB8,0x45,0x98,0x60,0xDB,0x00}, +// 0x88,0x60,0xF0,0x6C,0xD4,0x40,0x02,0x00,0x9A,0xF4,0x1F,0x00,0xE6,0xF5,0x3A,0xB2,0xC0,0xC2,0x5C,0x12,0x00,0x52,0xA8,0x25,0x9A,0xF2,0x02,0x00,0x8A,0xF4,0x15,0xC0,0xD4,0x40,0x02,0x00,0x88,0x40,0xC0,0xCC,0xDA,0x85,0x0E,0x87,0x08,0x02,0xC0,0xC4,0x5C,0x14,0xD4,0x54,0x3A,0xB2,0x9A,0xF5,0x3C,0xC0,0xD4,0x40,0x02,0x00,0x1A,0xF4,0x10,0x10,0xC4,0x40,0x02,0x00,0xEA,0x00,0x04,0x98,0xD4,0x40,0x02,0x00,0x8A,0xF4,0x0C,0x00,0xC0,0xC5,0x5C,0x15,0xD4,0x25,0x3A,0xB2,0x9A,0xF2,0x06,0x00,0x88,0x40,0xC0,0xCC,0xDA,0x85,0xF4,0x8A,0x08,0x02,0x0D,0x24,0xD4,0x40,0x02,0x00,0x9A,0xF4,0x09,0x10,0xC0,0xC5,0x5C,0x15,0xD4,0x25,0x3A,0xB2,0x8A,0xF2,0x03,0x10,0xC0,0xCC,0xDA,0x85,0x9E,0x8C,0xC0,0xC4,0x5C,0x14,0xD4,0x54,0x3A,0xB2,0x7C,0x85,0x66,0xF5,0x0F,0x00,0xD4,0x40,0x02,0x00,0x7C,0x84,0x66,0xF4,0x0F,0x00,0x40,0x45,0x2D,0x09,0xD4,0x40,0x02,0x00,0x9A,0xF4,0x05,0x00,0x88,0x40,0xC0,0xCC,0xDA,0x85,0xF6,0x8D,0x08,0x02,0xD4,0x40,0x02,0x00,0xE6,0xF5,0x3A,0xB2,0xC0,0xC2,0x5C,0x12,0x00,0x52,0xB8,0x45,0x98,0x60,0xDB,0x00 + //0x88,0x60,0xF0,0x6C,0xD4,0x40,0x02,0x00,0x9A,0xF4,0x1F,0x00,0xE6,0xF5,0x04,0xBB,0xC0,0xC2,0x5C,0x12,0x00,0x52,0xA8,0x25,0x9A,0xF2,0x02,0x00,0x8A,0xF4,0x15,0xC0,0xD4,0x40,0x02,0x00,0x88,0x40,0xC0,0xCC,0xDA,0x84,0xB8,0x65,0x08,0x02,0xC0,0xC4,0x5C,0x14,0xD4,0x54,0x04,0xBB,0x9A,0xF5,0x3C,0xC0,0xD4,0x40,0x02,0x00,0x1A,0xF4,0x10,0x10,0xC4,0x40,0x02,0x00,0xEA,0x00,0xFA,0x76,0xD4,0x40,0x02,0x00,0x8A,0xF4,0x0C,0x00,0xC0,0xC5,0x5C,0x15,0xD4,0x25,0x04,0xBB,0x9A,0xF2,0x06,0x00,0x88,0x40,0xC0,0xCC,0xDA,0x84,0xE6,0x69,0x08,0x02,0x0D,0x24,0xD4,0x40,0x02,0x00,0x9A,0xF4,0x09,0x10,0xC0,0xC5,0x5C,0x15,0xD4,0x25,0x04,0xBB,0x8A,0xF2,0x03,0x10,0xC0,0xCC,0xDA,0x84,0xB2,0x6B,0xC0,0xC4,0x5C,0x14,0xD4,0x54,0x04,0xBB,0x7C,0x85,0x66,0xF5,0x0F,0x00,0xD4,0x40,0x02,0x00,0x7C,0x84,0x66,0xF4,0x0F,0x00,0x40,0x45,0x2D,0x09,0xD4,0x40,0x02,0x00,0x9A,0xF4,0x05,0x00,0x88,0x40,0xC0,0xCC,0xDA,0x84,0xFE,0x6C,0x08,0x02,0xD4,0x40,0x02,0x00,0xE6,0xF5,0x04,0xBB,0xC0,0xC2,0x5C,0x12,0x00,0x52,0xB8,0x45,0x98,0x60,0xDB,0x00) + //SetDTCME75Porsche (len 308) + {0x88, 0xff, 0x88, 0xff, 0x88, 0xff, 0x88, 0xff, 0xff, 0xff, 0x26, 0xf0, 0xff, 0xff, + 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5c, 0x15, 0x00, 0x45, 0xa8, 0x54, + 0xc4, 0x50, 0x10, 0x00, 0x88, 0x50, 0xd4, 0xc0, 0x42, 0x00, 0xda, 0xff, 0xff, 0xff, + 0x08, 0x02, 0xa8, 0x54, 0xc4, 0x50, 0x20, 0x00, 0xd4, 0x40, 0x40, 0x00, 0x46, 0xf4, + 0xf1, 0x00, 0xea, 0xe0, 0xf6, 0x95, 0xd4, 0x20, 0x42, 0x00, 0x7c, 0x82, 0x66, 0xf2, + 0x0f, 0x00, 0xf4, 0xff, 0xff, 0xff, 0xc0, 0x84, 0x46, 0xf4, 0xff, 0x00, 0x3d, 0x12, + 0xd4, 0x40, 0x40, 0x00, 0xd7, 0x40, 0xe1, 0x00, 0xf6, 0xf4, 0xff, 0xff, 0xe6, 0xf2, + 0xff, 0xff, 0xd7, 0x40, 0xe1, 0x00, 0x74, 0xf2, 0xff, 0xff, 0xd4, 0x20, 0x42, 0x00, + 0x1a, 0xf2, 0x08, 0x0f, 0xc4, 0x20, 0x42, 0x00, 0xe1, 0x08, 0xe4, 0x80, 0x22, 0x00, + 0xf2, 0xf4, 0xff, 0xff, 0xea, 0x20, 0x46, 0x95, 0xf6, 0x8e, 0xff, 0xff, 0xd4, 0x40, + 0x42, 0x00, 0x88, 0x40, 0xd4, 0xc0, 0x42, 0x00, 0xda, 0xff, 0xff, 0xff, 0x08, 0x02, + 0xa8, 0x54, 0xc4, 0x50, 0x08, 0x00, 0xd4, 0x40, 0x20, 0x00, 0x50, 0x54, 0xc4, 0x50, + 0x1c, 0x00, 0xd4, 0x20, 0x08, 0x00, 0x7c, 0x82, 0x66, 0xf2, 0x0f, 0x00, 0xf4, 0xff, + 0xff, 0xff, 0xe4, 0x80, 0x18, 0x00, 0xd4, 0x40, 0x08, 0x00, 0x9a, 0xf4, 0x44, 0x00, + 0x66, 0xf4, 0x00, 0x0f, 0xea, 0x20, 0xaa, 0x04, 0xd4, 0x40, 0x40, 0x00, 0xd7, 0x50, + 0xe1, 0x00, 0xf4, 0xa4, 0xff, 0xff, 0xcc, 0x00, 0x49, 0xa0, 0x2d, 0x2c, 0xd4, 0x40, + 0x40, 0x00, 0xd7, 0x50, 0xe1, 0x00, 0xf4, 0xa4, 0xff, 0xff, 0xcc, 0x00, 0xc0, 0xa5, + 0xf0, 0x25, 0x5c, 0x22, 0x00, 0x25, 0xf4, 0x80, 0x18, 0x00, 0xc0, 0x84, 0x00, 0x24, + 0xd7, 0x50, 0xe1, 0x00, 0xf4, 0x82, 0xff, 0xff, 0xcc, 0x00, 0x49, 0x80, 0x2d, 0x16, + 0xd4, 0x40, 0x40, 0x00, 0xd7, 0x50, 0xe1, 0x00, 0xf4, 0xa4, 0xff, 0xff, 0xcc, 0x00, + 0xc0, 0xa5, 0xf0, 0x25, 0x5c, 0x22, 0x00, 0x25, 0xf4, 0x80, 0x18, 0x00, 0xc0, 0x84, + 0x00, 0x24, 0xd7, 0x50, 0xe1, 0x00, 0xf4, 0x82, 0xff, 0xff, 0xcc, 0x00, 0x29, 0x81, + 0x0d, 0x02}, + //SetDTCME75Porsche (len 308) + {0x88, 0x90, 0x88, 0x80, 0x88, 0x70, 0x88, 0x60, 0x26, 0xf0, 0x1e, 0x00, 0xf0, 0x9c, + 0xff, 0xff, 0xff, 0xff, 0xf0, 0xd9, 0x5c, 0x1d, 0xc4, 0xd0, 0x10, 0x00, 0x00, 0xcd, + 0xa8, 0xcc, 0xc4, 0xc0, 0x02, 0x00, 0x88, 0xc0, 0xf0, 0xc9, 0xff, 0xff, 0xff, 0xff, + 0x08, 0x02, 0xa8, 0x84, 0xc4, 0x80, 0x0e, 0x00, 0x46, 0xf9, 0xf3, 0x00, 0xea, 0xe0, + 0xa2, 0x50, 0xd4, 0x60, 0x26, 0x00, 0x7c, 0x86, 0x66, 0xf6, 0x0f, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xc0, 0xe6, 0x46, 0xff, 0xff, 0x00, 0x3d, 0x10, 0xe6, 0xf6, 0xff, 0xff, + 0xd7, 0x40, 0xe1, 0x00, 0xff, 0xff, 0xff, 0xff, 0xd7, 0x40, 0xe1, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xd4, 0x70, 0x26, 0x00, 0x1a, 0xf7, 0x08, 0x0f, 0xc4, 0x70, 0x26, 0x00, + 0xe1, 0x0c, 0xe4, 0xc0, 0x0a, 0x00, 0xff, 0xff, 0xff, 0xff, 0xea, 0x20, 0x12, 0x50, + 0xff, 0xff, 0xff, 0xff, 0xd4, 0x80, 0x26, 0x00, 0x88, 0x80, 0xf0, 0xc9, 0xda, 0xff, + 0xff, 0xff, 0x08, 0x02, 0xc8, 0x04, 0xa8, 0x80, 0xd4, 0x60, 0x0e, 0x00, 0x50, 0x86, + 0xc4, 0x80, 0x0c, 0x00, 0xa8, 0x70, 0x7c, 0x87, 0x66, 0xf7, 0x0f, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x9a, 0xf7, 0x33, 0x00, 0xa8, 0xc0, 0x66, 0xfc, 0x00, 0x0f, + 0x48, 0xc0, 0x2d, 0x2e, 0xd7, 0x40, 0xe1, 0x00, 0xff, 0xff, 0xff, 0xff, 0x2d, 0x1f, + 0xd7, 0x40, 0xe1, 0x00, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xe7, 0xf0, 0xc7, 0x5c, 0x2c, + 0x00, 0xc7, 0xc0, 0xc7, 0x00, 0xc7, 0xd7, 0x40, 0xe1, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x2d, 0x10, 0xd7, 0x40, 0xe1, 0x00, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xe7, 0xf0, 0xc7, + 0x5c, 0x2c, 0x00, 0xc7, 0xc0, 0xc7, 0x00, 0xc7, 0xd7, 0x40, 0xe1, 0x00, 0xff, 0xff, + 0xff, 0xff, 0x29, 0xe1, 0x0d, 0x02, 0xe7, 0xfe, 0xff, 0x00, 0x47, 0xfe, 0xff, 0x00, + 0x3d, 0x02, 0xe0, 0x17, 0x0d, 0x01, 0xe0, 0x07, 0xf0, 0x87, 0x0d, 0x01, 0xe0, 0x08, + 0x48, 0x80, 0x2d, 0x17, 0xf0, 0x89, 0x5c, 0x28, 0xc0, 0xc7, 0x00, 0x87, 0xd7, 0x40, + 0x06, 0x02, 0xff, 0xff, 0xff, 0xff, 0x49, 0xe0, 0x2d, 0x0d, 0xf0, 0x89, 0x5c, 0x28}, + //SetDTCME71 (len 71) + {0x88,0x60,0xF0,0x6C,0xD4,0x40,0x02,0x00,0x9A,0xF4,0x11,0x00,0xC0,0xC5,0x5C,0x15,0xD4, + 0x25,0x04,0xBB,0x9A,0xF2,0x02,0x00,0x8A,0xF4,0x09,0xC0,0xD4,0x40,0x02,0x00,0x88,0x40, + 0xC0,0xCC,0xDA,0xff,0xff,0xff,0x08,0x02,0xEA,0x00,0xBC,0xEA,0xD4,0x40,0x02,0x00,0x8A, + 0xF4,0x0C,0x00,0xC0,0xC5,0x5C,0x15,0xD4,0x25,0x04,0xBB,0x9A,0xF2,0x06,0x00,0x88,0x40, + 0xC0,0xCC,0xDA,0xff,0xff,0xff,0x08,0x02,0x0D,0x24,0xD4,0x40,0x02,0x00,0x9A,0xF4,0x09, + 0x10,0xC0,0xC5,0x5C,0x15,0xD4,0x25,0x04,0xBB,0x8A,0xF2,0x03,0x10,0xC0,0xCC,0xDA,0xff, + 0xff,0xff,0xC0,0xC4,0x5C,0x14,0xD4,0x54,0x04,0xBB,0x7C,0x85,0x66,0xF5,0x0F,0x00,0xD4, + 0x40,0x02,0x00,0x7C,0x84,0x66,0xF4,0x0F,0x00,0x40,0x45,0x2D,0x09,0xD4,0x40,0x02,0x00, + 0x9A,0xF4,0x05,0x00,0x88,0x40,0xC0,0xCC,0xDA,0xff,0xff,0xff,0x08,0x02,0xD4,0x40,0x02, + 0x00,0xE6,0xF5,0xff,0xff,0xC0,0xC2,0x5C,0x12,0x00,0x52,0xB8,0x45,0x98,0x60,0xDB,0x00}, + //SetDTC Bentley (len 120) + {0x88, 0xc0, 0x88, 0x90, 0x88, 0x80, 0x88, 0x70, 0x88, 0x60, 0x26, 0xf0, 0x28, 0x00, + 0xe6, 0xf4, 0xff, 0xff, 0xd4, 0x50, 0x30, 0x00, 0x5c, 0x15, 0x00, 0x45, 0xa8, 0x54, + 0xc4, 0x50, 0x02, 0x00, 0x88, 0x50, 0xd4, 0xc0, 0x32, 0x00, 0xda, 0xff, 0xff, 0xff, + 0x08, 0x02, 0xa8, 0x54, 0xc4, 0x50, 0x0a, 0x00, 0xd4, 0x40, 0x30, 0x00, 0x46, 0xf4, + 0xd4, 0x00, 0xea, 0xe0, 0xfe, 0xfb, 0xd4, 0x20, 0x32, 0x00, 0x7c, 0x82, 0x66, 0xf2, + 0x0f, 0x00, 0xf4, 0x82, 0xff, 0xff, 0xc0, 0x84, 0x46, 0xf4, 0xff, 0x00, 0x3d, 0x12, + 0xd4, 0x40, 0x30, 0x00, 0xd7, 0x40, 0xe1, 0x00, 0xf6, 0xf4, 0xff, 0xff, 0xe6, 0xf2, + 0xff, 0xff, 0xd7, 0x40, 0xe1, 0x00, 0x74, 0xf2, 0xff, 0xff, 0xd4, 0x20, 0x32, 0x00, + 0x1a, 0xf2, 0x08, 0x0f, 0xc4, 0x20, 0x32, 0x00}, + //Set DTC ME7.5 (Len 58) + {0x88, 0x60, 0xf0, 0x6c, 0xd4, 0x40, 0x02, 0x00, 0x9a, 0xf4, 0x11, 0x00, 0xc0, 0xc5, 0x5c, 0x15, + 0xd4, 0x25, 0xff, 0xff, 0x9a, 0xf2, 0x02, 0x00, 0x8a, 0xf4, 0x09, 0xc0, 0xd4, 0x40, 0x02, 0x00, + 0x88, 0x40, 0xc0, 0xcc, 0xda, 0xff, 0xff, 0xff, 0x08, 0x02, 0xea, 0x00, 0x44, 0x14, 0xd4, 0x40, + 0x02, 0x00, 0x8a, 0xf4, 0x0c, 0x00, 0xc0, 0xc5, 0x5c, 0x15}, + //Set DTC ME7.6.1 (Len 32) + {0x88, 0x90, 0x88, 0x80, 0x88, 0x60, 0xF0, 0x9E, 0xF0, 0x8D, 0xF0, 0x6C, 0x47, 0xFC, 0x2C, 0x00, + 0x2D, 0x06, 0x47, 0xFC, 0x2D, 0x00, 0x2D, 0x03, 0x47, 0xFC, 0x2E, 0x00, 0x3D, 0x33, 0xC0, 0xCC, + 0xDA, 0xff, 0xff, 0xff, 0x49, 0x82, 0x3D, 0x0D, 0xDC, 0x09, 0xA9, 0x48, 0xF0, 0xC8, 0xF0, 0xD9, + 0x08, 0xC1, 0x18, 0xD0, 0xDC, 0x0D, 0xA9, 0x2C, 0xDC, 0x09, 0xB9, 0x28, 0xDC, 0x0D, 0xB9, 0x4C}, + //Reset Handler (len 20) (Ferrari) + {0xe6, 0x08, 0xff, 0xff, 0xe6, 0x86, 0xff, 0xff, 0x9a, 0x89, 0x03, 0xa0, 0xe6, 0x89, 0xff, 0xff, + 0x0d, 0x02, 0xe6, 0x89}, + //Reset Handler (len 27) (ME7.6.2) + {0xCA, 0x00, 0x04, 0x02, 0xE6, 0x08, 0x00, 0xFC, 0xE6, 0x09, 0x00, 0xFC, 0xE6, 0x0A, 0x00, 0xFA, + 0xE6, 0x0B, 0x00, 0xFC, 0xE6, 0x88, 0x00, 0x00, 0x9A, 0x89, 0x03}, + //Chksum803c (len 76) (Ferrari) + {0x88, 0x90, 0x88, 0x80, 0x88, 0x70, 0x88, 0x60, 0x26, 0xf0, 0xff, 0x00, 0xe1, 0x08, 0xff, 0x80, + 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xec, 0x00, 0xf0, 0xc0, 0xe0, 0x1d, 0x00, 0xd0, 0xda, 0xff, + 0xff, 0xff, 0xf3, 0xf8, 0xff, 0xff, 0x47, 0xf8, 0x55, 0x00, 0xea, 0x20, 0xd4, 0x73, 0x47, 0xf8, + 0xaa, 0x00, 0x3d, 0x0c, 0xe6, 0xf4, 0xff, 0xff, 0xe6, 0xf5, 0xff, 0xff, 0xdc, 0x55, 0x98, 0xa4, + 0xa8, 0xb4, 0xc4, 0xa0, 0x02, 0x00, 0xc4, 0xb0, 0x04, 0x00, 0x0d, 0x0b}, + //Chksum803c (len 64) (ME7.6.1) + {0x88, 0x90, 0x88, 0x80, 0xd7, 0x40, 0x06, 0x00, 0xf2, 0xfc, 0x00, 0x00, 0x46, 0xfc, 0xaa, 0x55, + 0x3d, 0x17, 0xd7, 0x40, 0x23, 0x00, 0xf2, 0xfd, 0xfe, 0x3f, 0x46, 0xfd, 0x55, 0xaa, 0x3d, 0x10, + 0xd7, 0x40, 0x30, 0x00, 0xf2, 0xfe, 0x00, 0x00, 0x46, 0xfe, 0x5a, 0x5a, 0x3d, 0x09, 0xd7, 0x40, + 0x33, 0x00, 0xf2, 0xff, 0xfe, 0x3f, 0x46, 0xff, 0xa5, 0xa5, 0x3d, 0x02, 0xe0, 0x1c, 0x0d, 0x01}, + //Chksum803c (len 150) (ME7.5) + {0x88, 0x90, 0x88, 0x80, 0x88, 0x70, 0x88, 0x60, 0x26, 0xf0, 0x18, 0x00, 0xe1, 0x08, 0xe4, 0x80, + 0x04, 0x00, 0xe1, 0x0a, 0xe4, 0xa0, 0x05, 0x00, 0xec, 0x00, 0xe0, 0x04, 0xe6, 0xf5, 0xff, 0xff, + 0xb8, 0x40, 0xc4, 0x50, 0x02, 0x00, 0xe0, 0x4c, 0x00, 0xc0, 0xe0, 0x5d, 0x00, 0xd0, 0xff, 0xff, + 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0x47, 0xf8, 0x55, 0x00, 0xea, 0x20, 0x7c, 0x61, 0x47, 0xf8, + 0xaa, 0x00, 0x3d, 0x0b, 0xe6, 0xff, 0xff, 0xff, 0xe6, 0xff, 0xff, 0xff, 0xdc, 0x55, 0x98, 0x74, + 0xa8, 0x84, 0x28, 0x70, 0x36, 0xf8, 0x80, 0x00, 0x0d, 0x0a, 0xe6, 0xf4, 0xff, 0xff, 0xe6, 0xf5, + 0xff, 0xff, 0xdc, 0x55, 0x98, 0x74, 0xa8, 0x84, 0x28, 0x70, 0x36, 0xf8, 0x80, 0x00, 0xf0, 0x47, + 0xf0, 0x58, 0xf0, 0x25, 0x7c, 0xd4, 0x7c, 0xd5, 0x5c, 0x32, 0x70, 0x42, 0xc4, 0x40, 0x0a, 0x00, + 0xf0, 0x97, 0x66, 0xf9, 0xff, 0x1f, 0x2d, 0x03, 0x08, 0x41, 0xc4, 0x40, 0x0a, 0x00, 0xe0, 0x04, + 0xe0, 0x05, 0xc4, 0x40, 0x06, 0x00}, + //Chksum803c (len 64) (ME7.1.1) + {0x88, 0x90, 0x88, 0x80, 0xD7, 0x40, 0xE1, 0x00, 0xF6, 0xff, 0xff, 0xff, 0xD7, 0x40, 0x08, 0x00, + 0xF2, 0xff, 0xff, 0xff, 0x46, 0xFC, 0xAA, 0x55, 0x3D, 0x25, 0xD7, 0x40, 0x33, 0x00, 0xF2, 0xFf, + 0xFf, 0xfF, 0x46, 0xFD, 0x55, 0xAA, 0x3D, 0x1E, 0xD7, 0x40, 0x00, 0x00, 0xF2, 0xFE, 0xff, 0xff, + 0x46, 0xFE, 0x5A, 0x5A, 0x3D, 0x17, 0xD7, 0x40, 0x01, 0x00, 0xF2, 0xFF, 0xff, 0xfF, 0x46, 0xFF}, + //Main ROM chksum validate during boot ME7.6 + {0x88, 0x60, 0xf3, 0xf8, 0x08, 0xfe, 0xea, 0x30, 0x52, 0x0b, 0xe6, 0xf4, 0xff, 0xff, 0xe0, 0x05, + 0xdc, 0x05, 0xa8, 0x24, 0x46, 0xf2, 0xff, 0xff, 0x3d, 0x02, 0xe0, 0x1c, 0x0d, 0x01, 0xe0, 0x0c, + 0x48, 0xc0, 0xea, 0x30, 0x52, 0x0b, 0xe6, 0x86, 0xff, 0xff, 0xe6, 0x8b, 0xff, 0xff, 0xe6, 0x0d, + 0xff, 0xff, 0xd1, 0x80, 0xe6, 0x0e, 0xff, 0xff, 0xe1, 0x0c}, + //Main ROM Chksum ME7.6 (len 58) + {0xda, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0x49, 0x21, 0xea, 0x30, 0x42, 0x6f, 0xc2, 0xff, + 0xff, 0xff, 0x46, 0xfc, 0x08, 0x00, 0xea, 0x90, 0x08, 0x6f, 0xf2, 0xfd, 0xff, 0xff, 0xf2, 0xfe, + 0xff, 0xff, 0xe0, 0x0c, 0x0d, 0x0a, 0xdc, 0x0e, 0xa8, 0xfd, 0xe0, 0x01, 0x04, 0xff, 0xff, 0xff, + 0x14, 0xf1, 0xff, 0xff, 0x08, 0xd2, 0x18, 0xe0, 0x08, 0xc1}, + //Main ROM Chksum Ferrari (len 62) + {0x88, 0x90, 0x88, 0x80, 0x88, 0x70, 0x88, 0x60, 0xda, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, + 0x49, 0x81, 0xea, 0x30, 0x8e, 0x47, 0xf3, 0xff, 0xff, 0xff, 0x49, 0xa4, 0x9d, 0x27, 0xf2, 0xff, + 0xff, 0xff, 0xf2, 0xff, 0xff, 0xff, 0xe0, 0x07, 0x0d, 0x0a, 0xdc, 0x09, 0xa8, 0x48, 0xe0, 0x05, + 0x04, 0xff, 0xff, 0xff, 0x14, 0xff, 0xff, 0xff, 0x08, 0x82, 0x18, 0x90, 0x08, 0x71} + }; + +unsigned int fs_siglen[NUM_FUNC_SIGS] = {10, 9, 6, 64, 62, 104, 98, 58, 252, 108, 202, 64, 40, 28, 44, 58, 120, 150, 66, 96, + 88, 108, 6, 48, 40, 48, 62, 92, 108, 18, 24, 20, 44, 12, 8, 12, 16, 34, 28, 14, + 26, 12, 10, 32,14, 14, 106, 106, 150, 64, 62, 42, 64, 64, 72, 72, 74, 140, 122, 84, 100, 122, + 120, 122, 234, 284, 70, 70, 78, 78, 38, 13, 14, 12, 38, 36, 48, 116, 144, 156, + 48, 48, 112, 20, 118, 66, 52, 118, 118, 110, 59, 99, 308, 308, 71, 120, 58, 32, + 20, 27, 76, 64, 150, 64, 58, 58, 62}; + +////////////////////////////////////////////////////////////////////// +// Table Signatures +////////////////////////////////////////////////////////////////////// +#define NUM_DATA_SIGS 20 + +unsigned char ts_Tablenames[NUM_DATA_SIGS][255] = + { + {"CRC32_HashTable"}, + {"ME71OBDProgHashTable"}, + {"Do803cChksumLoop"}, + {"Do803cChksumLoop"}, + {"Do803cChksumLoop"}, + {"DTC_LookupTable"}, + {"DTC_LookupTable"}, + {"DTC_LookupTable"}, + {"DTC_FormTable"}, + {"LineariseOilTemp"}, + {"LineariseIAT"}, + {"LineariseMAF"}, + {"LineariseEGT"}, + {"LineariseCTS"}, + {"MultipointChksumBlk"}, + {"MultipointChksumBlk"}, + {"DoCRC8"}, + {"DoCRC8"}, + {"MainROMChksumBlk"}, + {"me72002_crc32"} +}; + +unsigned char ts_Tablecomments[NUM_DATA_SIGS][255] = + { + {"Hash Table for CRC32 Checksum/n256 words long"}, + {"Hash Table for OBD-II Programming"}, + {"This is the 0x803c checksum code that cycles through ROM"}, + {"This is the 0x803c checksum code that cycles through ROM"}, + {"This is the 0x803c checksum code that cycles through ROM (ME7.6.1)"}, + {"DTC Lookup Table"}, + {"DTC Lookup Table"}, + {"DTC Lookup Table"}, + {"DTC Forming Table"}, + {"Table to linearise the Oil Temp output"}, + {"Table to linearise the IAT output"}, + {"Table to linearise the Hot Wire MAF output"}, + {"Table to linearise the EGT output"}, + {"Table to linearise the CTS output"}, + {"Multipoint chksum block"}, + {"Multipoint chksum block"}, + {"CRC8 done here"}, + {"CRC8 done here"}, + {"Sets range of Main ROM CRC8 Chksum"}, + { "ME72002 crc32 checksum code" } + }; +unsigned char ts_Tablesigs[NUM_DATA_SIGS][310] = + { + //CRC32 Hash Table (len 128) + {0x00, 0x00, 0x00, 0x00, 0x96, 0x30, 0x07, 0x77, 0x2c, 0x61, 0x0e, 0xee, 0xba, 0x51, 0x09, 0x99}, + //0x19, 0xc4, 0x6d, 0x07, 0x8f, 0xf4, 0x6a, 0x70, 0x35, 0xa5, 0x63, 0xe9, 0xa3, 0x95, 0x64, 0x9e, + //0x32, 0x88, 0xdb, 0x0e, 0xa4, 0xb8, 0xdc, 0x79, 0x1e, 0xe9, 0xd5, 0xe0, 0x88, 0xd9, 0xd2, 0x97, + //0x2b, 0x4c, 0xb6, 0x09, 0xbd, 0x7c, 0xb1, 0x7e, 0x07, 0x2d, 0xb8, 0xe7, 0x91, 0x1d, 0xbf, 0x90, + //0x64, 0x10, 0xb7, 0x1d, 0xf2, 0x20, 0xb0, 0x6a, 0x48, 0x71, 0xb9, 0xf3, 0xde, 0x41, 0xbe, 0x84, + //0x7d, 0xd4, 0xda, 0x1a, 0xeb, 0xe4, 0xdd, 0x6d, 0x51, 0xb5, 0xd4, 0xf4, 0xc7, 0x85, 0xd3, 0x83, + //0x56, 0x98, 0x6c, 0x13, 0xc0, 0xa8, 0x6b, 0x64, 0x7a, 0xf9, 0x62, 0xfd, 0xec, 0xc9, 0x65, 0x8a, + //0x4f, 0x5c, 0x01, 0x14, 0xd9, 0x6c, 0x06, 0x63, 0x63, 0x3d, 0x0f, 0xfa, 0xf5, 0x0d, 0x08, 0x8d}, + //ME7.1 OBD-II Programming Hash (len 256) + {0x89, 0x12, 0x22, 0x0a, 0xa1, 0x90, 0x48, 0x14, 0x91, 0x24, 0x21, 0x24, 0x85, 0x02, 0x0a, 0x29, + 0x91, 0x50, 0x14, 0x42, 0xc1, 0x22, 0x48, 0x50, 0xc1, 0xc4, 0x24, 0x0a, 0x29, 0x22, 0x25, 0x14, + 0x25, 0x05, 0x25, 0x24, 0x91, 0xa4, 0x10, 0x25, 0x63, 0x88, 0x48, 0x28, 0x85, 0x88, 0x14, 0x29, + 0xa5, 0x84, 0x21, 0x42, 0x21, 0x85, 0x12, 0x49, 0x85, 0x4a, 0x84, 0x50, 0x11, 0xc2, 0x0c, 0x62, + 0xa9, 0x52, 0x44, 0x12, 0x51, 0x22, 0x93, 0x18, 0x59, 0xa4, 0x24, 0x24, 0x21, 0x95, 0x14, 0x29, + 0x21, 0x26, 0x35, 0x42, 0x89, 0x22, 0x51, 0x4a, 0x11, 0x89, 0xa4, 0x52, 0x75, 0x14, 0x89, 0x11, + 0x23, 0x65, 0x34, 0x22, 0xd1, 0x18, 0x31, 0x4a, 0x11, 0x71, 0x49, 0x64, 0x29, 0x45, 0xe3, 0x0a, + 0x89, 0x89, 0x39, 0x15, 0x67, 0x4a, 0x32, 0x22, 0x89, 0xb4, 0x12, 0x2d, 0x75, 0x4a, 0x2a, 0x13, + 0x69, 0x34, 0xb1, 0x19, 0x53, 0xc4, 0xd2, 0x25, 0x9b, 0x34, 0x49, 0x49, 0x59, 0x92, 0x4e, 0x52, + 0x6b, 0xca, 0x64, 0x19, 0x9b, 0x24, 0xf5, 0x24, 0x75, 0x91, 0x97, 0x28, 0x59, 0x59, 0x2a, 0x35, + 0x49, 0x17, 0x39, 0x3a, 0xa9, 0x4e, 0xd4, 0x51, 0x25, 0x4f, 0x4a, 0x56, 0x49, 0x26, 0xd5, 0x6a, + 0x25, 0x39, 0x49, 0x76, 0xc9, 0x52, 0xde, 0x25, 0x33, 0x93, 0x2e, 0x33, 0x97, 0x49, 0xd6, 0x68, + 0xfb, 0x47, 0x49, 0x49, 0xcf, 0x9a, 0x74, 0x33, 0x5d, 0x5b, 0xd5, 0x5a, 0x4f, 0x2a, 0x27, 0x7f, + 0x75, 0x5b, 0xbd, 0x35, 0x5d, 0xd5, 0x5a, 0x3f, 0xad, 0x6d, 0x5b, 0x5b, 0x6b, 0xad, 0x5d, 0x6b, + 0xd5, 0x7a, 0xb5, 0x75, 0x6f, 0xd5, 0xba, 0x5d, 0xad, 0x6a, 0xbf, 0x6d, 0xb5, 0x5e, 0x77, 0x75, + 0xd5, 0xfe, 0xed, 0x5a, 0xd5, 0x7d, 0x5f, 0x6b, 0x6b, 0x7b, 0x75, 0x6f, 0xbd, 0x5d, 0xbd, 0x5f}, + //803c chksum code seq (len 36) + {0xdc, 0x09, 0xa8, 0x48, 0xe0, 0x05, 0x00, 0x64, 0x10, 0x75, 0xf0, 0x48, 0xf0, 0x59, 0x06, 0xf4, + 0xfe, 0x1f, 0x18, 0x50, 0xdc, 0x05, 0xa8, 0x24, 0xe0, 0x03, 0x00, 0x62, 0x10, 0x73, 0x06, 0xf8, + 0x00, 0x20, 0x18, 0x90}, + //803c chksum code seq (len 88) + {0x9f, 0x89, 0xc2, 0xf4, 0x4f, 0xb2, 0x5c, 0x84, 0xf6, 0xf4, 0x5e, 0x8f, 0xc2, 0xfc, 0x4f, 0xb2, + 0xc2, 0xf5, 0x9b, 0x89, 0x1b, 0xc5, 0xf2, 0xfc, 0x0e, 0xfe, 0x7c, 0x7c, 0x46, 0xfc, 0xff, 0x00, + 0x8d, 0x03, 0xf7, 0x8f, 0x9d, 0x89, 0x0d, 0x03, 0xf0, 0x4c, 0xf7, 0xf8, 0x9d, 0x89, 0xc2, 0xf4, + 0x9d, 0x89, 0x5c, 0x24, 0xf6, 0xf4, 0x62, 0x8f, 0xf2, 0xf4, 0x16, 0xbc, 0x9a, 0xf4, 0x08, 0x70, + 0xf7, 0x8e, 0xa3, 0x89, 0xf7, 0x8e, 0xa5, 0x89, 0xf6, 0x8e, 0x64, 0x8f, 0xf6, 0x8e, 0x66, 0x8f, + 0xf2, 0xf4, 0x14, 0xbc, 0x8a, 0xf4, 0x04, 0x70}, + //803c chksum code seq (len 36) (ME7.6.1) + {0xdc, 0x0d, 0xa8, 0x8c, 0xe0, 0x09, 0x00, 0xe8, 0x10, 0xf9, 0xf0, 0x8c, 0xf0, 0x1d, 0x06, 0xf8, + 0xfe, 0x1f, 0x18, 0x10, 0xdc, 0x01, 0xa8, 0x88, 0xe0, 0x01, 0x00, 0xe8, 0x10, 0xf1, 0x06, 0xfc, + 0x00, 0x20, 0x18, 0xd0}, + //DTC Table (len 64) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x14, 0x01, 0x14, 0x40, 0x14, 0x00, 0x14, + 0x02, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x56, 0x14, 0x56, 0x14, 0x56, 0x14, 0x56, 0x14, + 0x60, 0x14, 0x60, 0x14, 0x60, 0x14, 0x60, 0x14, 0x61, 0x14, 0x61, 0x14, 0x61, 0x14, 0x61, 0x14, + 0x62, 0x14, 0x62, 0x14, 0x62, 0x14, 0x62, 0x14, 0x53, 0x14, 0x54, 0x14, 0x55, 0x14, 0x55, 0x14}, + //DTC Table(len 60) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x06, 0x01, 0x06, 0x01, 0x06, + 0x02, 0x14, 0x01, 0x14, 0x40, 0x14, 0x00, 0x14, 0x02, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, + 0x56, 0x14, 0x56, 0x14, 0x56, 0x14, 0x56, 0x14, 0x60, 0x14, 0x60, 0x14, 0x60, 0x14, 0x60, 0x14, + 0x61, 0x14, 0x61, 0x14, 0x61, 0x14, 0x61, 0x14, 0x62, 0x14, 0x62, 0x14}, + //DTC Table (len 60) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x06, 0x01, 0x06, 0x01, 0x06, + 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x02, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, + 0x56, 0x14, 0x56, 0x14, 0x56, 0x14, 0x56, 0x14, 0x60, 0x14, 0x60, 0x14, 0x60, 0x14, 0x60, 0x14, + 0x61, 0x14, 0x61, 0x14, 0x61, 0x14, 0x61, 0x14, 0x62, 0x14, 0x62, 0x14}, + //DTC Related Lookup (len 64) + {0x00, 0x00, 0x57, 0x00, 0x56, 0x00, 0x5f, 0x01, 0x60, 0x01, 0xbc, 0x02, 0xbd, 0x02, 0x62, 0x01, + 0x63, 0x01, 0x6f, 0x00, 0x6c, 0x01, 0xa4, 0x01, 0xa5, 0x01, 0xbe, 0x02, 0xd8, 0x00, 0x40, 0x02, + 0xec, 0x00, 0x29, 0x01, 0x32, 0x01, 0x0a, 0x02, 0x75, 0x00, 0xae, 0x01, 0xaf, 0x01, 0x6c, 0x00, + 0x61, 0x01, 0x49, 0x01, 0x2b, 0x01, 0xb8, 0x01, 0x93, 0x01, 0x9c, 0x01, 0x1d, 0x02, 0x92, 0x01}, + // Oil Temp Linearise (Len 38) + {0x14, 0x09, 0x0b, 0x0d, 0x11, 0x16, 0x1c, 0x25, 0x2f, 0x3d, 0x4d, 0x62, 0x79, 0x91, 0xa9, 0xc0, + 0xce, 0xda, 0xe2, 0xeb, 0xfd, 0xed, 0xe0, 0xd3, 0xc5, 0xb8, 0xab, 0x9d, 0x90, 0x83, 0x75, 0x68, + 0x5b, 0x4d, 0x40, 0x33, 0x25, 0x18}, + // IAT Linearise (Len 38) + {0x14, 0x00, 0x08, 0x09, 0x0c, 0x0e, 0x12, 0x17, 0x1d, 0x25, 0x30, 0x3d, 0x4d, 0x6c, 0x8f, 0xa6, + 0xba, 0xcc, 0xd8, 0xe1, 0xff, 0xff, 0xfb, 0xed, 0xe0, 0xd3, 0xc5, 0xb8, 0xab, 0x9d, 0x90, 0x83, + 0x75, 0x61, 0x4d, 0x40, 0x33, 0x25}, + //Linearise MAF (len 16) + {0x93,0x05,0x9B,0x05,0xA2,0x05,0xAA,0x05,0xB2,0x05,0xB9,0x05,0xC1,0x05,0xC8,0x05}, + //Linearise EGT (len 16) + {0x12,0x00,0x00,0x00,0x9A,0x19,0x17,0x28,0x39,0x36,0x0B,0x44,0x9D,0x51,0xFA,0x5E}, + //Linearise CTS (len 16) + {0x14,0x00,0x00,0x00,0x24,0x00,0x2C,0x00,0x38,0x00,0x44,0x00,0x58,0x00,0x70,0x00}, + //Multipoint chksum (len 40) + {0x00, 0x00, 0x00, 0x00, 0xff, 0x3f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x40, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x80, 0x01, 0x00, 0xff, 0xbf, 0x01, 0x00}, + //Multipoint chksum (len 40) + {0x00, 0x00, 0x00, 0x00, 0xff, 0x3f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x40, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x80, 0x00, 0xff, 0x3f, 0x80, 0x00}, + //CRC8 Code (len 20) + {0xdc, 0x09, 0xa8, 0x48, 0xe0, 0x05, 0x04, 0xff, 0xff, 0xff, 0x14, 0xff, 0xff, 0xff, 0x08, 0x82, + 0x18, 0x90, 0x08, 0x71}, + //CRC8 Code (len 20) + {0xdc, 0x0e, 0xa8, 0xfd, 0xe0, 0x01, 0x04, 0xff, 0xff, 0xff, 0x14, 0xff, 0xff, 0xff, 0x08, 0xd2, + 0x18, 0xe0, 0x08, 0xc1}, + //Main ROM Chksum Range (len 16) + {0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xff, 0xff, 0x08, 0x00}, + //me72002_crc32 (len 48) + { 0x88, 0x60, 0x28, 0x04, 0xc2, 0xf4, 0x69, 0x85, 0x68, 0x41, 0xea, 0x20, 0xda, 0x2a, 0xd7, 0x40, + 0xe1, 0x00, 0xc2, 0xf4, 0x51, 0x08, 0x68, 0x41, 0xea, 0x30, 0xda, 0x2a, 0xc2, 0xf4, 0x68, 0x85, 0x68, + 0x42, 0xea, 0x30, 0xda, 0x2a, 0xf3, 0xf8, 0x0c, 0xc7, 0x49, 0x81, 0xea, 0x30, 0x20, 0x2a }, + }; + +unsigned int ts_siglen[NUM_DATA_SIGS] = {16, 256, 36, 88, 36, 64, 60, 60, 64, 38, 38, 16, 16, 16, 40, 40, 20, 20, 16, 48}; + +////////////////////////////////////////////////////////////////////// +//,Construction/Destruction +////////////////////////////////////////////////////////////////////// + +FunctionSigs::FunctionSigs() +{ +} + +FunctionSigs::~FunctionSigs() +{ + +} +////////////////////////////////////////////////////////////////////// +// Helpers +////////////////////////////////////////////////////////////////////// + +//Finds a given binary sequence in the given binary. If 0xff then this is don't care +ea_t FunctionSigs::FindBinaryWithDontCare(uchar* ubinstr,unsigned __int32 nSLength, ea_t eaStartAddress, ea_t eaEndAddr) +{ + ea_t eaAddr = BADADDR,eaSearchAddr=0,nIndexA=0,nIndexB=0; + uchar nRead=0; + int iBit = 0; + uint32 v=0; + +// ea1stAddr = find_binary(ea_t startea,ea_t endea,ubinstr,16,sflag); + if(nSLength == 0) + { + msg("WARNING, Length = 0 - nothing to do!\n"); + return BADADDR; + } + + show_wait_box("Searching for binary pattern"); + + //for loop. nIndexA is automatically incremented. + for (nIndexA = eaStartAddress; nIndexA < eaEndAddr;) + { + //replace_wait_box("Searching for binary pattern at address 0x%02X", nIndexA); + eaAddr = nIndexA;//Store where we are. + nRead = get_8bit(nIndexA, v, iBit);//Read 8bits but remember that nIndexA is automatically incremented + if (nIndexA==BADADDR)//Have we ran out of bytes? + { + eaAddr = BADADDR; + msg(" not found, ran beyond binary address space\n"); + goto exit; + } + if (nIndexA >= (eaEndAddr - 1)) + { + eaAddr = BADADDR; + msg(" not found, ran beyond binary address space\n"); + goto exit; + } + + //Check if user wants to exit, + if ((eaAddr % 0x100) == 0) + { + showAddr(eaAddr);// Show an address on the autoanalysis indicator. + if (wasBreak()) + goto exit; + //break; + } + + if (nRead == *ubinstr) + {// We're matched for the 1st byte, now check the rest + //msg("FindBinaryWithDontCare() matched 1st byte '0x%0x' at 0x%0x with length %lu\n", nRead, nIndexA, nSLength); + //eaSearchAddr = eaAddr; + for (nIndexB = 1; nIndexB < nSLength; nIndexB++) + { + eaSearchAddr = eaAddr + nIndexB; + if (*(ubinstr + nIndexB) != 0xff) //check for don't care flag + { + //Read an 8 bit value from the database. This increments eaSearchAddr automatically. + nRead = get_8bit(eaSearchAddr, v, iBit); + //msg(": found '0x%0x' at 0x%0x\n", nRead, eaSearchAddr); + if (eaSearchAddr==BADADDR)//Have we ran out of bytes? + { + eaAddr=BADADDR; + msg(" not found, ran beyond binary address space\n"); + goto exit; + } + if(nRead != *(ubinstr+nIndexB)) + { + //msg(" no longer matched.\n"); + eaAddr=BADADDR; + break;// No longer matched,exit this for(..) loop + } + else if(nIndexB==(nSLength-1)) + { + msg(" binary string matched at 0x%x.\n", eaAddr); + goto exit; + } + else if (wasBreak()) + goto exit; + } +// else +// msg(": ignoring 0xff\n"); + } + } + }//for + + exit: + hide_wait_box(); + // msg("\n"); + return eaAddr; +} + +// Creates a function at the address and auto comments it +ea_t FunctionSigs::CreateFunctionAndComment(ea_t eaAddr, unsigned char* pFuncName, unsigned char* pComment, unsigned int iTries) +{ + if(del_func(eaAddr))//delete any function that already exists because the rest of the code may fail. + { + msg(" Try %d, function %s deleted at 0x%x -",iTries, pFuncName, eaAddr); + } + else + { + msg(" Try %d, del_func failed at 0x%x for some reason -", iTries, eaAddr); + } + + if(add_func(eaAddr,BADADDR)) + { + char ucBuf[512]; + msg(" function %s created at 0x%x\n", pFuncName, eaAddr); + qsnprintf(ucBuf, 40, "%s_%x", pFuncName, eaAddr);//Create a unique name + set_name(eaAddr, ucBuf, SN_PUBLIC);//set the name of the function + } + else + { + msg(" found %s at 0x%x but add_func failed for some reason\n", pFuncName, eaAddr); + } + + //Comment the new function + func_t* functFunction = get_func(eaAddr); // get a pointer to the function chunk + if (functFunction!=NULL) + { + del_func_cmt(functFunction,1);//delete the existing comment + //update_func(functFunction); + set_func_cmt(functFunction, reinterpret_cast(pComment), TRUE);//Make a repeatable comment + update_func(functFunction);//Crashes plugin if NULL + //Try the next set of addresses + eaAddr=functFunction->endEA;// the end of the function just created. + } + else + { + eaAddr+=0x2;// No success but index on 16 bits to try again + } + return eaAddr; +} + +//Comments the address given +void FunctionSigs::Comment(ea_t eaAddr, unsigned char* pDataName, unsigned char* pComment, unsigned int iTries) +{ + if (eaAddr != BADADDR) + { + char ucBuf[512]; + qsnprintf(ucBuf, 40, "%s_%x", reinterpret_cast(pDataName), eaAddr);//Create a unique name + if( set_name(eaAddr, ucBuf, SN_NOCHECK | SN_PUBLIC) != 0) + { //set the name of the Table + msg(" data table %s commented at 0x%x\n", pDataName, eaAddr); + } + else + { + msg(" data table %s failed to be commented at 0x%x\n", pDataName, eaAddr); + } +// if( generate_big_comment((const char *)pComment, COLOR_AUTOCMT) == 0) + if( set_cmt(eaAddr, reinterpret_cast(pComment), TRUE) == 1 )// comment the label and make repeatable + { + msg(" set_cmt() suceeded\n"); + } + else + { + msg(" set_cmt() failed\n"); + } + } +} + +////////////////////////////////////////////////////////////////////// +// Implementation +////////////////////////////////////////////////////////////////////// + +//Looks for specific binary patterns and then makes a subroutine and comments it +void FunctionSigs::FindFuncSigsAndComment(ea_t eaStartAddr, ea_t eaEndAddr) +{ + msg("Finding function and data signatures....\n"); + + unsigned int uIndex=0; + ea_t eaAddr = 0, eaTryAddr = 0, iTries = 0; + + show_wait_box("Finding function signatures...."); + + //1st we search for function signatures + for(uIndex=0; uIndex < NUM_FUNC_SIGS; uIndex++) + //for(uIndex=0; uIndex < 0; uIndex++) // For testing + { + msg("\nSearching for function %s, len = %lu\n", fs_functionnames[uIndex], fs_siglen[uIndex]); + for (eaTryAddr = eaStartAddr, iTries = 0; eaTryAddr 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class FunctionSigs +{ +public: + FunctionSigs(); + virtual ~FunctionSigs(); + +private: +public: + ea_t FindBinaryWithDontCare(uchar* ubinstr, unsigned __int32 nSLength, ea_t eaStartAddress, ea_t eaEndAddr);//Finds the given binary string in the given binary. If 0xff then this is don't care + ea_t CreateFunctionAndComment(ea_t eaAddr, unsigned char* pFuncName, unsigned char* pComment, unsigned int iTries);// Creates a function at the address and auto comments it + void Comment(ea_t eaAddr, unsigned char* pDataName, unsigned char* pComment, unsigned int iTries);//Comments the address given +public: + void FindFuncSigsAndComment(ea_t eaStartAddr, ea_t eaEndAddr);//Looks for specific binary patterns and then makes a subroutine and comments it + +}; + +#endif // !defined(AFX_FUNCTIONSIGS_H__C6DB9FEB_257B_46A5_A944_3629C2B0D33C__INCLUDED_) diff --git a/IDAMemCopyPaste.cpp b/IDAMemCopyPaste.cpp new file mode 100644 index 0000000..4ad664e --- /dev/null +++ b/IDAMemCopyPaste.cpp @@ -0,0 +1,95 @@ +// IDAMemCopyPaste.cpp: implementation of the IDAMemCopyPaste class. +// +////////////////////////////////////////////////////////////////////// +//Standard Defs +typedef int BOOL; +#define FALSE 0 +#define TRUE 1 +#define NULL 0 + +#include +#include +#include +//#include +//#include +//#include +//#include +//#include +//#include + +#include "IDAMemCopyPaste.h"// + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////// +//,Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IDAMemCopyPaste::IDAMemCopyPaste() +{ +} + +IDAMemCopyPaste::~IDAMemCopyPaste() +{ + +} +////////////////////////////////////////////////////////////////////// +// Helpers +////////////////////////////////////////////////////////////////////// + +#define MAX_COPYPASTE 1024 + +// This will hold our copied buffer for pasting +char data[MAX_COPYPASTE]; + +void IDAMemCopyPaste::copy_buffer(ea_t eaStartAddr, ea_t eaEndAddr) +{ + ssize_t size; + + // Work out the size, make sure it doesn't exceed the buffer + // we have allocated. + size = eaEndAddr - eaStartAddr; + if (size > MAX_COPYPASTE) + { + warning("You can only copy a max of %d bytes\n", MAX_COPYPASTE); + return; + } + // Get the bytes from the file, store it in our buffer + if (get_many_bytes(eaStartAddr, data, size)) + { + msg("Successfully copied %d bytes from %a into memory.\n", size, eaStartAddr); + } + else + { + msg("FAILED to copy %d bytes from %a into memory.\n", size, eaStartAddr); + } +} + +void IDAMemCopyPaste::paste_buffer(ea_t eaStartAddr, ea_t eaEndAddr) +{ + ssize_t size; + + // Work out the size, make sure it doesn't exceed the buffer + // we have allocated. + size = eaEndAddr - eaStartAddr; + if (size > MAX_COPYPASTE) + { + warning("You can only copy a max of %d bytes\n", MAX_COPYPASTE); + return; + } + // Patch the binary (paste) + patch_many_bytes(eaStartAddr, data, size); + msg("Patched %d bytes at %a.\n", size, eaStartAddr); +} + +////////////////////////////////////////////////////////////////////// +// Implementation +////////////////////////////////////////////////////////////////////// + +//Looks for specific binary patterns and then makes a subroutine and comments it +void IDAMemCopyPaste::FindFuncSigsAndComment(void) +{ + +} \ No newline at end of file diff --git a/IDAMemCopyPaste.h b/IDAMemCopyPaste.h new file mode 100644 index 0000000..bb89e59 --- /dev/null +++ b/IDAMemCopyPaste.h @@ -0,0 +1,29 @@ +// IDAMemCopyPaste.h: interface for the IDAMemCopyPaste class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_IDAMemCopyPaste_H__C6DB9FEB_257B_46A5_A944_3629C2B0D33C__INCLUDED_) +#define AFX_IDAMemCopyPaste_H__C6DB9FEB_257B_46A5_A944_3629C2B0D33C__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class IDAMemCopyPaste +{ +public: + IDAMemCopyPaste(); + virtual ~IDAMemCopyPaste(); + +private: + void copy_buffer(ea_t eaStartAddr, ea_t eaEndAddr); + void paste_buffer(ea_t eaStartAddr, ea_t eaEndAddr); + +public: + +public: + void FindFuncSigsAndComment(void);//Looks for specific binary patterns and then makes a subroutine and comments it + +}; + +#endif // !defined(AFX_IDAMemCopyPaste_H__C6DB9FEB_257B_46A5_A944_3629C2B0D33C__INCLUDED_) diff --git a/Me71 1024K Search without prompts.idc b/Me71 1024K Search without prompts.idc new file mode 100644 index 0000000..8955214 --- /dev/null +++ b/Me71 1024K Search without prompts.idc @@ -0,0 +1,1287 @@ +// +// ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» +// º This file is generated by The Interactive Disassembler (IDA) º +// º Copyright (c) 2003 by DataRescue sa/nv, º +// º Licensed to: Andy Whittaker, Special, 1 user, adv, 01/2002 º +// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ +// +// +// This file contains the user-defined type definitions. +// To use it press F2 in IDA and enter the name of this file. +// + +#define UNLOADED_FILE 1 +#include + +static main(void) { + Bytes(); // Defines in the binary + Segments(); // Create all the segments + Enums(); // enumerations + Structures(); // structure types + AutoAnalyse();// Tries to automatically disassemble the binary + + DTC_Enum();// search for and emumerate DTC references + + // Stuff for Bosch ME7.1 ECUs + TranslateOffsets();// find lookup tables + TranslateJmpi();//Find jmpi and tries to find the jump table + FindSeedTable(); + LoadMapPackCSV();//Import Map Pack tables +} + +//Runs through each segment and tries to disassemble everything +static AutoAnalyse(void) +{ + auto addr; + auto index; +#define ROM_START 0x800000 +#define MAP_AREA_START 0x810000 +#define MAP_AREA_FINISH 0x822000 + +// if (AskYN(1,"Do you want to Auto-Disassemble?") != 1) +// return; + + Message("++++++++++++++++++++++++++ \n"); + Message("Trying to Auto-Disassemble \n"); + Message("++++++++++++++++++++++++++ \n"); + + + addr = ROM_START; //start address + MakeFunction(addr, BADADDR); + while(addr != BADADDR) + { + addr = FindUnexplored(addr, SEARCH_DOWN | SEARCH_NEXT); + // The previous MakeFunction may not have disassembled the instructions + // following a relative jmp instruction. + // If Makefunction fails, try and create code + if (MakeFunction(addr, BADADDR)) + Message("Function found at 0x%0lx \n", addr); + else + if(MakeCode(addr) != 0) + Message("Code created at 0x%0lx \n", addr); + if( (addr > MAP_AREA_START) & (addr < MAP_AREA_FINISH) ) + { + Message("Ignoring data - within MAP area\n"); + addr = MAP_AREA_FINISH; + } + if(addr == BADADDR) + Message("End of Auto-Disassemble analysis loop\n"); + } +} + +//Finds where the XOR seed routine and table are located +static FindSeedTable(void) +{ + auto found; + auto namestr; + auto table_address; + auto offset; + auto seg; + + namestr = ""; + +// if (AskYN(1,"Do you want to search for the seed table?") != 1) +// return; + + Message("++++++++++++++++++++++++ \n"); + Message("Searching for Seed-Table \n"); + Message("++++++++++++++++++++++++ \n"); + + found = FindBinary(0x810000, SEARCH_DOWN | SEARCH_NEXT, "8c f0 9d 0d 1e dc 09 a9 88 f0 56 51 a8 b9 a0"); + if (found == BADADDR) + Message("** Seed Table Not Found **\n"); + else + { + found = found - 21; //Start of function + Message("XOR Seed routine is located at 0x%0lx", found); + namestr = "XORChkSumGenerate_"; + namestr = namestr + ltoa(found, 16); + MakeName(found, namestr); + + // Let's find out where the seed table is + found = found + 0x24;// this is where the seed table is referenced + ExtLinA(found, 0, ";"); + ExtLinA(found, 1, "; This is where the seed table is referenced"); + ExtLinA(found, 2, ";"); + //convert the C16x offset into an address + table_address = GetOperandValue(found, 1); //find what the table's address is + seg = GetOperandValue(found + 4, 1); + offset = seg << 16; + table_address = table_address + offset; + Message(" - XOR Seed table is located at 0x%0lx\n", table_address); + namestr = "XORSeedTable_"; + namestr = namestr + ltoa(table_address, 16); + MakeName(table_address, namestr); + ExtLinA(table_address, 0, ";"); + ExtLinA(table_address, 1, "; XOR seed table - 256 words long, 32 bit data"); + ExtLinA(table_address, 2, ";"); + } +} + +static Segments(void) { +// auto filesize; + +// if (AskYN(1,"Do you want to create Segments?") != 1) +// return; + + Message("++++++++++++++++++\n"); + Message("Creating Segments \n"); + Message("++++++++++++++++++\n"); + + // Create the RAM segments + SetSelector(0x1,0x38000); + SegCreate(0x380000,0x390000,0x1,0,saRelWord,scPub); + SegRename(0x380000,"segRAM"); + SegClass (0x380000,"RAM"); + SetSegmentType(0x380000,SEG_DATA); + + // Create the segments + SetSelector(0x2,0x80000); + SegCreate(0x800000,0x808000,0x2,0,saRelWord,scPub); + SegRename(0x800000,"seg080"); + SegClass (0x800000,"CODE"); + SetSegmentType(0x800000,SEG_CODE); + // The ME7.1 sets up the data page pointers to the following values. + SegDefReg(0x800000,"dpp0",0x0204); + SegDefReg(0x800000,"dpp1",0x0205); + SegDefReg(0x800000,"dpp2",0x00E0); + SegDefReg(0x800000,"dpp3",0x0003); + + SetSelector(0x3,0x80800); + SegCreate(0x808000,0x80c000,0x3,0,saRelWord,scPub); + SegRename(0x808000,"seg202"); + SegClass (0x808000,"CODE"); + SetSegmentType(0x808000,SEG_CODE); + SegDefReg(0x808000,"dpp0",0x0204); + SegDefReg(0x808000,"dpp1",0x0205); + SegDefReg(0x808000,"dpp2",0x00E0); + SegDefReg(0x808000,"dpp3",0x0003); + + SetSelector(0x4,0x80c00); + SegCreate(0x80c000,0x810000,0x4,0,saRelWord,scPub); + SegRename(0x80c000,"seg203"); + SegClass (0x80c000,"CODE"); + SetSegmentType(0x80c000,SEG_CODE); + SegDefReg(0x80c000,"dpp0",0x0204); + SegDefReg(0x80c000,"dpp1",0x0205); + SegDefReg(0x80c000,"dpp2",0x00E0); + SegDefReg(0x80c000,"dpp3",0x0003); + + SetSelector(0x5,0x81000); + SegCreate(0x810000,0x814000,0x5,0,saRelWord,scPub); + SegRename(0x810000,"seg204"); + SegClass (0x810000,"MAP"); + SetSegmentType(0x810000,SEG_DATA); + SegDefReg(0x810000,"dpp0",0x0204); + SegDefReg(0x810000,"dpp1",0x0205); + SegDefReg(0x810000,"dpp2",0x00E0); + SegDefReg(0x810000,"dpp3",0x0003); + + SetSelector(0x6,0x81400); + SegCreate(0x814000,0x818000,0x6,0,saRelWord,scPub); + SegRename(0x814000,"seg205"); + SegClass (0x814000,"MAP"); + SetSegmentType(0x814000,SEG_DATA); + SegDefReg(0x814000,"dpp0",0x0204); + SegDefReg(0x814000,"dpp1",0x0205); + SegDefReg(0x814000,"dpp2",0x00E0); + SegDefReg(0x814000,"dpp3",0x0003); + + SetSelector(0x7,0x81800); + SegCreate(0x818000,0x81c000,0x7,0,saRelWord,scPub); + SegRename(0x818000,"seg206"); + SegClass (0x818000,"MAP"); + SetSegmentType(0x818000,SEG_DATA); + SegDefReg(0x818000,"dpp0",0x0204); + SegDefReg(0x818000,"dpp1",0x0205); + SegDefReg(0x818000,"dpp2",0x00E0); + SegDefReg(0x818000,"dpp3",0x0003); + + SetSelector(0x8,0x81c00); + SegCreate(0x81c000,0x820000,0x8,0,saRelWord,scPub); + SegRename(0x81c000,"seg207"); + SegClass (0x81c000,"MAP"); + SetSegmentType(0x81c000,SEG_DATA); + SegDefReg(0x81c000,"dpp0",0x0204); + SegDefReg(0x81c000,"dpp1",0x0205); + SegDefReg(0x81c000,"dpp2",0x00E0); + SegDefReg(0x81c000,"dpp3",0x0003); + + SetSelector(0x9,0x82000); + SegCreate(0x820000,0x830000,0x9,0,saRelWord,scPub); + SegRename(0x820000,"seg082"); + SegClass (0x820000,"CODE"); + SetSegmentType(0x820000,SEG_CODE); + SegDefReg(0x820000,"dpp0",0x0204); + SegDefReg(0x820000,"dpp1",0x0205); + SegDefReg(0x820000,"dpp2",0x00E0); + SegDefReg(0x820000,"dpp3",0x0003); + + SetSelector(0xa,0x83000); + SegCreate(0x830000,0x840000,0xa,0,saRelWord,scPub); + SegRename(0x830000,"seg083"); + SegClass (0x830000,"CODE"); + SetSegmentType(0x830000,SEG_CODE); + SegDefReg(0x830000,"dpp0",0x0204); + SegDefReg(0x830000,"dpp1",0x0205); + SegDefReg(0x830000,"dpp2",0x00E0); + SegDefReg(0x830000,"dpp3",0x0003); + + SetSelector(0xb,0x84000); + SegCreate(0x840000,0x850000,0xb,0,saRelWord,scPub); + SegRename(0x840000,"seg084"); + SegClass (0x840000,"CODE"); + SetSegmentType(0x840000,SEG_CODE); + SegDefReg(0x840000,"dpp0",0x0204); + SegDefReg(0x840000,"dpp1",0x0205); + SegDefReg(0x840000,"dpp2",0x00E0); + SegDefReg(0x840000,"dpp3",0x0003); + + SetSelector(0xc,0x85000); + SegCreate(0x850000,0x860000,0xc,0,saRelWord,scPub); + SegRename(0x850000,"seg085"); + SegClass (0x850000,"CODE"); + SetSegmentType(0x850000,SEG_CODE); + SegDefReg(0x850000,"dpp0",0x0204); + SegDefReg(0x850000,"dpp1",0x0205); + SegDefReg(0x850000,"dpp2",0x00E0); + SegDefReg(0x850000,"dpp3",0x0003); + + SetSelector(0xd,0x86000); + SegCreate(0x860000,0x870000,0xd,0,saRelWord,scPub); + SegRename(0x860000,"seg086"); + SegClass (0x860000,"CODE"); + SetSegmentType(0x860000,SEG_CODE); + SegDefReg(0x860000,"dpp0",0x0204); + SegDefReg(0x860000,"dpp1",0x0205); + SegDefReg(0x860000,"dpp2",0x00E0); + SegDefReg(0x860000,"dpp3",0x0003); + + SetSelector(0xe,0x87000); + SegCreate(0x870000,0x880000,0xe,0,saRelWord,scPub); + SegRename(0x870000,"seg087"); + SegClass (0x870000,"CODE"); + SetSegmentType(0x870000,SEG_CODE); + SegDefReg(0x870000,"dpp0",0x0204); + SegDefReg(0x870000,"dpp1",0x0205); + SegDefReg(0x870000,"dpp2",0x00E0); + SegDefReg(0x870000,"dpp3",0x0003); + + SetSelector(0xf,0x88000); + SegCreate(0x880000,0x890000,0xf,0,saRelWord,scPub); + SegRename(0x880000,"seg088"); + SegClass (0x880000,"CODE"); + SetSegmentType(0x880000,SEG_CODE); + SegDefReg(0x880000,"dpp0",0x0204); + SegDefReg(0x880000,"dpp1",0x0205); + SegDefReg(0x880000,"dpp2",0x00E0); + SegDefReg(0x880000,"dpp3",0x0003); + + SetSelector(0x10,0x89000); + SegCreate(0x890000,0x8a0000,0x10,0,saRelWord,scPub); + SegRename(0x890000,"seg089"); + SegClass (0x890000,"CODE"); + SetSegmentType(0x890000,SEG_CODE); + SegDefReg(0x890000,"dpp0",0x0204); + SegDefReg(0x890000,"dpp1",0x0205); + SegDefReg(0x890000,"dpp2",0x00E0); + SegDefReg(0x890000,"dpp3",0x0003); + + SetSelector(0x11,0x8a000); + SegCreate(0x8a0000,0x8b0000,0x11,0,saRelWord,scPub); + SegRename(0x8a0000,"seg08a"); + SegClass (0x8a0000,"CODE"); + SetSegmentType(0x8a0000,SEG_CODE); + SegDefReg(0x8a0000,"dpp0",0x0204); + SegDefReg(0x8a0000,"dpp1",0x0205); + SegDefReg(0x8a0000,"dpp2",0x00E0); + SegDefReg(0x8a0000,"dpp3",0x0003); + + SetSelector(0x12,0x8b000); + SegCreate(0x8b0000,0x8c0000,0x12,0,saRelWord,scPub); + SegRename(0x8b0000,"seg08b"); + SegClass (0x8b0000,"CODE"); + SetSegmentType(0x8b0000,SEG_CODE); + SegDefReg(0x8b0000,"dpp0",0x0204); + SegDefReg(0x8b0000,"dpp1",0x0205); + SegDefReg(0x8b0000,"dpp2",0x00E0); + SegDefReg(0x8b0000,"dpp3",0x0003); + + SetSelector(0x13,0x8c000); + SegCreate(0x8c0000,0x8d0000,0x13,0,saRelWord,scPub); + SegRename(0x8c0000,"seg08c"); + SegClass (0x8c0000,"CODE"); + SetSegmentType(0x8c0000,SEG_CODE); + SegDefReg(0x8c0000,"dpp0",0x0204); + SegDefReg(0x8c0000,"dpp1",0x0205); + SegDefReg(0x8c0000,"dpp2",0x00E0); + SegDefReg(0x8c0000,"dpp3",0x0003); + +} + +static Enums_0(id) { + +// if (AskYN(1,"Do you want to define standard Bosch Enumerations?") != 1) +// return; + + Message("++++++++++++++++++++++\n"); + Message("Creating Emumerations \n"); + Message("++++++++++++++++++++++\n"); + + id = AddEnum(-1,"ECMERROR",0x1100000); + AddConstEx(id,"ECMERROR_00", 0x0, 0xffffffff); + AddConstEx(id,"ECMERROR_RAM01", 0x1, 0xffffffff); + AddConstEx(id,"ECMERROR_RAM02", 0x2, 0xffffffff); + AddConstEx(id,"ECMERROR_ILLBUS", 0x3, 0xffffffff); + AddConstEx(id,"ECMERROR_ILLINA", 0x4, 0xffffffff); + AddConstEx(id,"ECMERROR_ILLOPA", 0x5, 0xffffffff); + AddConstEx(id,"ECMERROR_PRTFLT", 0x6, 0xffffffff); + AddConstEx(id,"ECMERROR_UNDOPC", 0x7, 0xffffffff); + AddConstEx(id,"ECMERROR_08", 0x8, 0xffffffff); + AddConstEx(id,"ECMERROR_09", 0x9, 0xffffffff); + AddConstEx(id,"ECMERROR_10", 0xa, 0xffffffff); + AddConstEx(id,"ECMERROR_11", 0xb, 0xffffffff); + AddConstEx(id,"ECMERROR_12", 0xc, 0xffffffff); + AddConstEx(id,"ECMERROR_13", 0xd, 0xffffffff); + AddConstEx(id,"ECMERROR_14", 0xe, 0xffffffff); + AddConstEx(id,"ECMERROR_15", 0xf, 0xffffffff); + AddConstEx(id,"ECMERROR_16", 0x10, 0xffffffff); + AddConstEx(id,"ECMERROR_17", 0x11, 0xffffffff); + AddConstEx(id,"ECMERROR_18", 0x12, 0xffffffff); + AddConstEx(id,"ECMERROR_19", 0x13, 0xffffffff); + AddConstEx(id,"ECMERROR_20", 0x14, 0xffffffff); + AddConstEx(id,"ECMERROR_21", 0x15, 0xffffffff); + AddConstEx(id,"ECMERROR_22", 0x16, 0xffffffff); + AddConstEx(id,"ECMERROR_23", 0x17, 0xffffffff); + AddConstEx(id,"ECMERROR_24", 0x18, 0xffffffff); + AddConstEx(id,"ECMERROR_25", 0x19, 0xffffffff); + AddConstEx(id,"ECMERROR_26", 0x1a, 0xffffffff); + SetConstCmt(GetConst(id,0x1a,0xffffffff),"Data Corruption",1); + AddConstEx(id,"ECMERROR_27", 0x1b, 0xffffffff); + AddConstEx(id,"ECMERROR_28", 0x1c, 0xffffffff); + AddConstEx(id,"ECMERROR_29", 0x1d, 0xffffffff); + AddConstEx(id,"ECMERROR_30", 0x1e, 0xffffffff); + AddConstEx(id,"ECMERROR_31", 0x1f, 0xffffffff); + AddConstEx(id,"ECMERROR_32", 0x20, 0xffffffff); + AddConstEx(id,"ECMERROR_33", 0x21, 0xffffffff); + AddConstEx(id,"ECMERROR_106", 0x6a, 0xffffffff); + AddConstEx(id,"ECMERROR_147", 0x93, 0xffffffff); + AddConstEx(id,"ECMERROR_149", 0x95, 0xffffffff); + id = AddEnum(-1,"Bits",0x1100000); + SetEnumBf(id,1); + AddConstEx(id,"Bit0", 0x1, 0x1); + AddConstEx(id,"Bit1", 0x2, 0x2); + AddConstEx(id,"Bit2", 0x4, 0x4); + AddConstEx(id,"Bit3", 0x8, 0x8); + AddConstEx(id,"Bit4", 0x10, 0x10); + AddConstEx(id,"Bit5", 0x20, 0x20); + AddConstEx(id,"Bit6", 0x40, 0x40); + AddConstEx(id,"Bit7", 0x80, 0x80); + AddConstEx(id,"Bit8", 0x100, 0x100); + AddConstEx(id,"Bit9", 0x200, 0x200); + AddConstEx(id,"Bit10", 0x400, 0x400); + AddConstEx(id,"Bit11", 0x800, 0x800); + AddConstEx(id,"Bit12", 0x1000, 0x1000); + AddConstEx(id,"Bit13", 0x2000, 0x2000); + AddConstEx(id,"Bit14", 0x4000, 0x4000); + AddConstEx(id,"Bit15", 0x8000, 0x8000); + id = AddEnum(-1,"AirFuelStatus",0x1100000); + SetEnumBf(id,1); + AddConstEx(id,"BaroFaulty", 0x5, 0x5); + id = AddEnum(-1,"Const",0x1100000); + AddConstEx(id,"NUMCYL", 0x6, 0xffffffff); + id = AddEnum(-1,"DTCLBit",0x1100000); + SetEnumBf(id,1); + AddConstEx(id,"DTCBit_L0", 0x1, 0x1); + AddConstEx(id,"DTCBit_L1", 0x2, 0x2); + AddConstEx(id,"DTCBit_L2", 0x4, 0x4); + AddConstEx(id,"DTCBit_L3", 0x8, 0x8); + AddConstEx(id,"DTCBit_L4", 0x10, 0x10); + AddConstEx(id,"DTCBit_L5", 0x20, 0x20); + AddConstEx(id,"DTCBit_L6", 0x40, 0x40); + AddConstEx(id,"DTCBit_L7", 0x80, 0x80); + id = AddEnum(-1,"DTCHBit",0x1100000); + SetEnumBf(id,1); + AddConstEx(id,"DTCFieldA_H0", 0x1, 0x1); + SetConstCmt(GetConst(id,0x1,0x1),"Select member 0",1); + AddConstEx(id,"DTCFieldB_H1", 0x2, 0x2); + SetConstCmt(GetConst(id,0x2,0x2),"Select member 1",1); + AddConstEx(id,"DTCFieldC_H2", 0x4, 0x4); + SetConstCmt(GetConst(id,0x4,0x4),"Select member 2",1); + AddConstEx(id,"DTCFieldD_H3", 0x8, 0x8); + SetConstCmt(GetConst(id,0x8,0x8),"Select member 3",1); + AddConstEx(id,"DTCBit_H4", 0x10, 0x10); + AddConstEx(id,"DTCBit_H5", 0x20, 0x20); + AddConstEx(id,"DTCBit_H6", 0x40, 0x40); + AddConstEx(id,"DTCBit_H7", 0x80, 0x80); + id = AddEnum(-1,"DTC",0x1100000); + AddConstEx(id,"DTC_P1402", 0x1, 0xffffffff); + SetConstCmt(GetConst(id,0x1,0xffffffff),"EGR Valve Circ Short to B+",1); + AddConstEx(id,"DTC_P0402", 0x2, 0xffffffff); + SetConstCmt(GetConst(id,0x2,0xffffffff),"EGR - Excessive Flow",1); + AddConstEx(id,"DTC_P1456", 0x3, 0xffffffff); + SetConstCmt(GetConst(id,0x3,0xffffffff),"Exhaust gas temperature control bank 1 limit attained",1); + AddConstEx(id,"DTC_P1460", 0x4, 0xffffffff); + SetConstCmt(GetConst(id,0x4,0xffffffff),"Exhaust gas temperature control bank 2 limit attained",1); + AddConstEx(id,"DTC_P1461", 0x5, 0xffffffff); + SetConstCmt(GetConst(id,0x5,0xffffffff),"Exhaust gas temperature control bank 1 Range/Performance",1); + AddConstEx(id,"DTC_P1462", 0x6, 0xffffffff); + SetConstCmt(GetConst(id,0x6,0xffffffff),"Exhaust gas temperature control bank 2 Range/Performance",1); + AddConstEx(id,"DTC_P1453", 0x7, 0xffffffff); + SetConstCmt(GetConst(id,0x7,0xffffffff),"Exhaust gas temperature sensor 1 open/short to B+",1); + AddConstEx(id,"DTC_P1457", 0x8, 0xffffffff); + SetConstCmt(GetConst(id,0x8,0xffffffff),"Exhaust gas temperature sensor 2 open/short to B+",1); + AddConstEx(id,"DTC_P0321", 0x9, 0xffffffff); + SetConstCmt(GetConst(id,0x9,0xffffffff),"Ign./Distributor Eng.Speed Inp.Circ Range/Performance",1); + AddConstEx(id,"DTC_P0571", 0xa, 0xffffffff); + SetConstCmt(GetConst(id,0xa,0xffffffff),"Cruise/Brake Switch (A) Circ Malfunction",1); + AddConstEx(id,"DTC_P1639", 0xb, 0xffffffff); + SetConstCmt(GetConst(id,0xb,0xffffffff),"Accelera.Pedal Pos.Sensor 1+2 Range/Performance",1); + AddConstEx(id,"DTC_P1629", 0xc, 0xffffffff); + SetConstCmt(GetConst(id,0xc,0xffffffff),"Data-Bus Powertrain missing message from distance control",1); + AddConstEx(id,"DTC_P1645", 0xd, 0xffffffff); + SetConstCmt(GetConst(id,0xd,0xffffffff),"Data Bus Powertrain missing message f.all wheel drive contr.",1); + AddConstEx(id,"DTC_P1853", 0xe, 0xffffffff); + SetConstCmt(GetConst(id,0xe,0xffffffff),"Data-Bus Powertrain Unplausible Message from Brake Contr.",1); + AddConstEx(id,"DTC_P1649", 0xf, 0xffffffff); + SetConstCmt(GetConst(id,0xf,0xffffffff),"Data Bus Powertrain Missing message from ABS Control Module",1); + AddConstEx(id,"DTC_P1626", 0x10, 0xffffffff); + SetConstCmt(GetConst(id,0x10,0xffffffff),"Data-Bus Powertrain Missing Message from Transm.Contr.",1); + AddConstEx(id,"DTC_P1648", 0x11, 0xffffffff); + SetConstCmt(GetConst(id,0x11,0xffffffff),"Data Bus Powertrain Malfunction",1); + AddConstEx(id,"DTC_P1650", 0x12, 0xffffffff); + SetConstCmt(GetConst(id,0x12,0xffffffff),"Data Bus Powertrain Missing message fr.instrument panel ECU",1); + AddConstEx(id,"DTC_P1628", 0x13, 0xffffffff); + SetConstCmt(GetConst(id,0x13,0xffffffff),"Data-Bus Powertrain missing message from steering sensor",1); + AddConstEx(id,"DTC_P1544_1", 0x14, 0xffffffff); + SetConstCmt(GetConst(id,0x14,0xffffffff),"Throttle Actuation Potentiometer Signal too High",1); + AddConstEx(id,"DTC_P1544", 0x15, 0xffffffff); + SetConstCmt(GetConst(id,0x15,0xffffffff),"Throttle Actuation Potentiometer Signal too High",1); + AddConstEx(id,"DTC_P1173", 0x16, 0xffffffff); + SetConstCmt(GetConst(id,0x16,0xffffffff),"Throttle Actuation Potentiometer Sign.2 Signal too High",1); + AddConstEx(id,"DTC_P1602", 0x17, 0xffffffff); + SetConstCmt(GetConst(id,0x17,0xffffffff),"Power Supply (B+) Terminal 30 Low Voltage",1); + AddConstEx(id,"DTC_P0238", 0x18, 0xffffffff); + SetConstCmt(GetConst(id,0x18,0xffffffff),"Turbocharger Boost Sensor (A) Circ High Input",1); + AddConstEx(id,"DTC_P0108", 0x19, 0xffffffff); + SetConstCmt(GetConst(id,0x19,0xffffffff),"MAP - Hi",1); + AddConstEx(id,"DTC_P1387", 0x1a, 0xffffffff); + SetConstCmt(GetConst(id,0x1a,0xffffffff),"Internal Contr. Module altitude sensor error",1); + AddConstEx(id,"DTC_P0106", 0x1b, 0xffffffff); + SetConstCmt(GetConst(id,0x1b,0xffffffff),"Manifold Abs.Pressure or Bar.Pressure Range/Performance",1); + AddConstEx(id,"DTC_P1604_1", 0x1c, 0xffffffff); + SetConstCmt(GetConst(id,0x1c,0xffffffff),"Internal Control Module Driver Error",1); + AddConstEx(id,"DTC_P1568_0", 0x1d, 0xffffffff); + SetConstCmt(GetConst(id,0x1d,0xffffffff),"Idle Speed Contr.Throttle Pos. mechanical Malfunction",1); + AddConstEx(id,"DTC_P1568_1", 0x1e, 0xffffffff); + SetConstCmt(GetConst(id,0x1e,0xffffffff),"Idle Speed Contr.Throttle Pos. mechanical Malfunction",1); + AddConstEx(id,"DTC_P1545", 0x1f, 0xffffffff); + SetConstCmt(GetConst(id,0x1f,0xffffffff),"Throttle Pos.Contr Malfunction",1); + AddConstEx(id,"DTC_P1559_1", 0x20, 0xffffffff); + SetConstCmt(GetConst(id,0x20,0xffffffff),"Idle Speed Contr.Throttle Pos. Adaptation Malfunction",1); + AddConstEx(id,"DTC_P1545_1", 0x21, 0xffffffff); + SetConstCmt(GetConst(id,0x21,0xffffffff),"Throttle Pos.Contr Malfunction",1); + AddConstEx(id,"DTC_P1579_1", 0x22, 0xffffffff); + SetConstCmt(GetConst(id,0x22,0xffffffff),"Idle Speed Contr.Throttle Pos. Adaptation not started",1); + AddConstEx(id,"DTC_P1565", 0x23, 0xffffffff); + SetConstCmt(GetConst(id,0x23,0xffffffff),"Idle Speed Control Throttle Position lower limit not attained",1); + AddConstEx(id,"DTC_P1579", 0x24, 0xffffffff); + SetConstCmt(GetConst(id,0x24,0xffffffff),"Idle Speed Contr.Throttle Pos. Adaptation not started",1); + AddConstEx(id,"DTC_P1559", 0x25, 0xffffffff); + SetConstCmt(GetConst(id,0x25,0xffffffff),"Idle Speed Contr.Throttle Pos. Adaptation Malfunction",1); + AddConstEx(id,"DTC_P1604", 0x26, 0xffffffff); + SetConstCmt(GetConst(id,0x26,0xffffffff),"Internal Control Module Driver Error",1); + AddConstEx(id,"DTC_P1141", 0x27, 0xffffffff); + SetConstCmt(GetConst(id,0x27,0xffffffff),"Load Calculation Cross Check Range/Performance",1); + AddConstEx(id,"DTC_P1677", 0x28, 0xffffffff); + SetConstCmt(GetConst(id,0x28,0xffffffff),"Drive by Wire-MIL Circ. Short to B+",1); + AddConstEx(id,"DTC_P1258", 0x29, 0xffffffff); + SetConstCmt(GetConst(id,0x29,0xffffffff),"Engine Coolant System Valve Short to B+",1); + AddConstEx(id,"DTC_P1213", 0x2a, 0xffffffff); + SetConstCmt(GetConst(id,0x2a,0xffffffff),"Cyl.1-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1216", 0x2b, 0xffffffff); + SetConstCmt(GetConst(id,0x2b,0xffffffff),"Cyl.4-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1215", 0x2c, 0xffffffff); + SetConstCmt(GetConst(id,0x2c,0xffffffff),"Cyl.3-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1218", 0x2d, 0xffffffff); + SetConstCmt(GetConst(id,0x2d,0xffffffff),"Cyl.6-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1214", 0x2e, 0xffffffff); + SetConstCmt(GetConst(id,0x2e,0xffffffff),"Cyl.2-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1217", 0x2f, 0xffffffff); + SetConstCmt(GetConst(id,0x2f,0xffffffff),"Cyl.5-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1219", 0x30, 0xffffffff); + SetConstCmt(GetConst(id,0x30,0xffffffff),"Cyl.7-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1220", 0x31, 0xffffffff); + SetConstCmt(GetConst(id,0x31,0xffffffff),"Cyl.8-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1631", 0x32, 0xffffffff); + SetConstCmt(GetConst(id,0x32,0xffffffff),"Accelera.Pedal Pos.Sensor 1 Signal too High",1); + AddConstEx(id,"DTC_P1634", 0x33, 0xffffffff); + SetConstCmt(GetConst(id,0x33,0xffffffff),"Accelera.Pedal Pos.Sensor 2 Signal too High",1); + AddConstEx(id,"DTC_P1631_1", 0x34, 0xffffffff); + SetConstCmt(GetConst(id,0x34,0xffffffff),"Accelera.Pedal Pos.Sensor 1 Signal too High",1); + AddConstEx(id,"DTC_P1128_0", 0x35, 0xffffffff); + SetConstCmt(GetConst(id,0x35,0xffffffff),"Long Term Fuel Trim mult.,Bank1 System too Lean",1); + AddConstEx(id,"DTC_P1130_0", 0x36, 0xffffffff); + SetConstCmt(GetConst(id,0x36,0xffffffff),"Long Term Fuel Trim mult.,Bank2 System too Lean",1); + AddConstEx(id,"DTC_P1128_1", 0x37, 0xffffffff); + SetConstCmt(GetConst(id,0x37,0xffffffff),"Long Term Fuel Trim mult.,Bank1 System too Lean",1); + AddConstEx(id,"DTC_P1130_1", 0x38, 0xffffffff); + SetConstCmt(GetConst(id,0x38,0xffffffff),"Long Term Fuel Trim mult.,Bank2 System too Lean",1); + AddConstEx(id,"DTC_P1111", 0x39, 0xffffffff); + SetConstCmt(GetConst(id,0x39,0xffffffff),"O2 Control (Bank 1) System too lean",1); + AddConstEx(id,"DTC_P1147", 0x3a, 0xffffffff); + SetConstCmt(GetConst(id,0x3a,0xffffffff),"O2 Control (Bank 2) System too lean",1); + AddConstEx(id,"DTC_P1612", 0x3b, 0xffffffff); + SetConstCmt(GetConst(id,0x3b,0xffffffff),"Electronic Control Module Incorrect Coding",1); + AddConstEx(id,"DTC_P1569", 0x3c, 0xffffffff); + SetConstCmt(GetConst(id,0x3c,0xffffffff),"Cruise control switch Incorrect signal",1); + AddConstEx(id,"DTC_P1114", 0x3d, 0xffffffff); + SetConstCmt(GetConst(id,0x3d,0xffffffff),"Bank1-Sensor2 Internal Resistance too High",1); + AddConstEx(id,"DTC_P1140", 0x3e, 0xffffffff); + SetConstCmt(GetConst(id,0x3e,0xffffffff),"Bank2-Sensor2 Internal Resistance too High",1); + AddConstEx(id,"DTC_P1105", 0x3f, 0xffffffff); + SetConstCmt(GetConst(id,0x3f,0xffffffff),"O2 Sensor Heating Circ.,Bank1-Sensor2 Short to B+",1); + AddConstEx(id,"DTC_P1110", 0x40, 0xffffffff); + SetConstCmt(GetConst(id,0x40,0xffffffff),"O2 Sensor Heating Circ.,Bank2-Sensor2 Short to B+",1); + AddConstEx(id,"DTC_P1102", 0x41, 0xffffffff); + SetConstCmt(GetConst(id,0x41,0xffffffff),"O2 Sensor Heating Circ.,Bank1-Sensor1 Short to B+",1); + AddConstEx(id,"DTC_P1107", 0x42, 0xffffffff); + SetConstCmt(GetConst(id,0x42,0xffffffff),"O2 Sensor Heating Circ.,Bank2-Sensor1 Short to B+",1); + AddConstEx(id,"DTC_P0422", 0x43, 0xffffffff); + SetConstCmt(GetConst(id,0x43,0xffffffff),"Main Catalyst,Bank1 Efficiency Below Threshold",1); + AddConstEx(id,"DTC_P0432", 0x44, 0xffffffff); + SetConstCmt(GetConst(id,0x44,0xffffffff),"Main Catalyst,Bank2 Efficiency Below Threshold",1); + AddConstEx(id,"DTC_P1502", 0x45, 0xffffffff); + SetConstCmt(GetConst(id,0x45,0xffffffff),"Fuel Pump Relay Circ. Short to B+",1); + AddConstEx(id,"DTC_P1325", 0x46, 0xffffffff); + SetConstCmt(GetConst(id,0x46,0xffffffff),"Cyl.1-Knock Contr. -Limit Attained",1); + AddConstEx(id,"DTC_P1328", 0x47, 0xffffffff); + SetConstCmt(GetConst(id,0x47,0xffffffff),"Cyl.4-Knock Contr. -Limit Attained",1); + AddConstEx(id,"DTC_P1327", 0x48, 0xffffffff); + SetConstCmt(GetConst(id,0x48,0xffffffff),"Cyl.3-Knock Contr. Limit Attained",1); + AddConstEx(id,"DTC_P1330", 0x49, 0xffffffff); + SetConstCmt(GetConst(id,0x49,0xffffffff),"Cyl.6-Knock Contr. Limit Attained",1); + AddConstEx(id,"DTC_P1326", 0x4a, 0xffffffff); + SetConstCmt(GetConst(id,0x4a,0xffffffff),"Cyl.2-Knock Contr. Limit Attained",1); + AddConstEx(id,"DTC_P1329", 0x4b, 0xffffffff); + SetConstCmt(GetConst(id,0x4b,0xffffffff),"Cyl.5-Knock Contr. Limit Attained",1); + AddConstEx(id,"DTC_P1331", 0x4c, 0xffffffff); + SetConstCmt(GetConst(id,0x4c,0xffffffff),"Cyl.7-Knock Contr. Limit Attained",1); + AddConstEx(id,"DTC_P1332", 0x4d, 0xffffffff); + SetConstCmt(GetConst(id,0x4d,0xffffffff),"Cyl.8-Knock Contr. Limit Attained",1); + AddConstEx(id,"DTC_P1386_1", 0x4e, 0xffffffff); + SetConstCmt(GetConst(id,0x4e,0xffffffff),"Internal Control Module Knock Control Circ.Error",1); + AddConstEx(id,"DTC_P1386_0", 0x4f, 0xffffffff); + SetConstCmt(GetConst(id,0x4f,0xffffffff),"Internal Control Module Knock Control Circ.Error",1); + AddConstEx(id,"DTC_P1386", 0x50, 0xffffffff); + SetConstCmt(GetConst(id,0x50,0xffffffff),"Internal Control Module Knock Control Circ.Error",1); + AddConstEx(id,"DTC_P0328", 0x51, 0xffffffff); + SetConstCmt(GetConst(id,0x51,0xffffffff),"Knock Sensor 1 Circ High Input",1); + AddConstEx(id,"DTC_P0333", 0x52, 0xffffffff); + SetConstCmt(GetConst(id,0x52,0xffffffff),"Knock Sensor 2 Circ High Input",1); + AddConstEx(id,"DTC_P1322", 0x53, 0xffffffff); + SetConstCmt(GetConst(id,0x53,0xffffffff),"Knock Sensor 3 Circ. High Input",1); + AddConstEx(id,"DTC_P1324", 0x54, 0xffffffff); + SetConstCmt(GetConst(id,0x54,0xffffffff),"Knock Sensor 4 Circ. High Input",1); + AddConstEx(id,"DTC_P1539", 0x55, 0xffffffff); + SetConstCmt(GetConst(id,0x55,0xffffffff),"Clutch Vacuum Vent Valve Switch Incorrect signal",1); + AddConstEx(id,"DTC_P0139", 0x56, 0xffffffff); + SetConstCmt(GetConst(id,0x56,0xffffffff),"O2 Sensor Circ.,Bank1-Sensor2 Slow Response",1); + AddConstEx(id,"DTC_P0159", 0x57, 0xffffffff); + SetConstCmt(GetConst(id,0x57,0xffffffff),"O2 Sensor Circ.,Bank2-Sensor2 Slow Response",1); + AddConstEx(id,"DTC_P0133", 0x58, 0xffffffff); + SetConstCmt(GetConst(id,0x58,0xffffffff),"O2 Sensor Circ.,Bank1-Sensor1 Slow Response",1); + AddConstEx(id,"DTC_P0153", 0x59, 0xffffffff); + SetConstCmt(GetConst(id,0x59,0xffffffff),"O2 Sensor Circ.,Bank2-Sensor1 Slow Response",1); + AddConstEx(id,"DTC_P1176", 0x5a, 0xffffffff); + SetConstCmt(GetConst(id,0x5a,0xffffffff),"O2 Correction Behind Catalyst,B1 Limit Attained",1); + AddConstEx(id,"DTC_P1177", 0x5b, 0xffffffff); + SetConstCmt(GetConst(id,0x5b,0xffffffff),"O2 Correction Behind Catalyst,B2 Limit Attained",1); + AddConstEx(id,"DTC_P1546", 0x5c, 0xffffffff); + SetConstCmt(GetConst(id,0x5c,0xffffffff),"Boost Pressure Contr.Valve Short to B+",1); + AddConstEx(id,"DTC_P1555", 0x5d, 0xffffffff); + SetConstCmt(GetConst(id,0x5d,0xffffffff),"Charge Pressure -Upper Limit exceeded",1); + AddConstEx(id,"DTC_P1475", 0x5e, 0xffffffff); + SetConstCmt(GetConst(id,0x5e,0xffffffff),"EVAP Emission Contr.LDP Circ Malfunction/Signal Circ.Open",1); + AddConstEx(id,"DTC_P1471", 0x5f, 0xffffffff); + SetConstCmt(GetConst(id,0x5f,0xffffffff),"EVAP Emission Contr.LDP Circ Short to B+",1); + AddConstEx(id,"DTC_P1557", 0x60, 0xffffffff); + SetConstCmt(GetConst(id,0x60,0xffffffff),"Charge Pressure Contr. -Positive Deviation",1); + AddConstEx(id,"DTC_P0507", 0x61, 0xffffffff); + SetConstCmt(GetConst(id,0x61,0xffffffff),"Idle Control System Higher than Expected",1); + AddConstEx(id,"DTC_P0103", 0x62, 0xffffffff); + SetConstCmt(GetConst(id,0x62,0xffffffff),"Mass or Volume Air Flow Circ High Input",1); + AddConstEx(id,"DTC_P0138", 0x63, 0xffffffff); + SetConstCmt(GetConst(id,0x63,0xffffffff),"O2 Sensor Circ.,Bank1-Sensor2 High Voltage",1); + AddConstEx(id,"DTC_P0158", 0x64, 0xffffffff); + SetConstCmt(GetConst(id,0x64,0xffffffff),"O2 Sensor Circ.,Bank2-Sensor2 High Voltage",1); + AddConstEx(id,"DTC_P0132", 0x65, 0xffffffff); + SetConstCmt(GetConst(id,0x65,0xffffffff),"O2 Sensor Circ.,Bank1-Sensor1 High Voltage",1); + AddConstEx(id,"DTC_P0152", 0x66, 0xffffffff); + SetConstCmt(GetConst(id,0x66,0xffffffff),"O2 Sensor Circ.,Bank2-Sensor1 High Voltage",1); + AddConstEx(id,"DTC_P0300", 0x67, 0xffffffff); + SetConstCmt(GetConst(id,0x67,0xffffffff),"Random/Multiple Cylinder Misfire Detected",1); + AddConstEx(id,"DTC_P0301", 0x68, 0xffffffff); + SetConstCmt(GetConst(id,0x68,0xffffffff),"Cyl.1 Misfire Detected",1); + AddConstEx(id,"DTC_P0304", 0x69, 0xffffffff); + SetConstCmt(GetConst(id,0x69,0xffffffff),"Cyl.4 Misfire Detected",1); + AddConstEx(id,"DTC_P1336", 0x6e, 0xffffffff); + SetConstCmt(GetConst(id,0x6e,0xffffffff),"Engine Torque Monitoring - Adaptation at limit",1); + AddConstEx(id,"DTC_P0300_1", 0x6f, 0xffffffff); + SetConstCmt(GetConst(id,0x6f,0xffffffff),"Random/Multiple Cylinder Misfire Detected",1); + AddConstEx(id,"DTC_P0301_1", 0x70, 0xffffffff); + SetConstCmt(GetConst(id,0x70,0xffffffff),"Cyl.1 Misfire Detected",1); + AddConstEx(id,"DTC_P0304_1", 0x71, 0xffffffff); + SetConstCmt(GetConst(id,0x71,0xffffffff),"Cyl.4 Misfire Detected",1); + AddConstEx(id,"DTC_P0303", 0x72, 0xffffffff); + SetConstCmt(GetConst(id,0x72,0xffffffff),"Cyl.3 Misfire Detected",1); + AddConstEx(id,"DTC_P1693", 0x76, 0xffffffff); + SetConstCmt(GetConst(id,0x76,0xffffffff),"Malfunction Indication Light -Short circuit to B+",1); + AddConstEx(id,"DTC_P0322", 0x77, 0xffffffff); + SetConstCmt(GetConst(id,0x77,0xffffffff),"Ign./Distributor Eng.Speed Inp.Circ No Signal",1); + AddConstEx(id,"DTC_P1347", 0x78, 0xffffffff); + SetConstCmt(GetConst(id,0x78,0xffffffff),"Bank2,Crankshaft-/Camshaft os.Sens.Sign. Out of Sequence",1); + AddConstEx(id,"DTC_P1340", 0x79, 0xffffffff); + SetConstCmt(GetConst(id,0x79,0xffffffff),"Crankshaft-/Camshaft Pos.Sens.Signals Out of Sequence",1); + AddConstEx(id,"DTC_P1522", 0x7a, 0xffffffff); + SetConstCmt(GetConst(id,0x7a,0xffffffff),"Intake Camshaft Contr.,Bank2 Malfunction",1); + AddConstEx(id,"DTC_P1519", 0x7b, 0xffffffff); + SetConstCmt(GetConst(id,0x7b,0xffffffff),"Intake Camshaft Contr.,Bank1 Malfunction",1); + AddConstEx(id,"DTC_P1529", 0x7c, 0xffffffff); + SetConstCmt(GetConst(id,0x7c,0xffffffff),"Camshaft Control Circuit Short to B+",1); + AddConstEx(id,"DTC_P1560", 0x7d, 0xffffffff); + SetConstCmt(GetConst(id,0x7d,0xffffffff),"Maximum Engine Speed Exceeded",1); + AddConstEx(id,"DTC_P1392", 0x7e, 0xffffffff); + SetConstCmt(GetConst(id,0x7e,0xffffffff),"Camshaft Pos.Sensor,Bank2 Open Circ./Short to B+",1); + AddConstEx(id,"DTC_P1338", 0x7f, 0xffffffff); + SetConstCmt(GetConst(id,0x7f,0xffffffff),"Internal Contr. Module drive by wire error",1); + AddConstEx(id,"DTC_P1606", 0x80, 0xffffffff); + SetConstCmt(GetConst(id,0x80,0xffffffff),"Rough Road Spec Engine Torque ABS-ECU Electrical Malfunction",1); + AddConstEx(id,"DTC_P1136_0", 0x81, 0xffffffff); + SetConstCmt(GetConst(id,0x81,0xffffffff),"Long Term Fuel Trim Add.Fuel,Bank1 System too Lean",1); + AddConstEx(id,"DTC_P1138_0", 0x82, 0xffffffff); + SetConstCmt(GetConst(id,0x82,0xffffffff),"Long Term Fuel Trim Add.Fuel,Bank2 System too Lean",1); + AddConstEx(id,"DTC_P1136_1", 0x83, 0xffffffff); + SetConstCmt(GetConst(id,0x83,0xffffffff),"Long Term Fuel Trim Add.Fuel,Bank1 System too Lean",1); + AddConstEx(id,"DTC_P1138_1", 0x84, 0xffffffff); + SetConstCmt(GetConst(id,0x84,0xffffffff),"Long Term Fuel Trim Add.Fuel,Bank2 System too Lean",1); + AddConstEx(id,"DTC_P1640", 0x85, 0xffffffff); + SetConstCmt(GetConst(id,0x85,0xffffffff),"Internal Control Module (EEPROM) Error",1); + AddConstEx(id,"DTC_P1434", 0x86, 0xffffffff); + SetConstCmt(GetConst(id,0x86,0xffffffff),"Sec.Air Inj.Sys.Pump Relay Circ. Short to B+",1); + AddConstEx(id,"DTC_P1423", 0x87, 0xffffffff); + SetConstCmt(GetConst(id,0x87,0xffffffff),"Sec.Air Inj.Sys.,Bank1 Flow too Low",1); + AddConstEx(id,"DTC_P1411", 0x88, 0xffffffff); + SetConstCmt(GetConst(id,0x88,0xffffffff),"Sec.Air Inj.Sys.,Bank2 Flow too Flow",1); + AddConstEx(id,"DTC_P1424", 0x89, 0xffffffff); + SetConstCmt(GetConst(id,0x89,0xffffffff),"Sec.Air Inj.Sys.,Bank1 Leak Detected",1); + AddConstEx(id,"DTC_P1414", 0x8a, 0xffffffff); + SetConstCmt(GetConst(id,0x8a,0xffffffff),"Sec.Air Inj.Sys.,Bank2 Leak Detected",1); + AddConstEx(id,"DTC_P1422", 0x8b, 0xffffffff); + SetConstCmt(GetConst(id,0x8b,0xffffffff),"Sec.Air Inj.Sys.Contr.Valve Circ Short to B+",1); + AddConstEx(id,"DTC_P1002", 0x8c, 0xffffffff); + AddConstEx(id,"DTC_P1512", 0x8d, 0xffffffff); + SetConstCmt(GetConst(id,0x8d,0xffffffff),"Intake Manifold Changeover Valve circuit Short to B+",1); + AddConstEx(id,"DTC_P1606_1", 0x8e, 0xffffffff); + SetConstCmt(GetConst(id,0x8e,0xffffffff),"Rough Road Spec Engine Torque ABS-ECU Electrical Malfunction",1); + AddConstEx(id,"DTC_P0112", 0x8f, 0xffffffff); + SetConstCmt(GetConst(id,0x8f,0xffffffff),"Intake Air Temp.Circ Low Input",1); + AddConstEx(id,"DTC_P1250", 0x90, 0xffffffff); + SetConstCmt(GetConst(id,0x90,0xffffffff),"Fuel too low",1); + AddConstEx(id,"DTC_P0441", 0x91, 0xffffffff); + SetConstCmt(GetConst(id,0x91,0xffffffff),"EVAP Emission Contr.Sys.Incorrect Purge Flow",1); + AddConstEx(id,"DTC_P0442", 0x92, 0xffffffff); + SetConstCmt(GetConst(id,0x92,0xffffffff),"EVAP Emission Contr.Sys.(Small Leak) Leak Detected",1); + AddConstEx(id,"DTC_P0455", 0x93, 0xffffffff); + SetConstCmt(GetConst(id,0x93,0xffffffff),"EVAP Emission Contr.Sys.(Gross Leak) Leak Detected",1); + AddConstEx(id,"DTC_P1410", 0x94, 0xffffffff); + SetConstCmt(GetConst(id,0x94,0xffffffff),"Tank Ventilation Valve Circ. Short to B+",1); + AddConstEx(id,"DTC_P1467", 0x95, 0xffffffff); + SetConstCmt(GetConst(id,0x95,0xffffffff),"EVAP Canister Purge Solenoid Valve Short Circuit to B+",1); + AddConstEx(id,"DTC_P0117", 0x96, 0xffffffff); + SetConstCmt(GetConst(id,0x96,0xffffffff),"Engine Coolant Temp.Circ Low Input",1); + AddConstEx(id,"DTC_P1620", 0x97, 0xffffffff); + SetConstCmt(GetConst(id,0x97,0xffffffff),"Engine coolant temperature signal open/short to B+",1); + AddConstEx(id,"DTC_P0197", 0x98, 0xffffffff); + SetConstCmt(GetConst(id,0x98,0xffffffff),"Engine Oil Temperature Circuit Low Input",1); + AddConstEx(id,"DTC_P1029", 0x99, 0xffffffff); + AddConstEx(id,"DTC_P0601", 0x9a, 0xffffffff); + SetConstCmt(GetConst(id,0x9a,0xffffffff),"ECM - Checksum",1); + AddConstEx(id,"DTC_P0563", 0x9b, 0xffffffff); + SetConstCmt(GetConst(id,0x9b,0xffffffff),"System Voltage High Voltage",1); + AddConstEx(id,"DTC_P1335", 0x9c, 0xffffffff); + SetConstCmt(GetConst(id,0x9c,0xffffffff),"Engine Torque Monitoring 2 Control Limit Exceeded",1); + AddConstEx(id,"DTC_P1388", 0x9d, 0xffffffff); + SetConstCmt(GetConst(id,0x9d,0xffffffff),"Internal Contr. Module drive by wire error",1); + AddConstEx(id,"DTC_P0604", 0x9e, 0xffffffff); + SetConstCmt(GetConst(id,0x9e,0xffffffff),"Memory (RAM) Error",1); + AddConstEx(id,"DTC_P0605", 0x9f, 0xffffffff); + SetConstCmt(GetConst(id,0x9f,0xffffffff),"Internal Contr. Module ROM Test Error",1); + AddConstEx(id,"DTC_P1603", 0xa0, 0xffffffff); + SetConstCmt(GetConst(id,0xa0,0xffffffff),"Internal Control Module Malfunction",1); + AddConstEx(id,"DTC_P1288", 0xa1, 0xffffffff); + SetConstCmt(GetConst(id,0xa1,0xffffffff),"Turbocharger bypass valve short to B+",1); + AddConstEx(id,"DTC_P0501", 0xa2, 0xffffffff); + SetConstCmt(GetConst(id,0xa2,0xffffffff),"Vehicle Speed Sensor Range/Performance",1); + AddConstEx(id,"DTC_P1570", 0xa3, 0xffffffff); + SetConstCmt(GetConst(id,0xa3,0xffffffff),"Control Module Locked",1); + AddConstEx(id,"DTC_P0606", 0xa4, 0xffffffff); + SetConstCmt(GetConst(id,0xa4,0xffffffff),"ECM - Watchdog",1); + AddConstEx(id,"DTC_P1356", 0xa5, 0xffffffff); + SetConstCmt(GetConst(id,0xa5,0xffffffff),"Cyl. 1, ignition circuit Short to B+",1); + AddConstEx(id,"DTC_P1365", 0xa6, 0xffffffff); + SetConstCmt(GetConst(id,0xa6,0xffffffff),"Cyl. 4, ignition circuit Short circuit to B+",1); + AddConstEx(id,"DTC_P1362", 0xa7, 0xffffffff); + SetConstCmt(GetConst(id,0xa7,0xffffffff),"Cyl. 3, ignition circuit Short Circuit to B+",1); + AddConstEx(id,"DTC_P1371", 0xa8, 0xffffffff); + SetConstCmt(GetConst(id,0xa8,0xffffffff),"Cyl. 6, ignition circuit Short Circuit to B+",1); + AddConstEx(id,"DTC_P1359", 0xa9, 0xffffffff); + SetConstCmt(GetConst(id,0xa9,0xffffffff),"Cyl. 2, ignition circuit Short Circuit to B+",1); + AddConstEx(id,"DTC_P1368", 0xaa, 0xffffffff); + SetConstCmt(GetConst(id,0xaa,0xffffffff),"Cyl. 5, ignition circuit Short Circuit to B+",1); + AddConstEx(id,"DTC_P1374", 0xab, 0xffffffff); + SetConstCmt(GetConst(id,0xab,0xffffffff),"Cyl. 7, ignition circuit Short Circuit to B+",1); + AddConstEx(id,"DTC_P1377", 0xac, 0xffffffff); + SetConstCmt(GetConst(id,0xac,0xffffffff),"Cyl. 8, ignition circuit Short Circuit to B+",1); + AddConstEx(id,"DTC_MAX", 0xad, 0xffffffff); + SetConstCmt(GetConst(id,0xad,0xffffffff),"Maximum number of DTC blocks",1); + id = AddEnum(-1,"LOCALVAR",0x1100000); + AddConstEx(id,"LOCALVAR_0", 0x0, 0xffffffff); + AddConstEx(id,"LOCALVAR_1", 0x1, 0xffffffff); + AddConstEx(id,"LOCALVAR_2", 0x2, 0xffffffff); + AddConstEx(id,"LOCALVAR_3", 0x3, 0xffffffff); + AddConstEx(id,"LOCALVAR_4", 0x4, 0xffffffff); + AddConstEx(id,"LOCALVAR_5", 0x5, 0xffffffff); + AddConstEx(id,"LOCALVAR_6", 0x6, 0xffffffff); + AddConstEx(id,"LOCALVAR_7", 0x7, 0xffffffff); + AddConstEx(id,"LOCALVAR_8", 0x8, 0xffffffff); + AddConstEx(id,"LOCALVAR_9", 0x9, 0xffffffff); + AddConstEx(id,"LOCALVAR_10", 0xa, 0xffffffff); + AddConstEx(id,"LOCALVAR_11", 0xb, 0xffffffff); + AddConstEx(id,"LOCALVAR_12", 0xc, 0xffffffff); + AddConstEx(id,"LOCALVAR_13", 0xd, 0xffffffff); + AddConstEx(id,"LOCALVAR_14", 0xe, 0xffffffff); + AddConstEx(id,"LOCALVAR_15", 0xf, 0xffffffff); + AddConstEx(id,"LOCALVAR_16", 0x10, 0xffffffff); + AddConstEx(id,"LOCALVAR_17", 0x11, 0xffffffff); + AddConstEx(id,"LOCALVAR_18", 0x12, 0xffffffff); + AddConstEx(id,"LOCALVAR_19", 0x13, 0xffffffff); + AddConstEx(id,"LOCALVAR_20", 0x14, 0xffffffff); + AddConstEx(id,"LOCALVAR_21", 0x15, 0xffffffff); + AddConstEx(id,"LOCALVAR_22", 0x16, 0xffffffff); + AddConstEx(id,"LOCALVAR_23", 0x17, 0xffffffff); + AddConstEx(id,"LOCALVAR_24", 0x18, 0xffffffff); + AddConstEx(id,"LOCALVAR_25", 0x19, 0xffffffff); + AddConstEx(id,"LOCALVAR_26", 0x1a, 0xffffffff); + id = AddEnum(-1,"FLASH_OPS",0x1100000); + AddConstEx(id,"FLASH_OPS_0", 0x0, 0xffffffff); + AddConstEx(id,"FLASH_OPS_1", 0x1, 0xffffffff); + AddConstEx(id,"FLASH_OPS_2", 0x2, 0xffffffff); + AddConstEx(id,"FLASH_OPS_3", 0x3, 0xffffffff); + AddConstEx(id,"FLASH_OPS_4", 0x4, 0xffffffff); + AddConstEx(id,"FLASH_OPS_5", 0x5, 0xffffffff); + AddConstEx(id,"FLASH_OPS_6", 0x6, 0xffffffff); + id = AddEnum(-1,"LOGIC",0x1100000); + AddConstEx(id,"FALSE", 0x0, 0xffffffff); + AddConstEx(id,"TRUE", 0x1, 0xffffffff); +} + +//------------------------------------------------------------------------ +// Information about enum types + +static Enums(void) { + auto id; + id = Enums_0(id); +} + +static Structures_0(id) { + +// if (AskYN(1,"Do you want to define structures?") != 1) +// return; + + Message("++++++++++++++++++++\n"); + Message("Creating Structures \n"); + Message("++++++++++++++++++++\n"); + + id = AddStrucEx(-1,"strDTC_Struct",0); + SetStrucComment(id,"DTC Structure",1); + id = AddStrucEx(-1,"SeedLookup",0); + id = AddStrucEx(-1,"ADCCheck",0); + id = AddStrucEx(-1,"strChkSumBlock",0); + id = AddStrucEx(-1,"strDTC_Store",0); + + id = GetStrucIdByName("strDTC_Struct"); + AddStrucMember(id,"DTC1", 0x0, 0x10100400, -1, 2); + AddStrucMember(id,"DTC2", 0x2, 0x10100400, -1, 2); + AddStrucMember(id,"DTC3", 0x4, 0x10100400, -1, 2); + AddStrucMember(id,"DTC4", 0x6, 0x10100400, -1, 2); + + id = GetStrucIdByName("SeedLookup"); + AddStrucMember(id,"Seed", 0x0, 0x10000400, -1, 4); + + id = GetStrucIdByName("ADCCheck"); + AddStrucMember(id,"bField_0", 0x0, 0x10000400, -1, 2); + AddStrucMember(id,"bField_2", 0x2, 0x10000400, -1, 2); + AddStrucMember(id,"ValueA", 0x4, 0x10000400, -1, 2); + AddStrucMember(id,"ValueB", 0x6, 0x10000400, -1, 2); + + id = GetStrucIdByName("strChkSumBlock"); + AddStrucMember(id,"StartAddr", 0x0, 0x10100400, -1, 2); + AddStrucMember(id,"StartSeg", 0x2, 0x10100400, -1, 2); + AddStrucMember(id,"EndAddr", 0x4, 0x10100400, -1, 2); + AddStrucMember(id,"EndSeg", 0x6, 0x10100400, -1, 2); + AddStrucMember(id,"ChksumLo", 0x8, 0x10100400, -1, 2); + SetMemberComment(id, 0x8, "Chksum Lo", 1); + AddStrucMember(id,"ChksumHi", 0xa, 0x10100400, -1, 2); + SetMemberComment(id, 0xa, "Chksum Hi", 1); + AddStrucMember(id,"InvChksumLo", 0xc, 0x10100400, -1, 2); + SetMemberComment(id, 0xc, "Chksum Lo inverted", 1); + AddStrucMember(id,"InvChksumHi", 0xe, 0x10100400, -1, 2); + SetMemberComment(id, 0xe, "Chksum Hi inverted", 1); + + id = GetStrucIdByName("strDTC_Store"); + AddStrucMember(id,"field_0", 0x0, 0x000400, -1, 1); + AddStrucMember(id,"DTCA_Hi", 0x1, 0x100400, -1, 1); + AddStrucMember(id,"DTCA_Lo", 0x2, 0x100400, -1, 1); + AddStrucMember(id,"DTCB_Hi", 0x3, 0x100400, -1, 1); + AddStrucMember(id,"DTCB_Lo", 0x4, 0x100400, -1, 1); + AddStrucMember(id,"field_5", 0x5, 0x000400, -1, 1); + AddStrucMember(id,"field_6", 0x6, 0x000400, -1, 1); + AddStrucMember(id,"field_7", 0x7, 0x000400, -1, 1); + AddStrucMember(id,"field_8", 0x8, 0x000400, -1, 1); + AddStrucMember(id,"field_9", 0x9, 0x000400, -1, 1); + AddStrucMember(id,"field_A", 0xa, 0x000400, -1, 1); + AddStrucMember(id,"field_B", 0xb, 0x000400, -1, 1); + AddStrucMember(id,"field_C", 0xc, 0x000400, -1, 1); + AddStrucMember(id,"field_D", 0xd, 0x000400, -1, 1); +} + +//------------------------------------------------------------------------ +// Information about structure types + +static Structures(void) { + auto id; + id = Structures_0(id); +} + +//------------------------------------------------------------------------ +// Information about bytes + +static Bytes_0(void) { + auto x; +#define id x + +// ExtLinA (0x0, 0, "; GOLF 4 R32 3.2L V6"); + ExtLinA (0x0, 1, "; Disassembly by Andy Whittaker"); + ExtLinA (0x0, 2, "; http://www.andywhittaker.com/"); + +// MakeRptCmt (0x812d10, "This is a test repeat comment at 0x812d10"); +// MakeWord (x=0x812d10); +// OpHex (x, 0); +// MakeName (0x812d10, "TestName_812D10"); +} + +static Bytes(void) { + Bytes_0(); +} + +static DTC_Enum(void) { +auto string; + + +// if (AskYN(1,"Do you want to search for and translate DTC Enumerations?") != 1) +// return; + + Message("+++++++++++++++++++++++++++++++++++++++++++++++\n"); + Message("Searching and translating enumerations for DTCs \n"); + Message("+++++++++++++++++++++++++++++++++++++++++++++++\n"); + + string = "bfldh"; + MakeC16xEnum(0x800000,string); + string = "bfldl"; + MakeC16xEnum(0x800000,string); + + Message("\nDTC Enum search complete!\n"); +} + +//converts a C16x bitfield instruction to an Bosch Enum +// ea = linear address to search from +// search_string = string to search for +static MakeC16xEnum(ea,search_string) { + +auto enums_found; +auto lin_address; +auto next_address; +auto operand; + + enums_found = 0; + lin_address = 0; + + Message("\nLooking for Enums - Ref %s\n", search_string); + lin_address = FindText(ea,SEARCH_DOWN,0,0,search_string); + while(lin_address != BADADDR) + { + operand = GetOpnd(lin_address, 0); + Message("Found Enum %s at 0x%lx, operand %s", search_string, lin_address, operand); + if ((operand == "r1") | (operand == "r2") | (operand == "r3") | (operand == "r4") | (operand == "r5")) + { + if (search_string == "bfldh") + { + Message(" - Enumerating DTCHBit\n"); + OpEnumEx(lin_address,1,GetEnum("DTCHBit"),0); + } + else if (search_string == "bfldl") + { + Message(" - Enumerating DTCLBit\n"); + OpEnumEx(lin_address,1,GetEnum("DTCLBit"),0); + } + enums_found++; + } + else + Message("- Ignoring\n"); + + lin_address = lin_address + 0x10; + next_address = FindText(lin_address,SEARCH_DOWN | SEARCH_NEXT,0,0,search_string); + lin_address = next_address; // new search point + } + + Message("\nDTC Enum search for %s complete! Enums found = %ld\n", search_string, enums_found); +} + +//This routine increments through the disassembled code and tries to convert +//the segment:offset pairs into a real offset address. Bosch generally uses +//r12 as a table location with the following r13 instruction as the C16x +//segment offset. +//The routine finds the r13 reference, back-tracks 4 bytes to the r12 reference +//and passes this address onto the MakeC16xOffset function. +static TranslateOffsets(void) { +auto string; + +// if (AskYN(1,"Do you want to search for tables?") != 1) +// return; + + Message("++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + Message("Translating offsets in code to reference lookup tables\n"); + Message("++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + string = ", #204h"; + MakC16xOffsetLp(0x800000,0x204,string); + + string = ", #205h"; + MakC16xOffsetLp(0x800000,0x205,string); + + string = ", #206h"; + MakC16xOffsetLp(0x800000,0x206,string); + + string = ", #207h"; + MakC16xOffsetLp(0x800000,0x207,string); + + string = ", #209h"; + MakC16xOffsetLp(0x800000,0x209,string); + + string = ", #20Ah"; + MakC16xOffsetLp(0x800000,0x20a,string); + +// string = ", #20Bh"; +// MakC16xOffsetLp(0x800000,0x20b,string); + +// string = ", #20Ch"; +// MakC16xOffsetLp(0x800000,0x20c,string); + +// string = ", #20Dh"; +// MakC16xOffsetLp(0x800000,0x20d,string); + + Message("\nLookup tables search complete!\n"); + +} + +//converts a C16x table offset to an IDA linear offset over an address range +// ea = linear address to search from +// seg = the segment address the operand relates to +// search_string = string to search for +static MakC16xOffsetLp(ea,seg,search_string) { + +auto tables_found; +auto lin_address; +auto next_address; +auto operand; + + tables_found = 0; + + Message("\nLooking for tables in segment 0x%x (0x%lx) - Ref %s\n", seg, ea, search_string); + lin_address = FindText(ea,SEARCH_DOWN,0,0,search_string); + while(lin_address != BADADDR) + { + operand = GetOpnd(lin_address, 0); + Message("Found reference %s at 0x%lx, operand %s", search_string, lin_address, operand); + if ((operand == "r5") | (operand == "r13") | (operand == "r14") | (operand == "r15")) + { + MakeC16xOffset(lin_address, seg);// Create the table entry at the previous instruction + tables_found++; + } + else + Message("- Ignoring\n"); + lin_address = lin_address + 0x8; + next_address = FindText(lin_address,SEARCH_DOWN | SEARCH_NEXT,0,0,search_string); + lin_address = next_address; // new search point + } + + Message("\nLookup tables found = %ld at segment 0x%lx\n", tables_found, seg); +} + +//converts a C16x table offset to an IDA linear offset +// ea = linear address of instruction +// seg = the segment address the operand relates to +static MakeC16xOffset(ea,seg) { +auto x; +auto offset; +auto table_address; + + x=ea - 0x4; +// MakeCode (x=ea); + //convert the C16x offset into an address + offset = seg * 0x4000; + //create the offset + OpOff (x, 1, offset); + OpOff (x, 129, offset); + table_address = GetOperandValue(x,1) + offset; //find what the table's address is + Message("- Table reference at 0x%lx is probably: 0x%lx\n",x,table_address); + MakeRptCmt(table_address, "Probable Lookup Table"); +} + + +//This routine increments through the disassembled code and tries to convert +//the offsets for conditional jumps into a real addresses. +//The routine finds the jmpi reference, back-tracks 6 bytes to the offset reference +//and passes this address onto the MakeC16xOffset function. +static TranslateJmpi(void) { +auto string; +auto tables_found; +auto lin_address; +auto next_address; +auto segment; +auto table_address; +auto namestr; + +auto instruction;// test string + +// if (AskYN(1,"Do you want to search for jump tables?") != 1) +// return; + + Message("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + Message("Translating jumps in code to reference function jump lookup tables\n"); + Message("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + string = "jmpi cc_UC, ["; //what we want to search for + + tables_found = 0; + + lin_address = FindText(0x800000,SEARCH_DOWN,0,0,string); +// lin_address = FindText(0x834000,SEARCH_DOWN,0,0,string); + while(lin_address != BADADDR) + { + // Check where the offset table is by backtracking + // and checking for the add instruction. + if (GetMnem(lin_address - 4) == "add") + { + if (GetMnem(lin_address - 6) == "shl") + { //if we're here, then the table is an offset to the current segment. + + //If the add instruction is directly before the jmpi, + //the offset is an offset from the current segment. + lin_address = lin_address - 4; + segment = (lin_address & 0xff0000); + OpOff(lin_address,1, segment);//Make the offset + table_address = GetOperandValue(lin_address,1) + segment; //find what the table's address is + Message("Offset table reference at 0x%lx is probably: 0x%lx\n",lin_address, table_address); + MakeRptCmt(table_address, "Function Jump Table"); + namestr = "jtbl_"; + namestr = namestr + ltoa(table_address, 16); + MakeName(table_address, ""); + MakeName(table_address, namestr); + } + } + else if (GetMnem(lin_address - 6) == "add") + { + //If the add instruction is not before the jmpi, but a + //mov rx, [rx] is following it, then the offset is from + //the data segment. + lin_address = lin_address - 6; + segment = (lin_address & 0xff0000); +// OpOff(lin_address,1, segment);//Make the offset + OpOff(lin_address,1, 0x810000);//Make the offset + OpOff(lin_address,129, 0x810000); + table_address = GetOperandValue(lin_address,1) + 0x810000; //find what the table's address is +// table_address = GetOperandValue(lin_address,1); //find what the table's address is + Message("Function table reference at 0x%lx is probably: 0x%lx\n",lin_address,table_address); + MakeRptCmt(table_address, "Probable Function Lookup Table"); + namestr = "jtbl_"; + namestr = namestr + ltoa(table_address, 16); + MakeName(table_address, ""); + MakeName(table_address, namestr); + } + + tables_found++; + + lin_address = lin_address + 0x10; + next_address = FindText(lin_address,SEARCH_DOWN | SEARCH_NEXT,0,0,string); + +// if (next_address >= 0x840000) +// break; + lin_address = next_address; // new search point + } + + Message("\nConditional jump search complete! Jump tables found = %ld\n", tables_found); +} + +//Loads a WinOLS csv export +static LoadMapPackCSV(void) { + auto filename; + auto hFHandle; + auto flength; + auto chin; + auto fstring; + auto addressstr; + auto commentstr; + auto arraystr; + auto fstringlength; + auto stringindex; + auto address; + auto namestr; + + if (AskYN(1,"Do you want to import map pack tables?") != 1) + return; + + filename = AskFile(0,"*.csv","Select WinOLS CSV MapPack to import"); // ask a file name + if (filename == 0) + return; + + Message("++++++++++++++++++++++++++++++++++\n"); + Message("Importing Map Pack WinOLS csv file\n"); + Message("++++++++++++++++++++++++++++++++++\n"); + + hFHandle = fopen(filename,"r"); + flength = filelength(hFHandle); + + while(fstring != -1) + { + addressstr = ""; + commentstr = ""; + arraystr = ""; + + //read the first line in + fstring = readstr(hFHandle); + fstringlength = strlen(fstring); + + //check to see if the line contains an address + //if it's an address, the 2nd char will be a $ + if (substr(fstring, 1, 2) == "$") + { + stringindex = 2; + //Read through each character of the string to extract our 3 strings + + //1st the address string + for(;stringindex º +// º Licensed to: Andy Whittaker, Special, 1 user, adv, 01/2002 º +// ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ +// +// +// This file contains the user-defined type definitions. +// To use it press F2 in IDA and enter the name of this file. +// + +#define UNLOADED_FILE 1 +#include + +static main(void) { + Bytes(); // Defines in the binary + Segments(); // Create all the segments + Enums(); // enumerations + Structures(); // structure types + AutoAnalyse();// Tries to automatically disassemble the binary + + DTC_Enum();// search for and emumerate DTC references + + // Stuff for Bosch ME7.1 ECUs + TranslateOffsets();// find lookup tables + TranslateJmpi();//Find jmpi and tries to find the jump table + FindSeedTable(); + LoadMapPackCSV();//Import Map Pack tables +} + +//Runs through each segment and tries to disassemble everything +static AutoAnalyse(void) +{ + auto addr; + auto index; +#define ROM_START 0x800000 +#define MAP_AREA_START 0x810000 +#define MAP_AREA_FINISH 0x820000 + +// if (AskYN(1,"Do you want to Auto-Disassemble?") != 1) +// return; + + Message("++++++++++++++++++++++++++ \n"); + Message("Trying to Auto-Disassemble \n"); + Message("++++++++++++++++++++++++++ \n"); + + + addr = ROM_START; //start address + MakeFunction(addr, BADADDR); + while(addr != BADADDR) + { + addr = FindUnexplored(addr, SEARCH_DOWN | SEARCH_NEXT); + // The previous MakeFunction may not have disassembled the instructions + // following a relative jmp instruction. + // If Makefunction fails, try and create code + if (MakeFunction(addr, BADADDR)) + Message("Function found at 0x%0lx \n", addr); + else + if(MakeCode(addr) != 0) + Message("Code created at 0x%0lx \n", addr); + if( (addr > MAP_AREA_START) & (addr < MAP_AREA_FINISH) ) + { + Message("Ignoring data - within MAP area\n"); + addr = MAP_AREA_FINISH; + } + if(addr == BADADDR) + Message("End of Auto-Disassemble analysis loop\n"); + } +} + +//Finds where the XOR seed routine and table are located +static FindSeedTable(void) +{ + auto found; + auto namestr; + auto table_address; + auto offset; + auto seg; + + namestr = ""; + +// if (AskYN(1,"Do you want to search for the CRC32 table?") != 1) +// return; + + Message("++++++++++++++++++++++++ \n"); + Message("Searching for CRC32-Table \n"); + Message("++++++++++++++++++++++++ \n"); + + found = FindBinary(0x810000, SEARCH_DOWN | SEARCH_NEXT, "8c f0 9d 0d 1e dc 09 a9 88 f0 56 51 a8 b9 a0"); + if (found == BADADDR) + Message("** CRC32 Table Not Found **\n"); + else + { + found = found - 21; //Start of function + Message("XOR CRC32 routine is located at 0x%0lx", found); + namestr = "XORChkSumGenerate_"; + namestr = namestr + ltoa(found, 16); + MakeName(found, namestr); + + // Let's find out where the seed table is + found = found + 0x24;// this is where the seed table is referenced + ExtLinA(found, 0, ";"); + ExtLinA(found, 1, "; This is where the seed table is referenced"); + ExtLinA(found, 2, ";"); + //convert the C16x offset into an address + table_address = GetOperandValue(found, 1); //find what the table's address is + seg = GetOperandValue(found + 4, 1); + offset = seg << 16; + table_address = table_address + offset; + Message(" - XOR Seed table is located at 0x%0lx\n", table_address); + namestr = "XORSeedTable_"; + namestr = namestr + ltoa(table_address, 16); + MakeName(table_address, namestr); + ExtLinA(table_address, 0, ";"); + ExtLinA(table_address, 1, "; XOR CRC32 table - 256 words long, 32 bit data"); + ExtLinA(table_address, 2, ";"); + } +} + +static Segments(void) { +// auto filesize; + +// if (AskYN(1,"Do you want to create Segments?") != 1) +// return; + + Message("++++++++++++++++++\n"); + Message("Creating Segments \n"); + Message("++++++++++++++++++\n"); + + // Create the RAM segments + SetSelector(0x1,0x38000); + SegCreate(0x380000,0x390000,0x1,0,saRelWord,scPub); + SegRename(0x380000,"segRAM"); + SegClass (0x380000,"RAM"); + SetSegmentType(0x380000,SEG_DATA); + + // Create the segments + SetSelector(0x2,0x80000); + SegCreate(0x800000,0x808000,0x2,0,saRelWord,scPub); + SegRename(0x800000,"seg080"); + SegClass (0x800000,"CODE"); + SetSegmentType(0x800000,SEG_CODE); + // The ME7.1 sets up the data page pointers to the following values. + SegDefReg(0x800000,"dpp0",0x0204); + SegDefReg(0x800000,"dpp1",0x0205); + SegDefReg(0x800000,"dpp2",0x00E0); + SegDefReg(0x800000,"dpp3",0x0003); + + SetSelector(0x3,0x80800); + SegCreate(0x808000,0x80c000,0x3,0,saRelWord,scPub); + SegRename(0x808000,"seg202"); + SegClass (0x808000,"CODE"); + SetSegmentType(0x808000,SEG_CODE); + SegDefReg(0x808000,"dpp0",0x0204); + SegDefReg(0x808000,"dpp1",0x0205); + SegDefReg(0x808000,"dpp2",0x00E0); + SegDefReg(0x808000,"dpp3",0x0003); + + SetSelector(0x4,0x80c00); + SegCreate(0x80c000,0x810000,0x4,0,saRelWord,scPub); + SegRename(0x80c000,"seg203"); + SegClass (0x80c000,"CODE"); + SetSegmentType(0x80c000,SEG_CODE); + SegDefReg(0x80c000,"dpp0",0x0204); + SegDefReg(0x80c000,"dpp1",0x0205); + SegDefReg(0x80c000,"dpp2",0x00E0); + SegDefReg(0x80c000,"dpp3",0x0003); + + SetSelector(0x5,0x81000); + SegCreate(0x810000,0x814000,0x5,0,saRelWord,scPub); + SegRename(0x810000,"seg204"); + SegClass (0x810000,"MAP"); + SetSegmentType(0x810000,SEG_DATA); + SegDefReg(0x810000,"dpp0",0x0204); + SegDefReg(0x810000,"dpp1",0x0205); + SegDefReg(0x810000,"dpp2",0x00E0); + SegDefReg(0x810000,"dpp3",0x0003); + + SetSelector(0x6,0x81400); + SegCreate(0x814000,0x818000,0x6,0,saRelWord,scPub); + SegRename(0x814000,"seg205"); + SegClass (0x814000,"MAP"); + SetSegmentType(0x814000,SEG_DATA); + SegDefReg(0x814000,"dpp0",0x0204); + SegDefReg(0x814000,"dpp1",0x0205); + SegDefReg(0x814000,"dpp2",0x00E0); + SegDefReg(0x814000,"dpp3",0x0003); + + SetSelector(0x7,0x81800); + SegCreate(0x818000,0x81c000,0x7,0,saRelWord,scPub); + SegRename(0x818000,"seg206"); + SegClass (0x818000,"MAP"); + SetSegmentType(0x818000,SEG_DATA); + SegDefReg(0x818000,"dpp0",0x0204); + SegDefReg(0x818000,"dpp1",0x0205); + SegDefReg(0x818000,"dpp2",0x00E0); + SegDefReg(0x818000,"dpp3",0x0003); + + SetSelector(0x8,0x81c00); + SegCreate(0x81c000,0x820000,0x8,0,saRelWord,scPub); + SegRename(0x81c000,"seg207"); + SegClass (0x81c000,"MAP"); + SetSegmentType(0x81c000,SEG_DATA); + SegDefReg(0x81c000,"dpp0",0x0204); + SegDefReg(0x81c000,"dpp1",0x0205); + SegDefReg(0x81c000,"dpp2",0x00E0); + SegDefReg(0x81c000,"dpp3",0x0003); + + SetSelector(0x9,0x82000); + SegCreate(0x820000,0x830000,0x9,0,saRelWord,scPub); + SegRename(0x820000,"seg082"); + SegClass (0x820000,"CODE"); + SetSegmentType(0x820000,SEG_CODE); + SegDefReg(0x820000,"dpp0",0x0204); + SegDefReg(0x820000,"dpp1",0x0205); + SegDefReg(0x820000,"dpp2",0x00E0); + SegDefReg(0x820000,"dpp3",0x0003); + + SetSelector(0xa,0x83000); + SegCreate(0x830000,0x840000,0xa,0,saRelWord,scPub); + SegRename(0x830000,"seg083"); + SegClass (0x830000,"CODE"); + SetSegmentType(0x830000,SEG_CODE); + SegDefReg(0x830000,"dpp0",0x0204); + SegDefReg(0x830000,"dpp1",0x0205); + SegDefReg(0x830000,"dpp2",0x00E0); + SegDefReg(0x830000,"dpp3",0x0003); + + SetSelector(0xb,0x84000); + SegCreate(0x840000,0x850000,0xb,0,saRelWord,scPub); + SegRename(0x840000,"seg084"); + SegClass (0x840000,"CODE"); + SetSegmentType(0x840000,SEG_CODE); + SegDefReg(0x840000,"dpp0",0x0204); + SegDefReg(0x840000,"dpp1",0x0205); + SegDefReg(0x840000,"dpp2",0x00E0); + SegDefReg(0x840000,"dpp3",0x0003); + + SetSelector(0xc,0x85000); + SegCreate(0x850000,0x860000,0xc,0,saRelWord,scPub); + SegRename(0x850000,"seg085"); + SegClass (0x850000,"CODE"); + SetSegmentType(0x850000,SEG_CODE); + SegDefReg(0x850000,"dpp0",0x0204); + SegDefReg(0x850000,"dpp1",0x0205); + SegDefReg(0x850000,"dpp2",0x00E0); + SegDefReg(0x850000,"dpp3",0x0003); + + SetSelector(0xd,0x86000); + SegCreate(0x860000,0x870000,0xd,0,saRelWord,scPub); + SegRename(0x860000,"seg086"); + SegClass (0x860000,"CODE"); + SetSegmentType(0x860000,SEG_CODE); + SegDefReg(0x860000,"dpp0",0x0204); + SegDefReg(0x860000,"dpp1",0x0205); + SegDefReg(0x860000,"dpp2",0x00E0); + SegDefReg(0x860000,"dpp3",0x0003); + + SetSelector(0xe,0x87000); + SegCreate(0x870000,0x880000,0xe,0,saRelWord,scPub); + SegRename(0x870000,"seg087"); + SegClass (0x870000,"CODE"); + SetSegmentType(0x870000,SEG_CODE); + SegDefReg(0x870000,"dpp0",0x0204); + SegDefReg(0x870000,"dpp1",0x0205); + SegDefReg(0x870000,"dpp2",0x00E0); + SegDefReg(0x870000,"dpp3",0x0003); +} + +static Enums_0(id) { + +// if (AskYN(1,"Do you want to define standard Bosch Enumerations?") != 1) +// return; + + Message("++++++++++++++++++++++\n"); + Message("Creating Emumerations \n"); + Message("++++++++++++++++++++++\n"); + + id = AddEnum(-1,"ECMERROR",0x1100000); + AddConstEx(id,"ECMERROR_00", 0x0, 0xffffffff); + AddConstEx(id,"ECMERROR_RAM01", 0x1, 0xffffffff); + AddConstEx(id,"ECMERROR_RAM02", 0x2, 0xffffffff); + AddConstEx(id,"ECMERROR_ILLBUS", 0x3, 0xffffffff); + AddConstEx(id,"ECMERROR_ILLINA", 0x4, 0xffffffff); + AddConstEx(id,"ECMERROR_ILLOPA", 0x5, 0xffffffff); + AddConstEx(id,"ECMERROR_PRTFLT", 0x6, 0xffffffff); + AddConstEx(id,"ECMERROR_UNDOPC", 0x7, 0xffffffff); + AddConstEx(id,"ECMERROR_08", 0x8, 0xffffffff); + AddConstEx(id,"ECMERROR_09", 0x9, 0xffffffff); + AddConstEx(id,"ECMERROR_10", 0xa, 0xffffffff); + AddConstEx(id,"ECMERROR_11", 0xb, 0xffffffff); + AddConstEx(id,"ECMERROR_12", 0xc, 0xffffffff); + AddConstEx(id,"ECMERROR_13", 0xd, 0xffffffff); + AddConstEx(id,"ECMERROR_14", 0xe, 0xffffffff); + AddConstEx(id,"ECMERROR_15", 0xf, 0xffffffff); + AddConstEx(id,"ECMERROR_16", 0x10, 0xffffffff); + AddConstEx(id,"ECMERROR_17", 0x11, 0xffffffff); + AddConstEx(id,"ECMERROR_18", 0x12, 0xffffffff); + AddConstEx(id,"ECMERROR_19", 0x13, 0xffffffff); + AddConstEx(id,"ECMERROR_20", 0x14, 0xffffffff); + AddConstEx(id,"ECMERROR_21", 0x15, 0xffffffff); + AddConstEx(id,"ECMERROR_22", 0x16, 0xffffffff); + AddConstEx(id,"ECMERROR_23", 0x17, 0xffffffff); + AddConstEx(id,"ECMERROR_24", 0x18, 0xffffffff); + AddConstEx(id,"ECMERROR_25", 0x19, 0xffffffff); + AddConstEx(id,"ECMERROR_26", 0x1a, 0xffffffff); + SetConstCmt(GetConst(id,0x1a,0xffffffff),"Data Corruption",1); + AddConstEx(id,"ECMERROR_27", 0x1b, 0xffffffff); + AddConstEx(id,"ECMERROR_28", 0x1c, 0xffffffff); + AddConstEx(id,"ECMERROR_29", 0x1d, 0xffffffff); + AddConstEx(id,"ECMERROR_30", 0x1e, 0xffffffff); + AddConstEx(id,"ECMERROR_31", 0x1f, 0xffffffff); + AddConstEx(id,"ECMERROR_32", 0x20, 0xffffffff); + AddConstEx(id,"ECMERROR_33", 0x21, 0xffffffff); + AddConstEx(id,"ECMERROR_106", 0x6a, 0xffffffff); + AddConstEx(id,"ECMERROR_147", 0x93, 0xffffffff); + AddConstEx(id,"ECMERROR_149", 0x95, 0xffffffff); + id = AddEnum(-1,"Bits",0x1100000); + SetEnumBf(id,1); + AddConstEx(id,"Bit0", 0x1, 0x1); + AddConstEx(id,"Bit1", 0x2, 0x2); + AddConstEx(id,"Bit2", 0x4, 0x4); + AddConstEx(id,"Bit3", 0x8, 0x8); + AddConstEx(id,"Bit4", 0x10, 0x10); + AddConstEx(id,"Bit5", 0x20, 0x20); + AddConstEx(id,"Bit6", 0x40, 0x40); + AddConstEx(id,"Bit7", 0x80, 0x80); + AddConstEx(id,"Bit8", 0x100, 0x100); + AddConstEx(id,"Bit9", 0x200, 0x200); + AddConstEx(id,"Bit10", 0x400, 0x400); + AddConstEx(id,"Bit11", 0x800, 0x800); + AddConstEx(id,"Bit12", 0x1000, 0x1000); + AddConstEx(id,"Bit13", 0x2000, 0x2000); + AddConstEx(id,"Bit14", 0x4000, 0x4000); + AddConstEx(id,"Bit15", 0x8000, 0x8000); + id = AddEnum(-1,"AirFuelStatus",0x1100000); + SetEnumBf(id,1); + AddConstEx(id,"BaroFaulty", 0x5, 0x5); + id = AddEnum(-1,"Const",0x1100000); + AddConstEx(id,"NUMCYL", 0x6, 0xffffffff); + id = AddEnum(-1,"DTCLBit",0x1100000); + SetEnumBf(id,1); + AddConstEx(id,"DTCBit_L0", 0x1, 0x1); + AddConstEx(id,"DTCBit_L1", 0x2, 0x2); + AddConstEx(id,"DTCBit_L2", 0x4, 0x4); + AddConstEx(id,"DTCBit_L3", 0x8, 0x8); + AddConstEx(id,"DTCBit_L4", 0x10, 0x10); + AddConstEx(id,"DTCBit_L5", 0x20, 0x20); + AddConstEx(id,"DTCBit_L6", 0x40, 0x40); + AddConstEx(id,"DTCBit_L7", 0x80, 0x80); + id = AddEnum(-1,"DTCHBit",0x1100000); + SetEnumBf(id,1); + AddConstEx(id,"DTCFieldA_H0", 0x1, 0x1); + SetConstCmt(GetConst(id,0x1,0x1),"Select member 0",1); + AddConstEx(id,"DTCFieldB_H1", 0x2, 0x2); + SetConstCmt(GetConst(id,0x2,0x2),"Select member 1",1); + AddConstEx(id,"DTCFieldC_H2", 0x4, 0x4); + SetConstCmt(GetConst(id,0x4,0x4),"Select member 2",1); + AddConstEx(id,"DTCFieldD_H3", 0x8, 0x8); + SetConstCmt(GetConst(id,0x8,0x8),"Select member 3",1); + AddConstEx(id,"DTCBit_H4", 0x10, 0x10); + AddConstEx(id,"DTCBit_H5", 0x20, 0x20); + AddConstEx(id,"DTCBit_H6", 0x40, 0x40); + AddConstEx(id,"DTCBit_H7", 0x80, 0x80); + id = AddEnum(-1,"DTC",0x1100000); + AddConstEx(id,"DTC_P1402", 0x1, 0xffffffff); + SetConstCmt(GetConst(id,0x1,0xffffffff),"EGR Valve Circ Short to B+",1); + AddConstEx(id,"DTC_P0402", 0x2, 0xffffffff); + SetConstCmt(GetConst(id,0x2,0xffffffff),"EGR - Excessive Flow",1); + AddConstEx(id,"DTC_P1456", 0x3, 0xffffffff); + SetConstCmt(GetConst(id,0x3,0xffffffff),"Exhaust gas temperature control bank 1 limit attained",1); + AddConstEx(id,"DTC_P1460", 0x4, 0xffffffff); + SetConstCmt(GetConst(id,0x4,0xffffffff),"Exhaust gas temperature control bank 2 limit attained",1); + AddConstEx(id,"DTC_P1461", 0x5, 0xffffffff); + SetConstCmt(GetConst(id,0x5,0xffffffff),"Exhaust gas temperature control bank 1 Range/Performance",1); + AddConstEx(id,"DTC_P1462", 0x6, 0xffffffff); + SetConstCmt(GetConst(id,0x6,0xffffffff),"Exhaust gas temperature control bank 2 Range/Performance",1); + AddConstEx(id,"DTC_P1453", 0x7, 0xffffffff); + SetConstCmt(GetConst(id,0x7,0xffffffff),"Exhaust gas temperature sensor 1 open/short to B+",1); + AddConstEx(id,"DTC_P1457", 0x8, 0xffffffff); + SetConstCmt(GetConst(id,0x8,0xffffffff),"Exhaust gas temperature sensor 2 open/short to B+",1); + AddConstEx(id,"DTC_P0321", 0x9, 0xffffffff); + SetConstCmt(GetConst(id,0x9,0xffffffff),"Ign./Distributor Eng.Speed Inp.Circ Range/Performance",1); + AddConstEx(id,"DTC_P0571", 0xa, 0xffffffff); + SetConstCmt(GetConst(id,0xa,0xffffffff),"Cruise/Brake Switch (A) Circ Malfunction",1); + AddConstEx(id,"DTC_P1639", 0xb, 0xffffffff); + SetConstCmt(GetConst(id,0xb,0xffffffff),"Accelera.Pedal Pos.Sensor 1+2 Range/Performance",1); + AddConstEx(id,"DTC_P1629", 0xc, 0xffffffff); + SetConstCmt(GetConst(id,0xc,0xffffffff),"Data-Bus Powertrain missing message from distance control",1); + AddConstEx(id,"DTC_P1645", 0xd, 0xffffffff); + SetConstCmt(GetConst(id,0xd,0xffffffff),"Data Bus Powertrain missing message f.all wheel drive contr.",1); + AddConstEx(id,"DTC_P1853", 0xe, 0xffffffff); + SetConstCmt(GetConst(id,0xe,0xffffffff),"Data-Bus Powertrain Unplausible Message from Brake Contr.",1); + AddConstEx(id,"DTC_P1649", 0xf, 0xffffffff); + SetConstCmt(GetConst(id,0xf,0xffffffff),"Data Bus Powertrain Missing message from ABS Control Module",1); + AddConstEx(id,"DTC_P1626", 0x10, 0xffffffff); + SetConstCmt(GetConst(id,0x10,0xffffffff),"Data-Bus Powertrain Missing Message from Transm.Contr.",1); + AddConstEx(id,"DTC_P1648", 0x11, 0xffffffff); + SetConstCmt(GetConst(id,0x11,0xffffffff),"Data Bus Powertrain Malfunction",1); + AddConstEx(id,"DTC_P1650", 0x12, 0xffffffff); + SetConstCmt(GetConst(id,0x12,0xffffffff),"Data Bus Powertrain Missing message fr.instrument panel ECU",1); + AddConstEx(id,"DTC_P1628", 0x13, 0xffffffff); + SetConstCmt(GetConst(id,0x13,0xffffffff),"Data-Bus Powertrain missing message from steering sensor",1); + AddConstEx(id,"DTC_P1544_1", 0x14, 0xffffffff); + SetConstCmt(GetConst(id,0x14,0xffffffff),"Throttle Actuation Potentiometer Signal too High",1); + AddConstEx(id,"DTC_P1544", 0x15, 0xffffffff); + SetConstCmt(GetConst(id,0x15,0xffffffff),"Throttle Actuation Potentiometer Signal too High",1); + AddConstEx(id,"DTC_P1173", 0x16, 0xffffffff); + SetConstCmt(GetConst(id,0x16,0xffffffff),"Throttle Actuation Potentiometer Sign.2 Signal too High",1); + AddConstEx(id,"DTC_P1602", 0x17, 0xffffffff); + SetConstCmt(GetConst(id,0x17,0xffffffff),"Power Supply (B+) Terminal 30 Low Voltage",1); + AddConstEx(id,"DTC_P0238", 0x18, 0xffffffff); + SetConstCmt(GetConst(id,0x18,0xffffffff),"Turbocharger Boost Sensor (A) Circ High Input",1); + AddConstEx(id,"DTC_P0108", 0x19, 0xffffffff); + SetConstCmt(GetConst(id,0x19,0xffffffff),"MAP - Hi",1); + AddConstEx(id,"DTC_P1387", 0x1a, 0xffffffff); + SetConstCmt(GetConst(id,0x1a,0xffffffff),"Internal Contr. Module altitude sensor error",1); + AddConstEx(id,"DTC_P0106", 0x1b, 0xffffffff); + SetConstCmt(GetConst(id,0x1b,0xffffffff),"Manifold Abs.Pressure or Bar.Pressure Range/Performance",1); + AddConstEx(id,"DTC_P1604_1", 0x1c, 0xffffffff); + SetConstCmt(GetConst(id,0x1c,0xffffffff),"Internal Control Module Driver Error",1); + AddConstEx(id,"DTC_P1568_0", 0x1d, 0xffffffff); + SetConstCmt(GetConst(id,0x1d,0xffffffff),"Idle Speed Contr.Throttle Pos. mechanical Malfunction",1); + AddConstEx(id,"DTC_P1568_1", 0x1e, 0xffffffff); + SetConstCmt(GetConst(id,0x1e,0xffffffff),"Idle Speed Contr.Throttle Pos. mechanical Malfunction",1); + AddConstEx(id,"DTC_P1545", 0x1f, 0xffffffff); + SetConstCmt(GetConst(id,0x1f,0xffffffff),"Throttle Pos.Contr Malfunction",1); + AddConstEx(id,"DTC_P1559_1", 0x20, 0xffffffff); + SetConstCmt(GetConst(id,0x20,0xffffffff),"Idle Speed Contr.Throttle Pos. Adaptation Malfunction",1); + AddConstEx(id,"DTC_P1545_1", 0x21, 0xffffffff); + SetConstCmt(GetConst(id,0x21,0xffffffff),"Throttle Pos.Contr Malfunction",1); + AddConstEx(id,"DTC_P1579_1", 0x22, 0xffffffff); + SetConstCmt(GetConst(id,0x22,0xffffffff),"Idle Speed Contr.Throttle Pos. Adaptation not started",1); + AddConstEx(id,"DTC_P1565", 0x23, 0xffffffff); + SetConstCmt(GetConst(id,0x23,0xffffffff),"Idle Speed Control Throttle Position lower limit not attained",1); + AddConstEx(id,"DTC_P1579", 0x24, 0xffffffff); + SetConstCmt(GetConst(id,0x24,0xffffffff),"Idle Speed Contr.Throttle Pos. Adaptation not started",1); + AddConstEx(id,"DTC_P1559", 0x25, 0xffffffff); + SetConstCmt(GetConst(id,0x25,0xffffffff),"Idle Speed Contr.Throttle Pos. Adaptation Malfunction",1); + AddConstEx(id,"DTC_P1604", 0x26, 0xffffffff); + SetConstCmt(GetConst(id,0x26,0xffffffff),"Internal Control Module Driver Error",1); + AddConstEx(id,"DTC_P1141", 0x27, 0xffffffff); + SetConstCmt(GetConst(id,0x27,0xffffffff),"Load Calculation Cross Check Range/Performance",1); + AddConstEx(id,"DTC_P1677", 0x28, 0xffffffff); + SetConstCmt(GetConst(id,0x28,0xffffffff),"Drive by Wire-MIL Circ. Short to B+",1); + AddConstEx(id,"DTC_P1258", 0x29, 0xffffffff); + SetConstCmt(GetConst(id,0x29,0xffffffff),"Engine Coolant System Valve Short to B+",1); + AddConstEx(id,"DTC_P1213", 0x2a, 0xffffffff); + SetConstCmt(GetConst(id,0x2a,0xffffffff),"Cyl.1-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1216", 0x2b, 0xffffffff); + SetConstCmt(GetConst(id,0x2b,0xffffffff),"Cyl.4-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1215", 0x2c, 0xffffffff); + SetConstCmt(GetConst(id,0x2c,0xffffffff),"Cyl.3-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1218", 0x2d, 0xffffffff); + SetConstCmt(GetConst(id,0x2d,0xffffffff),"Cyl.6-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1214", 0x2e, 0xffffffff); + SetConstCmt(GetConst(id,0x2e,0xffffffff),"Cyl.2-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1217", 0x2f, 0xffffffff); + SetConstCmt(GetConst(id,0x2f,0xffffffff),"Cyl.5-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1219", 0x30, 0xffffffff); + SetConstCmt(GetConst(id,0x30,0xffffffff),"Cyl.7-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1220", 0x31, 0xffffffff); + SetConstCmt(GetConst(id,0x31,0xffffffff),"Cyl.8-Fuel Inj.Circ. Short to B+",1); + AddConstEx(id,"DTC_P1631", 0x32, 0xffffffff); + SetConstCmt(GetConst(id,0x32,0xffffffff),"Accelera.Pedal Pos.Sensor 1 Signal too High",1); + AddConstEx(id,"DTC_P1634", 0x33, 0xffffffff); + SetConstCmt(GetConst(id,0x33,0xffffffff),"Accelera.Pedal Pos.Sensor 2 Signal too High",1); + AddConstEx(id,"DTC_P1631_1", 0x34, 0xffffffff); + SetConstCmt(GetConst(id,0x34,0xffffffff),"Accelera.Pedal Pos.Sensor 1 Signal too High",1); + AddConstEx(id,"DTC_P1128_0", 0x35, 0xffffffff); + SetConstCmt(GetConst(id,0x35,0xffffffff),"Long Term Fuel Trim mult.,Bank1 System too Lean",1); + AddConstEx(id,"DTC_P1130_0", 0x36, 0xffffffff); + SetConstCmt(GetConst(id,0x36,0xffffffff),"Long Term Fuel Trim mult.,Bank2 System too Lean",1); + AddConstEx(id,"DTC_P1128_1", 0x37, 0xffffffff); + SetConstCmt(GetConst(id,0x37,0xffffffff),"Long Term Fuel Trim mult.,Bank1 System too Lean",1); + AddConstEx(id,"DTC_P1130_1", 0x38, 0xffffffff); + SetConstCmt(GetConst(id,0x38,0xffffffff),"Long Term Fuel Trim mult.,Bank2 System too Lean",1); + AddConstEx(id,"DTC_P1111", 0x39, 0xffffffff); + SetConstCmt(GetConst(id,0x39,0xffffffff),"O2 Control (Bank 1) System too lean",1); + AddConstEx(id,"DTC_P1147", 0x3a, 0xffffffff); + SetConstCmt(GetConst(id,0x3a,0xffffffff),"O2 Control (Bank 2) System too lean",1); + AddConstEx(id,"DTC_P1612", 0x3b, 0xffffffff); + SetConstCmt(GetConst(id,0x3b,0xffffffff),"Electronic Control Module Incorrect Coding",1); + AddConstEx(id,"DTC_P1569", 0x3c, 0xffffffff); + SetConstCmt(GetConst(id,0x3c,0xffffffff),"Cruise control switch Incorrect signal",1); + AddConstEx(id,"DTC_P1114", 0x3d, 0xffffffff); + SetConstCmt(GetConst(id,0x3d,0xffffffff),"Bank1-Sensor2 Internal Resistance too High",1); + AddConstEx(id,"DTC_P1140", 0x3e, 0xffffffff); + SetConstCmt(GetConst(id,0x3e,0xffffffff),"Bank2-Sensor2 Internal Resistance too High",1); + AddConstEx(id,"DTC_P1105", 0x3f, 0xffffffff); + SetConstCmt(GetConst(id,0x3f,0xffffffff),"O2 Sensor Heating Circ.,Bank1-Sensor2 Short to B+",1); + AddConstEx(id,"DTC_P1110", 0x40, 0xffffffff); + SetConstCmt(GetConst(id,0x40,0xffffffff),"O2 Sensor Heating Circ.,Bank2-Sensor2 Short to B+",1); + AddConstEx(id,"DTC_P1102", 0x41, 0xffffffff); + SetConstCmt(GetConst(id,0x41,0xffffffff),"O2 Sensor Heating Circ.,Bank1-Sensor1 Short to B+",1); + AddConstEx(id,"DTC_P1107", 0x42, 0xffffffff); + SetConstCmt(GetConst(id,0x42,0xffffffff),"O2 Sensor Heating Circ.,Bank2-Sensor1 Short to B+",1); + AddConstEx(id,"DTC_P0422", 0x43, 0xffffffff); + SetConstCmt(GetConst(id,0x43,0xffffffff),"Main Catalyst,Bank1 Efficiency Below Threshold",1); + AddConstEx(id,"DTC_P0432", 0x44, 0xffffffff); + SetConstCmt(GetConst(id,0x44,0xffffffff),"Main Catalyst,Bank2 Efficiency Below Threshold",1); + AddConstEx(id,"DTC_P1502", 0x45, 0xffffffff); + SetConstCmt(GetConst(id,0x45,0xffffffff),"Fuel Pump Relay Circ. Short to B+",1); + AddConstEx(id,"DTC_P1325", 0x46, 0xffffffff); + SetConstCmt(GetConst(id,0x46,0xffffffff),"Cyl.1-Knock Contr. -Limit Attained",1); + AddConstEx(id,"DTC_P1328", 0x47, 0xffffffff); + SetConstCmt(GetConst(id,0x47,0xffffffff),"Cyl.4-Knock Contr. -Limit Attained",1); + AddConstEx(id,"DTC_P1327", 0x48, 0xffffffff); + SetConstCmt(GetConst(id,0x48,0xffffffff),"Cyl.3-Knock Contr. Limit Attained",1); + AddConstEx(id,"DTC_P1330", 0x49, 0xffffffff); + SetConstCmt(GetConst(id,0x49,0xffffffff),"Cyl.6-Knock Contr. Limit Attained",1); + AddConstEx(id,"DTC_P1326", 0x4a, 0xffffffff); + SetConstCmt(GetConst(id,0x4a,0xffffffff),"Cyl.2-Knock Contr. Limit Attained",1); + AddConstEx(id,"DTC_P1329", 0x4b, 0xffffffff); + SetConstCmt(GetConst(id,0x4b,0xffffffff),"Cyl.5-Knock Contr. Limit Attained",1); + AddConstEx(id,"DTC_P1331", 0x4c, 0xffffffff); + SetConstCmt(GetConst(id,0x4c,0xffffffff),"Cyl.7-Knock Contr. Limit Attained",1); + AddConstEx(id,"DTC_P1332", 0x4d, 0xffffffff); + SetConstCmt(GetConst(id,0x4d,0xffffffff),"Cyl.8-Knock Contr. Limit Attained",1); + AddConstEx(id,"DTC_P1386_1", 0x4e, 0xffffffff); + SetConstCmt(GetConst(id,0x4e,0xffffffff),"Internal Control Module Knock Control Circ.Error",1); + AddConstEx(id,"DTC_P1386_0", 0x4f, 0xffffffff); + SetConstCmt(GetConst(id,0x4f,0xffffffff),"Internal Control Module Knock Control Circ.Error",1); + AddConstEx(id,"DTC_P1386", 0x50, 0xffffffff); + SetConstCmt(GetConst(id,0x50,0xffffffff),"Internal Control Module Knock Control Circ.Error",1); + AddConstEx(id,"DTC_P0328", 0x51, 0xffffffff); + SetConstCmt(GetConst(id,0x51,0xffffffff),"Knock Sensor 1 Circ High Input",1); + AddConstEx(id,"DTC_P0333", 0x52, 0xffffffff); + SetConstCmt(GetConst(id,0x52,0xffffffff),"Knock Sensor 2 Circ High Input",1); + AddConstEx(id,"DTC_P1322", 0x53, 0xffffffff); + SetConstCmt(GetConst(id,0x53,0xffffffff),"Knock Sensor 3 Circ. High Input",1); + AddConstEx(id,"DTC_P1324", 0x54, 0xffffffff); + SetConstCmt(GetConst(id,0x54,0xffffffff),"Knock Sensor 4 Circ. High Input",1); + AddConstEx(id,"DTC_P1539", 0x55, 0xffffffff); + SetConstCmt(GetConst(id,0x55,0xffffffff),"Clutch Vacuum Vent Valve Switch Incorrect signal",1); + AddConstEx(id,"DTC_P0139", 0x56, 0xffffffff); + SetConstCmt(GetConst(id,0x56,0xffffffff),"O2 Sensor Circ.,Bank1-Sensor2 Slow Response",1); + AddConstEx(id,"DTC_P0159", 0x57, 0xffffffff); + SetConstCmt(GetConst(id,0x57,0xffffffff),"O2 Sensor Circ.,Bank2-Sensor2 Slow Response",1); + AddConstEx(id,"DTC_P0133", 0x58, 0xffffffff); + SetConstCmt(GetConst(id,0x58,0xffffffff),"O2 Sensor Circ.,Bank1-Sensor1 Slow Response",1); + AddConstEx(id,"DTC_P0153", 0x59, 0xffffffff); + SetConstCmt(GetConst(id,0x59,0xffffffff),"O2 Sensor Circ.,Bank2-Sensor1 Slow Response",1); + AddConstEx(id,"DTC_P1176", 0x5a, 0xffffffff); + SetConstCmt(GetConst(id,0x5a,0xffffffff),"O2 Correction Behind Catalyst,B1 Limit Attained",1); + AddConstEx(id,"DTC_P1177", 0x5b, 0xffffffff); + SetConstCmt(GetConst(id,0x5b,0xffffffff),"O2 Correction Behind Catalyst,B2 Limit Attained",1); + AddConstEx(id,"DTC_P1546", 0x5c, 0xffffffff); + SetConstCmt(GetConst(id,0x5c,0xffffffff),"Boost Pressure Contr.Valve Short to B+",1); + AddConstEx(id,"DTC_P1555", 0x5d, 0xffffffff); + SetConstCmt(GetConst(id,0x5d,0xffffffff),"Charge Pressure -Upper Limit exceeded",1); + AddConstEx(id,"DTC_P1475", 0x5e, 0xffffffff); + SetConstCmt(GetConst(id,0x5e,0xffffffff),"EVAP Emission Contr.LDP Circ Malfunction/Signal Circ.Open",1); + AddConstEx(id,"DTC_P1471", 0x5f, 0xffffffff); + SetConstCmt(GetConst(id,0x5f,0xffffffff),"EVAP Emission Contr.LDP Circ Short to B+",1); + AddConstEx(id,"DTC_P1557", 0x60, 0xffffffff); + SetConstCmt(GetConst(id,0x60,0xffffffff),"Charge Pressure Contr. -Positive Deviation",1); + AddConstEx(id,"DTC_P0507", 0x61, 0xffffffff); + SetConstCmt(GetConst(id,0x61,0xffffffff),"Idle Control System Higher than Expected",1); + AddConstEx(id,"DTC_P0103", 0x62, 0xffffffff); + SetConstCmt(GetConst(id,0x62,0xffffffff),"Mass or Volume Air Flow Circ High Input",1); + AddConstEx(id,"DTC_P0138", 0x63, 0xffffffff); + SetConstCmt(GetConst(id,0x63,0xffffffff),"O2 Sensor Circ.,Bank1-Sensor2 High Voltage",1); + AddConstEx(id,"DTC_P0158", 0x64, 0xffffffff); + SetConstCmt(GetConst(id,0x64,0xffffffff),"O2 Sensor Circ.,Bank2-Sensor2 High Voltage",1); + AddConstEx(id,"DTC_P0132", 0x65, 0xffffffff); + SetConstCmt(GetConst(id,0x65,0xffffffff),"O2 Sensor Circ.,Bank1-Sensor1 High Voltage",1); + AddConstEx(id,"DTC_P0152", 0x66, 0xffffffff); + SetConstCmt(GetConst(id,0x66,0xffffffff),"O2 Sensor Circ.,Bank2-Sensor1 High Voltage",1); + AddConstEx(id,"DTC_P0300", 0x67, 0xffffffff); + SetConstCmt(GetConst(id,0x67,0xffffffff),"Random/Multiple Cylinder Misfire Detected",1); + AddConstEx(id,"DTC_P0301", 0x68, 0xffffffff); + SetConstCmt(GetConst(id,0x68,0xffffffff),"Cyl.1 Misfire Detected",1); + AddConstEx(id,"DTC_P0304", 0x69, 0xffffffff); + SetConstCmt(GetConst(id,0x69,0xffffffff),"Cyl.4 Misfire Detected",1); + AddConstEx(id,"DTC_P1336", 0x6e, 0xffffffff); + SetConstCmt(GetConst(id,0x6e,0xffffffff),"Engine Torque Monitoring - Adaptation at limit",1); + AddConstEx(id,"DTC_P0300_1", 0x6f, 0xffffffff); + SetConstCmt(GetConst(id,0x6f,0xffffffff),"Random/Multiple Cylinder Misfire Detected",1); + AddConstEx(id,"DTC_P0301_1", 0x70, 0xffffffff); + SetConstCmt(GetConst(id,0x70,0xffffffff),"Cyl.1 Misfire Detected",1); + AddConstEx(id,"DTC_P0304_1", 0x71, 0xffffffff); + SetConstCmt(GetConst(id,0x71,0xffffffff),"Cyl.4 Misfire Detected",1); + AddConstEx(id,"DTC_P0303", 0x72, 0xffffffff); + SetConstCmt(GetConst(id,0x72,0xffffffff),"Cyl.3 Misfire Detected",1); + AddConstEx(id,"DTC_P1693", 0x76, 0xffffffff); + SetConstCmt(GetConst(id,0x76,0xffffffff),"Malfunction Indication Light -Short circuit to B+",1); + AddConstEx(id,"DTC_P0322", 0x77, 0xffffffff); + SetConstCmt(GetConst(id,0x77,0xffffffff),"Ign./Distributor Eng.Speed Inp.Circ No Signal",1); + AddConstEx(id,"DTC_P1347", 0x78, 0xffffffff); + SetConstCmt(GetConst(id,0x78,0xffffffff),"Bank2,Crankshaft-/Camshaft os.Sens.Sign. Out of Sequence",1); + AddConstEx(id,"DTC_P1340", 0x79, 0xffffffff); + SetConstCmt(GetConst(id,0x79,0xffffffff),"Crankshaft-/Camshaft Pos.Sens.Signals Out of Sequence",1); + AddConstEx(id,"DTC_P1522", 0x7a, 0xffffffff); + SetConstCmt(GetConst(id,0x7a,0xffffffff),"Intake Camshaft Contr.,Bank2 Malfunction",1); + AddConstEx(id,"DTC_P1519", 0x7b, 0xffffffff); + SetConstCmt(GetConst(id,0x7b,0xffffffff),"Intake Camshaft Contr.,Bank1 Malfunction",1); + AddConstEx(id,"DTC_P1529", 0x7c, 0xffffffff); + SetConstCmt(GetConst(id,0x7c,0xffffffff),"Camshaft Control Circuit Short to B+",1); + AddConstEx(id,"DTC_P1560", 0x7d, 0xffffffff); + SetConstCmt(GetConst(id,0x7d,0xffffffff),"Maximum Engine Speed Exceeded",1); + AddConstEx(id,"DTC_P1392", 0x7e, 0xffffffff); + SetConstCmt(GetConst(id,0x7e,0xffffffff),"Camshaft Pos.Sensor,Bank2 Open Circ./Short to B+",1); + AddConstEx(id,"DTC_P1338", 0x7f, 0xffffffff); + SetConstCmt(GetConst(id,0x7f,0xffffffff),"Internal Contr. Module drive by wire error",1); + AddConstEx(id,"DTC_P1606", 0x80, 0xffffffff); + SetConstCmt(GetConst(id,0x80,0xffffffff),"Rough Road Spec Engine Torque ABS-ECU Electrical Malfunction",1); + AddConstEx(id,"DTC_P1136_0", 0x81, 0xffffffff); + SetConstCmt(GetConst(id,0x81,0xffffffff),"Long Term Fuel Trim Add.Fuel,Bank1 System too Lean",1); + AddConstEx(id,"DTC_P1138_0", 0x82, 0xffffffff); + SetConstCmt(GetConst(id,0x82,0xffffffff),"Long Term Fuel Trim Add.Fuel,Bank2 System too Lean",1); + AddConstEx(id,"DTC_P1136_1", 0x83, 0xffffffff); + SetConstCmt(GetConst(id,0x83,0xffffffff),"Long Term Fuel Trim Add.Fuel,Bank1 System too Lean",1); + AddConstEx(id,"DTC_P1138_1", 0x84, 0xffffffff); + SetConstCmt(GetConst(id,0x84,0xffffffff),"Long Term Fuel Trim Add.Fuel,Bank2 System too Lean",1); + AddConstEx(id,"DTC_P1640", 0x85, 0xffffffff); + SetConstCmt(GetConst(id,0x85,0xffffffff),"Internal Control Module (EEPROM) Error",1); + AddConstEx(id,"DTC_P1434", 0x86, 0xffffffff); + SetConstCmt(GetConst(id,0x86,0xffffffff),"Sec.Air Inj.Sys.Pump Relay Circ. Short to B+",1); + AddConstEx(id,"DTC_P1423", 0x87, 0xffffffff); + SetConstCmt(GetConst(id,0x87,0xffffffff),"Sec.Air Inj.Sys.,Bank1 Flow too Low",1); + AddConstEx(id,"DTC_P1411", 0x88, 0xffffffff); + SetConstCmt(GetConst(id,0x88,0xffffffff),"Sec.Air Inj.Sys.,Bank2 Flow too Flow",1); + AddConstEx(id,"DTC_P1424", 0x89, 0xffffffff); + SetConstCmt(GetConst(id,0x89,0xffffffff),"Sec.Air Inj.Sys.,Bank1 Leak Detected",1); + AddConstEx(id,"DTC_P1414", 0x8a, 0xffffffff); + SetConstCmt(GetConst(id,0x8a,0xffffffff),"Sec.Air Inj.Sys.,Bank2 Leak Detected",1); + AddConstEx(id,"DTC_P1422", 0x8b, 0xffffffff); + SetConstCmt(GetConst(id,0x8b,0xffffffff),"Sec.Air Inj.Sys.Contr.Valve Circ Short to B+",1); + AddConstEx(id,"DTC_P1002", 0x8c, 0xffffffff); + AddConstEx(id,"DTC_P1512", 0x8d, 0xffffffff); + SetConstCmt(GetConst(id,0x8d,0xffffffff),"Intake Manifold Changeover Valve circuit Short to B+",1); + AddConstEx(id,"DTC_P1606_1", 0x8e, 0xffffffff); + SetConstCmt(GetConst(id,0x8e,0xffffffff),"Rough Road Spec Engine Torque ABS-ECU Electrical Malfunction",1); + AddConstEx(id,"DTC_P0112", 0x8f, 0xffffffff); + SetConstCmt(GetConst(id,0x8f,0xffffffff),"Intake Air Temp.Circ Low Input",1); + AddConstEx(id,"DTC_P1250", 0x90, 0xffffffff); + SetConstCmt(GetConst(id,0x90,0xffffffff),"Fuel too low",1); + AddConstEx(id,"DTC_P0441", 0x91, 0xffffffff); + SetConstCmt(GetConst(id,0x91,0xffffffff),"EVAP Emission Contr.Sys.Incorrect Purge Flow",1); + AddConstEx(id,"DTC_P0442", 0x92, 0xffffffff); + SetConstCmt(GetConst(id,0x92,0xffffffff),"EVAP Emission Contr.Sys.(Small Leak) Leak Detected",1); + AddConstEx(id,"DTC_P0455", 0x93, 0xffffffff); + SetConstCmt(GetConst(id,0x93,0xffffffff),"EVAP Emission Contr.Sys.(Gross Leak) Leak Detected",1); + AddConstEx(id,"DTC_P1410", 0x94, 0xffffffff); + SetConstCmt(GetConst(id,0x94,0xffffffff),"Tank Ventilation Valve Circ. Short to B+",1); + AddConstEx(id,"DTC_P1467", 0x95, 0xffffffff); + SetConstCmt(GetConst(id,0x95,0xffffffff),"EVAP Canister Purge Solenoid Valve Short Circuit to B+",1); + AddConstEx(id,"DTC_P0117", 0x96, 0xffffffff); + SetConstCmt(GetConst(id,0x96,0xffffffff),"Engine Coolant Temp.Circ Low Input",1); + AddConstEx(id,"DTC_P1620", 0x97, 0xffffffff); + SetConstCmt(GetConst(id,0x97,0xffffffff),"Engine coolant temperature signal open/short to B+",1); + AddConstEx(id,"DTC_P0197", 0x98, 0xffffffff); + SetConstCmt(GetConst(id,0x98,0xffffffff),"Engine Oil Temperature Circuit Low Input",1); + AddConstEx(id,"DTC_P1029", 0x99, 0xffffffff); + AddConstEx(id,"DTC_P0601", 0x9a, 0xffffffff); + SetConstCmt(GetConst(id,0x9a,0xffffffff),"ECM - Checksum",1); + AddConstEx(id,"DTC_P0563", 0x9b, 0xffffffff); + SetConstCmt(GetConst(id,0x9b,0xffffffff),"System Voltage High Voltage",1); + AddConstEx(id,"DTC_P1335", 0x9c, 0xffffffff); + SetConstCmt(GetConst(id,0x9c,0xffffffff),"Engine Torque Monitoring 2 Control Limit Exceeded",1); + AddConstEx(id,"DTC_P1388", 0x9d, 0xffffffff); + SetConstCmt(GetConst(id,0x9d,0xffffffff),"Internal Contr. Module drive by wire error",1); + AddConstEx(id,"DTC_P0604", 0x9e, 0xffffffff); + SetConstCmt(GetConst(id,0x9e,0xffffffff),"Memory (RAM) Error",1); + AddConstEx(id,"DTC_P0605", 0x9f, 0xffffffff); + SetConstCmt(GetConst(id,0x9f,0xffffffff),"Internal Contr. Module ROM Test Error",1); + AddConstEx(id,"DTC_P1603", 0xa0, 0xffffffff); + SetConstCmt(GetConst(id,0xa0,0xffffffff),"Internal Control Module Malfunction",1); + AddConstEx(id,"DTC_P1288", 0xa1, 0xffffffff); + SetConstCmt(GetConst(id,0xa1,0xffffffff),"Turbocharger bypass valve short to B+",1); + AddConstEx(id,"DTC_P0501", 0xa2, 0xffffffff); + SetConstCmt(GetConst(id,0xa2,0xffffffff),"Vehicle Speed Sensor Range/Performance",1); + AddConstEx(id,"DTC_P1570", 0xa3, 0xffffffff); + SetConstCmt(GetConst(id,0xa3,0xffffffff),"Control Module Locked",1); + AddConstEx(id,"DTC_P0606", 0xa4, 0xffffffff); + SetConstCmt(GetConst(id,0xa4,0xffffffff),"ECM - Watchdog",1); + AddConstEx(id,"DTC_P1356", 0xa5, 0xffffffff); + SetConstCmt(GetConst(id,0xa5,0xffffffff),"Cyl. 1, ignition circuit Short to B+",1); + AddConstEx(id,"DTC_P1365", 0xa6, 0xffffffff); + SetConstCmt(GetConst(id,0xa6,0xffffffff),"Cyl. 4, ignition circuit Short circuit to B+",1); + AddConstEx(id,"DTC_P1362", 0xa7, 0xffffffff); + SetConstCmt(GetConst(id,0xa7,0xffffffff),"Cyl. 3, ignition circuit Short Circuit to B+",1); + AddConstEx(id,"DTC_P1371", 0xa8, 0xffffffff); + SetConstCmt(GetConst(id,0xa8,0xffffffff),"Cyl. 6, ignition circuit Short Circuit to B+",1); + AddConstEx(id,"DTC_P1359", 0xa9, 0xffffffff); + SetConstCmt(GetConst(id,0xa9,0xffffffff),"Cyl. 2, ignition circuit Short Circuit to B+",1); + AddConstEx(id,"DTC_P1368", 0xaa, 0xffffffff); + SetConstCmt(GetConst(id,0xaa,0xffffffff),"Cyl. 5, ignition circuit Short Circuit to B+",1); + AddConstEx(id,"DTC_P1374", 0xab, 0xffffffff); + SetConstCmt(GetConst(id,0xab,0xffffffff),"Cyl. 7, ignition circuit Short Circuit to B+",1); + AddConstEx(id,"DTC_P1377", 0xac, 0xffffffff); + SetConstCmt(GetConst(id,0xac,0xffffffff),"Cyl. 8, ignition circuit Short Circuit to B+",1); + AddConstEx(id,"DTC_MAX", 0xad, 0xffffffff); + SetConstCmt(GetConst(id,0xad,0xffffffff),"Maximum number of DTC blocks",1); + id = AddEnum(-1,"LOCALVAR",0x1100000); + AddConstEx(id,"LOCALVAR_0", 0x0, 0xffffffff); + AddConstEx(id,"LOCALVAR_1", 0x1, 0xffffffff); + AddConstEx(id,"LOCALVAR_2", 0x2, 0xffffffff); + AddConstEx(id,"LOCALVAR_3", 0x3, 0xffffffff); + AddConstEx(id,"LOCALVAR_4", 0x4, 0xffffffff); + AddConstEx(id,"LOCALVAR_5", 0x5, 0xffffffff); + AddConstEx(id,"LOCALVAR_6", 0x6, 0xffffffff); + AddConstEx(id,"LOCALVAR_7", 0x7, 0xffffffff); + AddConstEx(id,"LOCALVAR_8", 0x8, 0xffffffff); + AddConstEx(id,"LOCALVAR_9", 0x9, 0xffffffff); + AddConstEx(id,"LOCALVAR_10", 0xa, 0xffffffff); + AddConstEx(id,"LOCALVAR_11", 0xb, 0xffffffff); + AddConstEx(id,"LOCALVAR_12", 0xc, 0xffffffff); + AddConstEx(id,"LOCALVAR_13", 0xd, 0xffffffff); + AddConstEx(id,"LOCALVAR_14", 0xe, 0xffffffff); + AddConstEx(id,"LOCALVAR_15", 0xf, 0xffffffff); + AddConstEx(id,"LOCALVAR_16", 0x10, 0xffffffff); + AddConstEx(id,"LOCALVAR_17", 0x11, 0xffffffff); + AddConstEx(id,"LOCALVAR_18", 0x12, 0xffffffff); + AddConstEx(id,"LOCALVAR_19", 0x13, 0xffffffff); + AddConstEx(id,"LOCALVAR_20", 0x14, 0xffffffff); + AddConstEx(id,"LOCALVAR_21", 0x15, 0xffffffff); + AddConstEx(id,"LOCALVAR_22", 0x16, 0xffffffff); + AddConstEx(id,"LOCALVAR_23", 0x17, 0xffffffff); + AddConstEx(id,"LOCALVAR_24", 0x18, 0xffffffff); + AddConstEx(id,"LOCALVAR_25", 0x19, 0xffffffff); + AddConstEx(id,"LOCALVAR_26", 0x1a, 0xffffffff); + id = AddEnum(-1,"FLASH_OPS",0x1100000); + AddConstEx(id,"FLASH_OPS_0", 0x0, 0xffffffff); + AddConstEx(id,"FLASH_OPS_1", 0x1, 0xffffffff); + AddConstEx(id,"FLASH_OPS_2", 0x2, 0xffffffff); + AddConstEx(id,"FLASH_OPS_3", 0x3, 0xffffffff); + AddConstEx(id,"FLASH_OPS_4", 0x4, 0xffffffff); + AddConstEx(id,"FLASH_OPS_5", 0x5, 0xffffffff); + AddConstEx(id,"FLASH_OPS_6", 0x6, 0xffffffff); + id = AddEnum(-1,"LOGIC",0x1100000); + AddConstEx(id,"FALSE", 0x0, 0xffffffff); + AddConstEx(id,"TRUE", 0x1, 0xffffffff); +} + +//------------------------------------------------------------------------ +// Information about enum types + +static Enums(void) { + auto id; + id = Enums_0(id); +} + +static Structures_0(id) { + +// if (AskYN(1,"Do you want to define structures?") != 1) +// return; + + Message("++++++++++++++++++++\n"); + Message("Creating Structures \n"); + Message("++++++++++++++++++++\n"); + + id = AddStrucEx(-1,"strDTC_Struct",0); + SetStrucComment(id,"DTC Structure",1); + id = AddStrucEx(-1,"SeedLookup",0); + id = AddStrucEx(-1,"ADCCheck",0); + id = AddStrucEx(-1,"strChkSumBlock",0); + id = AddStrucEx(-1,"strDTC_Store",0); + + id = GetStrucIdByName("strDTC_Struct"); + AddStrucMember(id,"DTC1", 0x0, 0x10100400, -1, 2); + AddStrucMember(id,"DTC2", 0x2, 0x10100400, -1, 2); + AddStrucMember(id,"DTC3", 0x4, 0x10100400, -1, 2); + AddStrucMember(id,"DTC4", 0x6, 0x10100400, -1, 2); + + id = GetStrucIdByName("SeedLookup"); + AddStrucMember(id,"Seed", 0x0, 0x10000400, -1, 4); + + id = GetStrucIdByName("ADCCheck"); + AddStrucMember(id,"bField_0", 0x0, 0x10000400, -1, 2); + AddStrucMember(id,"bField_2", 0x2, 0x10000400, -1, 2); + AddStrucMember(id,"ValueA", 0x4, 0x10000400, -1, 2); + AddStrucMember(id,"ValueB", 0x6, 0x10000400, -1, 2); + + id = GetStrucIdByName("strChkSumBlock"); + AddStrucMember(id,"StartAddr", 0x0, 0x10100400, -1, 2); + AddStrucMember(id,"StartSeg", 0x2, 0x10100400, -1, 2); + AddStrucMember(id,"EndAddr", 0x4, 0x10100400, -1, 2); + AddStrucMember(id,"EndSeg", 0x6, 0x10100400, -1, 2); + AddStrucMember(id,"ChksumLo", 0x8, 0x10100400, -1, 2); + SetMemberComment(id, 0x8, "Chksum Lo", 1); + AddStrucMember(id,"ChksumHi", 0xa, 0x10100400, -1, 2); + SetMemberComment(id, 0xa, "Chksum Hi", 1); + AddStrucMember(id,"InvChksumLo", 0xc, 0x10100400, -1, 2); + SetMemberComment(id, 0xc, "Chksum Lo inverted", 1); + AddStrucMember(id,"InvChksumHi", 0xe, 0x10100400, -1, 2); + SetMemberComment(id, 0xe, "Chksum Hi inverted", 1); + + id = GetStrucIdByName("strDTC_Store"); + AddStrucMember(id,"field_0", 0x0, 0x000400, -1, 1); + AddStrucMember(id,"DTCA_Hi", 0x1, 0x100400, -1, 1); + AddStrucMember(id,"DTCA_Lo", 0x2, 0x100400, -1, 1); + AddStrucMember(id,"DTCB_Hi", 0x3, 0x100400, -1, 1); + AddStrucMember(id,"DTCB_Lo", 0x4, 0x100400, -1, 1); + AddStrucMember(id,"field_5", 0x5, 0x000400, -1, 1); + AddStrucMember(id,"field_6", 0x6, 0x000400, -1, 1); + AddStrucMember(id,"field_7", 0x7, 0x000400, -1, 1); + AddStrucMember(id,"field_8", 0x8, 0x000400, -1, 1); + AddStrucMember(id,"field_9", 0x9, 0x000400, -1, 1); + AddStrucMember(id,"field_A", 0xa, 0x000400, -1, 1); + AddStrucMember(id,"field_B", 0xb, 0x000400, -1, 1); + AddStrucMember(id,"field_C", 0xc, 0x000400, -1, 1); + AddStrucMember(id,"field_D", 0xd, 0x000400, -1, 1); +} + +//------------------------------------------------------------------------ +// Information about structure types + +static Structures(void) { + auto id; + id = Structures_0(id); +} + +//------------------------------------------------------------------------ +// Information about bytes + +static Bytes_0(void) { + auto x; +#define id x + +// ExtLinA (0x0, 0, "; GOLF 4 R32 3.2L V6"); + ExtLinA (0x0, 1, "; Disassembly by Andy Whittaker"); + ExtLinA (0x0, 2, "; http://www.andywhittaker.com/"); + +// MakeRptCmt (0x812d10, "This is a test repeat comment at 0x812d10"); +// MakeWord (x=0x812d10); +// OpHex (x, 0); +// MakeName (0x812d10, "TestName_812D10"); +} + +static Bytes(void) { + Bytes_0(); +} + +static DTC_Enum(void) { +auto string; + + +// if (AskYN(1,"Do you want to search for and translate DTC Enumerations?") != 1) +// return; + + Message("+++++++++++++++++++++++++++++++++++++++++++++++\n"); + Message("Searching and translating enumerations for DTCs \n"); + Message("+++++++++++++++++++++++++++++++++++++++++++++++\n"); + + string = "bfldh"; + MakeC16xEnum(0x800000,string); + string = "bfldl"; + MakeC16xEnum(0x800000,string); + + Message("\nDTC Enum search complete!\n"); +} + +//converts a C16x bitfield instruction to an Bosch Enum +// ea = linear address to search from +// search_string = string to search for +static MakeC16xEnum(ea,search_string) { + +auto enums_found; +auto lin_address; +auto next_address; +auto operand; + + enums_found = 0; + lin_address = 0; + + Message("\nLooking for Enums - Ref %s\n", search_string); + lin_address = FindText(ea,SEARCH_DOWN,0,0,search_string); + while(lin_address != BADADDR) + { + operand = GetOpnd(lin_address, 0); + Message("Found Enum %s at 0x%lx, operand %s", search_string, lin_address, operand); + if ((operand == "r1") | (operand == "r2") | (operand == "r3") | (operand == "r4") | (operand == "r5")) + { + if (search_string == "bfldh") + { + Message(" - Enumerating DTCHBit\n"); + OpEnumEx(lin_address,1,GetEnum("DTCHBit"),0); + } + else if (search_string == "bfldl") + { + Message(" - Enumerating DTCLBit\n"); + OpEnumEx(lin_address,1,GetEnum("DTCLBit"),0); + } + enums_found++; + } + else + Message("- Ignoring\n"); + + lin_address = lin_address + 0x10; + next_address = FindText(lin_address,SEARCH_DOWN | SEARCH_NEXT,0,0,search_string); + lin_address = next_address; // new search point + } + + Message("\nDTC Enum search for %s complete! Enums found = %ld\n", search_string, enums_found); +} + +//This routine increments through the disassembled code and tries to convert +//the segment:offset pairs into a real offset address. Bosch generally uses +//r12 as a table location with the following r13 instruction as the C16x +//segment offset. +//The routine finds the r13 reference, back-tracks 4 bytes to the r12 reference +//and passes this address onto the MakeC16xOffset function. +static TranslateOffsets(void) { +auto string; + +// if (AskYN(1,"Do you want to search for tables?") != 1) +// return; + + Message("++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + Message("Translating offsets in code to reference lookup tables\n"); + Message("++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + string = ", #204h"; + MakC16xOffsetLp(0x800000,0x204,string); + + string = ", #205h"; + MakC16xOffsetLp(0x800000,0x205,string); + + string = ", #206h"; + MakC16xOffsetLp(0x800000,0x206,string); + + string = ", #207h"; + MakC16xOffsetLp(0x800000,0x207,string); + + string = ", #209h"; + MakC16xOffsetLp(0x800000,0x209,string); + + string = ", #20Ah"; + MakC16xOffsetLp(0x800000,0x20a,string); + +// string = ", #20Bh"; +// MakC16xOffsetLp(0x800000,0x20b,string); + +// string = ", #20Ch"; +// MakC16xOffsetLp(0x800000,0x20c,string); + +// string = ", #20Dh"; +// MakC16xOffsetLp(0x800000,0x20d,string); + + Message("\nLookup tables search complete!\n"); + +} + +//converts a C16x table offset to an IDA linear offset over an address range +// ea = linear address to search from +// seg = the segment address the operand relates to +// search_string = string to search for +static MakC16xOffsetLp(ea,seg,search_string) { + +auto tables_found; +auto lin_address; +auto next_address; +auto operand; + + tables_found = 0; + + Message("\nLooking for tables in segment 0x%x (0x%lx) - Ref %s\n", seg, ea, search_string); + lin_address = FindText(ea,SEARCH_DOWN,0,0,search_string); + while(lin_address != BADADDR) + { + operand = GetOpnd(lin_address, 0); + Message("Found reference %s at 0x%lx, operand %s", search_string, lin_address, operand); + if ((operand == "r5") | (operand == "r13") | (operand == "r14") | (operand == "r15")) + { + MakeC16xOffset(lin_address, seg);// Create the table entry at the previous instruction + tables_found++; + } + else + Message("- Ignoring\n"); + lin_address = lin_address + 0x8; + next_address = FindText(lin_address,SEARCH_DOWN | SEARCH_NEXT,0,0,search_string); + lin_address = next_address; // new search point + } + + Message("\nLookup tables found = %ld at segment 0x%lx\n", tables_found, seg); +} + +//converts a C16x table offset to an IDA linear offset +// ea = linear address of instruction +// seg = the segment address the operand relates to +static MakeC16xOffset(ea,seg) { +auto x; +auto offset; +auto table_address; + + x=ea - 0x4; +// MakeCode (x=ea); + //convert the C16x offset into an address + offset = seg * 0x4000; + //create the offset + OpOff (x, 1, offset); + OpOff (x, 129, offset); + table_address = GetOperandValue(x,1) + offset; //find what the table's address is + Message("- Table reference at 0x%lx is probably: 0x%lx\n",x,table_address); + MakeRptCmt(table_address, "Probable Lookup Table"); +} + + +//This routine increments through the disassembled code and tries to convert +//the offsets for conditional jumps into a real addresses. +//The routine finds the jmpi reference, back-tracks 6 bytes to the offset reference +//and passes this address onto the MakeC16xOffset function. +static TranslateJmpi(void) { +auto string; +auto tables_found; +auto lin_address; +auto next_address; +auto segment; +auto table_address; +auto namestr; + +auto instruction;// test string + +// if (AskYN(1,"Do you want to search for jump tables?") != 1) +// return; + + Message("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + Message("Translating jumps in code to reference function jump lookup tables\n"); + Message("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); + + string = "jmpi cc_UC, ["; //what we want to search for + + tables_found = 0; + + lin_address = FindText(0x800000,SEARCH_DOWN,0,0,string); +// lin_address = FindText(0x834000,SEARCH_DOWN,0,0,string); + while(lin_address != BADADDR) + { + // Check where the offset table is by backtracking + // and checking for the add instruction. + if (GetMnem(lin_address - 4) == "add") + { + if (GetMnem(lin_address - 6) == "shl") + { //if we're here, then the table is an offset to the current segment. + + //If the add instruction is directly before the jmpi, + //the offset is an offset from the current segment. + lin_address = lin_address - 4; + segment = (lin_address & 0xff0000); + OpOff(lin_address,1, segment);//Make the offset + table_address = GetOperandValue(lin_address,1) + segment; //find what the table's address is + Message("Offset table reference at 0x%lx is probably: 0x%lx\n",lin_address, table_address); + MakeRptCmt(table_address, "Function Jump Table"); + namestr = "jtbl_"; + namestr = namestr + ltoa(table_address, 16); + MakeName(table_address, ""); + MakeName(table_address, namestr); + } + } + else if (GetMnem(lin_address - 6) == "add") + { + //If the add instruction is not before the jmpi, but a + //mov rx, [rx] is following it, then the offset is from + //the data segment. + lin_address = lin_address - 6; + segment = (lin_address & 0xff0000); +// OpOff(lin_address,1, segment);//Make the offset + OpOff(lin_address,1, 0x810000);//Make the offset + OpOff(lin_address,129, 0x810000); + table_address = GetOperandValue(lin_address,1) + 0x810000; //find what the table's address is +// table_address = GetOperandValue(lin_address,1); //find what the table's address is + Message("Function table reference at 0x%lx is probably: 0x%lx\n",lin_address,table_address); + MakeRptCmt(table_address, "Probable Function Lookup Table"); + namestr = "jtbl_"; + namestr = namestr + ltoa(table_address, 16); + MakeName(table_address, ""); + MakeName(table_address, namestr); + } + + tables_found++; + + lin_address = lin_address + 0x10; + next_address = FindText(lin_address,SEARCH_DOWN | SEARCH_NEXT,0,0,string); + +// if (next_address >= 0x840000) +// break; + lin_address = next_address; // new search point + } + + Message("\nConditional jump search complete! Jump tables found = %ld\n", tables_found); +} + +//Loads a WinOLS csv export +static LoadMapPackCSV(void) { + auto filename; + auto hFHandle; + auto flength; + auto chin; + auto fstring; + auto addressstr; + auto commentstr; + auto arraystr; + auto fstringlength; + auto stringindex; + auto address; + auto namestr; + + if (AskYN(1,"Do you want to import map pack tables?") != 1) + return; + + filename = AskFile(0,"*.csv","Select WinOLS CSV MapPack to import"); // ask a file name + if (filename == 0) + return; + + Message("++++++++++++++++++++++++++++++++++\n"); + Message("Importing Map Pack WinOLS csv file\n"); + Message("++++++++++++++++++++++++++++++++++\n"); + + hFHandle = fopen(filename,"r"); + flength = filelength(hFHandle); + + while(fstring != -1) + { + addressstr = ""; + commentstr = ""; + arraystr = ""; + + //read the first line in + fstring = readstr(hFHandle); + fstringlength = strlen(fstring); + + //check to see if the line contains an address + //if it's an address, the 2nd char will be a $ + if (substr(fstring, 1, 2) == "$") + { + stringindex = 2; + //Read through each character of the string to extract our 3 strings + + //1st the address string + for(;stringindex> 24 ) & 0xff +XX : (seed >> 16 ) & 0xff +YY : (seed >> 8 ) & 0xff +ZZ : (seed ) & 0xff +00 +00 +CS : CRC + +The ECU should respond with + +83 : 3 data bytes +01 +F1 +67 : ISO 14230-3 positive reply +02 : Send Key +34 : Not sure what this means +12 : CRC + +Secure access granted, now you can read/write anything (eeprom etc.) + +Enjoy! diff --git a/SafFunctionSigs.h b/SafFunctionSigs.h new file mode 100644 index 0000000..470a704 --- /dev/null +++ b/SafFunctionSigs.h @@ -0,0 +1,71 @@ +// FunctionSigs.h: function signatures for the BoschHelper class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_BOSCHFUNCTIONSIGS_H__56f34b1a_19D4_4904_923E_1C391DF3A947__INCLUDED_) +#define AFX_BOSCHFUNCTIONSIGS_H__56f34b1a_19D4_4904_923E_1C391DF3A947__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +//FunctionSigs + +//3d array declaration + +#define NUM_SIGS 0x04 + +unsigned char fs_functionnames[NUM_SIGS][255] = { + { "CRC8Sub" }, + {"RSACallingSub"}, + {"CRC32ME71Sub"}, + {"CRC32ME75Sub"} + }; + +unsigned char fs_functioncomments[NUM_SIGS][255] = { + {"Works out a basic CRC8 checksum"}, + {"Deals with the RSA checking"}, + {"Works out the CRC32 checksums"}, + {"Works out the CRC32 checksums"} + }; + +unsigned char fs_sigs[NUM_SIGS][118] = { + //CRC8 + {0x88,0x90,0x88,0x80,0x88,0x70,0x88,0x60,0x28,0x04,0xc2,0xf4,0xff,0xff,0xc2,0xf5, + 0xff,0xff,0x1b,0x45,0xf2,0xf4,0x0e,0xfe,0xc2,0xf2,0xff,0xff,0x1b,0x42,0xf2,0xf5, + 0x0c,0xfe,0xf2,0xf4,0x0e,0xfe,0x26,0xf4,0x98,0xf3,0x36,0xf5,0x28,0x00,0x3d,0x04, + 0x8a,0xff,0x02,0xff,0xea,0x00,0xff,0xff,0xf2,0xf4,0xff,0xff,0x66,0xf4,0x00,0x80, + 0x2d,0x1d,0x84,0x00,0xff,0xff,0xa8,0x40,0x66,0xf4,0x00,0x0f,0x46,0xf4,0x00,0x01, + 0x2d,0x15,0xa8,0x40,0x0a,0xf4,0x02,0x02,0xb8,0x40,0xa8,0x50,0x1a,0xf5,0x20,0x20, + 0xb8,0x50,0xa8,0x40,0x0a,0xf4,0x01,0x01,0xb8,0x40,0xa8,0x50,0x1a,0xf5,0x01,0x0f, + 0xb8,0x50,0x88,0x50,0xe0,0x1c}, + //RSA Calling Sub + {0x8a,0xff,0x52,0xff,0xda,0xff,0xff,0xff,0xf3,0xf8,0xff,0xff,0x2d,0x27,0x25,0x8f, + 0xff,0xff,0xf3,0xfa,0xff,0xff,0x49,0xa5,0xfd,0x19,0xff,0xff,0xff,0xff,0xe6,0xfc, + 0xff,0xff,0xe0,0x0d,0xe6,0xfe,0x10,0x00,0xda,0xff,0xff,0xff,0xe6,0xfc,0xff,0xff, + 0xe0,0x0d,0xe6,0xfe}, + //CRC32 ME71 Sub + {0x88,0x90,0x88,0x80,0x88,0x70,0x88,0x60,0x28,0x06,0xc2,0xf4,0xff,0xff,0xc2,0xf5, + 0xff,0xff,0x1b,0x45,0xf2,0xf4,0x0e,0xfe,0xc2,0xf2,0xff,0xff,0x1b,0x42,0xf2,0xf5, + 0x0c,0xfe,0xf2,0xf4,0x0e,0xfe,0x26,0xf4,0x98,0xf3,0x36,0xf5,0x28,0x00,0xea,0x20, + 0xff,0xff,0xf3,0xf8,0xff,0xbd,0x47,0xf8,0x33,0x00,0xea,0x30,0xff,0xff,0xf3,0xfa, + 0xff,0xbd,0x47,0xfa,0x33,0x00,0xea,0x30,0xff,0xff,0xff,0xff,0xf3,0xf6,0xff,0xff, + 0xea,0x30,0xff,0xff,0xf3,0xf4,0xff,0xff,0x47,0xf4,0x33,0x00,0xea,0x30,0xff,0xff, + 0xe1,0x12,0xf7,0xf2,0xff,0xff,0xe1,0x28,0xf7,0xf8,0xff,0xff,0xf3,0xf8,0xff,0xbd, + 0xf7,0xf8,0xff,0xff,0xf7,0xfa}, + //CRC32 ME75 Sub + {0x88,0x90,0x88,0x80,0x88,0x70,0x88,0x60,0x28,0x06,0xc2,0xf4,0xff,0xa8,0xc2,0xf5, + 0xff,0xa8,0x1b,0x45,0xf2,0xf4,0x0e,0xfe,0xc2,0xf2,0xff,0xa8,0x1b,0x42,0xf2,0xf5, + 0x0c,0xfe,0xf2,0xf4,0x0e,0xfe,0x26,0xf4,0x98,0xf3,0x36,0xf5,0x28,0x00,0xea,0x20, + 0xff,0xff,0xf3,0xf8,0x7a,0xbb,0x47,0xf8,0x33,0x00,0xea,0x30,0xff,0xff,0xf3,0xfa, + 0x8a,0xbb,0x47,0xfa,0x33,0x00,0xea,0x30,0xff,0xff,0x4f,0xff,0xf3,0xf6,0xff,0xa8, + 0xea,0x30,0xff,0xff,0xf3,0xf4,0xff,0xa8,0x47,0xf4,0x33,0x00,0xea,0x30,0xff,0xff, + 0xe1,0x12,0xf7,0xf2,0xff,0xa8,0xe1,0x28,0xf7,0xf8,0xff,0xa8,0xf3,0xf8,0x7a,0xbb, + 0xf7,0xf8,0xff,0xa8,0xf7,0xfa}, + }; + + +unsigned char fs_siglen[NUM_SIGS] = { 118, 52, 118, 118 }; + + +#endif // !defined(AFX_BOSCHFUNCTIONSIGS_H__56f34b1a_19D4_4904_923E_1C391DF3A947__INCLUDED_) diff --git a/TableSigs.cpp b/TableSigs.cpp new file mode 100644 index 0000000..955dae9 --- /dev/null +++ b/TableSigs.cpp @@ -0,0 +1,175 @@ +// TableSigs.cpp: implementation of the TableSigs class. +// +////////////////////////////////////////////////////////////////////// +//Standard Defs +typedef int BOOL; +#define FALSE 0 +#define TRUE 1 +#define NULL 0 + +#include +#include +#include +//#include +#include +#include + +#include "TableSigs.h" //Has all the Table signatures stored within it + +////////////////////////////////////////////////////////////////////// +// Table Signatures +////////////////////////////////////////////////////////////////////// +#define NUM_DATA_SIGS 3 + +unsigned char ts_Tablenames[NUM_DATA_SIGS][255] = + { + {"LineariseMAF"}, + {"LineariseEGT"}, + {"LineariseCTS"} + }; + +unsigned char ts_Tablecomments[NUM_DATA_SIGS][255] = + { + {"Table to linearise the Hot Wire MAF output"}, + {"Table to linearise the EGT output"}, + {"Table to linearise the CTS output"} + }; +unsigned char ts_sigs[NUM_DATA_SIGS][310] = + { + //Linearise MAF + {0x93,0x05,0x9B,0x05,0xA2,0x05,0xAA,0x05,0xB2,0x05,0xB9,0x05,0xC1,0x05,0xC8,0x05}, + //Linearise EGT + {0x12,0x00,0x00,0x00,0x9A,0x19,0x17,0x28,0x39,0x36,0x0B,0x44,0x9D,0x51,0xFA,0x5E}, + //Linearise CTS + {0x14,0x00,0x00,0x00,0x24,0x00,0x2C,0x00,0x38,0x00,0x44,0x00,0x58,0x00,0x70,0x00} + }; + +unsigned int ts_siglen[NUM_DATA_SIGS] = {16, 16, 16}; + +////////////////////////////////////////////////////////////////////// +//,Construction/Destruction +////////////////////////////////////////////////////////////////////// + +TableSigs::TableSigs() +{ +} + +TableSigs::~TableSigs() +{ + +} +////////////////////////////////////////////////////////////////////// +// Helpers +////////////////////////////////////////////////////////////////////// + +//Finds the given binary string in the given binary. If 0xff then this is don't care +ea_t TableSigs::FindBinaryWithDontCare(uchar* ubinstr,unsigned __int32 nSLength,ea_t eaStartAddress,ea_t eaEndAddr) +{ + ea_t eaAddr = BADADDR,eaSearchAddr=0,nIndexA=0,nIndexB=0; + uchar nRead=0; + int iBit = 0; + ulong v=0; + +// ea1stAddr = find_binary(ea_t startea,ea_t endea,ubinstr,16,sflag); +// msg("FindBinaryWithDontCare()"); + for(nIndexA=eaStartAddress; nIndexA < eaEndAddr;) + { + eaAddr = nIndexA;//Store where we are. + nRead = get_8bit(nIndexA,v,iBit);//Read 8bits but remember that nIndexA is automatically incremented + if (nIndexA==BADADDR)//Have we ran out of bytes? + { + return BADADDR; + } + if (nIndexA>= (eaEndAddr-1)) + return BADADDR; + + if(nRead == *ubinstr) + {// We're matched for the 1st char,now check the rest +// msg("FindBinaryWithDontCare() found 0x%x at 0x%x with length %lu\n",nRead, nIndexA, nSLength); + for(nIndexB=1; nIndexB < nSLength; nIndexB++) + { + eaSearchAddr= eaAddr + nIndexB; + if(*(ubinstr+nIndexB) != 0xff) //check for don't care flag + { + nRead = get_8bit(eaSearchAddr,v,iBit); +// msg(": found 0x%x\n",nRead); + if (eaSearchAddr==BADADDR)//Have we ran out of bytes? + { + eaAddr=BADADDR; +// msg(" not found, ran beyond binary address space\n"); + return BADADDR; + } + if(nRead != *(ubinstr+nIndexB)) + { +// msg(" no match.\n"); + eaAddr=BADADDR; + break;// No longer matched,exit this for(..) loop + } + else if(nIndexB==(nSLength-1)) + { +// msg(" binary string matched at 0x%x.\n",eaAddr); + return eaAddr; // String completely matched + } + } +// else +// msg(": ignoring 0xff\n"); + } + } + } +// msg("\n"); + return eaAddr; +} + + +////////////////////////////////////////////////////////////////////// +// Implementation +////////////////////////////////////////////////////////////////////// + +//Looks for specific binary patterns and then makes a table and comments it +void TableSigs::FindTablesAndComment(ea_t eaStartAddr, ea_t eaEndAddr) +{ + msg("Finding Table signatures....\n"); + + unsigned int uIndex=0, iTry=0, iTries=0; + ea_t eaAddr; + char ucBuf[255]; + + for(uIndex=0; uIndex < NUM_DATA_SIGS; uIndex++) + { + msg("\nSearching for %s, len = %lu\n",ts_Tablenames[uIndex], ts_siglen[uIndex]); + for(iTry=eaStartAddr, iTries=0; iTryendEA); + //Try the next set of addresses +// eaAddr=functTable->endEA;// the end of the Table just created. + } + else if(iTries==0) + { + msg(" Try %d, nothing found\n", iTries); + eaAddr+=0x1;//TO DO: Find the length of the Table just created. + break; + } + else + { + msg(" Try %d, no further Tables found\n", iTries); + eaAddr+=0x1;//TO DO: Find the length of the Table just created. + break; + } +// eaAddr+=0x10;//TO DO: Find the length of the Table just created. +// eaAddr=functTable->endEA; + } + } +} \ No newline at end of file diff --git a/TableSigs.h b/TableSigs.h new file mode 100644 index 0000000..150bfe0 --- /dev/null +++ b/TableSigs.h @@ -0,0 +1,28 @@ +// TableSigs.h: interface for the TableSigs class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_TableSIGS_H__C6DB9FEB_257B_46A5_A944_3629C2BFD33C__INCLUDED_) +#define AFX_TableSIGS_H__C6DB9FEB_257B_46A5_A944_3629C2BFD33C__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class TableSigs +{ +public: + TableSigs(); + virtual ~TableSigs(); + +private: + +public: + ea_t FindBinaryWithDontCare(uchar* ubinstr, unsigned __int32 nSLength, ea_t eaStartAddress, ea_t eaEndAddr);//Finds the given binary string in the given binary. If 0xff then this is don't care + +public: + void FindTablesAndComment(ea_t eaStartAddr, ea_t eaEndAddr);//Looks for specific binary patterns and then makes a subroutine and comments it + +}; + +#endif // !defined(AFX_TableSIGS_H__C6DB9FEB_257B_46A5_A944_3629C2BFD33C__INCLUDED_) diff --git a/boschme7x -Pre JoeGrahamCopy.cpp b/boschme7x -Pre JoeGrahamCopy.cpp new file mode 100644 index 0000000..21e4e1f --- /dev/null +++ b/boschme7x -Pre JoeGrahamCopy.cpp @@ -0,0 +1,292 @@ +/* + * This is a sample plugin module + * + * It can be compiled by any of the supported compilers: + * + * - Borland C++, CBuilder, free C++ + * - Watcom C++ for DOS32 + * - Watcom C++ for OS/2 + * - Visual C++ + * + */ + +//Standard Defs +typedef int BOOL; +#define FALSE 0 +#define TRUE 1 +#define NULL 0 + +#include +#include +#include +#include + +//#include +//#include +//#include +//#include +//#include + +#include "BoschHelper.h" + +extern plugin_t PLUGIN; + +BoschHelper boschcode; //our class + +//-------------------------------------------------------------------------- +// Example of a user-defined IDC function in C++ + +static const char myBoschME7xfunc5_args[] = { VT_LONG, VT_STR, 0 }; +static error_t idaapi myfunc5(value_t *argv, value_t *res) +{ + msg("myBoschME7xfunc is called with arg0=%x and arg1=%s\n", argv[0].num, argv[1].str); + res->num = 5; // let's return 5 + return eOk; +} + +//-------------------------------------------------------------------------- +// This callback is called for UI notification events +static int idaapi BoschME7x_callback(void * /*user_data*/, int event_id, va_list /*va*/) +{ + if ( event_id != ui_msg ) // avoid recursion + if ( event_id != ui_setstate + && event_id != ui_showauto + && event_id != ui_refreshmarked ) // ignore uninteresting events + msg("ui_callback %d\n", event_id); + return 0; // 0 means "process the event" + // otherwise the event would be ignored +} + +//-------------------------------------------------------------------------- +// A sample how to generate user-defined line prefixes +static const int prefix_width = 8; + +static void get_user_defined_prefix(ea_t ea, + int lnnum, + int indent, + const char *line, + char *buf, + size_t bufsize) +{ + buf[0] = '\0'; // empty prefix by default + + // We want to display the prefix only the lines which + // contain the instruction itself + + if ( indent != -1 ) return; // a directive + if ( line[0] == '\0' ) return; // empty line + if ( tag_advance(line,1)[-1] == ash.cmnt[0] ) return; // comment line... + + // We don't want the prefix to be printed again for other lines of the + // same instruction/data. For that we remember the line number + // and compare it before generating the prefix + + static ea_t old_ea = BADADDR; + static int old_lnnum; + if ( old_ea == ea && old_lnnum == lnnum ) return; + + // Ok, seems that we found an instruction line. + + // Let's display the size of the current item as the user-defined prefix + ulong our_size = get_item_size(ea); + + // We don't bother about the width of the prefix + // because it will be padded with spaces by the kernel + + qsnprintf(buf, bufsize, " %d", our_size); + + // Remember the address and line number we produced the line prefix for: + old_ea = ea; + old_lnnum = lnnum; + +} + +//-------------------------------------------------------------------------- +// +// Initialize. +// +// IDA will call this function only once. +// If this function returns PLGUIN_SKIP, IDA will never load it again. +// If this function returns PLUGIN_OK, IDA will unload the plugin but +// remember that the plugin agreed to work with the database. +// The plugin will be loaded again if the user invokes it by +// pressing the hotkey or selecting it from the menu. +// After the second load the plugin will stay on memory. +// If this function returns PLUGIN_KEEP, IDA will keep the plugin +// in the memory. In this case the initialization function can hook +// into the processor module and user interface notification points. +// See the hook_to_notification_point() function. +// +// In this example we check the input file format and make the decision. +// You may or may not check any other conditions to decide what you do: +// whether you agree to work with the database or not. +// +int idaapi init(void) +{ + if ( inf.filetype == f_ELF ) return PLUGIN_SKIP; + +// Please uncomment the following line to see how the notification works +// hook_to_notification_point(HT_UI, sample_callback, NULL); +// PLUGIN.flags &= ~PLUGIN_UNL; + +// Please uncomment the following line to see how to the user-defined prefix works +// set_user_defined_prefix(prefix_width, get_user_defined_prefix); + +// Please uncomment the following line to see how to define IDC functions +// set_idc_func("MyBoschME7xFunc5", myfunc5, myfunc5_args); + + const char *options = get_plugin_options("BoschME7x"); + if ( options != NULL ) + warning("command line options: %s", options); + + return (PLUGIN.flags & PLUGIN_UNL) ? PLUGIN_OK : PLUGIN_KEEP; +} + +//-------------------------------------------------------------------------- +// Terminate. +// Usually this callback is empty. +// The plugin should unhook from the notification lists if +// hook_to_notification_point() was used. +// +// IDA will call this function when the user asks to exit. +// This function won't be called in the case of emergency exits. + +void idaapi term(void) +{ + unhook_from_notification_point(HT_UI, BoschME7x_callback); + set_user_defined_prefix(0, NULL); + set_idc_func("MyBoschME7xFunc5", NULL, NULL); +} + +//-------------------------------------------------------------------------- +// +// The plugin method +// +// This is the main function of plugin. +// +// It will be called when the user selects the plugin. +// +// arg - the input argument, it can be specified in +// plugins.cfg file. The default is zero. +// +// + +void idaapi run(int arg) +{ + msg("*******************\n"); + msg("*******************\n"); + msg(" BOSCH Diss Helper \n"); + msg("*******************\n"); + msg("*******************\n"); + +// if ( inf.filetype != f_PE ) return PLUGIN_SKIP; // only for PE files +// ph.id = PLFM_C166 + msg("myBoschME7xfunc - processor is %s, inf.filetype is %d, ph.id is %d\n", inf.procName, inf.filetype, ph.id); +// ExtLinA +// warning("BoschME7x plugin \"line_prefixes\" is called with arg %x\n", arg); + +// msg("just fyi: the current screen address is: %a\n", get_screen_ea()); + +/* if ( !autoIsOk() + && askyn_c(-1, "HIDECANCEL\n" + "The autoanalysis has not finished yet.\n" + "The result might be incomplete. Do you want to continue?") < 0 ) + return;*/ + + BOOL bNewME711 = FALSE; + + if(askyn_c(-1, "HIDECANCEL\n" + "Is this a new Bosch ME7.1.1? (Data table at 0xe00000)") == 1 ) + bNewME711 = TRUE; + else + bNewME711 = FALSE; + + if(askyn_c(-1, "HIDECANCEL\n" + "Define segments? (WARNING: Will delete your existing disassembly!!!)") == 1 ) + { + msg("Calling MakeSegments()\n"); + boschcode.MakeSegments(bNewME711); + } + + if(askyn_c(-1, "HIDECANCEL\n" + "Find Standard Functions and Comment Them?") == 1 ) + { + msg("Calling SearchForFuncSigsAndThenCmt()\n"); + boschcode.SearchForFuncSigsAndThenCmt(bNewME711); + } + + if(askyn_c(-1, "HIDECANCEL\n" + "Disassemble into code?") == 1 ) + { + msg("Calling MakeDissCode()\n"); + boschcode.MakeDissCode(bNewME711); + } + + if(askyn_c(-1, "HIDECANCEL\n" + "Find DTC Flag Settings?") == 1 ) + { + msg("Calling SearchForDTCFlagSetting()\n"); + boschcode.SearchForDTCFlagSetting(bNewME711); + } + + if(askyn_c(-1, "HIDECANCEL\n" + "Find and Create Offsets?") == 1 ) + { + msg("Calling SearchForArrayOffsetsAndThenCreate()\n"); + boschcode.SearchForArrayOffsetsAndThenCreate(bNewME711); + } + + msg("BoschMe7x Finshed.\n"); +} + +//-------------------------------------------------------------------------- +char comment[] = "BoschME7x - Assists in the disassembly of ME7.x ECUs"; + +char help[] = + "BoschME7x plugin module\n" + "\n" + "This module assists the user in disassembling Bosch ME7.x ECUs.\n" + "\n" + "It correctly sets up IDA with the ECU addresses and segments. Additionally,\n" + "it auto disassembles and identifies key routines within the binary.\n"; + + +//-------------------------------------------------------------------------- +// This is the preferred name of the plugin module in the menu system +// The preferred name may be overriden in plugins.cfg file + +char wanted_name[] = "BoschME7x"; + + +// This is the preferred hotkey for the plugin module +// The preferred hotkey may be overriden in plugins.cfg file +// Note: IDA won't tell you if the hotkey is not correct +// It will just disable the hotkey. + +char wanted_hotkey[] = "Alt-1"; + + +//-------------------------------------------------------------------------- +// +// PLUGIN DESCRIPTION BLOCK +// +//-------------------------------------------------------------------------- +plugin_t PLUGIN = +{ + IDP_INTERFACE_VERSION, + PLUGIN_UNL, // plugin flags + init, // initialize + + term, // terminate. this pointer may be NULL. + + run, // invoke plugin + + comment, // long comment about the plugin + // it could appear in the status line + // or as a hint + + help, // multiline help about the plugin + + wanted_name, // the preferred short name of the plugin + wanted_hotkey // the preferred hotkey to run the plugin +}; diff --git a/boschme7x.cpp b/boschme7x.cpp new file mode 100644 index 0000000..4b1ccdb --- /dev/null +++ b/boschme7x.cpp @@ -0,0 +1,321 @@ +/* + * This is a sample plugin module + * + * It can be compiled by any of the supported compilers: + * + * - Borland C++, CBuilder, free C++ + * - Watcom C++ for DOS32 + * - Watcom C++ for OS/2 + * - Visual C++ + * + */ + +//Standard Defs +typedef int BOOL; +#define FALSE 0 +#define TRUE 1 +#define NULL 0 + +#include +#include +#include +#include +#include + +//#include +//#include +//#include +//#include +//#include + +#include "BoschHelper.h" + +extern plugin_t PLUGIN; + +BoschHelper boschcode; //our class + +//-------------------------------------------------------------------------- +// Example of a user-defined IDC function in C++ + +static const char myBoschME7xfunc5_args[] = { VT_LONG, VT_STR, 0 }; +static error_t idaapi myfunc5(idc_value_t *argv, idc_value_t *res) +{ + msg("myBoschME7xfunc is called with arg0=%x and arg1=%s\n", argv[0].num, argv[1].str); + res->num = 5; // let's return 5 + return eOk; +} + +//-------------------------------------------------------------------------- +// This callback is called for UI notification events +static int idaapi BoschME7x_callback(void * /*user_data*/, int event_id, va_list /*va*/) +{ + if ( event_id != ui_msg ) // avoid recursion + if (event_id != ui_obsolete_setstate + && event_id != ui_obsolete_showauto + && event_id != ui_refreshmarked ) // ignore uninteresting events + msg("ui_callback %d\n", event_id); + return 0; // 0 means "process the event" + // otherwise the event would be ignored +} + +//-------------------------------------------------------------------------- +// A sample how to generate user-defined line prefixes +static const int prefix_width = 8; + +static void get_user_defined_prefix(ea_t ea, + int lnnum, + int indent, + const char *line, + char *buf, + size_t bufsize) +{ + buf[0] = '\0'; // empty prefix by default + + // We want to display the prefix only the lines which + // contain the instruction itself + + if ( indent != -1 ) return; // a directive + if ( line[0] == '\0' ) return; // empty line + if ( tag_advance(line,1)[-1] == ash.cmnt[0] ) return; // comment line... + + // We don't want the prefix to be printed again for other lines of the + // same instruction/data. For that we remember the line number + // and compare it before generating the prefix + + static ea_t old_ea = BADADDR; + static int old_lnnum; + if ( old_ea == ea && old_lnnum == lnnum ) return; + + // Ok, seems that we found an instruction line. + + // Let's display the size of the current item as the user-defined prefix + ulong our_size = get_item_size(ea); + + // We don't bother about the width of the prefix + // because it will be padded with spaces by the kernel + + qsnprintf(buf, bufsize, " %d", our_size); + + // Remember the address and line number we produced the line prefix for: + old_ea = ea; + old_lnnum = lnnum; + +} + +//-------------------------------------------------------------------------- +// +// Initialize. +// +// IDA will call this function only once. +// If this function returns PLGUIN_SKIP, IDA will never load it again. +// If this function returns PLUGIN_OK, IDA will unload the plugin but +// remember that the plugin agreed to work with the database. +// The plugin will be loaded again if the user invokes it by +// pressing the hotkey or selecting it from the menu. +// After the second load the plugin will stay on memory. +// If this function returns PLUGIN_KEEP, IDA will keep the plugin +// in the memory. In this case the initialization function can hook +// into the processor module and user interface notification points. +// See the hook_to_notification_point() function. +// +// In this example we check the input file format and make the decision. +// You may or may not check any other conditions to decide what you do: +// whether you agree to work with the database or not. +// +int idaapi init(void) +{ + if ( inf.filetype == f_ELF ) return PLUGIN_SKIP; + +// Please uncomment the following line to see how the notification works +// hook_to_notification_point(HT_UI, sample_callback, NULL); +// PLUGIN.flags &= ~PLUGIN_UNL; + +// Please uncomment the following line to see how to the user-defined prefix works +// set_user_defined_prefix(prefix_width, get_user_defined_prefix); + +// Please uncomment the following line to see how to define IDC functions +// set_idc_func("MyBoschME7xFunc5", myfunc5, myfunc5_args); + + const char *options = get_plugin_options("BoschME7x"); + if ( options != NULL ) + warning("command line options: %s", options); + + return (PLUGIN.flags & PLUGIN_UNL) ? PLUGIN_OK : PLUGIN_KEEP; +} + +//-------------------------------------------------------------------------- +// Terminate. +// Usually this callback is empty. +// The plugin should unhook from the notification lists if +// hook_to_notification_point() was used. +// +// IDA will call this function when the user asks to exit. +// This function won't be called in the case of emergency exits. + +void idaapi term(void) +{ + unhook_from_notification_point(HT_UI, BoschME7x_callback); + set_user_defined_prefix(0, NULL); + set_idc_func_ex("MyBoschME7xFunc5", NULL, NULL, 0); +} + +//-------------------------------------------------------------------------- +// +// The plugin method +// +// This is the main function of plugin. +// +// It will be called when the user selects the plugin. +// +// arg - the input argument, it can be specified in +// plugins.cfg file. The default is zero. +// +// + +void idaapi run(int arg) +{ + unsigned short BOSCH = 0x01; + + unsigned short newBosch = 0x01; + unsigned short defSegs = 0x02; + unsigned short findSandFuncs =0x04; + unsigned short DissAsm = 0x08; + unsigned short findDTC =0x10; + unsigned short createOffsets=0x20; + unsigned short cfg_box_2_answer=0x00; + char label[MAXSTR] = ""; + BOOL bNewME711 = FALSE; + + static const char cfg_box_2 []= + "Select your option for BOSCH Processor\n" + "\n" + "\n" + "\n" + "\n" + "\n" + ">\n"; + + if (BOSCH) + { + if (! AskUsingForm_c(cfg_box_2, &cfg_box_2_answer) ) + { + return; + } + } + + + +// if ( inf.filetype != f_PE ) return PLUGIN_SKIP; // only for PE files +// ph.id = PLFM_C166 + msg("myBoschME7xfunc - processor is %s, inf.filetype is %d, ph.id is %d\n", inf.procName, inf.filetype, ph.id); + msg("just fyi: the current screen address is: %a\n", get_screen_ea()); + msg("newBosch =x%x\n ",newBosch); + + // if ( !autoIsOk()&& askyn_c(-1, "HIDECANCEL\n" +// "The autoanalysis has not finished yet.\n" +// "The result might be incomplete. Do you want to continue?") < 0 )// +// return; + + + + if(newBosch & cfg_box_2_answer) + bNewME711 = TRUE; + else + bNewME711 = FALSE; + + using namespace std; + + string sECU = ""; + + if (bNewME711) + { + sECU = "bNewME711"; + //sECU ="ME761Astra"; + msg("ME711\n"); + } + + if (defSegs & cfg_box_2_answer) + { + msg("Calling MakeSegments()\n"); + boschcode.MakeSegments(sECU); + } + + if(findSandFuncs & cfg_box_2_answer) + { + msg("Calling SearchForFuncSigsAndThenCmt()\n"); + boschcode.SearchForFuncSigsAndThenCmt(sECU); + } + + if(DissAsm & cfg_box_2_answer) + { + msg("Calling MakeDissCode()\n"); + boschcode.MakeDissCode(sECU); + } + + if (findDTC & cfg_box_2_answer) + { + msg("Calling SearchForDTCFlagSetting()\n"); + boschcode.SearchForDTCFlagSetting(sECU); + } + + if (createOffsets & cfg_box_2_answer) + { + msg("Calling SearchForArrayOffsetsAndThenCreate()\n"); + boschcode.SearchForArrayOffsetsAndThenCreate(sECU); + } + + + msg("BoschMe7x finished.\n"); +} + +//-------------------------------------------------------------------------- +char comment[] = "BoschME7x v2.1 - Assists in the disassembly of ME7.x ECUs"; + +char help[] = + "BoschME7x plugin module\n" + "\n" + "This module assists the user in disassembling Bosch ME7.x ECUs.\n" + "\n" + "It correctly sets up IDA with the ECU addresses and segments. Additionally,\n" + "it auto disassembles and identifies key routines within the binary.\n"; + + +//-------------------------------------------------------------------------- +// This is the preferred name of the plugin module in the menu system +// The preferred name may be overriden in plugins.cfg file + +char wanted_name[] = "BoschME7x"; + + +// This is the preferred hotkey for the plugin module +// The preferred hotkey may be overriden in plugins.cfg file +// Note: IDA won't tell you if the hotkey is not correct +// It will just disable the hotkey. + +char wanted_hotkey[] = "Alt-1"; + + +//-------------------------------------------------------------------------- +// +// PLUGIN DESCRIPTION BLOCK +// +//-------------------------------------------------------------------------- +plugin_t PLUGIN = +{ + IDP_INTERFACE_VERSION, + PLUGIN_UNL, // plugin flags + init, // initialize + + term, // terminate. this pointer may be NULL. + + run, // invoke plugin + + comment, // long comment about the plugin + // it could appear in the status line + // or as a hint + + help, // multiline help about the plugin + + wanted_name, // the preferred short name of the plugin + wanted_hotkey // the preferred hotkey to run the plugin +}; diff --git a/boschme7x.sln b/boschme7x.sln new file mode 100644 index 0000000..b0a9197 --- /dev/null +++ b/boschme7x.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boschme7x", "boschme7x.vcxproj", "{8FA89F4D-EBA9-4BDB-97AF-556FAC926BE9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8FA89F4D-EBA9-4BDB-97AF-556FAC926BE9}.Debug|Win32.ActiveCfg = Debug|Win32 + {8FA89F4D-EBA9-4BDB-97AF-556FAC926BE9}.Debug|Win32.Build.0 = Debug|Win32 + {8FA89F4D-EBA9-4BDB-97AF-556FAC926BE9}.Release|Win32.ActiveCfg = Release|Win32 + {8FA89F4D-EBA9-4BDB-97AF-556FAC926BE9}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/boschme7x.vcproj b/boschme7x.vcproj new file mode 100644 index 0000000..5838968 --- /dev/null +++ b/boschme7x.vcproj @@ -0,0 +1,342 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/boschme7x.vcxproj b/boschme7x.vcxproj new file mode 100644 index 0000000..15c0223 --- /dev/null +++ b/boschme7x.vcxproj @@ -0,0 +1,194 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {8FA89F4D-EBA9-4BDB-97AF-556FAC926BE9} + 8.1 + + + + DynamicLibrary + false + Unicode + v141 + + + DynamicLibrary + false + MultiByte + v141 + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + .\Release\ + false + .\Debug\ + false + AllRules.ruleset + + + AllRules.ruleset + + + .plw + .plw + + + $(ProjectName) + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Release/boschme7x.tlb + + + + + MaxSpeed + OnlyExplicitInline + C:\Ida\sdk\include;%(AdditionalIncludeDirectories) + NDEBUG;WIN32;_WINDOWS;_USRDLL;__NT__;__IDP__;MAXSTR=1024;%(PreprocessorDefinitions);__NT__;__IDP__ + true + MultiThreadedDebug + true + .\Release/boschme7x.pch + .\Release/ + .\Release/ + .\Release/ + Level3 + true + StdCall + + + NDEBUG;%(PreprocessorDefinitions) + 0x0809 + + + /export:PLUGIN %(AdditionalOptions) + odbc32.lib;odbccp32.lib;ida.lib;%(AdditionalDependencies) + true + C:\Ida\sdk\lib\x86_win_vc_32;%(AdditionalLibraryDirectories) + .\Release/boschme7x.pdb + .\Release/boschme7x.lib + MachineX86 + c:/ida/plugins/boschme7x.plw + + + true + .\Release/boschme7x.bsc + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Debug/boschme7x.tlb + + + + + Disabled + C:\Ida\sdk\include;%(AdditionalIncludeDirectories) + _DEBUG;__NT__;__IDP__;MAXSTR=1024;WIN32;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);__NT__;__IDP__ + true + EnableFastChecks + MultiThreadedDebug + .\Debug/boschme7x.pch + .\Debug/ + .\Debug/ + .\Debug/ + true + Level3 + true + ProgramDatabase + StdCall + + + _DEBUG;%(PreprocessorDefinitions) + 0x0809 + + + /export:PLUGIN %(AdditionalOptions) + c:/ida/plugins/boschme7x.plw + true + C:\Ida\sdk\lib\x86_win_vc_32;%(AdditionalLibraryDirectories) + true + .\Debug/boschme7x.pdb + true + .\Debug/boschme7x.map + .\Debug/boschme7x.lib + MachineX86 + + + true + .\Debug/boschme7x.bsc + + + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + __WIN32__;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/boschme7x.vcxproj.filters b/boschme7x.vcxproj.filters new file mode 100644 index 0000000..228cab6 --- /dev/null +++ b/boschme7x.vcxproj.filters @@ -0,0 +1,53 @@ + + + + + {b0f223cb-dc9b-4f9a-9765-3d4f29af7c2c} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {3719e080-c770-49cf-877f-bb4083d7bfa3} + h;hpp;hxx;hm;inl + + + {432ca54f-4095-434d-8755-771812a284a4} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/findcrypt.cpp b/findcrypt.cpp new file mode 100644 index 0000000..602bb3d --- /dev/null +++ b/findcrypt.cpp @@ -0,0 +1,254 @@ +// FindCrypt - find constants used in crypto algorithms +// Copyright 2006 Ilfak Guilfanov +// This is a freeware program. +// This copytight message must be kept intact. + +// This plugin looks for constant arrays used in popular crypto algorithms. +// If a crypto algorithm is found, it will rename the appropriate locations +// of the program and put bookmarks on them. + +// Version 2.0 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "findcrypt.hpp" + +//-------------------------------------------------------------------------- +// retrieve the first byte of the specified array +// take into account the byte sex +inline uchar get_first_byte(const array_info_t *a) +{ + const uchar *ptr = (const uchar *)a->array; + if ( !inf.mf ) + return ptr[0]; + return ptr[a->elsize-1]; +} + +//-------------------------------------------------------------------------- +// check that all constant arrays are distinct (no duplicates) +//lint -e528 not used +static void verify_constants(const array_info_t *consts) +{ + typedef std::set strset_t; + strset_t myset; + for ( const array_info_t *ptr=consts; ptr->size != 0; ptr++ ) + { + qstring s((char*)ptr->array, ptr->size); + if ( !myset.insert(s).second ) + error("duplicate array %s!", ptr->name); + } +} + +//-------------------------------------------------------------------------- +// match a constant array against the database at the specified address +static bool match_array_pattern(ea_t ea, const array_info_t *ai) +{ + uchar *ptr = (uchar *)ai->array; + for ( size_t i=0; i < ai->size; i++ ) + { + switch ( ai->elsize ) + { + case 1: + if ( get_byte(ea) != *(uchar*)ptr ) + return false; + break; + case 2: + if ( get_word(ea) != *(ushort*)ptr ) + return false; + break; + case 4: + if ( get_long(ea) != *(uint32*)ptr ) + return false; + break; + case 8: + if ( get_qword(ea)!= *(uint64*)ptr ) + return false; + break; + default: + error("interr: unexpected array '%s' element size %d", + ai->name, ai->elsize); + } + ptr += ai->elsize; + ea += ai->elsize; + } + return true; +} + +//-------------------------------------------------------------------------- +// match a sparse array against the database at the specified address +// NB: all sparse arrays must be word32! +static bool match_sparse_pattern(ea_t ea, const array_info_t *ai) +{ + const word32 *ptr = (const word32*)ai->array; + if ( get_long(ea) != *ptr++ ) + return false; + ea += 4; + for ( size_t i=1; i < ai->size; i++ ) + { + word32 c = *ptr++; + if ( inf.mf ) + c = swap32(c); + // look for the constant in the next N bytes + const size_t N = 64; + uchar mem[N+4]; + get_many_bytes(ea, mem, sizeof(mem)); + int j; + for ( j=0; j < N; j++ ) + if ( *(uint32*)(mem+j) == c ) + break; + if ( j == N ) + return false; + ea += j + 4; + } + return true; +} + +//-------------------------------------------------------------------------- +// mark a location with the name of the algorithm +// use the first free slot for the marker +static void mark_location(ea_t ea, const char *name) +{ + char buf[MAXSTR]; + curloc cl; + cl.ea = ea; + cl.target = ea; + cl.x = 0; + cl.y = 5; + cl.lnnum = 0; + cl.flags = 0; + // find free marked location slot + int i; + for ( i=1; i <= MAX_MARK_SLOT; i++ ) + { + if ( cl.markdesc(i, buf, sizeof(buf)) <= 0 ) + break; + // reuse old "Crypto: " slots + if ( strncmp(buf, "Crypto: ", 7) == 0 && cl.markedpos(&i) == ea ) + break; + } + if ( i <= MAX_MARK_SLOT ) + { + qsnprintf(buf, sizeof(buf), "Crypto: %s", name); + cl.mark(i, NULL, buf); + } +} + +//-------------------------------------------------------------------------- +// try to find constants at the given address range +static void recognize_constants(ea_t ea1, ea_t ea2) +{ + int count = 0; + show_wait_box("Searching for crypto constants..."); + for ( ea_t ea=ea1; ea < ea2; ea=nextaddr(ea) ) + { + if ( (ea % 0x1000) == 0 ) + { + showAddr(ea); + if ( wasBreak() ) + break; + } + uchar b = get_byte(ea); + // check against normal constants + for ( const array_info_t *ptr=non_sparse_consts; ptr->size != 0; ptr++ ) + { + if ( b != get_first_byte(ptr) ) + continue; + if ( match_array_pattern(ea, ptr) ) + { + msg("%a: found const array %s (used in %s)\n", ea, ptr->name, ptr->algorithm); + mark_location(ea, ptr->algorithm); + do_name_anyway(ea, ptr->name); + count++; + break; + } + } + // check against sparse constants + for ( const array_info_t *ptr=sparse_consts; ptr->size != 0; ptr++ ) + { + if ( b != get_first_byte(ptr) ) + continue; + if ( match_sparse_pattern(ea, ptr) ) + { + msg("%a: found sparse constants for %s\n", ea, ptr->algorithm); + mark_location(ea, ptr->algorithm); + count++; + break; + } + } + } + hide_wait_box(); + if ( count != 0 ) + msg("Found %d known constant arrays in total.\n", count); +} + +//-------------------------------------------------------------------------- +// This callback is called for IDP notification events +static int idaapi search_callback(void * /*user_data*/, int event_id, va_list /*va*/) +{ + if ( event_id == processor_t::newfile ) // A new file is loaded (already) + recognize_constants(inf.minEA, inf.maxEA); + return 0; +} + +//-------------------------------------------------------------------------- +void idaapi run(int) +{ + ea_t ea1, ea2; + read_selection(&ea1, &ea2); // if fails, inf.minEA and inf.maxEA will be used + recognize_constants(ea1, ea2); +} + +//-------------------------------------------------------------------------- +int idaapi init(void) +{ +// verify_constants(non_sparse_consts); +// verify_constants(sparse_consts); + // agree to work with any database + hook_to_notification_point(HT_IDP, search_callback, NULL); + return PLUGIN_KEEP; +} + +//-------------------------------------------------------------------------- +void idaapi term(void) +{ + unhook_from_notification_point(HT_IDP, search_callback, NULL); +} + +//-------------------------------------------------------------------------- +static const char help[] = "Find crypt v2"; +static const char comment[] = "Find crypt v2"; +static const char wanted_name[] = "Find crypt v2"; +static const char wanted_hotkey[] = ""; + +//-------------------------------------------------------------------------- +// +// PLUGIN DESCRIPTION BLOCK +// +//-------------------------------------------------------------------------- +plugin_t PLUGIN = +{ + IDP_INTERFACE_VERSION, + PLUGIN_PROC, // plugin flags + init, // initialize + + term, // terminate. this pointer may be NULL. + + run, // invoke plugin + + comment, // long comment about the plugin + // it could appear in the status line + // or as a hint + + help, // multiline help about the plugin + + wanted_name, // the preferred short name of the plugin + wanted_hotkey // the preferred hotkey to run the plugin +}; diff --git a/makefile b/makefile new file mode 100644 index 0000000..b6b7160 --- /dev/null +++ b/makefile @@ -0,0 +1,9 @@ +PROC=boschme7x +!include ..\plugin.mak + +# MAKEDEP dependency list ------------------ +$(F)boschme7x$(O) : $(I)area.hpp $(I)bytes.hpp $(I)expr.hpp $(I)fpro.h \ + $(I)funcs.hpp $(I)help.h $(I)ida.hpp $(I)idp.hpp \ + $(I)kernwin.hpp $(I)lines.hpp $(I)llong.hpp \ + $(I)loader.hpp $(I)nalt.hpp $(I)netnode.hpp $(I)pro.h \ + $(I)segment.hpp $(I)ua.hpp $(I)xref.hpp boschme7x.cpp diff --git a/makefile.gcc b/makefile.gcc new file mode 100644 index 0000000..28b8057 --- /dev/null +++ b/makefile.gcc @@ -0,0 +1,9 @@ +PROC=boschme7x +include ../plugin.gcc.mak + +# MAKEDEP dependency list ------------------ +$(F)boschme7x$(O): $(I)area.hpp $(I)bytes.hpp $(I)fpro.h $(I)funcs.hpp \ + $(I)help.h $(I)ida.hpp $(I)idp.hpp $(I)kernwin.hpp \ + $(I)lines.hpp $(I)llong.hpp $(I)loader.hpp $(I)nalt.hpp \ + $(I)netnode.hpp $(I)pro.h $(I)segment.hpp $(I)ua.hpp \ + $(I)xref.hpp boschme7x.cpp diff --git a/makefile.vc b/makefile.vc new file mode 100644 index 0000000..5032c23 --- /dev/null +++ b/makefile.vc @@ -0,0 +1,9 @@ +PROC=boschme7x +!include ..\plugin.vc.mak + +# MAKEDEP dependency list ------------------ +$(F)boschme7x$(O): $(I)area.hpp $(I)bytes.hpp $(I)fpro.h $(I)funcs.hpp \ + $(I)help.h $(I)ida.hpp $(I)idp.hpp $(I)kernwin.hpp \ + $(I)lines.hpp $(I)llong.hpp $(I)loader.hpp $(I)nalt.hpp \ + $(I)netnode.hpp $(I)pro.h $(I)segment.hpp $(I)ua.hpp \ + $(I)xref.hpp boschme7x.cpp diff --git a/stdio.h b/stdio.h new file mode 100644 index 0000000..8a9e61d --- /dev/null +++ b/stdio.h @@ -0,0 +1,733 @@ +/*** +*stdio.h - definitions/declarations for standard I/O routines +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines the structures, values, macros, and functions +* used by the level 2 I/O ("standard I/O") routines. +* [ANSI/System V] +* +* [Public] +* +****/ + +#pragma once + +#ifndef _INC_STDIO +#define _INC_STDIO + +#include + +/* + * Currently, all MS C compilers for Win32 platforms default to 8 byte + * alignment. + */ +#pragma pack(push,_CRT_PACKING) + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* Buffered I/O macros */ + +#define BUFSIZ 512 + +#ifdef _CRTBLD +/* + * Real default size for stdio buffers + */ +#define _INTERNAL_BUFSIZ 4096 +#define _SMALL_BUFSIZ 512 +#endif /* _CRTBLD */ + +/* + * Default number of supported streams. _NFILE is confusing and obsolete, but + * supported anyway for backwards compatibility. + */ +#define _NFILE _NSTREAM_ + +#define _NSTREAM_ 512 + +/* + * Number of entries in _iob[] (declared below). Note that _NSTREAM_ must be + * greater than or equal to _IOB_ENTRIES. + */ +#define _IOB_ENTRIES 20 + +#define EOF (-1) + + +#ifndef _FILE_DEFINED +struct _iobuf { + char *_ptr; + int _cnt; + char *_base; + int _flag; + int _file; + int _charbuf; + int _bufsiz; + char *_tmpfname; + }; +typedef struct _iobuf FILE; +#define _FILE_DEFINED +#endif /* _FILE_DEFINED */ + + +/* Directory where temporary files may be created. */ + +#define _P_tmpdir "\\" +#define _wP_tmpdir L"\\" + +/* L_tmpnam = length of string _P_tmpdir + * + 1 if _P_tmpdir does not end in "/" or "\", else 0 + * + 12 (for the filename string) + * + 1 (for the null terminator) + * L_tmpnam_s = length of string _P_tmpdir + * + 1 if _P_tmpdir does not end in "/" or "\", else 0 + * + 16 (for the filename string) + * + 1 (for the null terminator) + */ +#define L_tmpnam (sizeof(_P_tmpdir) + 12) +#if __STDC_WANT_SECURE_LIB__ +#define L_tmpnam_s (sizeof(_P_tmpdir) + 16) +#endif /* __STDC_WANT_SECURE_LIB__ */ + + + +/* Seek method constants */ + +#define SEEK_CUR 1 +#define SEEK_END 2 +#define SEEK_SET 0 + + +#define FILENAME_MAX 260 +#define FOPEN_MAX 20 +#define _SYS_OPEN 20 +#define TMP_MAX 32767 /* SHRT_MAX */ +#if __STDC_WANT_SECURE_LIB__ +#define TMP_MAX_S _TMP_MAX_S +#define _TMP_MAX_S 2147483647 /* INT_MAX */ +#endif /* __STDC_WANT_SECURE_LIB__ */ + +/* Define NULL pointer value */ +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else /* __cplusplus */ +#define NULL ((void *)0) +#endif /* __cplusplus */ +#endif /* NULL */ + +/* Declare _iob[] array */ + +#ifndef _STDIO_DEFINED +#ifdef _CRTBLD +/* These functions are for enabling STATIC_CPPLIB functionality */ +#if defined (_DLL) && defined (_M_IX86) +/* Retained for compatibility with VC++ 5.0 and earlier versions */ +_CRTIMP extern FILE * __cdecl __p__iob(void); +#endif /* defined (_DLL) && defined (_M_IX86) */ +#ifndef _M_CEE_PURE +_CRTIMP extern FILE _iob[]; +#endif /* _M_CEE_PURE */ +#endif /* _CRTBLD */ +_CRTIMP FILE * __cdecl __iob_func(void); +#endif /* _STDIO_DEFINED */ + + +/* Define file position type */ + +#ifndef _FPOS_T_DEFINED +typedef __int64 fpos_t; +#define _FPOS_T_DEFINED +#endif /* _FPOS_T_DEFINED */ + +#ifndef _STDSTREAM_DEFINED +#define stdin (&__iob_func()[0]) +#define stdout (&__iob_func()[1]) +#define stderr (&__iob_func()[2]) +#define _STDSTREAM_DEFINED +#endif /* _STDSTREAM_DEFINED */ + +#define _IOREAD 0x0001 +#define _IOWRT 0x0002 + +#define _IOFBF 0x0000 +#define _IOLBF 0x0040 +#define _IONBF 0x0004 + +#define _IOMYBUF 0x0008 +#define _IOEOF 0x0010 +#define _IOERR 0x0020 +#define _IOSTRG 0x0040 +#define _IORW 0x0080 + +/* constants used by _set_output_format */ +#define _TWO_DIGIT_EXPONENT 0x1 + +/* Function prototypes */ + +#ifndef _STDIO_DEFINED + +_Check_return_ _CRTIMP int __cdecl _filbuf(_Inout_ FILE * _File ); +_Check_return_opt_ _CRTIMP int __cdecl _flsbuf(_In_ int _Ch, _Inout_ FILE * _File); + +_Check_return_ _CRTIMP FILE * __cdecl _fsopen(_In_z_ const char * _Filename, _In_z_ const char * _Mode, _In_ int _ShFlag); + +_CRTIMP void __cdecl clearerr(_Inout_ FILE * _File); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_wat_ _CRTIMP errno_t __cdecl clearerr_s(_Inout_ FILE * _File ); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP int __cdecl _fcloseall(void); + +_Check_return_ _CRTIMP FILE * __cdecl _fdopen(_In_ int _FileHandle, _In_z_ const char * _Mode); + +_Check_return_ _CRTIMP int __cdecl feof(_In_ FILE * _File); +_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE * _File); +_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE * _File); +_Check_return_opt_ _CRTIMP int __cdecl fgetc(_Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP int __cdecl _fgetchar(void); +_Check_return_opt_ _CRTIMP int __cdecl fgetpos(_Inout_ FILE * _File , _Out_ fpos_t * _Pos); +_Check_return_opt_ _CRTIMP char * __cdecl fgets(_Out_writes_z_(_MaxCount) char * _Buf, _In_ int _MaxCount, _Inout_ FILE * _File); + +_Check_return_ _CRTIMP int __cdecl _fileno(_In_ FILE * _File); + +#if defined (_DEBUG) && defined (_CRTDBG_MAP_ALLOC) +#pragma push_macro("_tempnam") +#undef _tempnam +#endif /* defined (_DEBUG) && defined (_CRTDBG_MAP_ALLOC) */ + +_Check_return_ _CRTIMP char * __cdecl _tempnam(_In_opt_z_ const char * _DirName, _In_opt_z_ const char * _FilePrefix); + +#if defined (_DEBUG) && defined (_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_tempnam") +#endif /* defined (_DEBUG) && defined (_CRTDBG_MAP_ALLOC) */ + +_Check_return_opt_ _CRTIMP int __cdecl _flushall(void); +_Check_return_ _CRT_INSECURE_DEPRECATE(fopen_s) _CRTIMP FILE * __cdecl fopen(_In_z_ const char * _Filename, _In_z_ const char * _Mode); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_wat_ _CRTIMP errno_t __cdecl fopen_s(_Outptr_result_maybenull_ FILE ** _File, _In_z_ const char * _Filename, _In_z_ const char * _Mode); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const char * _Format, ...); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP int __cdecl fprintf_s(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const char * _Format, ...); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP int __cdecl _fputchar(_In_ int _Ch); +_Check_return_opt_ _CRTIMP int __cdecl fputs(_In_z_ const char * _Str, _Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize*_Count) void * _DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE * _File); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP size_t __cdecl fread_s(_Out_writes_bytes_(_ElementSize*_Count) void * _DstBuf, _In_ size_t _DstSize, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE * _File); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_ _CRT_INSECURE_DEPRECATE(freopen_s) _CRTIMP FILE * __cdecl freopen(_In_z_ const char * _Filename, _In_z_ const char * _Mode, _Inout_ FILE * _File); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_wat_ _CRTIMP errno_t __cdecl freopen_s(_Outptr_result_maybenull_ FILE ** _File, _In_z_ const char * _Filename, _In_z_ const char * _Mode, _Inout_ FILE * _OldFile); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_ _CRT_INSECURE_DEPRECATE(fscanf_s) _CRTIMP int __cdecl fscanf(_Inout_ FILE * _File, _In_z_ _Scanf_format_string_ const char * _Format, ...); +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_fscanf_s_l) _CRTIMP int __cdecl _fscanf_l(_Inout_ FILE * _File, _In_z_ _Scanf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +#pragma warning(push) +#pragma warning(disable:6530) +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP int __cdecl fscanf_s(_Inout_ FILE * _File, _In_z_ _Scanf_s_format_string_ const char * _Format, ...); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP int __cdecl _fscanf_s_l(_Inout_ FILE * _File, _In_z_ _Scanf_s_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +#pragma warning(pop) +_Check_return_opt_ _CRTIMP int __cdecl fsetpos(_Inout_ FILE * _File, _In_ const fpos_t * _Pos); +_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE * _File, _In_ long _Offset, _In_ int _Origin); +_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE * _File); + +_Check_return_opt_ _CRTIMP int __cdecl _fseeki64(_Inout_ FILE * _File, _In_ __int64 _Offset, _In_ int _Origin); +_Check_return_ _CRTIMP __int64 __cdecl _ftelli64(_Inout_ FILE * _File); + +_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size*_Count) const void * _Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE * _File); +_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE * _File); +_Check_return_ _CRTIMP int __cdecl getchar(void); +_Check_return_ _CRTIMP int __cdecl _getmaxstdio(void); +#if __STDC_WANT_SECURE_LIB__ +_CRTIMP char * __cdecl gets_s(_Out_writes_z_(_Size) char * _Buf, _In_ rsize_t _Size); +#endif /* __STDC_WANT_SECURE_LIB__ */ +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(char *, gets_s, char, _Buffer) +__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0(char *, __RETURN_POLICY_SAME, _CRTIMP, gets, _Pre_notnull_ _Post_z_ _Out_writes_z_(((size_t)-1)), char, _Buffer) +_Check_return_ int __cdecl _getw(_Inout_ FILE * _File); +#ifndef _CRT_PERROR_DEFINED +#define _CRT_PERROR_DEFINED +_CRTIMP void __cdecl perror(_In_opt_z_ const char * _ErrMsg); +#endif /* _CRT_PERROR_DEFINED */ +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP +_Check_return_opt_ _CRTIMP int __cdecl _pclose(_Inout_ FILE * _File); +_Check_return_ _CRTIMP FILE * __cdecl _popen(_In_z_ const char * _Command, _In_z_ const char * _Mode); +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ +_Check_return_opt_ _CRTIMP int __cdecl printf(_In_z_ _Printf_format_string_ const char * _Format, ...); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP int __cdecl printf_s(_In_z_ _Printf_format_string_ const char * _Format, ...); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP int __cdecl putc(_In_ int _Ch, _Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP int __cdecl putchar(_In_ int _Ch); +_Check_return_opt_ _CRTIMP int __cdecl puts(_In_z_ const char * _Str); +_Check_return_opt_ _CRTIMP int __cdecl _putw(_In_ int _Word, _Inout_ FILE * _File); +#ifndef _CRT_DIRECTORY_DEFINED +#define _CRT_DIRECTORY_DEFINED +_CRTIMP int __cdecl remove(_In_z_ const char * _Filename); +_Check_return_ _CRTIMP int __cdecl rename(_In_z_ const char * _OldFilename, _In_z_ const char * _NewFilename); +_CRTIMP int __cdecl _unlink(_In_z_ const char * _Filename); +#if !__STDC__ +_CRT_NONSTDC_DEPRECATE(_unlink) _CRTIMP int __cdecl unlink(_In_z_ const char * _Filename); +#endif /* !__STDC__ */ +#endif /* _CRT_DIRECTORY_DEFINED */ +_CRTIMP void __cdecl rewind(_Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP int __cdecl _rmtmp(void); +_Check_return_ _CRT_INSECURE_DEPRECATE(scanf_s) _CRTIMP int __cdecl scanf(_In_z_ _Scanf_format_string_ const char * _Format, ...); +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_scanf_s_l) _CRTIMP int __cdecl _scanf_l(_In_z_ _Scanf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +#pragma warning(push) +#pragma warning(disable:6530) +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl scanf_s(_In_z_ _Scanf_s_format_string_ const char * _Format, ...); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _scanf_s_l(_In_z_ _Scanf_s_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +#pragma warning(pop) +_CRT_INSECURE_DEPRECATE(setvbuf) _CRTIMP void __cdecl setbuf(_Inout_ FILE * _File, _Inout_updates_opt_(BUFSIZ) _Post_readable_size_(0) char * _Buffer); +_Check_return_opt_ _CRTIMP int __cdecl _setmaxstdio(_In_ int _Max); +_Check_return_opt_ _CRTIMP unsigned int __cdecl _set_output_format(_In_ unsigned int _Format); +_Check_return_opt_ _CRTIMP unsigned int __cdecl _get_output_format(void); +_Check_return_opt_ _CRTIMP int __cdecl setvbuf(_Inout_ FILE * _File, _Inout_updates_opt_z_(_Size) char * _Buf, _In_ int _Mode, _In_ size_t _Size); +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _snprintf_s(_Out_writes_z_(_SizeInBytes) char * _DstBuf, _In_ size_t _SizeInBytes, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const char * _Format, ...); +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2_ARGLIST(int, _snprintf_s, _vsnprintf_s, _Post_z_ char, _Dest, _In_ size_t, _MaxCount, _In_z_ _Printf_format_string_ const char *,_Format) +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl sprintf_s(_Out_writes_z_(_SizeInBytes) char * _DstBuf, _In_ size_t _SizeInBytes, _In_z_ _Printf_format_string_ const char * _Format, ...); +#endif /* __STDC_WANT_SECURE_LIB__ */ +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1_ARGLIST(int, sprintf_s, vsprintf_s, _Post_z_ char, _Dest, _In_z_ _Printf_format_string_ const char *, _Format) +_Check_return_ _CRTIMP int __cdecl _scprintf(_In_z_ _Printf_format_string_ const char * _Format, ...); +_Check_return_ _CRT_INSECURE_DEPRECATE(sscanf_s) _CRTIMP int __cdecl sscanf(_In_z_ const char * _Src, _In_z_ _Scanf_format_string_ const char * _Format, ...); +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_sscanf_s_l) _CRTIMP int __cdecl _sscanf_l(_In_z_ const char * _Src, _In_z_ _Scanf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +#pragma warning(push) +#pragma warning(disable:6530) +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl sscanf_s(_In_z_ const char * _Src, _In_z_ _Scanf_s_format_string_ const char * _Format, ...); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _sscanf_s_l(_In_z_ const char * _Src, _In_z_ _Scanf_s_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_snscanf_s) _CRTIMP int __cdecl _snscanf(_In_reads_bytes_(_MaxCount) _Pre_z_ const char * _Src, _In_ size_t _MaxCount, _In_z_ _Scanf_format_string_ const char * _Format, ...); +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_snscanf_s_l) _CRTIMP int __cdecl _snscanf_l(_In_reads_bytes_(_MaxCount) _Pre_z_ const char * _Src, _In_ size_t _MaxCount, _In_z_ _Scanf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _snscanf_s(_In_reads_bytes_(_MaxCount) _Pre_z_ const char * _Src, _In_ size_t _MaxCount, _In_z_ _Scanf_s_format_string_ const char * _Format, ...); +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _snscanf_s_l(_In_reads_bytes_(_MaxCount) _Pre_z_ const char * _Src, _In_ size_t _MaxCount, _In_z_ _Scanf_s_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +#pragma warning(pop) +_Check_return_ _CRT_INSECURE_DEPRECATE(tmpfile_s) _CRTIMP FILE * __cdecl tmpfile(void); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_wat_ _CRTIMP errno_t __cdecl tmpfile_s(_Out_opt_ _Deref_post_valid_ FILE ** _File); +_Check_return_wat_ _CRTIMP errno_t __cdecl tmpnam_s(_Out_writes_z_(_Size) char * _Buf, _In_ rsize_t _Size); +#endif /* __STDC_WANT_SECURE_LIB__ */ +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(errno_t, tmpnam_s, _Post_z_ char, _Buf) +__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0(char *, __RETURN_POLICY_DST, _CRTIMP, tmpnam, _Pre_maybenull_ _Post_z_, char, _Buffer) +_Check_return_opt_ _CRTIMP int __cdecl ungetc(_In_ int _Ch, _Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl vfscanf(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP int __cdecl vfprintf_s(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl vfscanf_s(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP int __cdecl vprintf(_In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl vscanf(_In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP int __cdecl vprintf_s(_In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl vscanf_s(_In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(vsnprintf_s) _CRTIMP int __cdecl vsnprintf(_Out_writes_(_MaxCount) char * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP int __cdecl vsnprintf_s(_Out_writes_z_(_DstSize) char * _DstBuf, _In_ size_t _DstSize, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(int, vsnprintf_s, _Post_z_ char, _Dest, _In_ size_t, _MaxCount, _In_z_ _Printf_format_string_ const char *, _Format, va_list, _Args) +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _vsnprintf_s(_Out_writes_z_(_SizeInBytes) char * _DstBuf, _In_ size_t _SizeInBytes, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(int, _vsnprintf_s, _Post_z_ char, _Dest, _In_ size_t, _MaxCount, _In_z_ _Printf_format_string_ const char *, _Format, va_list, _Args) +#pragma warning(push) +#pragma warning(disable:4793) +__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST_EX(int, __RETURN_POLICY_SAME, _CRTIMP, _snprintf, _vsnprintf, _Pre_notnull_ _Post_maybez_ char, _Out_writes_(_Count) _Post_maybez_, char, _Dest, _In_ size_t, _Count, _In_z_ _Printf_format_string_ const char *, _Format) +#pragma warning(pop) +#if __STDC_WANT_SECURE_LIB__ +_CRTIMP_ALTERNATIVE int __cdecl vsprintf_s(_Out_writes_z_(_SizeInBytes) char * _DstBuf, _In_ size_t _SizeInBytes, _In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2(int, vsprintf_s, _Post_z_ char, _Dest, _In_z_ _Printf_format_string_ const char *, _Format, va_list, _Args) +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl vsscanf_s(const char * _Src, _In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2(int, vsscanf_s, _Post_z_ const char, _Src, _In_z_ _Printf_format_string_ const char *, _Format, va_list, _Args) +#endif /* __STDC_WANT_SECURE_LIB__ */ +#pragma warning(push) +#pragma warning(disable:4793) +__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST(int, __RETURN_POLICY_SAME, _CRTIMP, sprintf, vsprintf, _Pre_notnull_ _Post_z_, char, _Dest, _In_z_ _Printf_format_string_ const char *, _Format) +_Check_return_opt_ _CRTIMP int __cdecl vsscanf(const char * _srcBuf, _In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +#pragma warning(pop) +_Check_return_ _CRTIMP int __cdecl _vscprintf(_In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _snprintf_c(_Out_writes_(_MaxCount) char * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const char * _Format, ...); +_Check_return_opt_ _CRTIMP int __cdecl _vsnprintf_c(_Out_writes_(_MaxCount) char *_DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); + +_Check_return_opt_ _CRTIMP int __cdecl _fprintf_p(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const char * _Format, ...); +_Check_return_opt_ _CRTIMP int __cdecl _printf_p(_In_z_ _Printf_format_string_ const char * _Format, ...); +_Check_return_opt_ _CRTIMP int __cdecl _sprintf_p(_Out_writes_z_(_MaxCount) char * _Dst, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const char * _Format, ...); +_Check_return_opt_ _CRTIMP int __cdecl _vfprintf_p(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vprintf_p(_In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vsprintf_p(_Out_writes_z_(_MaxCount) char * _Dst, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +_Check_return_ _CRTIMP int __cdecl _scprintf_p(_In_z_ _Printf_format_string_ const char * _Format, ...); +_Check_return_ _CRTIMP int __cdecl _vscprintf_p(_In_z_ _Printf_format_string_ const char * _Format, va_list _ArgList); +_CRTIMP int __cdecl _set_printf_count_output(_In_ int _Value); +_CRTIMP int __cdecl _get_printf_count_output(void); + +_Check_return_opt_ _CRTIMP int __cdecl _printf_l(_In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _printf_p_l(_In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _printf_s_l(_In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _vprintf_l(_In_z_ _Printf_format_string_params_(2) const char * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vprintf_p_l(_In_z_ _Printf_format_string_params_(2) const char * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vprintf_s_l(_In_z_ _Printf_format_string_params_(2) const char * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); + +_Check_return_opt_ _CRTIMP int __cdecl _fprintf_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _fprintf_p_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _fprintf_s_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _vfprintf_l(_Inout_ FILE * _File, _In_z_ const char * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vfprintf_p_l(_Inout_ FILE * _File, _In_z_ const char * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vfprintf_s_l(_Inout_ FILE * _File, _In_z_ const char * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); + +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_sprintf_s_l) _CRTIMP int __cdecl _sprintf_l(_Pre_notnull_ _Post_z_ char * _DstBuf, _In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _sprintf_p_l(_Out_writes_z_(_MaxCount) char * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _sprintf_s_l(_Out_writes_z_(_DstSize) char * _DstBuf, _In_ size_t _DstSize, _In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_vsprintf_s_l) _CRTIMP int __cdecl _vsprintf_l(_Pre_notnull_ _Post_z_ char * _DstBuf, _In_z_ const char * _Format, _In_opt_ _locale_t, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vsprintf_p_l(_Out_writes_z_(_MaxCount) char * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(2) const char* _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _vsprintf_s_l(_Out_writes_z_(_DstSize) char * _DstBuf, _In_ size_t _DstSize, _In_z_ _Printf_format_string_params_(2) const char * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); + +_Check_return_opt_ _CRTIMP int __cdecl _scprintf_l(_In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _scprintf_p_l(_In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _vscprintf_l(_In_z_ _Printf_format_string_params_(2) const char * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vscprintf_p_l(_In_z_ _Printf_format_string_params_(2) const char * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); + +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_snprintf_s_l) _CRTIMP int __cdecl _snprintf_l(_Out_writes_(_MaxCount) char * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _snprintf_c_l(_Out_writes_(_MaxCount) char * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _snprintf_s_l(_Out_writes_z_(_DstSize) char * _DstBuf, _In_ size_t _DstSize, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(0) const char * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_vsnprintf_s_l) _CRTIMP int __cdecl _vsnprintf_l(_Out_writes_(_MaxCount) char * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(2) const char * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vsnprintf_c_l(_Out_writes_(_MaxCount) char * _DstBuf, _In_ size_t _MaxCount, const char *, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vsnprintf_s_l(_Out_writes_z_(_DstSize) char * _DstBuf, _In_ size_t _DstSize, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(2) const char* _Format,_In_opt_ _locale_t _Locale, va_list _ArgList); + +#ifndef _WSTDIO_DEFINED + +/* wide function prototypes, also declared in wchar.h */ + +#ifndef WEOF +#define WEOF (wint_t)(0xFFFF) +#endif /* WEOF */ + +_Check_return_ _CRTIMP FILE * __cdecl _wfsopen(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _Mode, _In_ int _ShFlag); + +_Check_return_opt_ _CRTIMP wint_t __cdecl fgetwc(_Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP wint_t __cdecl _fgetwchar(void); +_Check_return_opt_ _CRTIMP wint_t __cdecl fputwc(_In_ wchar_t _Ch, _Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP wint_t __cdecl _fputwchar(_In_ wchar_t _Ch); +_Check_return_ _CRTIMP wint_t __cdecl getwc(_Inout_ FILE * _File); +_Check_return_ _CRTIMP wint_t __cdecl getwchar(void); +_Check_return_opt_ _CRTIMP wint_t __cdecl putwc(_In_ wchar_t _Ch, _Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP wint_t __cdecl putwchar(_In_ wchar_t _Ch); +_Check_return_opt_ _CRTIMP wint_t __cdecl ungetwc(_In_ wint_t _Ch, _Inout_ FILE * _File); + +_Check_return_opt_ _CRTIMP wchar_t * __cdecl fgetws(_Out_writes_z_(_SizeInWords) wchar_t * _Dst, _In_ int _SizeInWords, _Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP int __cdecl fputws(_In_z_ const wchar_t * _Str, _Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP wchar_t * __cdecl _getws_s(_Out_writes_z_(_SizeInWords) wchar_t * _Str, _In_ size_t _SizeInWords); +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(wchar_t *, _getws_s, _Post_z_ wchar_t, _String) +__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0(wchar_t *, __RETURN_POLICY_SAME, _CRTIMP, _getws, _Pre_notnull_ _Post_z_, wchar_t, _String) +_Check_return_opt_ _CRTIMP int __cdecl _putws(_In_z_ const wchar_t * _Str); + +_Check_return_opt_ _CRTIMP int __cdecl fwprintf(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, ...); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP int __cdecl fwprintf_s(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, ...); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP int __cdecl wprintf(_In_z_ _Printf_format_string_ const wchar_t * _Format, ...); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP int __cdecl wprintf_s(_In_z_ _Printf_format_string_ const wchar_t * _Format, ...); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_ _CRTIMP int __cdecl _scwprintf(_In_z_ _Printf_format_string_ const wchar_t * _Format, ...); +_Check_return_opt_ _CRTIMP int __cdecl vfwprintf(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl vfwscanf(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP int __cdecl vfwprintf_s(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl vfwscanf_s(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP int __cdecl vwprintf(_In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl vwscanf(_In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP int __cdecl vwprintf_s(_In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl vwscanf_s(_In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +#endif /* __STDC_WANT_SECURE_LIB__ */ + +#if __STDC_WANT_SECURE_LIB__ +_CRTIMP_ALTERNATIVE int __cdecl swprintf_s(_Out_writes_z_(_SizeInWords) wchar_t * _Dst, _In_ size_t _SizeInWords, _In_z_ _Printf_format_string_ const wchar_t * _Format, ...); +#endif /* __STDC_WANT_SECURE_LIB__ */ +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1_ARGLIST(int, swprintf_s, vswprintf_s, _Post_z_ wchar_t, _Dest, _In_z_ _Printf_format_string_ const wchar_t *, _Format) +#if __STDC_WANT_SECURE_LIB__ +_CRTIMP_ALTERNATIVE int __cdecl vswprintf_s(_Out_writes_z_(_SizeInWords) wchar_t * _Dst, _In_ size_t _SizeInWords, _In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl vswscanf_s(const wchar_t * _Src, _In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +#endif /* __STDC_WANT_SECURE_LIB__ */ +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2(int, vswprintf_s, _Post_z_ wchar_t, _Dest, _In_z_ _Printf_format_string_ const wchar_t *, _Format, va_list, _Args) +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2(int, vswscanf_s, _Post_z_ wchar_t, _Dest, _In_z_ _Printf_format_string_ const wchar_t *, _Format, va_list, _Args) +_Check_return_opt_ _CRTIMP int __cdecl vswscanf(const wchar_t * _srcBuf, _In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); + +_Check_return_opt_ _CRTIMP int __cdecl _swprintf_c(_Out_writes_z_(_SizeInWords) wchar_t * _DstBuf, _In_ size_t _SizeInWords, _In_z_ _Printf_format_string_ const wchar_t * _Format, ...); +_Check_return_opt_ _CRTIMP int __cdecl _vswprintf_c(_Out_writes_z_(_SizeInWords) wchar_t * _DstBuf, _In_ size_t _SizeInWords, _In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); + +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _snwprintf_s(_Out_writes_z_(_SizeInWords) wchar_t * _DstBuf, _In_ size_t _SizeInWords, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const wchar_t * _Format, ...); +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2_ARGLIST(int, _snwprintf_s, _vsnwprintf_s, _Post_z_ wchar_t, _Dest, _In_ size_t, _Count, _In_z_ _Printf_format_string_ const wchar_t *, _Format) +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _vsnwprintf_s(_Out_writes_z_(_SizeInWords) wchar_t * _DstBuf, _In_ size_t _SizeInWords, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(int, _vsnwprintf_s, _Post_z_ wchar_t, _Dest, _In_ size_t, _Count, _In_z_ _Printf_format_string_ const wchar_t *, _Format, va_list, _Args) +#pragma warning(push) +#pragma warning(disable:4793) +__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST_EX(int, __RETURN_POLICY_SAME, _CRTIMP, _snwprintf, _vsnwprintf, _Pre_notnull_ _Post_maybez_ wchar_t, _Out_writes_(_Count) _Post_maybez_, wchar_t, _Dest, _In_ size_t, _Count, _In_z_ _Printf_format_string_ const wchar_t *, _Format) +#pragma warning(pop) + +_Check_return_opt_ _CRTIMP int __cdecl _fwprintf_p(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, ...); +_Check_return_opt_ _CRTIMP int __cdecl _wprintf_p(_In_z_ _Printf_format_string_ const wchar_t * _Format, ...); +_Check_return_opt_ _CRTIMP int __cdecl _vfwprintf_p(_Inout_ FILE * _File, _In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vwprintf_p(_In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _swprintf_p(_Out_writes_z_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const wchar_t * _Format, ...); +_Check_return_opt_ _CRTIMP int __cdecl _vswprintf_p(_Out_writes_z_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +_Check_return_ _CRTIMP int __cdecl _scwprintf_p(_In_z_ _Printf_format_string_ const wchar_t * _Format, ...); +_Check_return_ _CRTIMP int __cdecl _vscwprintf_p(_In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); + +_Check_return_opt_ _CRTIMP int __cdecl _wprintf_l(_In_z_ _Printf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _wprintf_p_l(_In_z_ _Printf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _wprintf_s_l(_In_z_ _Printf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _vwprintf_l(_In_z_ _Printf_format_string_params_(2) const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vwprintf_p_l(_In_z_ _Printf_format_string_params_(2) const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vwprintf_s_l(_In_z_ _Printf_format_string_params_(2) const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); + +_Check_return_opt_ _CRTIMP int __cdecl _fwprintf_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _fwprintf_p_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _fwprintf_s_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _vfwprintf_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_params_(2) const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vfwprintf_p_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_params_(2) const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vfwprintf_s_l(_Inout_ FILE * _File, _In_z_ _Printf_format_string_params_(2) const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); + +_Check_return_opt_ _CRTIMP int __cdecl _swprintf_c_l(_Out_writes_z_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _swprintf_p_l(_Out_writes_z_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _swprintf_s_l(_Out_writes_z_(_DstSize) wchar_t * _DstBuf, _In_ size_t _DstSize, _In_z_ _Printf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP int __cdecl _vswprintf_c_l(_Out_writes_z_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(2) const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP int __cdecl _vswprintf_p_l(_Out_writes_z_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(2) const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _vswprintf_s_l(_Out_writes_z_(_DstSize) wchar_t * _DstBuf, _In_ size_t _DstSize, _In_z_ _Printf_format_string_params_(2) const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); + +_Check_return_ _CRTIMP int __cdecl _scwprintf_l(_In_z_ _Printf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_ _CRTIMP int __cdecl _scwprintf_p_l(_In_z_ _Printf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_ _CRTIMP int __cdecl _vscwprintf_p_l(_In_z_ _Printf_format_string_params_(2) const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); + +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_snwprintf_s_l) _CRTIMP int __cdecl _snwprintf_l(_Out_writes_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _snwprintf_s_l(_Out_writes_z_(_DstSize) wchar_t * _DstBuf, _In_ size_t _DstSize, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_vsnwprintf_s_l) _CRTIMP int __cdecl _vsnwprintf_l(_Out_writes_(_MaxCount) wchar_t * _DstBuf, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(2) const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _vsnwprintf_s_l(_Out_writes_z_(_DstSize) wchar_t * _DstBuf, _In_ size_t _DstSize, _In_ size_t _MaxCount, _In_z_ _Printf_format_string_params_(2) const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); + + +#ifndef _CRT_NON_CONFORMING_SWPRINTFS + +#define _SWPRINTFS_DEPRECATED _CRT_DEPRECATE_TEXT("swprintf has been changed to conform with the ISO C standard, adding an extra character count parameter. To use traditional Microsoft swprintf, set _CRT_NON_CONFORMING_SWPRINTFS.") + +#else /* _CRT_NON_CONFORMING_SWPRINTFS */ + +#define _SWPRINTFS_DEPRECATED + +#endif /* _CRT_NON_CONFORMING_SWPRINTFS */ + +/* we could end up with a double deprecation, disable warnings 4141 and 4996 */ +#pragma warning(push) +#pragma warning(disable:4141 4996 4793) +__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST_EX(int, __RETURN_POLICY_SAME, _SWPRINTFS_DEPRECATED _CRTIMP, _swprintf, _swprintf_s, _vswprintf, vswprintf_s, _Pre_notnull_ _Post_z_, wchar_t, _Dest, _In_z_ _Printf_format_string_ const wchar_t *, _Format) +__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_ARGLIST_EX(int, __RETURN_POLICY_SAME, _SWPRINTFS_DEPRECATED _CRTIMP, __swprintf_l, __vswprintf_l, _vswprintf_s_l, _Pre_notnull_ _Post_z_ wchar_t, _Pre_notnull_ _Post_z_, wchar_t, _Dest, _In_z_ _Printf_format_string_params_(2) const wchar_t *, _Format, _locale_t, _Plocinfo) +#pragma warning(pop) + +#if !defined (RC_INVOKED) && !defined (__midl) +#include +#endif /* !defined (RC_INVOKED) && !defined (__midl) */ + +#ifdef _CRT_NON_CONFORMING_SWPRINTFS +#ifndef __cplusplus +#define swprintf _swprintf +#define vswprintf _vswprintf +#define _swprintf_l __swprintf_l +#define _vswprintf_l __vswprintf_l +#endif /* __cplusplus */ +#endif /* _CRT_NON_CONFORMING_SWPRINTFS */ + +#if defined (_DEBUG) && defined (_CRTDBG_MAP_ALLOC) +#pragma push_macro("_wtempnam") +#undef _wtempnam +#endif /* defined (_DEBUG) && defined (_CRTDBG_MAP_ALLOC) */ + +_Check_return_ _CRTIMP wchar_t * __cdecl _wtempnam(_In_opt_z_ const wchar_t * _Directory, _In_opt_z_ const wchar_t * _FilePrefix); + +#if defined (_DEBUG) && defined (_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_wtempnam") +#endif /* defined (_DEBUG) && defined (_CRTDBG_MAP_ALLOC) */ + +_Check_return_ _CRTIMP int __cdecl _vscwprintf(_In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _ArgList); +_Check_return_ _CRTIMP int __cdecl _vscwprintf_l(_In_z_ _Printf_format_string_params_(2) const wchar_t * _Format, _In_opt_ _locale_t _Locale, va_list _ArgList); +_Check_return_ _CRT_INSECURE_DEPRECATE(fwscanf_s) _CRTIMP int __cdecl fwscanf(_Inout_ FILE * _File, _In_z_ _Scanf_format_string_ const wchar_t * _Format, ...); +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_fwscanf_s_l) _CRTIMP int __cdecl _fwscanf_l(_Inout_ FILE * _File, _In_z_ _Scanf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +#pragma warning(push) +#pragma warning(disable:6530) +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP int __cdecl fwscanf_s(_Inout_ FILE * _File, _In_z_ _Scanf_s_format_string_ const wchar_t * _Format, ...); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP int __cdecl _fwscanf_s_l(_Inout_ FILE * _File, _In_z_ _Scanf_s_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_ _CRT_INSECURE_DEPRECATE(swscanf_s) _CRTIMP int __cdecl swscanf(_In_z_ const wchar_t * _Src, _In_z_ _Scanf_format_string_ const wchar_t * _Format, ...); +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_swscanf_s_l) _CRTIMP int __cdecl _swscanf_l(_In_z_ const wchar_t * _Src, _In_z_ _Scanf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl swscanf_s(_In_z_ const wchar_t *_Src, _In_z_ _Scanf_s_format_string_ const wchar_t * _Format, ...); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _swscanf_s_l(_In_z_ const wchar_t * _Src, _In_z_ _Scanf_s_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_snwscanf_s) _CRTIMP int __cdecl _snwscanf(_In_reads_(_MaxCount) _Pre_z_ const wchar_t * _Src, _In_ size_t _MaxCount, _In_z_ _Scanf_format_string_ const wchar_t * _Format, ...); +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_snwscanf_s_l) _CRTIMP int __cdecl _snwscanf_l(_In_reads_(_MaxCount) _Pre_z_ const wchar_t * _Src, _In_ size_t _MaxCount, _In_z_ _Scanf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _snwscanf_s(_In_reads_(_MaxCount) _Pre_z_ const wchar_t * _Src, _In_ size_t _MaxCount, _In_z_ _Scanf_s_format_string_ const wchar_t * _Format, ...); +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _snwscanf_s_l(_In_reads_(_MaxCount) _Pre_z_ const wchar_t * _Src, _In_ size_t _MaxCount, _In_z_ _Scanf_s_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +_Check_return_ _CRT_INSECURE_DEPRECATE(wscanf_s) _CRTIMP int __cdecl wscanf(_In_z_ _Scanf_format_string_ const wchar_t * _Format, ...); +_Check_return_opt_ _CRT_INSECURE_DEPRECATE(_wscanf_s_l) _CRTIMP int __cdecl _wscanf_l(_In_z_ _Scanf_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +#if __STDC_WANT_SECURE_LIB__ +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl wscanf_s(_In_z_ _Scanf_s_format_string_ const wchar_t * _Format, ...); +#endif /* __STDC_WANT_SECURE_LIB__ */ +_Check_return_opt_ _CRTIMP_ALTERNATIVE int __cdecl _wscanf_s_l(_In_z_ _Scanf_s_format_string_params_(0) const wchar_t * _Format, _In_opt_ _locale_t _Locale, ...); +#pragma warning(pop) + +_Check_return_ _CRTIMP FILE * __cdecl _wfdopen(_In_ int _FileHandle , _In_z_ const wchar_t * _Mode); +_Check_return_ _CRT_INSECURE_DEPRECATE(_wfopen_s) _CRTIMP FILE * __cdecl _wfopen(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _Mode); +_Check_return_wat_ _CRTIMP errno_t __cdecl _wfopen_s(_Outptr_result_maybenull_ FILE ** _File, _In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _Mode); +_Check_return_ _CRT_INSECURE_DEPRECATE(_wfreopen_s) _CRTIMP FILE * __cdecl _wfreopen(_In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _Mode, _Inout_ FILE * _OldFile); +_Check_return_wat_ _CRTIMP errno_t __cdecl _wfreopen_s(_Outptr_result_maybenull_ FILE ** _File, _In_z_ const wchar_t * _Filename, _In_z_ const wchar_t * _Mode, _Inout_ FILE * _OldFile); + +#ifndef _CRT_WPERROR_DEFINED +#define _CRT_WPERROR_DEFINED +_CRTIMP void __cdecl _wperror(_In_opt_z_ const wchar_t * _ErrMsg); +#endif /* _CRT_WPERROR_DEFINED */ +#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP +_Check_return_ _CRTIMP FILE * __cdecl _wpopen(_In_z_ const wchar_t *_Command, _In_z_ const wchar_t * _Mode); +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ +_CRTIMP int __cdecl _wremove(_In_z_ const wchar_t * _Filename); +_Check_return_wat_ _CRTIMP errno_t __cdecl _wtmpnam_s(_Out_writes_z_(_SizeInWords) wchar_t * _DstBuf, _In_ size_t _SizeInWords); +__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(errno_t, _wtmpnam_s, _Post_z_ wchar_t, _Buffer) +__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0(wchar_t *, __RETURN_POLICY_DST, _CRTIMP, _wtmpnam, _Pre_maybenull_ _Post_z_, wchar_t, _Buffer) + +_Check_return_opt_ _CRTIMP wint_t __cdecl _fgetwc_nolock(_Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP wint_t __cdecl _fputwc_nolock(_In_ wchar_t _Ch, _Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP wint_t __cdecl _ungetwc_nolock(_In_ wint_t _Ch, _Inout_ FILE * _File); + +#ifdef _CRTBLD +#define _CRT_GETPUTWCHAR_NOINLINE +#else /* _CRTBLD */ +#undef _CRT_GETPUTWCHAR_NOINLINE +#endif /* _CRTBLD */ + +#if !defined (__cplusplus) || defined (_M_CEE_PURE) || defined (_CRT_GETPUTWCHAR_NOINLINE) +#define getwchar() fgetwc(stdin) +#define putwchar(_c) fputwc((_c),stdout) +#else /* !defined (__cplusplus) || defined (_M_CEE_PURE) || defined (_CRT_GETPUTWCHAR_NOINLINE) */ +inline _Check_return_ wint_t __CRTDECL getwchar() + {return (fgetwc(stdin)); } /* stdin */ +inline _Check_return_opt_ wint_t __CRTDECL putwchar(_In_ wchar_t _C) + {return (fputwc(_C, stdout)); } /* stdout */ +#endif /* !defined (__cplusplus) || defined (_M_CEE_PURE) || defined (_CRT_GETPUTWCHAR_NOINLINE) */ + +#define getwc(_stm) fgetwc(_stm) +#define putwc(_c,_stm) fputwc(_c,_stm) +#define _putwc_nolock(_c,_stm) _fputwc_nolock(_c,_stm) +#define _getwc_nolock(_stm) _fgetwc_nolock(_stm) + +#if defined (_CRT_DISABLE_PERFCRIT_LOCKS) && !defined (_DLL) +#define fgetwc(_stm) _getwc_nolock(_stm) +#define fputwc(_c,_stm) _putwc_nolock(_c,_stm) +#define ungetwc(_c,_stm) _ungetwc_nolock(_c,_stm) +#endif /* defined (_CRT_DISABLE_PERFCRIT_LOCKS) && !defined (_DLL) */ + +#define _WSTDIO_DEFINED +#endif /* _WSTDIO_DEFINED */ + +#define _STDIO_DEFINED +#endif /* _STDIO_DEFINED */ + + +/* Macro definitions */ + +#if defined (_CRT_DISABLE_PERFCRIT_LOCKS) && !defined (_DLL) +#define feof(_stream) ((_stream)->_flag & _IOEOF) +#define ferror(_stream) ((_stream)->_flag & _IOERR) +#define _fileno(_stream) ((_stream)->_file) +#define fgetc(_stream) (--(_stream)->_cnt >= 0 \ + ? 0xff & *(_stream)->_ptr++ : _filbuf(_stream)) +#define putc(_c,_stream) (--(_stream)->_cnt >= 0 \ + ? 0xff & (*(_stream)->_ptr++ = (char)(_c)) : _flsbuf((_c),(_stream))) +#define getc(_stream) fgetc(_stream) +#define getchar() getc(stdin) +#define putchar(_c) putc((_c),stdout) +#endif /* defined (_CRT_DISABLE_PERFCRIT_LOCKS) && !defined (_DLL) */ + + +#define _fgetc_nolock(_stream) (--(_stream)->_cnt >= 0 ? 0xff & *(_stream)->_ptr++ : _filbuf(_stream)) +#define _fputc_nolock(_c,_stream) (--(_stream)->_cnt >= 0 ? 0xff & (*(_stream)->_ptr++ = (char)(_c)) : _flsbuf((_c),(_stream))) +#define _getc_nolock(_stream) _fgetc_nolock(_stream) +#define _putc_nolock(_c, _stream) _fputc_nolock(_c, _stream) +#define _getchar_nolock() _getc_nolock(stdin) +#define _putchar_nolock(_c) _putc_nolock((_c),stdout) +#define _getwchar_nolock() _getwc_nolock(stdin) +#define _putwchar_nolock(_c) _putwc_nolock((_c),stdout) + +_CRTIMP void __cdecl _lock_file(_Inout_ FILE * _File); +_CRTIMP void __cdecl _unlock_file(_Inout_ FILE * _File); + +_Check_return_opt_ _CRTIMP int __cdecl _fclose_nolock(_Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP int __cdecl _fflush_nolock(_Inout_opt_ FILE * _File); +_Check_return_opt_ _CRTIMP size_t __cdecl _fread_nolock(_Out_writes_bytes_(_ElementSize*_Count) void * _DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP size_t __cdecl _fread_nolock_s(_Out_writes_bytes_(_ElementSize*_Count) void * _DstBuf, _In_ size_t _DstSize, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP int __cdecl _fseek_nolock(_Inout_ FILE * _File, _In_ long _Offset, _In_ int _Origin); +_Check_return_ _CRTIMP long __cdecl _ftell_nolock(_Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP int __cdecl _fseeki64_nolock(_Inout_ FILE * _File, _In_ __int64 _Offset, _In_ int _Origin); +_Check_return_ _CRTIMP __int64 __cdecl _ftelli64_nolock(_Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP size_t __cdecl _fwrite_nolock(_In_reads_bytes_(_Size*_Count) const void * _DstBuf, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE * _File); +_Check_return_opt_ _CRTIMP int __cdecl _ungetc_nolock(_In_ int _Ch, _Inout_ FILE * _File); + +#if defined (_CRT_DISABLE_PERFCRIT_LOCKS) && !defined (_DLL) +#define fclose(_stm) _fclose_nolock(_stm) +#define fflush(_stm) _fflush_nolock(_stm) +#define fread(_DstBuf, _ElementSize, _Count, _File) _fread_nolock(_DstBuf, _ElementSize, _Count, _File) +#define fread_s(_DstBuf, _DstSize, _ElementSize, _Count, _File) _fread_nolock_s(_DstBuf, _DstSize, _ElementSize, _Count, _File) +#define fseek(_stm,_offset,_origin) _fseek_nolock(_stm,_offset,_origin) +#define ftell(_stm) _ftell_nolock(_stm) +#define _fseeki64(_stm,_offset,_origin) _fseeki64_nolock(_stm,_offset,_origin) +#define _ftelli64(_stm) _ftelli64_nolock(_stm) +#define fwrite(_buf,_siz,_cnt,_stm) _fwrite_nolock(_buf,_siz,_cnt,_stm) +#define ungetc(_c,_stm) _ungetc_nolock(_c,_stm) +#endif /* defined (_CRT_DISABLE_PERFCRIT_LOCKS) && !defined (_DLL) */ + +#if !__STDC__ + +/* Non-ANSI names for compatibility */ + +#define P_tmpdir _P_tmpdir +#define SYS_OPEN _SYS_OPEN + +#if defined (_DEBUG) && defined (_CRTDBG_MAP_ALLOC) +#pragma push_macro("tempnam") +#undef tempnam +#endif /* defined (_DEBUG) && defined (_CRTDBG_MAP_ALLOC) */ + +_CRT_NONSTDC_DEPRECATE(_tempnam) _CRTIMP char * __cdecl tempnam(_In_opt_z_ const char * _Directory, _In_opt_z_ const char * _FilePrefix); + +#if defined (_DEBUG) && defined (_CRTDBG_MAP_ALLOC) +#pragma pop_macro("tempnam") +#endif /* defined (_DEBUG) && defined (_CRTDBG_MAP_ALLOC) */ + +_Check_return_opt_ _CRT_NONSTDC_DEPRECATE(_fcloseall) _CRTIMP int __cdecl fcloseall(void); +_Check_return_ _CRT_NONSTDC_DEPRECATE(_fdopen) _CRTIMP FILE * __cdecl fdopen(_In_ int _FileHandle, _In_z_ const char * _Format); +_Check_return_opt_ _CRT_NONSTDC_DEPRECATE(_fgetchar) _CRTIMP int __cdecl fgetchar(void); +_Check_return_ _CRT_NONSTDC_DEPRECATE(_fileno) _CRTIMP int __cdecl fileno(_In_ FILE * _File); +_Check_return_opt_ _CRT_NONSTDC_DEPRECATE(_flushall) _CRTIMP int __cdecl flushall(void); +_Check_return_opt_ _CRT_NONSTDC_DEPRECATE(_fputchar) _CRTIMP int __cdecl fputchar(_In_ int _Ch); +_Check_return_ _CRT_NONSTDC_DEPRECATE(_getw) _CRTIMP int __cdecl getw(_Inout_ FILE * _File); +_Check_return_opt_ _CRT_NONSTDC_DEPRECATE(_putw) _CRTIMP int __cdecl putw(_In_ int _Ch, _Inout_ FILE * _File); +_Check_return_ _CRT_NONSTDC_DEPRECATE(_rmtmp) _CRTIMP int __cdecl rmtmp(void); + +#endif /* !__STDC__ */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#pragma pack(pop) + +#endif /* _INC_STDIO */