#ifndef CODEGENERATOR_H #define CODEGENERATOR_H #include #include #include "CodeInjector.h" std::vector x86_relJump(unsigned long dst, unsigned long src); class CodeGenerator { public: CodeGenerator(const native_data& nd); virtual ~CodeGenerator(); void clear() { codes.clear(); } bool hasCode(int index); CodeGenerator& addCode(const std::vector& code); CodeGenerator& setCode(int index, const std::vector& code); CodeGenerator& setCodeSized(int index, const std::vector& code); CodeGenerator& setRel32JMP(int index, unsigned long dst, unsigned long src, bool reversed = false); std::vector::size_type buildSize(int maxCodes = -1); std::vector build(); std::vector buildAndClear(); std::string toString(); private: const native_data& nd; std::vector> codes; unsigned long diffRel32JMP(bool reversed, int index = -1) { return (!reversed ? buildSize(index) - 0x5 : buildSize(index)); } }; #endif // CODEGENERATOR_H