#pragma once #include #include #include /// /// this namespace encompasses all recomposition related code. /// namespace theo::recomp { /// /// a function which is called by recomp_t to resolve external symbols /// using resolver_t = std::function; /// /// a function which is called by recomp_t to copy symbols into memory. /// using copier_t = std::function; /// /// a function which is called to allocate space for a symbol. /// /// the first param is the size of the symbol, the second param is the /// characteristics of the section which the symbol is allocated in. /// using allocator_t = std::function; /// /// the main class responsible for recomposition /// class recomp_t { public: /// /// the explicit constructor for the recomp_t class. /// /// pointer to a decomp_t class. /// lambda function which is used to allocate memory for /// symbols. lambda function used to copy bytes /// into allocations. lambda function used to /// resolve external symbols. explicit recomp_t(decomp::decomp_t* dcmp, allocator_t alloc, copier_t copy, resolver_t resolve); /// /// when called, this function allocates space for every symbol. /// void allocate(); /// /// when called, this function resolves all relocations in every symbol. /// void resolve(); /// /// when called, this function copies symbols into allocations. /// void copy_syms(); /// /// setter for the allocater lambda function. /// /// lambda function which allocates memory for /// symbols. void allocator(allocator_t alloc); /// /// setter for the copier lambda function. /// /// copier lambda function used to copy bytes into /// allocations made by the allocator. void copier(copier_t copy); /// /// setter for the resolve lambda function. /// /// lambda function to resolve external symbols. void resolver(resolver_t resolve); /// /// resolves the address of a function given its name. /// /// the name of the symbol to resolve the location /// of. the address of the symbol. std::uintptr_t resolve(const std::string&& sym); private: decomp::decomp_t* m_dcmp; resolver_t m_resolver; copier_t m_copier; allocator_t m_allocator; }; } // namespace theo::recomp