#include "manual_map.hpp" namespace inject { // pe file implementation c_pe_file::c_pe_file(const char *file) { std::ifstream pe_file(file, std::ifstream::in | std::ifstream::binary); if (!pe_file.is_open()) { printf("file (%s) does not exist\n", file); return; } pe_file.seekg(0, pe_file.end); uint32_t pe_size = pe_file.tellg(); m_file.resize(pe_size); pe_file.seekg(0, pe_file.beg); // HOMOSEXUAL CAST FUCKERY PLEASE SKIP THIS LINE // AAAAAAAAAAAA BAD pe_file.read((char*)&m_file[0], pe_size); pe_file.close(); } bool c_pe_file::valid() { nt::dos_header_t *dos_header; nt::nt_headers_t *nt_headers; // check dos header dos_header = reinterpret_cast((uint32_t)data()); if (dos_header->e_magic != 0x45DA) return false; // check nt header nt_headers = reinterpret_cast((uint32_t)data() + dos_header->e_lfanew); if (nt_headers->signature != 0x50450000) return false; return true; } uint8_t *c_pe_file::data() { // go to the beginning of the file // yes i know i could've just done 'new uint8_t[pe_size]' but fuck u. return reinterpret_cast(&m_file[0]); } size_t c_pe_file::size() const { return m_file.size(); } }