Exemple #1
0
    static bool parsing_supported(boost::filesystem::ifstream& f) {
        dos_t dos;
        f.seekg(0);
        f.read((char*)&dos, sizeof(dos));

        // 'MZ' and 'ZM' according to Wikipedia
        if (dos.e_magic != 0x4D5A && dos.e_magic != 0x5A4D) {
            return false;
        }

        header_t h;
        f.seekg(dos.e_lfanew);
        f.read((char*)&h, sizeof(h));

        return h.Signature == 0x00004550; // 'PE00'
    }
Exemple #2
0
    static bool parsing_supported(boost::filesystem::ifstream& f) {
        static const uint32_t magic_bytes = (sizeof(AddressOffsetT) <= sizeof(uint32_t) ? 0xfeedface : 0xfeedfacf);

        uint32_t magic;
        f.seekg(0);
        f.read(reinterpret_cast<char*>(&magic), sizeof(magic));
        return (magic_bytes == magic);
    }