added open_binary_file to vmutils.hpp

master
IDontCode 3 years ago
parent 05748c67be
commit dd7d3777ad

@ -3,6 +3,7 @@
#include <Zydis/Zydis.h> #include <Zydis/Zydis.h>
#include <xmmintrin.h> #include <xmmintrin.h>
#include <fstream>
#include <memory> #include <memory>
#include <optional> #include <optional>
#include <vector> #include <vector>
@ -94,6 +95,23 @@ inline void init() {
} }
} }
inline bool open_binary_file(const std::string &file,
std::vector<uint8_t> &data) {
std::ifstream fstr(file, std::ios::binary);
if (!fstr.is_open()) return false;
fstr.unsetf(std::ios::skipws);
fstr.seekg(0, std::ios::end);
const auto file_size = fstr.tellg();
fstr.seekg(NULL, std::ios::beg);
data.reserve(static_cast<uint32_t>(file_size));
data.insert(data.begin(), std::istream_iterator<uint8_t>(fstr),
std::istream_iterator<uint8_t>());
return true;
}
/// <summary> /// <summary>
/// utils pertaining to native registers... /// utils pertaining to native registers...
/// </summary> /// </summary>

Loading…
Cancel
Save