Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Mac OS support #536

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
[submodule "QuasarAppLib"]
path = QuasarAppLib
url = https://github.com/QuasarApp/QuasarAppLib.git
[submodule "qtTools"]
path = qtTools
url = https://github.com/qt/qttools.git
[submodule "pe"]
path = pe
url = https://github.com/QuasarApp/pe-parse.git
[submodule "QuasarAppScripts"]
path = QuasarAppScripts
url = https://github.com/QuasarApp/QuasarAppScripts.git
[submodule "zip"]
path = zip
url = https://github.com/QuasarApp/zip.git
[submodule "LIEF"]
path = LIEF
url = https://github.com/QuasarApp/LIEF
6 changes: 3 additions & 3 deletions CQtDeployer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ android: DEFINES += WITHOUT_TESTS

!android {
SUBDIRS += QuasarAppLib \
Pe \
zip \
Deploy \
CQtDeployer \
Expand All @@ -42,7 +41,6 @@ android: DEFINES += WITHOUT_TESTS
CQtDeployer.depends=Deploy

QuasarAppLib.file = $$PWD/QuasarAppLib/QuasarApp.pro
Pe.file = $$PWD/pe/pe-parser-library/pe-parser-library.pro

include('$$PWD/QIFData/installerCQtDeployer.pri')

Expand All @@ -53,5 +51,7 @@ android: DEFINES += WITHOUT_TESTS


}
include($$PWD/test.pri)
include(LIEF/LIEF.pri)
include($$PWD/test.pri)


2 changes: 0 additions & 2 deletions CQtDeployer/CQtDeployer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ include('$$PWD/../QuasarAppLib/QuasarLib.pri')
include('$$PWD/../Deploy/Deploy.pri')
include('$$PWD/../zip/zip.pri')

include('$$PWD/../pe/pe-parser-library/pe-parser-library.pri')


TARGET = cqtdeployer

Expand Down
1 change: 1 addition & 0 deletions Deploy/Deploy.pri
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CONFIG(release, debug|release): {
unix:LIBS += -L$$DEPLOY_LIB_OUTPUT_DIR -lDeploy
win32:LIBS += -L$$DEPLOY_LIB_OUTPUT_DIR -lDeploy1

include('$$PWD/../LIEF/includeLIEF.pri')

INCLUDEPATH += "$$PWD/"

Expand Down
19 changes: 12 additions & 7 deletions Deploy/Deploy.pro
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,32 @@ CONFIG(release, debug|release): {
}

include('$$PWD/../QuasarAppLib/QuasarLib.pri')
include('$$PWD/../pe/pe-parser-library/pe-parser-library.pri')
include('$$PWD/../zip/zip.pri')
include('$$PWD/../LIEF/includeLIEF.pri')

INCLUDEPATH += $$PWD/Parsers


SOURCES += \
Distributions/deb.cpp \
Distributions/defaultdistro.cpp \
Distributions/templateinfo.cpp \
Distributions/ziparhive.cpp \
Parsers/macho_type.cpp \
dependencymap.cpp \
deployconfig.cpp \
distromodule.cpp \
distrostruct.cpp \
configparser.cpp \
deploy.cpp \
deploycore.cpp \
elf_type.cpp \
Parsers/elf_type.cpp \
envirement.cpp \
extra.cpp \
extracter.cpp \
filemanager.cpp \
Distributions/idistribution.cpp \
generalfiles_type.cpp \
Parsers/generalfiles_type.cpp \
ignorerule.cpp \
metafilemanager.cpp \
packagecontrol.cpp \
Expand All @@ -72,7 +75,7 @@ SOURCES += \
igetlibinfo.cpp \
dependenciesscanner.cpp \
../qtTools/src/shared/winutils/elfreader.cpp \
pe_type.cpp \
Parsers/pe_type.cpp \
pluginsparser.cpp \
Distributions/qif.cpp \
qml.cpp \
Expand All @@ -87,6 +90,7 @@ HEADERS += \
Distributions/defaultdistro.h \
Distributions/templateinfo.h \
Distributions/ziparhive.h \
Parsers/macho_type.h \
defines.h \
dependencymap.h \
deployconfig.h \
Expand All @@ -96,13 +100,13 @@ HEADERS += \
deploy.h \
deploy_global.h \
deploycore.h \
elf_type.h \
Parsers/elf_type.h \
envirement.h \
extra.h \
extracter.h \
filemanager.h \
Distributions/idistribution.h \
generalfiles_type.h \
Parsers/generalfiles_type.h \
ignorerule.h \
metafilemanager.h \
packagecontrol.h \
Expand All @@ -111,7 +115,7 @@ HEADERS += \
igetlibinfo.h \
dependenciesscanner.h \
../qtTools/src/shared/winutils/elfreader.h \
pe_type.h \
Parsers/pe_type.h \
pluginsparser.h \
Distributions/qif.h \
qml.h \
Expand All @@ -121,6 +125,7 @@ HEADERS += \
targetinfo.h \
zipcompresser.h


STATECHARTS +=

RESOURCES += \
Expand Down
1 change: 1 addition & 0 deletions Deploy/elf_type.cpp → Deploy/Parsers/elf_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <cmath>
#include <QFileInfo>
#include <quasarapp.h>
#include "../qtTools/src/shared/winutils/elfreader.h"

ELF::ELF()
{
Expand Down
3 changes: 2 additions & 1 deletion Deploy/elf_type.h → Deploy/Parsers/elf_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

#ifndef ELF_H
#define ELF_H
#include "../qtTools/src/shared/winutils/elfreader.h"

#include "igetlibinfo.h"

class ElfReader;

class ELF : public IGetLibInfo
{

Expand Down
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions Deploy/Parsers/macho_type.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//#
//# Copyright (C) 2021-2021 QuasarApp.
EndrII marked this conversation as resolved.
Show resolved Hide resolved
//# Distributed under the lgplv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#


#include "macho_type.h"

MachO::MachO() {

}

bool MachO::getLibInfo(const QString &lib, LibInfo &info) const {

}
25 changes: 25 additions & 0 deletions Deploy/Parsers/macho_type.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//#
//# Copyright (C) 2021-2021 QuasarApp.
//# Distributed under the lgplv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#

#ifndef MACHO_H
#define MACHO_H

#include "igetlibinfo.cpp"

/**
* @brief The MachO class is wraper class for the extract dependecies of the Mach Object files.
*/
class MachO : public IGetLibInfo
{
public:
MachO();

// IGetLibInfo interface
bool getLibInfo(const QString &lib, LibInfo &info) const override;
};

#endif // MACHO_H
39 changes: 8 additions & 31 deletions Deploy/pe_type.cpp → Deploy/Parsers/pe_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,11 @@
#include <QFileInfo>
#include <QSet>
#include <QVector>
#include <pe-parse/parse.h>
#include <quasarapp.h>
#include <LIEF/LIEF.hpp>

#include <set>

namespace peparse {

class section;

struct importent {
VA addr;
std::string symbolName;
std::string moduleName;
};

struct exportent {
VA addr;
std::string symbolName;
std::string moduleName;
};

class reloc;
class symbol;

struct parsed_pe_internal {
std::vector<section> secs;
std::vector<resource> rsrcs;
std::vector<importent> imports;
std::vector<reloc> relocs;
std::vector<exportent> exports;
std::vector<symbol> symbols;
};

}

bool PE::getDep(peparse::parsed_pe_internal * internal, LibInfo &res) const {
auto imports = internal->imports;
std::set<std::string> filter;
Expand Down Expand Up @@ -112,6 +82,13 @@ PE::PE(): IGetLibInfo () {
bool PE::getLibInfo(const QString &lib, LibInfo &info) const {
auto parsedPeLib = peparse::ParsePEFromFile(lib.toLatin1());

try {
std::unique_ptr<LIEF::PE::Binary> pe = LIEF::PE::Parser::parse("C:\\Windows\\explorer.exe");
std::cout << *pe << std::endl;
} catch (const LIEF::exception& err) {
std::cerr << err.what() << std::endl;
}

if (!parsedPeLib)
return false;

Expand Down
File renamed without changes.
27 changes: 17 additions & 10 deletions Deploy/dependenciesscanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
#include <QDir>
#include <QDebug>
#include "pathutils.h"
#include "pe_type.h"
#include "elf_type.h"
#include "generalfiles_type.h"

DependenciesScanner::DependenciesScanner() {

_peScaner = new PE();
_elfScaner = new ELF();
_filesScaner = new GeneralFiles();
}

void DependenciesScanner::clearScaned() {
Expand Down Expand Up @@ -88,15 +93,15 @@ bool DependenciesScanner::fillLibInfo(LibInfo &info, const QString &file) const

switch (scaner) {
case PrivateScaner::PE: {
return _peScaner.getLibInfo(file, info);
return _peScaner->getLibInfo(file, info);
}

case PrivateScaner::ELF: {
return _elfScaner.getLibInfo(file, info);
return _elfScaner->getLibInfo(file, info);
}

default:
return _filesScaner.getLibInfo(file, info);
return _filesScaner->getLibInfo(file, info);
}
}

Expand Down Expand Up @@ -126,7 +131,7 @@ void DependenciesScanner::recursiveDep(LibInfo &lib, QSet<LibInfo> &res, QSet<QS

libStack.insert(lib.fullPath());

for (auto i : lib.dependncies) {
for (const auto &i : qAsConst(lib.dependncies)) {

auto libs = getLibsFromEnvirement(i);

Expand Down Expand Up @@ -172,7 +177,7 @@ void DependenciesScanner::recursiveDep(LibInfo &lib, QSet<LibInfo> &res, QSet<QS
void DependenciesScanner::addToWinAPI(const QString &lib, QHash<WinAPI, QSet<QString>>& res) {
#ifdef Q_OS_WIN
if (QuasarAppUtils::Params::isEndable("deploySystem")) {
WinAPI api = _peScaner.getAPIModule(lib);
WinAPI api = _peScaner->getAPIModule(lib);
if (api != WinAPI::NoWinAPI) {
res[api] += lib;
}
Expand All @@ -192,7 +197,7 @@ void DependenciesScanner::setEnvironment(const QStringList &env) {
winAPI[WinAPI::Crt] += "UCRTBASE.DLL";
#endif

for (auto i : env) {
for (const auto &i : env) {

dir.setPath(i);
if (!dir.exists()) {
Expand All @@ -203,15 +208,15 @@ void DependenciesScanner::setEnvironment(const QStringList &env) {
<< "*.SO*" << "*.so*",
QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden);

for (auto i : list) {
for (const auto &i : list) {
addToWinAPI(i.fileName().toUpper(), winAPI);
_EnvLibs.insert(i.fileName().toUpper(), i.absoluteFilePath());
}

}


_peScaner.setWinAPI(winAPI);
_peScaner->setWinAPI(winAPI);
}

QSet<LibInfo> DependenciesScanner::scan(const QString &path) {
Expand All @@ -230,5 +235,7 @@ QSet<LibInfo> DependenciesScanner::scan(const QString &path) {
}

DependenciesScanner::~DependenciesScanner() {

delete _elfScaner;
delete _peScaner;
delete _filesScaner;
}
Loading