56 lines
1.6 KiB
C
Raw Normal View History

2019-03-17 18:42:07 +03:00
#ifndef PE_H
#define PE_H
2019-03-20 18:05:14 +03:00
#include <QFile>
2019-03-17 18:42:07 +03:00
#include <QString>
2019-03-18 10:33:03 +03:00
#include "igetlibinfo.h"
2019-03-17 18:42:07 +03:00
struct LIB_META_INFO {
2019-03-17 20:16:48 +03:00
unsigned short mashine = 0x0;
unsigned short type = 0x0;
unsigned int addressImports = 0x0;
unsigned int sizeImportTable = 0x0;
};
2019-03-17 18:42:07 +03:00
2019-03-18 10:33:03 +03:00
class PE : public IGetLibInfo {
2019-03-17 18:42:07 +03:00
2019-03-17 20:16:48 +03:00
private:
2019-03-20 18:05:14 +03:00
int findIndexPE(QFile &file);
2019-03-17 20:16:48 +03:00
bool fillMetaInfo(LIB_META_INFO& info, const QString &file);
2019-03-17 18:42:07 +03:00
2019-03-18 17:12:40 +03:00
constexpr static unsigned int PE_MAGIC = 0x00004550;
constexpr static unsigned int INDEX_PE_MAGIC = 0x80;
2019-03-20 18:05:14 +03:00
constexpr static unsigned int INDEX_MAGIC = 0x18;
constexpr static unsigned int INDEX_IMPORTS_32 = 0x68;
constexpr static unsigned int INDEX_IMPORTS_64 = 0x78;
2019-03-18 17:12:40 +03:00
2019-03-17 18:42:07 +03:00
public:
enum class MashineTypesS: unsigned short {
IMAGE_FILE_MACHINE_UNKNOWN = 0x0,
IMAGE_FILE_MACHINE_AMD64 = 0x8664, // x64
IMAGE_FILE_MACHINE_ARM = 0x1c0, // ARM little endian
IMAGE_FILE_MACHINE_ARM64 = 0xaa64, // ARM64 little endian
IMAGE_FILE_MACHINE_ARMNT = 0x1c4, // ARM Thumb-2 little endian
IMAGE_FILE_MACHINE_I386 = 0x14c, // Intel 386 or later processors and compatible processors
};
enum class RunType: unsigned short {
_UNKNOWN = 0x0,
_32bit = 0x10B,
_64bit = 0x20B,
_ROM = 0x107,
};
2019-03-18 10:33:03 +03:00
bool is32bit(const QString& file, const LIB_META_INFO *info = nullptr);
bool dependecies(QStringList& lisr, const QString& file,
const LIB_META_INFO *info = nullptr);
2019-03-17 18:42:07 +03:00
PE();
2019-03-18 10:33:03 +03:00
2019-03-19 21:50:05 +03:00
bool getLibInfo(const QString& lib, LibInfo& info) override;
2019-03-18 17:12:40 +03:00
~PE() override;
2019-03-17 18:42:07 +03:00
};
#endif // PE_H