mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-05-06 22:49:35 +00:00
fix pe
This commit is contained in:
parent
467a49da08
commit
cc80354c0d
@ -45,7 +45,9 @@ SOURCES += \
|
||||
windependenciesscanner.cpp \
|
||||
../qtTools/src/windeployqt/elfreader.cpp \
|
||||
../qtTools/src/windeployqt/utils.cpp \
|
||||
pe.cpp
|
||||
pe.cpp \
|
||||
igetlibinfo.cpp \
|
||||
structs.cpp
|
||||
|
||||
HEADERS += \
|
||||
deploy.h \
|
||||
@ -54,6 +56,8 @@ HEADERS += \
|
||||
windependenciesscanner.h\
|
||||
../qtTools/src/windeployqt/elfreader.h \
|
||||
../qtTools/src/windeployqt/utils.h \
|
||||
pe.h
|
||||
pe.h \
|
||||
igetlibinfo.h \
|
||||
structs.h
|
||||
|
||||
win32: LIBS += -lshlwapi
|
||||
|
1
Deploy/igetlibinfo.cpp
Normal file
1
Deploy/igetlibinfo.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "igetlibinfo.h"
|
17
Deploy/igetlibinfo.h
Normal file
17
Deploy/igetlibinfo.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef IGETLIBINFO_H
|
||||
#define IGETLIBINFO_H
|
||||
|
||||
#include "structs.h"
|
||||
|
||||
class IGetLibInfo
|
||||
{
|
||||
public:
|
||||
IGetLibInfo() = default;
|
||||
|
||||
virtual LibInfo&& getLibInfo(const QString& lib) = 0;
|
||||
|
||||
virtual ~IGetLibInfo() = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // IGETLIBINFO_H
|
@ -1,8 +1,7 @@
|
||||
#include "pe.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
bool PE::fillMetaInfo(LIB_META_INFO &info, const QString &file) {
|
||||
QFile f(file);
|
||||
@ -69,24 +68,34 @@ bool PE::fillMetaInfo(LIB_META_INFO &info, const QString &file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO is sucks rewrite!
|
||||
bool PE::is32bit(const QString &file) {
|
||||
bool PE::is32bit(const QString &file, const LIB_META_INFO * info) {
|
||||
|
||||
LIB_META_INFO meta;
|
||||
if (!info) {
|
||||
LIB_META_INFO meta;
|
||||
|
||||
if (!fillMetaInfo(meta, file)) {
|
||||
return false;
|
||||
if (!fillMetaInfo(meta, file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return static_cast<RunType>(meta.type) == RunType::_32bit;
|
||||
}
|
||||
|
||||
return static_cast<RunType>(meta.type) == RunType::_32bit;
|
||||
return static_cast<RunType>(info->type) == RunType::_32bit;
|
||||
}
|
||||
|
||||
bool PE::dependecies(QStringList &list, const QString &file) {
|
||||
// TODO
|
||||
bool PE::dependecies(QStringList &list, const QString &file,
|
||||
const LIB_META_INFO * info) {
|
||||
|
||||
|
||||
LIB_META_INFO meta;
|
||||
|
||||
if (!fillMetaInfo(meta, file)) {
|
||||
return false;
|
||||
if (!info) {
|
||||
|
||||
if (!fillMetaInfo(meta, file)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
meta = std::move(*info);
|
||||
}
|
||||
|
||||
QFile f(file);
|
||||
@ -102,7 +111,7 @@ bool PE::dependecies(QStringList &list, const QString &file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray data = f.read(meta.sizeImportTable);
|
||||
auto data = f.read(meta.sizeImportTable).split(char(0x0));
|
||||
|
||||
f.close();
|
||||
|
||||
@ -110,13 +119,39 @@ bool PE::dependecies(QStringList &list, const QString &file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
for (QString i : data) {
|
||||
if (i.contains(".dll")) {
|
||||
list.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PE::PE()
|
||||
{
|
||||
PE::PE() {
|
||||
|
||||
}
|
||||
|
||||
LibInfo &&PE::getLibInfo(const QString &lib) {
|
||||
LibInfo info;
|
||||
LIB_META_INFO meta;
|
||||
|
||||
if (!fillMetaInfo(meta, lib)) {
|
||||
return std::move(info);
|
||||
}
|
||||
|
||||
info.name = QFileInfo(lib).fileName();
|
||||
info.path = QFileInfo(lib).filePath();
|
||||
|
||||
if (static_cast<RunType>(meta.type) == RunType::_32bit) {
|
||||
info.platform = Platform::Win32;
|
||||
} else if (static_cast<RunType>(meta.type) == RunType::_64bit) {
|
||||
info.platform = Platform::Win64;
|
||||
} else {
|
||||
info.platform = Platform::UnknownPlatform;
|
||||
}
|
||||
|
||||
dependecies(info.dependncies, lib, &meta);
|
||||
|
||||
return std::move(info);
|
||||
}
|
||||
|
13
Deploy/pe.h
13
Deploy/pe.h
@ -2,6 +2,7 @@
|
||||
#define PE_H
|
||||
|
||||
#include <QString>
|
||||
#include "igetlibinfo.h"
|
||||
|
||||
struct LIB_META_INFO {
|
||||
unsigned short mashine = 0x0;
|
||||
@ -10,7 +11,7 @@ struct LIB_META_INFO {
|
||||
unsigned int sizeImportTable = 0x0;
|
||||
};
|
||||
|
||||
class PE {
|
||||
class PE : public IGetLibInfo {
|
||||
|
||||
private:
|
||||
bool fillMetaInfo(LIB_META_INFO& info, const QString &file);
|
||||
@ -38,9 +39,15 @@ public:
|
||||
constexpr static unsigned int INDEX_IMPORTS_32 = INDEX_MAGIC + 0x68;
|
||||
constexpr static unsigned int INDEX_IMPORTS_64 = INDEX_MAGIC + 0x78;
|
||||
|
||||
bool is32bit(const QString& file);
|
||||
bool dependecies(QStringList& lisr, const QString& file);
|
||||
bool is32bit(const QString& file, const LIB_META_INFO *info = nullptr);
|
||||
bool dependecies(QStringList& lisr, const QString& file,
|
||||
const LIB_META_INFO *info = nullptr);
|
||||
PE();
|
||||
~PE();
|
||||
|
||||
// IGetLibInfo interface
|
||||
public:
|
||||
LibInfo &&getLibInfo(const QString& lib);
|
||||
};
|
||||
|
||||
#endif // PE_H
|
||||
|
10
Deploy/structs.cpp
Normal file
10
Deploy/structs.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "structs.h"
|
||||
|
||||
bool LibInfo::operator ==(const LibInfo &other) {
|
||||
return platform == other.platform &&
|
||||
name == other.name;
|
||||
}
|
||||
|
||||
QString LibInfo::fullPath() {
|
||||
return path + "/" + name;
|
||||
}
|
25
Deploy/structs.h
Normal file
25
Deploy/structs.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef LIBINFO_H
|
||||
#define LIBINFO_H
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
enum Platform {
|
||||
UnknownPlatform = 0x0,
|
||||
Win32,
|
||||
Win64,
|
||||
Unix
|
||||
};
|
||||
|
||||
struct LibInfo {
|
||||
Platform platform = Platform::UnknownPlatform;
|
||||
QString name;
|
||||
QString path;
|
||||
QStringList dependncies;
|
||||
|
||||
bool operator == (const LibInfo& other);
|
||||
|
||||
QString fullPath();
|
||||
};
|
||||
|
||||
#endif // LIBINFO_H
|
@ -13,48 +13,48 @@
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
struct Options {
|
||||
enum DebugDetection {
|
||||
DebugDetectionAuto,
|
||||
DebugDetectionForceDebug,
|
||||
DebugDetectionForceRelease
|
||||
};
|
||||
//struct Options {
|
||||
// enum DebugDetection {
|
||||
// DebugDetectionAuto,
|
||||
// DebugDetectionForceDebug,
|
||||
// DebugDetectionForceRelease
|
||||
// };
|
||||
|
||||
enum AngleDetection {
|
||||
AngleDetectionAuto,
|
||||
AngleDetectionForceOn,
|
||||
AngleDetectionForceOff
|
||||
};
|
||||
// enum AngleDetection {
|
||||
// AngleDetectionAuto,
|
||||
// AngleDetectionForceOn,
|
||||
// AngleDetectionForceOff
|
||||
// };
|
||||
|
||||
bool plugins = true;
|
||||
bool libraries = true;
|
||||
bool quickImports = true;
|
||||
bool translations = true;
|
||||
bool systemD3dCompiler = true;
|
||||
bool compilerRunTime = false;
|
||||
AngleDetection angleDetection = AngleDetectionAuto;
|
||||
bool softwareRasterizer = true;
|
||||
Platform platform = Windows;
|
||||
quint64 additionalLibraries = 0;
|
||||
quint64 disabledLibraries = 0;
|
||||
unsigned updateFileFlags = 0;
|
||||
QStringList qmlDirectories; // Project's QML files.
|
||||
QString directory;
|
||||
QString translationsDirectory; // Translations target directory
|
||||
QString libraryDirectory;
|
||||
QString pluginDirectory;
|
||||
QStringList binaries;
|
||||
JsonOutput *json = nullptr;
|
||||
ListOption list = ListNone;
|
||||
DebugDetection debugDetection = DebugDetectionAuto;
|
||||
bool deployPdb = false;
|
||||
bool dryRun = false;
|
||||
bool patchQt = true;
|
||||
// bool plugins = true;
|
||||
// bool libraries = true;
|
||||
// bool quickImports = true;
|
||||
// bool translations = true;
|
||||
// bool systemD3dCompiler = true;
|
||||
// bool compilerRunTime = false;
|
||||
// AngleDetection angleDetection = AngleDetectionAuto;
|
||||
// bool softwareRasterizer = true;
|
||||
// Platform platform = Windows;
|
||||
// quint64 additionalLibraries = 0;
|
||||
// quint64 disabledLibraries = 0;
|
||||
// unsigned updateFileFlags = 0;
|
||||
// QStringList qmlDirectories; // Project's QML files.
|
||||
// QString directory;
|
||||
// QString translationsDirectory; // Translations target directory
|
||||
// QString libraryDirectory;
|
||||
// QString pluginDirectory;
|
||||
// QStringList binaries;
|
||||
// JsonOutput *json = nullptr;
|
||||
// ListOption list = ListNone;
|
||||
// DebugDetection debugDetection = DebugDetectionAuto;
|
||||
// bool deployPdb = false;
|
||||
// bool dryRun = false;
|
||||
// bool patchQt = true;
|
||||
|
||||
inline bool isWinRt() const {
|
||||
return platform == WinRtArm || platform == WinRtIntel;
|
||||
}
|
||||
};
|
||||
// inline bool isWinRt() const {
|
||||
// return platform == WinRtArm || platform == WinRtIntel;
|
||||
// }
|
||||
//};
|
||||
|
||||
WinDependenciesScanner::WinDependenciesScanner() {}
|
||||
|
||||
@ -137,24 +137,24 @@ void WinDependenciesScanner::setEnvironment(const QStringList &env) {
|
||||
|
||||
}
|
||||
|
||||
Platform WinDependenciesScanner::platformFromMkSpec(const QString &xSpec)
|
||||
{
|
||||
if (xSpec == QLatin1String("linux-g++"))
|
||||
return Unix;
|
||||
if (xSpec.startsWith(QLatin1String("win32-")))
|
||||
return xSpec.contains(QLatin1String("g++")) ? WindowsMinGW : Windows;
|
||||
if (xSpec.startsWith(QLatin1String("winrt-x")))
|
||||
return WinRtIntel;
|
||||
if (xSpec.startsWith(QLatin1String("winrt-arm")))
|
||||
return WinRtArm;
|
||||
if (xSpec.startsWith(QLatin1String("wince"))) {
|
||||
if (xSpec.contains(QLatin1String("-x86-")))
|
||||
return WinCEIntel;
|
||||
if (xSpec.contains(QLatin1String("-arm")))
|
||||
return WinCEArm;
|
||||
}
|
||||
return UnknownPlatform;
|
||||
}
|
||||
//Platform WinDependenciesScanner::platformFromMkSpec(const QString &xSpec)
|
||||
//{
|
||||
// if (xSpec == QLatin1String("linux-g++"))
|
||||
// return Unix;
|
||||
// if (xSpec.startsWith(QLatin1String("win32-")))
|
||||
// return xSpec.contains(QLatin1String("g++")) ? WindowsMinGW : Windows;
|
||||
// if (xSpec.startsWith(QLatin1String("winrt-x")))
|
||||
// return WinRtIntel;
|
||||
// if (xSpec.startsWith(QLatin1String("winrt-arm")))
|
||||
// return WinRtArm;
|
||||
// if (xSpec.startsWith(QLatin1String("wince"))) {
|
||||
// if (xSpec.contains(QLatin1String("-x86-")))
|
||||
// return WinCEIntel;
|
||||
// if (xSpec.contains(QLatin1String("-arm")))
|
||||
// return WinCEArm;
|
||||
// }
|
||||
// return UnknownPlatform;
|
||||
//}
|
||||
|
||||
QStringList WinDependenciesScanner::scan(const QString &path, Platform platfr,
|
||||
const QString& qmake) {
|
||||
@ -170,7 +170,7 @@ QStringList WinDependenciesScanner::scan(const QString &path, Platform platfr,
|
||||
}
|
||||
|
||||
QStringList dep;
|
||||
readExecutable(path, platfr, &errorMessage, &dep);
|
||||
// readExecutable(path, platfr, &errorMessage, &dep);
|
||||
|
||||
if (!errorMessage.isEmpty()) {
|
||||
qCritical() << errorMessage;
|
||||
@ -190,13 +190,3 @@ QStringList WinDependenciesScanner::scan(const QString &path, Platform platfr,
|
||||
WinDependenciesScanner::~WinDependenciesScanner() {
|
||||
|
||||
}
|
||||
|
||||
bool LibInfo::operator ==(const LibInfo &other) {
|
||||
return platform == other.platform &&
|
||||
name == other.name &&
|
||||
is32bit == other.is32bit;
|
||||
}
|
||||
|
||||
QString LibInfo::fullPath() {
|
||||
return path + "/" + name;
|
||||
}
|
||||
|
@ -10,19 +10,9 @@
|
||||
|
||||
#include <QMultiMap>
|
||||
#include <QStringList>
|
||||
#include "../qtTools/src/windeployqt/utils.h"
|
||||
#include "deploy_global.h"
|
||||
#include "structs.h"
|
||||
|
||||
struct LibInfo {
|
||||
Platform platform = Platform::UnknownPlatform;
|
||||
bool is32bit = false;
|
||||
QString name;
|
||||
QString path;
|
||||
|
||||
bool operator == (const LibInfo& other);
|
||||
|
||||
QString fullPath();
|
||||
};
|
||||
|
||||
class DEPLOYSHARED_EXPORT WinDependenciesScanner {
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user