|
|
@ -27,14 +27,11 @@
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#pragma once
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <obf/transform/transform.hpp>
|
|
|
|
#include <obf/transform/transform.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
namespace theo::recomp {
|
|
|
|
namespace theo::recomp {
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// meta data about a relocation for a symbol
|
|
|
|
/// meta data about a relocation for a symbol
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -53,19 +50,16 @@ class reloc_t {
|
|
|
|
std::size_t hash,
|
|
|
|
std::size_t hash,
|
|
|
|
const std::string&& sym_name)
|
|
|
|
const std::string&& sym_name)
|
|
|
|
: m_offset(offset), m_hash(hash), m_sym_name(sym_name) {}
|
|
|
|
: m_offset(offset), m_hash(hash), m_sym_name(sym_name) {}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// returns the hash of the relocation symbol.
|
|
|
|
/// returns the hash of the relocation symbol.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>hash of the relocation symbol</returns>
|
|
|
|
/// <returns>hash of the relocation symbol</returns>
|
|
|
|
std::size_t hash() { return m_hash; }
|
|
|
|
std::size_t hash() { return m_hash; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// returns the name of the relocation symbol.
|
|
|
|
/// returns the name of the relocation symbol.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>returns the name of the relocation symbol.</returns>
|
|
|
|
/// <returns>returns the name of the relocation symbol.</returns>
|
|
|
|
std::string name() { return m_sym_name; }
|
|
|
|
std::string name() { return m_sym_name; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// returns the offset into the symbol to which the relocation will be
|
|
|
|
/// returns the offset into the symbol to which the relocation will be
|
|
|
|
/// applied. the offset is in bytes. zero based.
|
|
|
|
/// applied. the offset is in bytes. zero based.
|
|
|
@ -73,15 +67,35 @@ class reloc_t {
|
|
|
|
/// <returns>returns the offset into the symbol to which the relocation will
|
|
|
|
/// <returns>returns the offset into the symbol to which the relocation will
|
|
|
|
/// be applied. the offset is in bytes. zero based.</returns>
|
|
|
|
/// be applied. the offset is in bytes. zero based.</returns>
|
|
|
|
std::uint32_t offset() { return m_offset; }
|
|
|
|
std::uint32_t offset() { return m_offset; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// sets the offset to which the relocation gets applied too.
|
|
|
|
/// sets the offset to which the relocation gets applied too.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="offset">offset to which the relocation gets applied
|
|
|
|
/// <param name="offset">offset to which the relocation gets applied
|
|
|
|
/// too.</param>
|
|
|
|
/// too.</param>
|
|
|
|
void offset(std::uint32_t offset) { m_offset = offset; }
|
|
|
|
void offset(std::uint32_t offset) { m_offset = offset; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// adds a transformation to be applied to the relocation prior to writing it
|
|
|
|
|
|
|
|
/// into the symbol.
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="entry">a pair containing a lambda function that when executed
|
|
|
|
|
|
|
|
/// transforms a relocation. the second value in the pair is a random value
|
|
|
|
|
|
|
|
/// which is passed to the lambda.</param>
|
|
|
|
|
|
|
|
void add_transform(
|
|
|
|
|
|
|
|
std::pair<obf::transform::transform_t*, std::uint32_t> entry) {
|
|
|
|
|
|
|
|
m_transforms.push_back(entry);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// gets the vector of transformation.
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <returns>returns the vector of transformations.</returns>
|
|
|
|
|
|
|
|
std::vector<std::pair<obf::transform::transform_t*, std::uint32_t>>&
|
|
|
|
|
|
|
|
get_transforms() {
|
|
|
|
|
|
|
|
return m_transforms;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
|
|
|
|
std::vector<std::pair<obf::transform::transform_t*, std::uint32_t>>
|
|
|
|
|
|
|
|
m_transforms;
|
|
|
|
std::string m_sym_name;
|
|
|
|
std::string m_sym_name;
|
|
|
|
std::size_t m_hash;
|
|
|
|
std::size_t m_hash;
|
|
|
|
std::uint32_t m_offset;
|
|
|
|
std::uint32_t m_offset;
|
|
|
|