Pages: 1 [2] 3 4 5
Author Topic: AutoIT script to simplify ME7 binary loading  (Read 85875 times)
phila_dot
Hero Member
*****

Karma: +173/-11
Offline Offline

Posts: 1709


« Reply #15 on: December 06, 2012, 08:54:39 AM »

Updated this script.
Now you can load a ME7Logger .ecu file and it will name all the variables for you...

Awesome feature.

I wanted to write an IDA script for labelling variables.

How does it handle condition bits?

Enumerating bit fields?

I personally like to split the files so that the map offsets reference the correct location (plus I'm weird and meticulous about this sort of thing), but if you have a good solution for condition bits then I might have to adopt this.

Can the labelling feature be used exclusive of the loading script?

Great contribution regardless.

Logged
prj
Hero Member
*****

Karma: +1072/-480
Offline Offline

Posts: 6035


« Reply #16 on: December 06, 2012, 09:04:09 AM »

The labeling feature can be used exclusive, as the whole GUI can.
Simply delete everything in the file until the first #Include.

It does not handle bits at all. It only populates those variables where the bitmask is 0x0000.
Look inside in the file, it's very simple code.

It's just a text script...
This is the ECU loading part:
Code:
Func LoadEcu()
   StopAll()
   Local $ecufile = FileOpenDialog("Select .ecu file...", @WorkingDir, "ME7Logger ECU files (*.ecu)");
   If Not @error Then
  WinActivate("IDA")
  Local $openedfile = FileOpen($ecufile)
  Local $line
  While $line <> "[Measurements]"
$line = FileReadLine($openedfile)
if @error = -1 then ExitLoop
  WEnd
 
  AutoItSetOption("SendKeyDelay", 0)
  While 1
$line = FileReadLine($openedfile)
If @error = -1 Then ExitLoop
If StringLeft($line, 1) = ";" or $line = "" Then
ContinueLoop
EndIf
Local $data = StringSplit($line, ",")
If (StringStripWS($data[5], 8) = "0x0000") Then
SetVarName(StringStripWS($data[1], 8), StringStripWS($data[3], 8))
EndIf
  WEnd
  AutoItSetOption("SendKeyDelay", 5)
  FileClose($ecufile)
   EndIf
EndFunc

Func SetVarName($name, $addr)
   ControlFocus("IDA", "", "[CLASSNN:TMemo1]");
   Send("MakeNameEx(" & $addr & ", """ & $name & """, 0x01){ENTER}")
EndFunc
Logged

PM's will not be answered, so don't even try.
Log your car properly - WinOLS database - Tools/patches
phila_dot
Hero Member
*****

Karma: +173/-11
Offline Offline

Posts: 1709


« Reply #17 on: December 06, 2012, 09:54:10 AM »

The labeling feature can be used exclusive, as the whole GUI can.
Simply delete everything in the file until the first #Include.

It does not handle bits at all. It only populates those variables where the bitmask is 0x0000.
Look inside in the file, it's very simple code.

It's just a text script...
This is the ECU loading part:
Code:
Func LoadEcu()
   StopAll()
   Local $ecufile = FileOpenDialog("Select .ecu file...", @WorkingDir, "ME7Logger ECU files (*.ecu)");
   If Not @error Then
  WinActivate("IDA")
  Local $openedfile = FileOpen($ecufile)
  Local $line
  While $line <> "[Measurements]"
$line = FileReadLine($openedfile)
if @error = -1 then ExitLoop
  WEnd
 
  AutoItSetOption("SendKeyDelay", 0)
  While 1
$line = FileReadLine($openedfile)
If @error = -1 Then ExitLoop
If StringLeft($line, 1) = ";" or $line = "" Then
ContinueLoop
EndIf
Local $data = StringSplit($line, ",")
If (StringStripWS($data[5], 8) = "0x0000") Then
SetVarName(StringStripWS($data[1], 8), StringStripWS($data[3], 8))
EndIf
  WEnd
  AutoItSetOption("SendKeyDelay", 5)
  FileClose($ecufile)
   EndIf
EndFunc

Func SetVarName($name, $addr)
   ControlFocus("IDA", "", "[CLASSNN:TMemo1]");
   Send("MakeNameEx(" & $addr & ", """ & $name & """, 0x01){ENTER}")
EndFunc

I will definitely be giving this a try. It will be nice to quickly populate new databases.

Thanks.
Logged
jibberjive
Hero Member
*****

Karma: +23/-2
Offline Offline

Posts: 536


« Reply #18 on: January 24, 2013, 08:36:47 PM »

Much thanks.
Logged
prj
Hero Member
*****

Karma: +1072/-480
Offline Offline

Posts: 6035


« Reply #19 on: January 25, 2013, 04:16:04 AM »

You're welcome.

I wanted to say that, those people having problems with this.
Make sure you don't run the 64 bit version of IDA!

I tried it with that and nothing worked. There is no need to run the 64 bit version unless you want to disassemble 64 bit binaries anyway.
So basically make sure you are starting it using "idag.exe".
Logged

PM's will not be answered, so don't even try.
Log your car properly - WinOLS database - Tools/patches
Bische
Sr. Member
****

Karma: +25/-4
Offline Offline

Posts: 397



WWW
« Reply #20 on: March 24, 2013, 01:23:37 PM »

Thanks again,

I noticed in the updated script attempts to convert to code if there was no function (pc^u vs. p^u), this pops a dialog where it asks if it should covert to code or not - halting the script.

Is this a IDA version mismatch somehow? I am running 6.1.
Logged
prj
Hero Member
*****

Karma: +1072/-480
Offline Offline

Posts: 6035


« Reply #21 on: April 12, 2013, 07:45:14 AM »

Thanks again,

I noticed in the updated script attempts to convert to code if there was no function (pc^u vs. p^u), this pops a dialog where it asks if it should covert to code or not - halting the script.

Is this a IDA version mismatch somehow? I am running 6.1.

If that dialog has an option to never ask again, then enable it Smiley
Logged

PM's will not be answered, so don't even try.
Log your car properly - WinOLS database - Tools/patches
Bische
Sr. Member
****

Karma: +25/-4
Offline Offline

Posts: 397



WWW
« Reply #22 on: April 15, 2013, 03:08:41 AM »

Its just Yes, No or Cancel. Sad
Logged
prj
Hero Member
*****

Karma: +1072/-480
Offline Offline

Posts: 6035


« Reply #23 on: April 17, 2013, 07:15:51 AM »

Its just Yes, No or Cancel. Sad

It's when you go over stuff that has already been identified I think...
Do a couple of binaries, and you will see a pattern as to where program code is located.
There is no need to let it go over the entire binary.
Logged

PM's will not be answered, so don't even try.
Log your car properly - WinOLS database - Tools/patches
nyet
Administrator
Hero Member
*****

Karma: +607/-168
Offline Offline

Posts: 12268


WWW
« Reply #24 on: April 17, 2013, 09:05:25 AM »

Is there a way to share idapro setups w/o all this search stuff?

i freaking hate IDEs for this reason... all sorts of stupid shit hard coded into some idiotic binary "saved workspace" bullshit.
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
nyet
Administrator
Hero Member
*****

Karma: +607/-168
Offline Offline

Posts: 12268


WWW
« Reply #25 on: May 11, 2013, 12:21:21 PM »

BTW this does not work with the ida pro 6.1.0110409 floating around the torrent sites.

Almost nothing in the autoit script matches up, not even the first WinWait() calls.
« Last Edit: May 11, 2013, 12:23:15 PM by nyet » 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
prj
Hero Member
*****

Karma: +1072/-480
Offline Offline

Posts: 6035


« Reply #26 on: May 11, 2013, 02:21:30 PM »

I am using IDA Pro 6 and everything is OK.

Well, I guess it has to be modified a little.
Not that hard to do since the script is open source.

So feel free to mod it and then post the modded version, and I'll put it in the first post.
Logged

PM's will not be answered, so don't even try.
Log your car properly - WinOLS database - Tools/patches
nyet
Administrator
Hero Member
*****

Karma: +607/-168
Offline Offline

Posts: 12268


WWW
« Reply #27 on: May 11, 2013, 03:28:32 PM »

Yea, working on it now. Some stuff got moved around, and there are some new delays needed (in particular !esc and !esu don't work)

I have it working up until the buttons.

I will post it as soon as I get a working version.

Right now I am working on the .ecu parser.

The good news is that hacking this AutoIt script is teaching me stuff about IDA i didn't know Smiley
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
nyet
Administrator
Hero Member
*****

Karma: +607/-168
Offline Offline

Posts: 12268


WWW
« Reply #28 on: May 11, 2013, 04:50:12 PM »

What I have so far for IDA PRO 6.1.0110409

.ecu loading was fine. I was a moron.

Re-organized it into functions so you can load rom or flash whenever (or not, so you don't have to always start from scratch, say to import a new .ecu, or reanalyze).
« Last Edit: May 11, 2013, 06:22:21 PM by nyet » 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
maZer.GTi
Full Member
***

Karma: +68/-6
Offline Offline

Posts: 246


« Reply #29 on: September 18, 2013, 03:19:11 PM »

I modded some timings in the 6.1 Script.
For me the timings was a way to short.
I adjusted the timings, maybe someone need this script.
Logged
Pages: 1 [2] 3 4 5
  Print  
 
Jump to:  

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