forked from guitar24t/VolvoDisassemblyHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VolvoDisassemblyHelper.au3
180 lines (154 loc) · 4.25 KB
/
VolvoDisassemblyHelper.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
;Originally developed by prj and the community of NefMoto
;Edited to work for Volvo BINs by guitar24t
If WinExists("[TITLE:IDA; CLASS:QWidget]") Then
WinActivate("[TITLE:IDA; CLASS:QWidget]")
Else
WinWaitActive("About")
Send("{ENTER}")
Endif
Sleep(100)
If WinExists("IDA: Quick start") Then
WinActivate("IDA: Quick start")
Send("{UP}")
Sleep(1)
Send("{ENTER}")
EndIf
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
GUICreate("Analysis Toolset", 150, 175, (@DeskTopWidth - 150 - 50))
$loadrbutton = GUICtrlCreateButton("Load BIN", 12, 15, 125, 25)
$startbutton = GUICtrlCreateButton("Start Analysis", 12, 45, 125, 25)
$startcbutton = GUICtrlCreateButton("Start Cleanup", 12, 75, 125, 25)
$stopbutton = GUICtrlCreateButton("Stop All", 12, 105, 125, 25)
$loadbutton = GUICtrlCreateButton("Load .ecu", 12, 135, 125, 25)
GUICtrlSetOnEvent($loadrbutton, "LoadROM")
GUICtrlSetOnEvent($startbutton, "StartAn")
GUICtrlSetOnEvent($stopbutton, "StopAll")
GUICtrlSetOnEvent($startcbutton, "StartClean")
GUICtrlSetOnEvent($loadbutton, "LoadEcu")
GuiSetState(@SW_SHOW)
Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitTool")
$analysis = False
$cleanup = False
WinSetOnTop("Analysis", "", 1)
Func LoadROM()
StopAll()
WinActivate("[TITLE:IDA; CLASS:QWidget]")
Send("!fo")
WinWaitActive("Load a new file")
Send("{TAB}Siemens C166{ENTER}")
Sleep(200)
Send("{ENTER}")
If WinExists("Please confirm") Then
WinActivate("Please confirm")
Send("{ENTER}")
EndIf
WinWaitActive("Disassembly memory organization")
Send("{SPACE}") ; create RAM section
; RAM start/size
Send("{TAB}0x300000{SPACE}{TAB}0x10000{SPACE}{TAB}")
; ROM start/size
Send("{TAB}0x0{SPACE}{TAB}0x100000{SPACE}{TAB}")
; Load address
Send("0x0{SPACE}{TAB}{ENTER}")
WinWaitActive("Choose the device name")
Send("C167CS{ENTER}")
Send("{ENTER}")
Sleep(200)
If WinExists("Information") Then
WinActivate("Information")
Send("{ENTER}")
EndIf
WinWaitActive("[TITLE:IDA; CLASS:QWidget]")
; set up DPPs
Send("!es")
Sleep(200)
Send("u")
WinWaitActive("Segment Default")
Send("{UP}{UP}{UP}!a!v4{TAB}{SPACE}{ENTER}")
Send("!es")
Sleep(200)
Send("u")
WinWaitActive("Segment Default")
Send("{DOWN}!a!v5{TAB}{SPACE}{ENTER}")
Send("!es")
Sleep(200)
Send("u")
WinWaitActive("Segment Default")
Send("{DOWN}!a!vC0{TAB}{SPACE}{ENTER}")
Send("!es")
Sleep(200)
Send("u")
WinWaitActive("Segment Default")
Send("{DOWN}!a!v3{TAB}{SPACE}{ENTER}")
WinWaitActive("[TITLE:IDA; CLASS:QWidget]")
Send("g")
WinWaitActive("Jump")
Send("0x8000{SPACE}{ENTER}")
MsgBox(0,"Load BIN","Setup completed. Please begin analysis now.")
EndFunc
While True
Sleep(1000)
While $analysis
Send("pc^u")
Sleep(1)
If WinExists("Please confirm") Then
WinActivate("Please confirm")
Send("{ENTER}")
Endif
WEnd
While $cleanup
Send("!hfuy")
Sleep(1)
WEnd
WEnd
Func StartAn()
StopAll()
$analysis = True
WinActivate("[TITLE:IDA; CLASS:QWidget]")
EndFunc
Func StopAll()
$analysis = False
$cleanup = False
EndFunc
Func StartClean()
StopAll()
$cleanup = True
WinActivate("[TITLE:IDA; CLASS:QWidget]")
EndFunc
Func LoadEcu()
StopAll()
Local $ecufile = FileOpenDialog("Select .ecu file...", @WorkingDir, "ME7Logger ECU files (*.ecu)");
If Not @error Then
WinActivate("[TITLE:IDA; CLASS:QWidget]")
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
Func ExitTool()
Exit
EndFunc