My Project
ifacedecomp.hh
1 /* ###
2  * IP: GHIDRA
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 // Interface to the decompilation routines
17 
18 #ifndef __IFACE_DECOMP__
19 #define __IFACE_DECOMP__
20 
21 #include "ifaceterm.hh"
22 #include "graph.hh"
23 #include "grammar.hh"
24 #include "callgraph.hh"
25 #include "paramid.hh"
26 #ifdef CPUI_RULECOMPILE
27 #include "rulecompile.hh"
28 #endif
29 
31  static IfaceDecompCapability ifaceDecompCapability; // Singleton instance
32  IfaceDecompCapability(void); // Singleton
33  IfaceDecompCapability(const IfaceDecompCapability &op2); // Not implemented
34  IfaceDecompCapability &operator=(const IfaceDecompCapability &op2); // Not implemented
35 public:
36  virtual void registerCommands(IfaceStatus *status);
37 };
38 
39 class IfaceDecompData : public IfaceData {
40 public:
41  Funcdata *fd; // Current function data
42  Architecture *conf;
43  CallGraph *cgraph;
44 
45  map<Funcdata*,PrototypePieces> prototypePieces;
46  void storePrototypePieces( Funcdata *fd_in, PrototypePieces pp_in ) { prototypePieces.insert(pair<Funcdata*,PrototypePieces>(fd_in,pp_in)); }
47  PrototypePieces findPrototypePieces( Funcdata *fd_in ) { return (*prototypePieces.find(fd_in)).second; }
48 
49 #ifdef CPUI_RULECOMPILE
50  string experimental_file; // File containing experimental rules
51 #endif
52 #ifdef OPACTION_DEBUG
53  bool jumptabledebug;
54 #endif
55  IfaceDecompData(void);
56  virtual ~IfaceDecompData(void);
57  void abortFunction(ostream &s);
58  void clearArchitecture(void);
59 };
60 
62  int4 mnemonicpad; // How much to pad the mnemonic
63  ostream *s;
64 public:
65  IfaceAssemblyEmit(ostream *val,int4 mp) { s = val; mnemonicpad=mp; }
66  virtual void dump(const Address &addr,const string &mnem,const string &body) {
67  addr.printRaw(*s);
68  *s << ": " << mnem;
69  for(int4 i=mnem.size();i<mnemonicpad;++i) *s << ' ';
70  *s << body << endl;
71  }
72 };
73 
74 extern void execute(IfaceStatus *status,IfaceDecompData *dcp);
75 extern void mainloop(IfaceStatus *status);
76 
78 protected:
79  IfaceStatus *status;
80  IfaceDecompData *dcp;
81  void iterateScopesRecursive(Scope *scope);
82  void iterateFunctionsAddrOrder(Scope *scope);
83 public:
84  virtual void setData(IfaceStatus *root,IfaceData *data) { status = root; dcp = (IfaceDecompData *)data; }
85  virtual string getModule(void) const { return "decompile"; }
86  virtual IfaceData *createData(void) { return new IfaceDecompData(); }
87  virtual void iterationCallback(Funcdata *fd) {}
88  void iterateFunctionsAddrOrder(void);
89  void iterateFunctionsLeafOrder(void);
90 };
91 
92 class IfcSource : public IfaceDecompCommand {
93 public:
94  virtual void execute(istream &s);
95 };
96 
97 class IfcOption : public IfaceDecompCommand {
98 public:
99  virtual void execute(istream &s);
100 };
101 
103 public:
104  virtual void execute(istream &s);
105 };
106 
108 public:
109  virtual void execute(istream &s);
110 };
111 
113 public:
114  virtual void execute(istream &s);
115 };
116 
118 public:
119  virtual void execute(istream &s);
120 };
121 
123 public:
124  virtual void execute(istream &s);
125 };
126 
128 public:
129  virtual void execute(istream &s);
130 };
131 
133 public:
134  virtual void execute(istream &s);
135 };
136 
138 public:
139  virtual void execute(istream &s);
140 };
141 
143 public:
144  virtual void execute(istream &s);
145 };
146 
148 public:
149  virtual void execute(istream &s);
150 };
151 
153 public:
154  virtual void execute(istream &s);
155 };
156 
158 public:
159  virtual void execute(istream &s);
160 };
161 
163 public:
164  virtual void execute(istream &s);
165 };
166 
167 class IfcDump : public IfaceDecompCommand {
168 public:
169  virtual void execute(istream &s);
170 };
171 
173 public:
174  virtual void execute(istream &s);
175 };
176 
178 public:
179  virtual void execute(istream &s);
180 };
181 
183 public:
184  virtual void execute(istream &s);
185 };
186 
188 public:
189  virtual void execute(istream &s);
190 };
191 
193 public:
194  virtual void execute(istream &s);
195 };
196 
198 public:
199  virtual void execute(istream &s);
200 };
201 
203 public:
204  virtual void execute(istream &s);
205 };
206 
208 public:
209  virtual void execute(istream &s);
210 };
211 
213 public:
214  virtual void execute(istream &s);
215  virtual void iterationCallback(Funcdata *fd);
216 };
217 
219 public:
220  virtual void execute(istream &s);
221  virtual void iterationCallback(Funcdata *fd);
222 };
223 
225 public:
226  virtual void execute(istream &s);
227 };
228 
230 public:
231  virtual void execute(istream &s);
232 };
233 
235 public:
236  virtual void execute(istream &s);
237 };
238 
240 public:
241  virtual void execute(istream &s);
242 };
243 
245 public:
246  virtual void execute(istream &s);
247 };
248 
250 public:
251  virtual void execute(istream &s);
252 };
253 
255 public:
256  virtual void execute(istream &s);
257 };
258 
260 public:
261  virtual void execute(istream &s);
262 };
263 
265 public:
266  virtual void execute(istream &s);
267 };
268 
270 public:
271  virtual void execute(istream &s);
272 };
273 
275 public:
276  virtual void execute(istream &s);
277 };
278 
280 public:
281  virtual void execute(istream &s);
282 };
283 
285 public:
286  virtual void execute(istream &s);
287 };
289 public:
290  virtual void execute(istream &s);
291 };
293 public:
294  virtual void execute(istream &s);
295 };
296 
298 public:
299  virtual void execute(istream &s);
300 };
301 
303 public:
304  virtual void execute(istream &s);
305 };
306 
308 public:
309  virtual void execute(istream &s);
310 };
311 
313 public:
314  virtual void execute(istream &s);
315 };
316 
318 public:
319  virtual void execute(istream &s);
320 };
321 
323 public:
324  virtual void execute(istream &s);
325 };
326 
328 public:
329  virtual void execute(istream &s);
330 };
331 
333 public:
334  virtual void execute(istream &s);
335 };
336 
338 public:
339  virtual void execute(istream &s);
340 };
341 
343 public:
344  virtual void execute(istream &s);
345 };
346 
348 public:
349  virtual void execute(istream &s);
350 };
351 
353 public:
354  virtual void execute(istream &s);
355 };
356 
358 public:
359  virtual void execute(istream &s);
360 };
361 
363 public:
364  virtual void execute(istream &s);
365 };
366 
368 public:
369  virtual void execute(istream &s);
370 };
371 
373 public:
374  virtual void execute(istream &s);
375 };
376 
378 public:
379  virtual void execute(istream &s);
380 };
381 
383 public:
384  virtual void execute(istream &s);
385 };
386 
388 public:
389  virtual void execute(istream &s);
390 };
391 
393 public:
394  virtual void execute(istream &s);
395 };
396 
398 public:
399  virtual void execute(istream &s);
400 };
401 
403 public:
404  virtual void execute(istream &s);
405 };
406 
408 public:
409  virtual void execute(istream &s);
410  virtual void iterationCallback(Funcdata *fd);
411 };
412 
414 public:
415  virtual void execute(istream &s);
416 };
417 
419 public:
420  virtual void execute(istream &s);
421 };
422 
424 public:
425  virtual void execute(istream &s);
426 };
427 
429 public:
430  virtual void execute(istream &s);
431 };
432 
434 public:
435  virtual void execute(istream &s);
436 };
437 
439 public:
440  virtual void execute(istream &s);
441 };
442 
444 public:
445  virtual void execute(istream &s);
446 };
447 
449 public:
450  virtual void execute(istream &s);
451 };
452 
454 public:
455  virtual void execute(istream &s);
456 };
457 
459 public:
460  virtual void execute(istream &s);
461 };
462 
464 public:
465  virtual void execute(istream &s);
466  virtual void iterationCallback(Funcdata *fd);
467 };
468 
470 public:
471  virtual void execute(istream &s);
472 };
473 
475 protected:
476  bool quick;
477 public:
478  virtual void execute(istream &s);
479  virtual void iterationCallback(Funcdata *fd);
480 };
481 
483  virtual void execute(istream &s);
484 };
485 
487 public:
488  virtual void execute(istream &s);
489 };
490 
492 protected:
493  bool quick;
494 public:
495  virtual void execute(istream &s);
496  virtual void iterationCallback(Funcdata *fd);
497 };
498 
500 public:
501  virtual void execute(istream &s);
502 };
503 
505 public:
506  virtual void execute(istream &s);
507 };
508 
510 public:
511  virtual void execute(istream &s);
512 };
513 
515 public:
516  virtual void execute(istream &s);
517 };
518 
520 public:
521  virtual void execute(istream &s);
522 };
523 
525 public:
526  virtual void execute(istream &s);
527 };
528 
530 public:
531  virtual void execute(istream &s);
532 };
533 
535 public:
536  virtual void execute(istream &s);
537 };
538 
540 public:
541  virtual void execute(istream &s);
542 };
543 
545 public:
546  virtual void execute(istream &s);
547 };
548 
549 #ifdef CPUI_RULECOMPILE
550 class IfcParseRule : public IfaceDecompCommand {
551 public:
552  virtual void execute(istream &s);
553 };
554 #endif
555 
557 public:
558  virtual void execute(istream &s);
559 };
560 
561 #ifdef OPACTION_DEBUG
562 class IfcDebugAction : public IfaceDecompCommand {
563 public:
564  virtual void execute(istream &s);
565 };
566 
567 class IfcTraceBreak : public IfaceDecompCommand {
568 public:
569  virtual void execute(istream &s);
570 };
571 
572 class IfcTraceAddress : public IfaceDecompCommand {
573 public:
574  virtual void execute(istream &s);
575 };
576 
577 class IfcTraceEnable : public IfaceDecompCommand {
578 public:
579  virtual void execute(istream &s);
580 };
581 
582 class IfcTraceDisable : public IfaceDecompCommand {
583 public:
584  virtual void execute(istream &s);
585 };
586 
587 class IfcTraceClear : public IfaceDecompCommand {
588 public:
589  virtual void execute(istream &s);
590 };
591 
592 class IfcTraceList : public IfaceDecompCommand {
593 public:
594  virtual void execute(istream &s);
595 };
596 
597 #endif
598 
599 #endif
Definition: ifacedecomp.hh:107
virtual void dump(const Address &addr, const string &mnem, const string &body)
The main disassembly emitting method.
Definition: ifacedecomp.hh:66
Definition: ifacedecomp.hh:524
Definition: interface.hh:62
Definition: ifacedecomp.hh:377
Definition: ifacedecomp.hh:482
Definition: ifacedecomp.hh:519
Definition: ifacedecomp.hh:556
Definition: ifacedecomp.hh:212
Definition: ifacedecomp.hh:428
Definition: ifacedecomp.hh:172
Definition: ifacedecomp.hh:92
Container for data structures associated with a single function.
Definition: funcdata.hh:45
Definition: ifacedecomp.hh:132
Definition: ifacedecomp.hh:182
Definition: ifacedecomp.hh:284
Definition: ifacedecomp.hh:322
Definition: ifacedecomp.hh:463
Definition: ifacedecomp.hh:509
void printRaw(ostream &s) const
Write a raw version of the address to a stream.
Definition: address.hh:276
Definition: ifacedecomp.hh:474
Definition: ifacedecomp.hh:407
Definition: ifacedecomp.hh:486
Definition: ifacedecomp.hh:392
Definition: ifacedecomp.hh:347
Definition: ifacedecomp.hh:112
Definition: ifacedecomp.hh:162
Definition: ifacedecomp.hh:152
Definition: ifacedecomp.hh:264
Raw components of a function prototype (obtained from parsing source code)
Definition: fspec.hh:1127
Definition: ifacedecomp.hh:177
Definition: ifacedecomp.hh:197
Definition: ifacedecomp.hh:418
Definition: callgraph.hh:91
Definition: ifacedecomp.hh:458
Definition: ifacedecomp.hh:352
Definition: ifacedecomp.hh:39
Definition: ifacedecomp.hh:30
Definition: ifacedecomp.hh:327
Definition: ifacedecomp.hh:302
Definition: ifacedecomp.hh:402
Definition: ifacedecomp.hh:288
Definition: ifacedecomp.hh:234
Definition: ifacedecomp.hh:224
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
Definition: ifacedecomp.hh:372
Definition: ifacedecomp.hh:239
Definition: ifacedecomp.hh:292
Definition: ifacedecomp.hh:157
Definition: ifacedecomp.hh:192
Definition: ifacedecomp.hh:499
Definition: ifacedecomp.hh:254
Definition: ifacedecomp.hh:453
Manager for all the major decompiler subsystems.
Definition: architecture.hh:117
Definition: ifacedecomp.hh:342
Definition: ifacedecomp.hh:469
Definition: ifacedecomp.hh:137
Definition: ifacedecomp.hh:413
Definition: ifacedecomp.hh:438
Definition: ifacedecomp.hh:218
Definition: ifacedecomp.hh:61
Definition: ifacedecomp.hh:491
Definition: ifacedecomp.hh:102
Definition: ifacedecomp.hh:387
Definition: interface.hh:108
Definition: ifacedecomp.hh:448
Definition: ifacedecomp.hh:142
Definition: ifacedecomp.hh:539
Definition: ifacedecomp.hh:77
Definition: ifacedecomp.hh:207
Definition: ifacedecomp.hh:362
Definition: ifacedecomp.hh:443
Definition: ifacedecomp.hh:229
Definition: ifacedecomp.hh:397
Definition: ifacedecomp.hh:529
Definition: ifacedecomp.hh:187
Definition: interface.hh:67
Definition: ifacedecomp.hh:147
Definition: ifacedecomp.hh:269
Definition: ifacedecomp.hh:307
Definition: ifacedecomp.hh:534
Definition: ifacedecomp.hh:433
Definition: ifacedecomp.hh:244
Definition: ifacedecomp.hh:312
Definition: ifacedecomp.hh:317
Definition: ifacedecomp.hh:167
Definition: interface.hh:96
Definition: ifacedecomp.hh:249
Definition: ifacedecomp.hh:332
Abstract class for emitting disassembly to an application.
Definition: translate.hh:118
Definition: ifacedecomp.hh:297
Definition: ifacedecomp.hh:279
Definition: ifacedecomp.hh:259
Definition: ifacedecomp.hh:504
Definition: ifacedecomp.hh:274
Definition: ifacedecomp.hh:122
Definition: ifacedecomp.hh:337
Definition: ifacedecomp.hh:202
Definition: ifacedecomp.hh:357
Definition: ifacedecomp.hh:514
Definition: ifacedecomp.hh:423
Definition: ifacedecomp.hh:127
Definition: ifacedecomp.hh:117
Definition: ifacedecomp.hh:367
Definition: ifacedecomp.hh:97
Definition: ifacedecomp.hh:544
Definition: ifacedecomp.hh:382
A collection of Symbol objects within a single (namespace or functional) scope.
Definition: database.hh:413