You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Theodosius/include/obf/passes/reloc_transform_pass.hpp

36 lines
1.1 KiB

#pragma once
#include <obf/pass.hpp>
#include <obf/transform/operation.hpp>
#include <obf/transform/transform.hpp>
namespace theo::obf {
/// <summary>
/// this pass is like the next_inst_pass, however, relocations are encrypted
/// with transformations instead of the address of the next instruction. this
/// pass only runs at the instruction level and appends transformations into the
/// reloc_t object of the instruction symbol.
///
/// given the following code:
///
/// mov rax, &MessageBoxA
///
/// this pass will generate a random number of transformations to encrypt the
/// address of "MessageBoxA". These transformations will then be applied by
/// theodosius internally when resolving relocations.
///
/// mov rax, enc_MessageBoxA
/// xor rax, 0x389284324
/// add rax, 0x345332567
/// ror rax, 0x5353
/// </summary>
class reloc_transform_pass_t : public pass_t {
explicit reloc_transform_pass_t() : pass_t(decomp::sym_type_t::instruction){};
public:
static reloc_transform_pass_t* get();
void run(decomp::symbol_t* sym);
private:
std::optional<recomp::reloc_t*> has_legit_reloc(decomp::symbol_t* sym);
};
} // namespace theo::obf