operation_t is the base class for all types of transformations. classes that inherit this class are singleton and simply call the super constructor (operation_t::operation_t).
More...
#include <operation.hpp>
|
| operation_t (transform_t op, xed_iclass_enum_t type) |
| explicit constructor for operation_t More...
|
|
std::vector< std::uint8_t > | native (const xed_decoded_inst_t *inst, std::uint32_t imm) |
| generates a native transform instruction given an existing instruction. it works like so: More...
|
|
xed_iclass_enum_t | inverse () |
| gets the inverse operation of the current operation. More...
|
|
transform_t * | get_transform () |
| gets a pointer to the lambda function which contains the transform logic. More...
|
|
xed_iclass_enum_t | type () |
| gets the operation type. such as XED_ICLASS_ADD, XED_ICLASS_SUB, etc... More...
|
|
|
static std::size_t | random (std::size_t lowest, std::size_t largest) |
| generate a random number in a range. More...
|
|
operation_t is the base class for all types of transformations. classes that inherit this class are singleton and simply call the super constructor (operation_t::operation_t).
◆ operation_t()
theo::obf::transform::operation_t::operation_t |
( |
transform_t |
op, |
|
|
xed_iclass_enum_t |
type |
|
) |
| |
|
inlineexplicit |
explicit constructor for operation_t
- Parameters
-
op | lambda function when executed applies transformations. |
type | type of transformation, such as XOR, ADD, SUB, etc... |
70 : m_transform(op), m_type(
type) {}
◆ get_transform()
transform_t* theo::obf::transform::operation_t::get_transform |
( |
| ) |
|
|
inline |
gets a pointer to the lambda function which contains the transform logic.
- Returns
- a pointer to the lambda function which contains the transform logic.
133 {
return &m_transform; }
◆ inverse()
xed_iclass_enum_t theo::obf::transform::operation_t::inverse |
( |
| ) |
|
|
inline |
gets the inverse operation of the current operation.
- Returns
- the inverse operation of the current operation.
126 {
return m_inverse_op[m_type]; }
◆ native()
std::vector<std::uint8_t> theo::obf::transform::operation_t::native |
( |
const xed_decoded_inst_t * |
inst, |
|
|
std::uint32_t |
imm |
|
) |
| |
|
inline |
generates a native transform instruction given an existing instruction. it works like so:
mov rax, &MessageBoxA ; original instruction with relocation
; this function takes the first operand and out of the original ; instruction and uses it to generate a transformation.
xor rax, 0x39280928 ; this would be an example output for the xor ;operation.
- Parameters
-
inst | instruction with a relocation to generate a transformation for. |
imm | random 32bit number used in the generate transform. |
- Returns
- returns the bytes of the native instruction that was encoded.
91 std::uint32_t inst_len = {};
92 std::uint8_t inst_buff[XED_MAX_INSTRUCTION_BYTES];
95 xed_encoder_request_init_from_decode((xed_decoded_inst_s*)inst);
96 xed_encoder_request_t* req = (xed_encoder_request_t*)inst;
101 xed_encoder_request_set_uimm0(req, imm, 1);
104 xed_encoder_request_set_uimm0(req, imm, 4);
108 xed_encoder_request_set_iclass(req, m_type);
109 xed_encoder_request_set_operand_order(req, 1, XED_OPERAND_IMM0);
111 if ((err = xed_encode(req, inst_buff,
sizeof(inst_buff), &inst_len)) !=
113 spdlog::error(
"failed to encode instruction... reason: {}",
114 xed_error_enum_t2str(err));
116 assert(err == XED_ERROR_NONE);
119 return std::vector<std::uint8_t>(inst_buff, inst_buff + inst_len);
◆ random()
static std::size_t theo::obf::transform::operation_t::random |
( |
std::size_t |
lowest, |
|
|
std::size_t |
largest |
|
) |
| |
|
inlinestatic |
generate a random number in a range.
- Parameters
-
lowest | lowest value of the range. |
largest | highest value of the range. |
- Returns
- a random value in a range.
149 std::random_device rd;
150 std::mt19937 gen(rd());
151 std::uniform_int_distribution<std::size_t> distr(lowest, largest);
◆ type()
xed_iclass_enum_t theo::obf::transform::operation_t::type |
( |
| ) |
|
|
inline |
gets the operation type. such as XED_ICLASS_ADD, XED_ICLASS_SUB, etc...
- Returns
- the operation type. such as XED_ICLASS_ADD, XED_ICLASS_SUB, etc...
The documentation for this class was generated from the following file: