#pragma once namespace perses { template class X86BinaryApplication { public: X86BinaryApplication() = delete; X86BinaryApplication(std::string_view filePath); ~X86BinaryApplication(); void loadFromFile(std::string_view filePath); SharedProtectionSchema buildSchema(int flag); bool scanForMarkers(); bool addRoutineByAddress(uptr address, int marker); bool addRoutineBySymbol(std::string_view symbolName, int marker); bool addRoutineBySymbol(const MapSymbol* symbol, int marker); bool addRoutineByAddress(uptr start, uptr end, int marker); bool transformRoutines(); bool isRelocationPresent(u32 rva); void removeRelocation(u32 rva); void dumpRoutines(); void linkCode(Routine* origRtn, assembler::CodeHolder& code, const std::vector& relocs, const std::vector& jumpTable); void compile(); bool linkMapFile(MapFileType type, std::filesystem::path filePath); bool hasMapFile() const; bool inquireJumpTable(instruction_t* insn, uptr begin, uptr end, int entryCount, std::vector& entries); bool parseFunctionList(std::filesystem::path path); assembler::Environment getEnvironment(); uptr getBaseAddress() { return _peFile.getImageBase(); } pe::Image& getImage() { return _peFile; } std::vector& getSymbols() { return _mapSymbols; } const std::vector& getRoutines() const { return _routines; } const std::set& getOriginalRelocs() const { return _originalRelocs; } private: std::vector _routines; std::map> _proutines; pe::Image _peFile; std::set _originalRelocs; std::vector _newRelocs; std::map> _relocBlocks; size_t _currentSectionOffset{}; std::filesystem::path _filePath; std::vector _mapSymbols; std::vector _mapFuncSymbols; MapFileType _mapType; uptr _persesAddr{}; }; }