From 7658321752585beb05668257628bc2ec3ddc17ef Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Thu, 26 Mar 2020 21:38:15 +0100 Subject: replaced age2hd cheat with a actually working one.. or at least worked Signed-off-by: Toni Uhlig --- aoe2hd/src/CodeGenerator.cpp | 105 ------------------------------------------- 1 file changed, 105 deletions(-) delete mode 100755 aoe2hd/src/CodeGenerator.cpp (limited to 'aoe2hd/src/CodeGenerator.cpp') diff --git a/aoe2hd/src/CodeGenerator.cpp b/aoe2hd/src/CodeGenerator.cpp deleted file mode 100755 index cbae48d..0000000 --- a/aoe2hd/src/CodeGenerator.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "CodeGenerator.h" - -#include -#include -#include - -#include "native.h" -#include "utils.h" - - -std::vector x86_relJump(unsigned long dst, - unsigned long src) -{ - std::vector code(5); - code[0] = 0xE9; - unsigned long addr = dst - src; - code[1] = (*((unsigned char *)(&addr)+0)); - code[2] = (*((unsigned char *)(&addr)+1)); - code[3] = (*((unsigned char *)(&addr)+2)); - code[4] = (*((unsigned char *)(&addr)+3)); - return code; -} - -CodeGenerator::CodeGenerator(const native_data& nd) - : nd(nd), codes() -{ -} - -CodeGenerator::~CodeGenerator() -{ -} - -CodeGenerator& CodeGenerator::addCode(const std::vector& code) -{ - codes.push_back(code); - return *this; -} - -CodeGenerator& CodeGenerator::addCode(const std::string& code) -{ - return *this; -} - -CodeGenerator& CodeGenerator::setCode(int index, const std::vector& code) -{ - codes.at(index) = code; - return *this; -} - -CodeGenerator& CodeGenerator::setCodeSized(int index, const std::vector& code) -{ - assert(codes.at(index).size() == code.size()); - return setCode(index, code); -} - -CodeGenerator& CodeGenerator::setRel32JMP(int index, unsigned long dst, unsigned long src, bool reversed) -{ - if (!reversed) - { - dst += (unsigned long) nd.proc.modbase - diffRel32JMP(reversed, index); - } - else - { - src += (unsigned long) nd.proc.modbase + diffRel32JMP(reversed, index); - } - auto jmp = x86_relJump(dst, src); - setCodeSized(index, jmp); - return *this; -} - -std::vector::size_type CodeGenerator::buildSize(int maxCodes) -{ - std::vector::size_type total = 0; - for (auto& code : codes) - { - total += code.size(); - if (maxCodes-- == 0) - break; - } - return total; -} - -std::vector CodeGenerator::build() -{ - std::vector result; - for (auto& code : codes) - { - result.insert(result.end(), code.begin(), code.end()); - } - return result; -} - -std::vector CodeGenerator::buildAndClear() -{ - auto result = build(); - clear(); - return result; -} - -std::string CodeGenerator::toString() -{ - std::stringstream out; - out << "CodeBin: " << utils::convertBinToHexstr(build()) << std::endl; - return out.str(); -} -- cgit v1.2.3