// Copyright (c) 2022, _xeroxz // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // #pragma once #include #include #include #include #include #include #include #include #include #include #include #define XED_ENCODER extern "C" { #include #include } /// /// The outer most encompassing namespace of this project. /// namespace theo { /// /// tuple of functions used by theo to allocate, copy, and resolve symbols. /// using lnk_fns_t = std::tuple; /// /// the main class which encapsulates a symbol table, decomp, and recomp /// objects. This class is a bridge that connects all three: decomp, obf, /// recomp. /// /// You will create an object of this type when using theo. /// class theo_t { public: /// /// explicit constructor for theo class. /// /// a vector of bytes consisting of a lib /// /// the name of the function which will be used as the /// entry point explicit theo_t(std::vector& lib, lnk_fns_t lnkr_fns, const std::string&& entry_sym); /// /// decomposes the lib file and return the number of symbols that are used. /// /// optional amount of symbols that are used. no value if /// decomposition fails. std::optional decompose(); /// /// compose the decomposed module. This will run obfuscation passes, the map /// and resolve symbols to each other. /// /// returns the address of the entry point symbol std::uintptr_t compose(); /// /// given the name of a symbol, it returns the address of where its mapped. /// /// the name of the symbol /// the address of the symbol std::uintptr_t resolve(const std::string&& sym); private: std::string m_entry_sym; decomp::decomp_t m_dcmp; recomp::recomp_t m_recmp; recomp::symbol_table_t m_sym_tbl; }; } // namespace theo