Load SimConnect dynamically at runtime.

Previously the FSX/P3D driver tried to link a very specific SimConnect version
from the Windows Assembly cache. This caused issues with machines
which did not have this specific version of SimConnect in the assembly
cache since drivers refused to load without much information. Having a different
version of SimConnect in the assembly cache or even in the bin folder did
not help.
To fix this problem, SimConnect is now loaded and resolved manually at
runtime. This allows to try loading different versions from the assembly
cache or prefer to load the shipped one.
For this, the manifests are linked into the binary's resource section and
activated manually before loading. This has the positive effect, that
loading errors can be handled by code instead of raising a cryptic error and
aborting.
This commit is contained in:
Roland Winklmeier
2018-07-08 12:37:24 +02:00
committed by Klaus Basan
parent 21f901590b
commit b16af78142
20 changed files with 559 additions and 62 deletions

View File

@@ -8,6 +8,7 @@ TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG += blackmisc blackcore blackconfig blackgui
CONFIG += simulatorfsxcommon simulatorfscommon simulatorplugincommon fsuipc simconnect
CONFIG += testcase
CONFIG += no_testcase_installs
@@ -17,16 +18,6 @@ HEADERS += *.h
SOURCES += *.cpp
DESTDIR = $$DestRoot/bin
LIBS *= -lsimulatorfsxcommon -lsimulatorfscommon -lfsuipc -lsimulatorplugincommon
# include(../../src/plugins/simulator/fsxp3d.pri)
include(../../src/plugins/simulator/fsxp3d_include.pri)
addStaticLibraryDependency(simulatorfscommon)
addStaticLibraryDependency(simulatorfsxcommon)
addStaticLibraryDependency(fsuipc)
addStaticLibraryDependency(simulatorplugincommon)
# Ignore linker warning about missing pdb files from Simconnect
msvc: QMAKE_LFLAGS *= /ignore:4099

View File

@@ -13,6 +13,7 @@
#include "testblacksimpluginfsxp3dmain.h"
#include "testfsxp3dcommon.h"
#include "testsimconnectsymbols.h"
#include "blackmisc/test/test.h"
#include <QStringList>
#include <QTest>
@@ -25,6 +26,9 @@ namespace BlackSimPluginFsxP3D
int status = 0;
{
CTestSimconnectSymbols simconnectSymbolsTest;
status |= test.exec(&simconnectSymbolsTest, "blacksimpluginfsxp3d_simconnectsymbols");
CTestFsxP3DCommon commonTest;
status |= test.exec(&commonTest, "blacksimpluginfsxp3d_fsxp3dcommon");
}

View File

@@ -0,0 +1,34 @@
/* Copyright (C) 2018
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \cond PRIVATE_TESTS
/*!
* \file
* \ingroup testblacksimplugin
*/
#include "testsimconnectsymbols.h"
#include "plugins/simulator/fsxcommon/simconnectsymbols.h"
#include "plugins/simulator/fsxcommon/simconnectwindows.h"
#include <QTest>
namespace BlackSimPluginFsxP3D
{
void CTestSimconnectSymbols::resolveSymbols()
{
QVERIFY2(loadAndResolveSimConnect(false), "Could not load and resolve SimConnect library!");
HANDLE hSimConnect;
SimConnect_Open(&hSimConnect, "Test", nullptr, 0, 0, 0);
SimConnect_Close(hSimConnect);
}
} // ns
//! \endcond

View File

@@ -0,0 +1,38 @@
/* Copyright (C) 2018
* swift project community / contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#ifndef BLACKSIMPLUGINFSXP3D_TESTSIMCONNECTSYMBOLS_H
#define BLACKSIMPLUGINFSXP3D_TESTSIMCONNECTSYMBOLS_H
//! \cond PRIVATE_TESTS
//! \file
//! \ingroup testblacksimplugin
#include <QObject>
namespace BlackSimPluginFsxP3D
{
//! FSX/P3D common tests
class CTestSimconnectSymbols : public QObject
{
Q_OBJECT
public:
//! Standard test case constructor
explicit CTestSimconnectSymbols(QObject *parent = nullptr) : QObject(parent) {}
private slots:
//! Resolve SimConnect Symbols
void resolveSymbols();
};
} // namespace
//! \endcond
#endif // guard