Files
pe-packer/pe-packer/utils/utils.hpp

21 lines
551 B
C++

#include <Windows.h>
#include <random>
inline int random_value(int from, int to) {
std::random_device dev;
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> dist6(from, to);
return dist6(rng);
}
inline void enable_virtual_terminal_processing() {
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hOut == INVALID_HANDLE_VALUE) return;
DWORD dwMode = 0;
if (!GetConsoleMode(hOut, &dwMode)) return;
dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
SetConsoleMode(hOut, dwMode);
}