multi thread support

master
IDontCode 3 years ago
parent bf2d6acba0
commit 7f217f9815

@ -5,7 +5,9 @@
#include <fstream> #include <fstream>
#include <memory> #include <memory>
#include <mutex>
#include <optional> #include <optional>
#include <thread>
#include <vector> #include <vector>
#ifdef _MSC_VER #ifdef _MSC_VER
@ -79,8 +81,8 @@ using zydis_routine_t = std::vector<zydis_instr_t>;
/// </summary> /// </summary>
namespace vm::util { namespace vm::util {
inline std::shared_ptr<ZydisDecoder> g_decoder = nullptr; inline thread_local std::shared_ptr<ZydisDecoder> g_decoder = nullptr;
inline std::shared_ptr<ZydisFormatter> g_formatter = nullptr; inline thread_local std::shared_ptr<ZydisFormatter> g_formatter = nullptr;
inline void init() { inline void init() {
if (!vm::util::g_decoder && !vm::util::g_formatter) { if (!vm::util::g_decoder && !vm::util::g_formatter) {

@ -169,21 +169,21 @@ void deobfuscate(zydis_routine_t &routine) {
}; };
std::uint32_t last_size = 0u; std::uint32_t last_size = 0u;
static const std::vector<ZydisMnemonic> blacklist = {
ZYDIS_MNEMONIC_CLC, ZYDIS_MNEMONIC_BT, ZYDIS_MNEMONIC_TEST,
ZYDIS_MNEMONIC_CMP, ZYDIS_MNEMONIC_CMC, ZYDIS_MNEMONIC_STC};
static const std::vector<ZydisMnemonic> whitelist = {
ZYDIS_MNEMONIC_PUSH, ZYDIS_MNEMONIC_POP, ZYDIS_MNEMONIC_CALL,
ZYDIS_MNEMONIC_DIV};
do { do {
last_size = routine.size(); last_size = routine.size();
for (auto itr = routine.begin(); itr != routine.end(); ++itr) { for (auto itr = routine.begin(); itr != routine.end(); ++itr) {
// dont remove these... at all... if (std::find(whitelist.begin(), whitelist.end(), itr->instr.mnemonic) !=
if (itr->instr.mnemonic == ZYDIS_MNEMONIC_PUSH || whitelist.end())
itr->instr.mnemonic == ZYDIS_MNEMONIC_POP ||
itr->instr.mnemonic == ZYDIS_MNEMONIC_CALL)
continue; continue;
static const std::vector<ZydisMnemonic> blacklist = {
ZYDIS_MNEMONIC_CLC, ZYDIS_MNEMONIC_BT, ZYDIS_MNEMONIC_TEST,
ZYDIS_MNEMONIC_CMP, ZYDIS_MNEMONIC_CMC, ZYDIS_MNEMONIC_STC};
if (std::find(blacklist.begin(), blacklist.end(), itr->instr.mnemonic) != if (std::find(blacklist.begin(), blacklist.end(), itr->instr.mnemonic) !=
blacklist.end()) { blacklist.end()) {
routine.erase(itr); routine.erase(itr);

Loading…
Cancel
Save