parent
8b7229ac75
commit
966d1e814c
@ -1,37 +1,97 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <decomp/decomp.hpp>
|
||||||
#include <obf/engine.hpp>
|
#include <obf/engine.hpp>
|
||||||
#include <recomp/symbol_table.hpp>
|
#include <recomp/symbol_table.hpp>
|
||||||
#include <decomp/decomp.hpp>
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// this namespace encompasses all recomposition related code.
|
||||||
|
/// </summary>
|
||||||
namespace theo::recomp {
|
namespace theo::recomp {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// a function which is called by recomp_t to resolve external symbols
|
||||||
|
/// </summary>
|
||||||
using resolver_t = std::function<std::uintptr_t(std::string)>;
|
using resolver_t = std::function<std::uintptr_t(std::string)>;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// a function which is called by recomp_t to copy symbols into memory.
|
||||||
|
/// </summary>
|
||||||
using copier_t = std::function<void(std::uintptr_t, void*, std::uint32_t)>;
|
using copier_t = std::function<void(std::uintptr_t, void*, std::uint32_t)>;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
using allocator_t =
|
using allocator_t =
|
||||||
std::function<std::uintptr_t(std::uint32_t,
|
std::function<std::uintptr_t(std::uint32_t,
|
||||||
coff::section_characteristics_t)>;
|
coff::section_characteristics_t)>;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// the main class responsible for recomposition
|
||||||
|
/// </summary>
|
||||||
class recomp_t {
|
class recomp_t {
|
||||||
public:
|
public:
|
||||||
explicit recomp_t(decomp::decomp_t* dcmp);
|
/// <summary>
|
||||||
|
/// the explicit constructor for the recomp_t class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dcmp">pointer to a decomp_t class.</param>
|
||||||
|
/// <param name="alloc">lambda function which is used to allocate memory for
|
||||||
|
/// symbols.</param> <param name="copy">lambda function used to copy bytes
|
||||||
|
/// into allocations.</param> <param name="resolve">lambda function used to
|
||||||
|
/// resolve external symbols.</param>
|
||||||
explicit recomp_t(decomp::decomp_t* dcmp,
|
explicit recomp_t(decomp::decomp_t* dcmp,
|
||||||
allocator_t alloc,
|
allocator_t alloc,
|
||||||
copier_t copy,
|
copier_t copy,
|
||||||
resolver_t resolve);
|
resolver_t resolve);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// when called, this function allocates space for every symbol.
|
||||||
|
/// </summary>
|
||||||
void allocate();
|
void allocate();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// when called, this function resolves all relocations in every symbol.
|
||||||
|
/// </summary>
|
||||||
void resolve();
|
void resolve();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// when called, this function copies symbols into allocations.
|
||||||
|
/// </summary>
|
||||||
void copy_syms();
|
void copy_syms();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// setter for the allocater lambda function.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="alloc">lambda function which allocates memory for
|
||||||
|
/// symbols.</param>
|
||||||
void allocator(allocator_t alloc);
|
void allocator(allocator_t alloc);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// setter for the copier lambda function.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="copy">copier lambda function used to copy bytes into
|
||||||
|
/// allocations made by the allocator.</param>
|
||||||
void copier(copier_t copy);
|
void copier(copier_t copy);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// setter for the resolve lambda function.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="resolve">lambda function to resolve external symbols.</param>
|
||||||
void resolver(resolver_t resolve);
|
void resolver(resolver_t resolve);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// resolves the address of a function given its name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sym">the name of the symbol to resolve the location
|
||||||
|
/// of.</param> <returns>the address of the symbol.</returns>
|
||||||
std::uintptr_t resolve(const std::string&& sym);
|
std::uintptr_t resolve(const std::string&& sym);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void gen_reloc_trans(decomp::symbol_t* sym);
|
|
||||||
decomp::decomp_t* m_dcmp;
|
decomp::decomp_t* m_dcmp;
|
||||||
resolver_t m_resolver;
|
resolver_t m_resolver;
|
||||||
copier_t m_copier;
|
copier_t m_copier;
|
||||||
allocator_t m_allocator;
|
allocator_t m_allocator;
|
||||||
};
|
};
|
||||||
} // namespace theo::comp
|
} // namespace theo::recomp
|
Loading…
Reference in new issue