Title: PROKONAL codewords searching? Post by: amd is the best on February 10, 2020, 09:37:40 AM Guys,
What's the best way to define the PROKONAL section of a binary? Is the only (or best) way in assembly? Guess and check takes way too long and no matter how similar another defined ECU seems to be, prokonal codewords always seem to be different. Can anyone give some tips? Thanks in advance! Title: Re: PROKONAL codewords searching? Post by: mdccode5150 on October 07, 2020, 05:34:39 PM I'm interested in this also! I'm reading the Function Documents now. I will post if I can figure it out. My strategy is to compare the Damos/A2L of different ECU's.
Title: Re: PROKONAL codewords searching? Post by: prj on October 08, 2020, 04:46:42 AM Dissassembly, but it's one of the harder sections to reverse...
Title: Re: PROKONAL codewords searching? Post by: mdccode5150 on October 21, 2020, 12:15:32 AM I found a Bosch project for MED17 3.6L TSFI, and have been reading the files, logs, C, H, O code, and A2L / Hex files...It's so missive compared to ME7's. I don't know coding but it still interests me.
Title: Re: PROKONAL codewords searching? Post by: IamwhoIam on October 21, 2020, 01:43:27 AM I found a Bosch project for MED17 3.6L TSFI, and have been reading the files, logs, C, H, O code, and A2L / Hex files...It's so missive compared to ME7's. I don't know coding but it still interests me. Care to share the hex file from this project with us? Title: Re: PROKONAL codewords searching? Post by: mdccode5150 on October 29, 2020, 10:00:40 AM YES! I will figure out how to make a link to Google for download...And I am translating other Version Coding Documents now. I will also share.
Title: Re: PROKONAL codewords searching? Post by: mdccode5150 on November 07, 2020, 06:44:41 PM Care to share the hex file from this project with us? Sorry for the delay Let me know if it downloads... https://drive.google.com/file/d/1gjo9-LSAj_l3o1nGwV3psBwcdmr4Gz_n/view?usp=sharing Also most files can be read with Notepad++ free download https://notepad-plus-plus.org/downloads/ Title: Re: PROKONAL codewords searching? Post by: terminator on March 04, 2021, 09:11:23 AM for me7
http://nefariousmotorsports.com/forum/index.php?topic=16741 (http://nefariousmotorsports.com/forum/index.php?topic=16741) Title: Re: PROKONAL codewords searching? Post by: 360trev on December 09, 2021, 12:20:27 PM Someone recently asked me to comment on this subject as a software developer
OK here goes. It helps to look at the source-code posted by mdccode5150 as even though its for ME17 the Project Configuration hasn't really changed all that much from ME7.x days. The reason why you don't get a match is related to "code generation" and the fact they change compilers and C167 GNU CC based compilers got better at code optimization as they get newer. Its also conditionally compiled for different projects... First lets look at the macro's used (C language) to define bits.. Code: #define b_MASK (uint8)0xFFu And here's a custom macro specific to a given bit (auto generated by some scripts) Code: #define SET_B_autget ((bits |= (uint8)1u << 0)) Note: Different projects defined bits settings to mean different things!! Code: /******************************************************************/ When you run this through one of the earlier compilers (as used on ME7.3) it spits out pretty crappy un-optimized code which looks something like this... Code: get_cw_sy_flags+0: F3 F8 1F 00 movb rl4, CWKONFZ1 ; CWKONFZ1 : Codewort fnr Konfiguration Fahrzeug [PROKON] Lets look at just one of these generated code's for a moment... Code: get_cw_sy_flags+4A F3 F8 1F 00 movb rl4, CWKONFZ1 ; CWKONFZ1 : Codewort fur Konfiguration Fahrzeug [PROKON] Lets remove 'code generator specifics' to make the signature a little bit more 'generic'... Code: get_cw_sy_flags+4A F3 F? ?? ?? movb r??, ?????? ; CWKONFZ1 : Codewort fur Konfiguration Fahrzeug [PROKON] This is because F3 is the opcode for 'moveb' F8 is references 'rl4' and finally 1F00 is (byte swapped to 001F is referencing map region +1F). so 0x810000+0x1F which is 0x81001F or file offset 0x1001F in this specific case... 67 is the opcode for 'andb' again 'register' F8 is referencing 'rl4' and then 80 00 becomes (byte swapped) 00 80 or 0x0080 which is the 7th bit... So the mask to detect this exact field is "F3 F? ?? ?? 67 F? 80 00 3A ?? ?? ?? 4A ?? 00 ??" And here's code generation on a different GCC compiled with large memory model. Code: D7 40 06 02 extp #206h, #1 You can see logically it does exactly the same as the original macros. The difference here is the extp #1 so it explicitly calls out that this is at segment 0x206. If you understand these opcodes (see C167 instruction manual) you'll see that means its at address 0x206*0x4000 (each segment is 0x4000 in size). So that equates to an address offset of 0x818000 + 0x01CF, so in this particular case its referencing 0x81801CF, or file offset 0x181CF. However this is NOT really the best way to detect these fields using crude 'static signature detection' because you'd literally have to detect all the different compiler variants used as the code is pretty different every time... why? Its because its FAR far better to find the byte and bit offset which actually USES these bit-fields and search for the bits referenced backwards from that... So in this case find all references to code using FD00.0.... Search for the signature which uses of one of them and extract the bit and byte offset used there and that will de-reference the memory set by the project bit setups. In this way its possible to fully automate detection of all prokon bits in a rom you've never even seen before.. Same technique works on MED9 (PowerPC) and ME17 (tricore) just with difference instructions. Any questions just ask.. |