Pages: [1]
Author Topic: Request tutorial on how to enum bits  (Read 7627 times)
elRey
Hero Member
*****

Karma: +32/-1
Offline Offline

Posts: 565


« on: January 14, 2015, 09:30:19 PM »

Also, masterj - how did you name each bit in IDA?

To name bits you have to create enum in ida and apply it to selected word or byte

Looking to change :

bmov    word_FD0E.5, USR0

to:

bmov    word_FD0E.my_var_name_for_bit_5, USR0

And have that name displayed in crossref list

Would be much appreciated!

Rey
Logged
elRey
Hero Member
*****

Karma: +32/-1
Offline Offline

Posts: 565


« Reply #1 on: August 04, 2015, 04:50:45 PM »

Please. This would make a world of difference.
Logged
elRey
Hero Member
*****

Karma: +32/-1
Offline Offline

Posts: 565


« Reply #2 on: August 06, 2015, 03:03:19 PM »

I'm surprised at the reluctance of the community for sharing this helpful info.

I fumbled thru it and I'm not sure I did it the best way.

Example shows word_FDA4.11 being changed to word_FDA4.B_nozwe

bit 11 = 0x800 in bitmask part.

Logged
automan001
Full Member
***

Karma: +47/-0
Offline Offline

Posts: 153


« Reply #3 on: August 07, 2015, 05:02:46 AM »

Cool stuff, thanks for the hint!
In damos file by the address xxxx of bits variable you can find all hex masks for these bits with respective names. Then you just need to define them as enum member of the new enum_word_xxxx. It's great! It solves all the issues with bits naming. Name of the bit is shown everywhere in xrefs and in the code.
« Last Edit: August 07, 2015, 05:12:02 AM by automan001 » Logged
nubcake
Sr. Member
****

Karma: +53/-4
Offline Offline

Posts: 400


« Reply #4 on: September 18, 2015, 11:31:38 AM »

I've been playing with IDA for a while now. Thought I'd share this little autoIT script I hacked together for parsing those "B_", "S_" and "Z_" flag variables generated by ME7info. It's based on one of the scripts posted in this thread, originally started by prj. I modded it for my needs and added the function to parse those flag vars, adding them as enums.

Anyways, I made it for IDA 6.4, but it could be easily modded for any other version. The "Parse FLAGS" button is added to the menu.
Prereqs: default IDA view ("structures" tab 2 tabs to the right from "ida view" tab), specially pre-parsed .csv file with flags.
How to prepare csv: you take the appropriate .ecu file from me7i, leave only flags inside (B_, S_, Z_), sort it by address, remove duplicate names, leave only 3 columns:
Code:
name;address;offset

Separated by semicolon for my locale, fix accordingly for your needs.
Abstract of said csv:

Code:
B_dlahieg;0xFD08;0x8000
B_elaof;0xFD0A;0x0008
B_lamka;0xFD0A;0x1000
B_fasla;0xFD0C;0x2000
B_mslon;0xFD0C;0x4000
B_dsl1;0xFD0E;0x0008
B_dsl4;0xFD0E;0x0010
B_sla;0xFD0E;0x1000
B_aircan;0xFD10;0x0080
B_sksc;0xFD16;0x0010
B_fofstp;0xFD26;0x0800
B_fonstp;0xFD26;0x2000
B_lustop;0xFD26;0x8000
B_mdstop_m;0xFD28;0x0020
B_mdarv;0xFD2A;0x0200
B_mdkat;0xFD2A;0x1000
B_mil;0xFD2C;0x0020
B_nowuc;0xFD2C;0x0008

Fire IDA up, launch the script, press "Parse FLAGS", feed said .csv in, sit back and enjoy! (Optionally) get a cup of coffee, it will take ~5 mins to finish for average .ecu.

P.S. I'm posting this here because the script is generally pretty messed up for anything else. It works for my needs, but the "parse ECU" is broken for example, etc.
« Last Edit: September 18, 2015, 02:07:01 PM by nubcake » Logged
nyet
Administrator
Hero Member
*****

Karma: +608/-168
Offline Offline

Posts: 12270


WWW
« Reply #5 on: September 18, 2015, 11:35:11 AM »

Thanks all, this is great info. Learned all sorts of stuff from this thread!
Logged

ME7.1 tuning guide
ECUx Plot
ME7Sum checksum
Trim heatmap tool

Please do not ask me for tunes. I'm here to help people make their own.

Do not PM me technical questions! Please, ask all questions on the forums! Doing so will ensure the next person with the same issue gets the opportunity to learn from your ex
masterj
Hero Member
*****

Karma: +62/-5
Offline Offline

Posts: 1049



WWW
« Reply #6 on: September 25, 2015, 09:53:59 AM »

Hm.. doesn't seem to work with ida 6.1. Maybe you could update script so it would save parsed csv data to txt as IDAPython script? For every single enum/member it would create a command to do it in ida.

Something using OpEnum or some other command.

https://www.hex-rays.com/products/ida/support/idadoc/704.shtml


Logged

nubcake
Sr. Member
****

Karma: +53/-4
Offline Offline

Posts: 400


« Reply #7 on: September 25, 2015, 10:50:30 AM »

Hm.. doesn't seem to work with ida 6.1. Maybe you could update script so it would save parsed csv data to txt as IDAPython script? For every single enum/member it would create a command to do it in ida.

Something using OpEnum or some other command.

https://www.hex-rays.com/products/ida/support/idadoc/704.shtml

I tried it with python at first, but enum members didn't seem to "attach" to the enum correctly. I didn't want to waste more time trying to figure out what's going wrong - and just remade it "the GUI" way.

At which point does it fail? Does it create the first enum? Does it add enum member? Does it go to the "Ida disassembly view" afterwards and to the RAM/IRAM address?

EDIT: I'm not sure I added trimming of the leading zeros for IRAM adresses, so those must be in the "0xFxxx" format.
EDIT2: I have noticed that it might bug for the first enum and not attach it correctly. For now doing it by hand istead, but will fix it sometimes probably. Wink
« Last Edit: November 06, 2015, 02:24:14 PM by nubcake » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Page created in 0.019 seconds with 17 queries. (Pretty URLs adds 0s, 0q)