\hypertarget { namespacetheo_ 1_ 1obf_ 1_ 1transform} { } \doxysection { theo\+ ::obf\+ ::transform Namespace Reference}
\label { namespacetheo_ 1_ 1obf_ 1_ 1transform} \index { theo::obf::transform@{ theo::obf::transform} }
this namespace encompasses the code for transforming relocations.
\doxysubsection * { Data Structures}
\begin { DoxyCompactItemize}
\item
class \mbox { \hyperlink { classtheo_ 1_ 1obf_ 1_ 1transform_ 1_ 1add_ _ op_ _ t} { add\+ \_ \+ op\+ \_ \+ t} }
\item
class \mbox { \hyperlink { classtheo_ 1_ 1obf_ 1_ 1transform_ 1_ 1operation_ _ t} { operation\+ \_ \+ t} }
\begin { DoxyCompactList} \small \item \em \mbox { \hyperlink { classtheo_ 1_ 1obf_ 1_ 1transform_ 1_ 1operation_ _ t} { operation\+ \_ \+ t} } is the base class for all types of transformations. classes that inherit this class are singleton and simply call the super constructor (\mbox { \hyperlink { classtheo_ 1_ 1obf_ 1_ 1transform_ 1_ 1operation_ _ t_ a3876ca1c7904aed54940e1519fc9fdf4} { operation\+ \_ \+ t\+ ::operation\+ \_ \+ t} } ). \end { DoxyCompactList} \item
class \mbox { \hyperlink { classtheo_ 1_ 1obf_ 1_ 1transform_ 1_ 1rol_ _ op_ _ t} { rol\+ \_ \+ op\+ \_ \+ t} }
\item
class \mbox { \hyperlink { classtheo_ 1_ 1obf_ 1_ 1transform_ 1_ 1ror_ _ op_ _ t} { ror\+ \_ \+ op\+ \_ \+ t} }
\item
class \mbox { \hyperlink { classtheo_ 1_ 1obf_ 1_ 1transform_ 1_ 1sub_ _ op_ _ t} { sub\+ \_ \+ op\+ \_ \+ t} }
\item
class \mbox { \hyperlink { classtheo_ 1_ 1obf_ 1_ 1transform_ 1_ 1xor_ _ op_ _ t} { xor\+ \_ \+ op\+ \_ \+ t} }
\end { DoxyCompactItemize}
\doxysubsection * { Typedefs}
\begin { DoxyCompactItemize}
\item
using \mbox { \hyperlink { namespacetheo_ 1_ 1obf_ 1_ 1transform_ a875984c1ce09aa998fe48cca55270ecc} { transform\+ \_ \+ t} } = std\+ ::function$ < $ std\+ ::size\+ \_ \+ t(std\+ ::size\+ \_ \+ t, std\+ ::uint32\+ \_ \+ t)$ > $
\begin { DoxyCompactList} \small \item \em lambda function which takes in a 64bit value (relocation address) and a 32bit value (random value used in transformation). \end { DoxyCompactList} \end { DoxyCompactItemize}
\doxysubsection * { Functions}
\begin { DoxyCompactItemize}
\item
std\+ ::vector$ < $ std\+ ::uint8\+ \_ \+ t $ > $ \mbox { \hyperlink { namespacetheo_ 1_ 1obf_ 1_ 1transform_ abb618f5ff8d88963dd77e682456ef982} { generate} } (xed\+ \_ \+ decoded\+ \_ \+ inst\+ \_ \+ t $ \ast $ inst, \mbox { \hyperlink { classtheo_ 1_ 1recomp_ 1_ 1reloc_ _ t} { recomp\+ ::reloc\+ \_ \+ t} } $ \ast $ reloc, std\+ ::uint8\+ \_ \+ t low, std\+ ::uint8\+ \_ \+ t high)
\begin { DoxyCompactList} \small \item \em generate a sequence of transformations given an instruction that has a relocation in it. \end { DoxyCompactList} \end { DoxyCompactItemize}
\doxysubsection * { Variables}
\begin { DoxyCompactItemize}
\item
std\+ ::map$ < $ xed\+ \_ \+ iclass\+ \_ \+ enum\+ \_ \+ t, \mbox { \hyperlink { classtheo_ 1_ 1obf_ 1_ 1transform_ 1_ 1operation_ _ t} { operation\+ \_ \+ t} } $ \ast $ $ > $ \mbox { \hyperlink { namespacetheo_ 1_ 1obf_ 1_ 1transform_ a6a4b1d5c0c9c2ea1f0b4ec8f5aba48b0} { operations} }
\begin { DoxyCompactList} \small \item \em map of all of the operations and their type. \end { DoxyCompactList} \end { DoxyCompactItemize}
\doxysubsection { Detailed Description}
this namespace encompasses the code for transforming relocations.
\doxysubsection { Typedef Documentation}
\mbox { \Hypertarget { namespacetheo_ 1_ 1obf_ 1_ 1transform_ a875984c1ce09aa998fe48cca55270ecc} \label { namespacetheo_ 1_ 1obf_ 1_ 1transform_ a875984c1ce09aa998fe48cca55270ecc} }
\index { theo::obf::transform@{ theo::obf::transform} !transform\_ t@{ transform\_ t} }
\index { transform\_ t@{ transform\_ t} !theo::obf::transform@{ theo::obf::transform} }
\doxysubsubsection { \texorpdfstring { transform\_ t} { transform\_ t} }
{ \footnotesize \ttfamily using \mbox { \hyperlink { namespacetheo_ 1_ 1obf_ 1_ 1transform_ a875984c1ce09aa998fe48cca55270ecc} { theo\+ ::obf\+ ::transform\+ ::transform\+ \_ \+ t} } = typedef std\+ ::function$ < $ std\+ ::size\+ \_ \+ t(std\+ ::size\+ \_ \+ t, std\+ ::uint32\+ \_ \+ t)$ > $ }
lambda function which takes in a 64bit value (relocation address) and a 32bit value (random value used in transformation).
Definition at line \mbox { \hyperlink { operation_ 8hpp_ source_ l00054} { 54} } of file \mbox { \hyperlink { operation_ 8hpp_ source} { operation.\+ hpp} } .
\doxysubsection { Function Documentation}
\mbox { \Hypertarget { namespacetheo_ 1_ 1obf_ 1_ 1transform_ abb618f5ff8d88963dd77e682456ef982} \label { namespacetheo_ 1_ 1obf_ 1_ 1transform_ abb618f5ff8d88963dd77e682456ef982} }
\index { theo::obf::transform@{ theo::obf::transform} !generate@{ generate} }
\index { generate@{ generate} !theo::obf::transform@{ theo::obf::transform} }
\doxysubsubsection { \texorpdfstring { generate()} { generate()} }
{ \footnotesize \ttfamily std\+ ::vector$ < $ std\+ ::uint8\+ \_ \+ t $ > $ theo\+ ::obf\+ ::transform\+ ::generate (\begin { DoxyParamCaption} \item [{xed\+\_\+decoded\+\_\+inst\+\_\+t $\ast$}] { inst, } \item [{\mbox{\hyperlink{classtheo_1_1recomp_1_1reloc__t}{recomp\+::reloc\+\_\+t}} $\ast$}] { reloc, } \item [{std\+::uint8\+\_\+t}] { low, } \item [{std\+::uint8\+\_\+t}] { high } \end { DoxyParamCaption} )\hspace { 0.3cm} { \ttfamily [inline]} }
generate a sequence of transformations given an instruction that has a relocation in it.
\begin { DoxyParams} { Parameters}
{ \em inst} & instruction that has a relocation in it.\\
\hline
{ \em reloc} & meta data relocation object for the instruction.\\
\hline
{ \em low} & lowest number of transformations to generate.\\
\hline
{ \em high} & highest number of transformations to generate.\\
\hline
\end { DoxyParams}
\begin { DoxyReturn} { Returns}
\end { DoxyReturn}
Definition at line \mbox { \hyperlink { gen_ 8hpp_ source_ l00045} { 45} } of file \mbox { \hyperlink { gen_ 8hpp_ source} { gen.\+ hpp} } .
\begin { DoxyCode} { 0}
\DoxyCodeLine { 00048 \{ }
\DoxyCodeLine { 00049 \textcolor { keyword} { auto} num\_ transforms = transform::operation\_ t::random(low, high);}
\DoxyCodeLine { 00050 \textcolor { keyword} { auto} num\_ ops = \mbox { \hyperlink { namespacetheo_ 1_ 1obf_ 1_ 1transform_ a6a4b1d5c0c9c2ea1f0b4ec8f5aba48b0} { transform::operations} } .size();}
\DoxyCodeLine { 00051 std::vector<std::uint8\_ t> new\_ inst\_ bytes;}
\DoxyCodeLine { 00052 }
\DoxyCodeLine { 00053 std::uint32\_ t inst\_ len = \{ \} ;}
\DoxyCodeLine { 00054 std::uint8\_ t inst\_ buff[XED\_ MAX\_ INSTRUCTION\_ BYTES];}
\DoxyCodeLine { 00055 xed\_ encoder\_ request\_ t req;}
\DoxyCodeLine { 00056 }
\DoxyCodeLine { 00057 xed\_ state\_ t istate\{ XED\_ MACHINE\_ MODE\_ LONG\_ 64, XED\_ ADDRESS\_ WIDTH\_ 64b\} ;}
\DoxyCodeLine { 00058 xed\_ encoder\_ request\_ zero\_ set\_ mode(\& req, \& istate);}
\DoxyCodeLine { 00059 xed\_ encoder\_ request\_ set\_ effective\_ operand\_ width(\& req, 64);}
\DoxyCodeLine { 00060 xed\_ encoder\_ request\_ set\_ iclass(\& req, XED\_ ICLASS\_ PUSHFQ);}
\DoxyCodeLine { 00061 xed\_ encode(\& req, inst\_ buff, \textcolor { keyword} { sizeof} (inst\_ buff), \& inst\_ len);}
\DoxyCodeLine { 00062 new\_ inst\_ bytes.insert(new\_ inst\_ bytes.end(), inst\_ buff, inst\_ buff + inst\_ len);}
\DoxyCodeLine { 00063 }
\DoxyCodeLine { 00064 \textcolor { keywordflow} { for} (\textcolor { keyword} { auto} cnt = 0u; cnt < num\_ transforms; ++cnt) \{ }
\DoxyCodeLine { 00065 std::uint32\_ t imm = transform::operation\_ t::random(}
\DoxyCodeLine { 00066 0, std::numeric\_ limits<std::int32\_ t>::max());}
\DoxyCodeLine { 00067 }
\DoxyCodeLine { 00068 \textcolor { keyword} { auto} itr = \mbox { \hyperlink { namespacetheo_ 1_ 1obf_ 1_ 1transform_ a6a4b1d5c0c9c2ea1f0b4ec8f5aba48b0} { transform::operations} } .begin();}
\DoxyCodeLine { 00069 std::advance(itr, transform::operation\_ t::random(0, num\_ ops -\/ 1));}
\DoxyCodeLine { 00070 \textcolor { keyword} { auto} transform\_ bytes = itr-\/ >second-\/ >native(inst, imm);}
\DoxyCodeLine { 00071 new\_ inst\_ bytes.insert(new\_ inst\_ bytes.end(), transform\_ bytes.begin(),}
\DoxyCodeLine { 00072 transform\_ bytes.end());}
\DoxyCodeLine { 00073 }
\DoxyCodeLine { 00074 reloc-\/ >\mbox { \hyperlink { classtheo_ 1_ 1recomp_ 1_ 1reloc_ _ t_ ab5214a9ff9135672e25f40406c37fb10} { add\_ transform} } (}
\DoxyCodeLine { 00075 \{ \mbox { \hyperlink { namespacetheo_ 1_ 1obf_ 1_ 1transform_ a6a4b1d5c0c9c2ea1f0b4ec8f5aba48b0} { transform::operations} } [itr-\/ >second-\/ >inverse()]-\/ >get\_ transform(), imm\} );}
\DoxyCodeLine { 00076 \} }
\DoxyCodeLine { 00077 }
\DoxyCodeLine { 00078 xed\_ encoder\_ request\_ zero\_ set\_ mode(\& req, \& istate);}
\DoxyCodeLine { 00079 xed\_ encoder\_ request\_ set\_ effective\_ operand\_ width(\& req, 64);}
\DoxyCodeLine { 00080 xed\_ encoder\_ request\_ set\_ iclass(\& req, XED\_ ICLASS\_ POPFQ);}
\DoxyCodeLine { 00081 xed\_ encode(\& req, inst\_ buff, \textcolor { keyword} { sizeof} (inst\_ buff), \& inst\_ len);}
\DoxyCodeLine { 00082 new\_ inst\_ bytes.insert(new\_ inst\_ bytes.end(), inst\_ buff, inst\_ buff + inst\_ len);}
\DoxyCodeLine { 00083 }
\DoxyCodeLine { 00084 \textcolor { comment} { // inverse the order in which the transformations are executed...} }
\DoxyCodeLine { 00085 \textcolor { comment} { //} }
\DoxyCodeLine { 00086 std::reverse(reloc-\/ >\mbox { \hyperlink { classtheo_ 1_ 1recomp_ 1_ 1reloc_ _ t_ af8abfa7a4f1052308a233629faf39a78} { get\_ transforms} } ().begin(), reloc-\/ >\mbox { \hyperlink { classtheo_ 1_ 1recomp_ 1_ 1reloc_ _ t_ af8abfa7a4f1052308a233629faf39a78} { get\_ transforms} } ().end());}
\DoxyCodeLine { 00087 \textcolor { keywordflow} { return} new\_ inst\_ bytes;}
\DoxyCodeLine { 00088 \} }
\end { DoxyCode}
References \mbox { \hyperlink { reloc_ 8hpp_ source_ l00091} { theo\+ ::recomp\+ ::reloc\+ \_ \+ t\+ ::add\+ \_ \+ transform()} } , \mbox { \hyperlink { reloc_ 8hpp_ source_ l00101} { theo\+ ::recomp\+ ::reloc\+ \_ \+ t\+ ::get\+ \_ \+ transforms()} } , \mbox { \hyperlink { transform_ 8hpp_ source_ l00042} { operations} } , and \mbox { \hyperlink { operation_ 8hpp_ source_ l00148} { theo\+ ::obf\+ ::transform\+ ::operation\+ \_ \+ t\+ ::random()} } .
Referenced by \mbox { \hyperlink { next_ _ inst_ _ pass_ 8cpp_ source_ l00038} { theo\+ ::obf\+ ::next\+ \_ \+ inst\+ \_ \+ pass\+ \_ \+ t\+ ::run()} } , and \mbox { \hyperlink { reloc_ _ transform_ _ pass_ 8cpp_ source_ l00039} { theo\+ ::obf\+ ::reloc\+ \_ \+ transform\+ \_ \+ pass\+ \_ \+ t\+ ::run()} } .
\doxysubsection { Variable Documentation}
\mbox { \Hypertarget { namespacetheo_ 1_ 1obf_ 1_ 1transform_ a6a4b1d5c0c9c2ea1f0b4ec8f5aba48b0} \label { namespacetheo_ 1_ 1obf_ 1_ 1transform_ a6a4b1d5c0c9c2ea1f0b4ec8f5aba48b0} }
\index { theo::obf::transform@{ theo::obf::transform} !operations@{ operations} }
\index { operations@{ operations} !theo::obf::transform@{ theo::obf::transform} }
\doxysubsubsection { \texorpdfstring { operations} { operations} }
{ \footnotesize \ttfamily std\+ ::map$ < $ xed\+ \_ \+ iclass\+ \_ \+ enum\+ \_ \+ t, \mbox { \hyperlink { classtheo_ 1_ 1obf_ 1_ 1transform_ 1_ 1operation_ _ t} { operation\+ \_ \+ t} } $ \ast $ $ > $ theo\+ ::obf\+ ::transform\+ ::operations\hspace { 0.3cm} { \ttfamily [inline]} }
{ \bfseries Initial value\+ :}
\begin { DoxyCode} { 0}
\DoxyCodeLine { = \{ }
\DoxyCodeLine { \{ XED\_ ICLASS\_ ADD, add\_ op\_ t::get()\} ,}
\DoxyCodeLine { \{ XED\_ ICLASS\_ SUB, sub\_ op\_ t::get()\} ,}
\DoxyCodeLine { \{ XED\_ ICLASS\_ ROL, rol\_ op\_ t::get()\} ,}
\DoxyCodeLine { \{ XED\_ ICLASS\_ ROR, ror\_ op\_ t::get()\} ,}
\DoxyCodeLine { \{ XED\_ ICLASS\_ XOR, xor\_ op\_ t::get()\} \} }
\end { DoxyCode}
map of all of the operations and their type.
Definition at line \mbox { \hyperlink { transform_ 8hpp_ source_ l00042} { 42} } of file \mbox { \hyperlink { transform_ 8hpp_ source} { transform.\+ hpp} } .
Referenced by \mbox { \hyperlink { gen_ 8hpp_ source_ l00045} { generate()} } .