/* ### * IP: GHIDRA * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /// \file ifacedecomp.hh /// \brief Console interface commands for the decompiler engine #ifndef __IFACE_DECOMP__ #define __IFACE_DECOMP__ #include "graph.hh" #include "grammar.hh" #include "callgraph.hh" #include "paramid.hh" #include "testfunction.hh" #ifdef CPUI_RULECOMPILE #include "rulecompile.hh" #endif /// \brief Interface capability point for all decompiler commands class IfaceDecompCapability : public IfaceCapability { static IfaceDecompCapability ifaceDecompCapability; ///< Singleton instance IfaceDecompCapability(void); ///< Singleton constructor IfaceDecompCapability(const IfaceDecompCapability &op2); ///< Not implemented IfaceDecompCapability &operator=(const IfaceDecompCapability &op2); ///< Not implemented public: virtual void registerCommands(IfaceStatus *status); }; /// \brief Common data shared by decompiler commands class IfaceDecompData : public IfaceData { public: Funcdata *fd; ///< Current function active in the console Architecture *conf; ///< Current architecture/program active in the console CallGraph *cgraph; ///< Call-graph information for the program FunctionTestCollection *testCollection; ///< Executable environment from a datatest #ifdef CPUI_RULECOMPILE string experimental_file; // File containing experimental rules #endif #ifdef OPACTION_DEBUG bool jumptabledebug; #endif IfaceDecompData(void); ///< Constructor virtual ~IfaceDecompData(void); void allocateCallGraph(void); ///< Allocate the call-graph object void abortFunction(ostream &s); ///< Clear references to current function void clearArchitecture(void); ///< Free all resources for the current architecture/program void followFlow(ostream &s,int4 size); Varnode *readVarnode(istream &s); ///< Read a varnode from the given stream }; /// \brief Disassembly emitter that prints to a console stream /// /// An instruction is printed to a stream simply, as an address /// followed by the mnemonic and then column aligned operands. class IfaceAssemblyEmit : public AssemblyEmit { int4 mnemonicpad; ///< How much to pad the mnemonic ostream *s; ///< The current stream to write to public: IfaceAssemblyEmit(ostream *val,int4 mp) { s = val; mnemonicpad=mp; } ///< Constructor virtual void dump(const Address &addr,const string &mnem,const string &body) { addr.printRaw(*s); *s << ": " << mnem; for(int4 i=mnem.size();i &inname, string &pcodestring); }; class IfcCallOtherFixup : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcCountPcode : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcPrintActionstats : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcResetActionstats : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcVolatile : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcReadonly : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcPointerSetting : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcPreferSplit : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcStructureBlocks : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcAnalyzeRange : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcLoadTestFile : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcListTestCommands : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcExecuteTestCommand : public IfaceDecompCommand { public: virtual void execute(istream &s); }; #ifdef CPUI_RULECOMPILE class IfcParseRule : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcExperimentalRules : public IfaceDecompCommand { public: virtual void execute(istream &s); }; #endif #ifdef OPACTION_DEBUG class IfcDebugAction : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcTraceBreak : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcTraceAddress : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcTraceEnable : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcTraceDisable : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcTraceClear : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcTraceList : public IfaceDecompCommand { public: virtual void execute(istream &s); }; class IfcBreakjump : public IfaceDecompCommand { public: virtual void execute(istream &s); }; #endif #endif