c++ - 从存档加载 DLL

标签 c++ dll

我目前正在编写一个应用程序,我想让它对我来说尽可能的广泛 -> 除了核心功能之外,每个组件都应该被视为扩展。

基本上我提供了需要实现的抽象类(头文件)和静态库。我还提供了带有抽象类的 .py 文件和 .component 文件的示例,它基本上是 .ini 文件 - 用户应该声明什么是 class_name, python_class_name

所以最终用户需要创建DLL、python脚本、.ini文件。然后压缩到扩展名为 package 的文件中。嗯,这就是计划。

我的应用程序应该查找 .package 文件,解压缩,从那里获取 .component 文件,读取它,按名称从 DLL 加载类,创建对象并将其存储在应用程序内的全局对象寄存器中。然后我创建了 c++python 桥(了解 python 类实现的接口(interface)有很大帮助),它允许调用 python 方法的名称。 python 脚本也应该存储到 zip 中。

我基本上有两个问题:

1. Is it possible to load DLL from `.zip` in runtime? I believe its hardly possible without creating temporary unzipped file and then deleting it.
2. Is there other to load DLL except basic approach with `windows.h` header? I use `boost` library there and there, maybe there is some way to do it?

据我所知,没有比使用 zlib 更好的解决方案了,所以我打算使用它。

最佳答案

  1. 可以从 zip/内存加载 DLL。实际上,许多 exe 加壳程序/病毒确实手动加载 dll。

  2. 其实和第一题是同一个题。

LoadLibrary 做什么?

Mapping or loading the DLL into memory.
Relocating offsets in the DLL using the relocating table of the DLL (if present).
Resolving the dependencies of the DLL, loading other DLLs needed by this DLL and resolving the offset of the needed functions.
Calling its entrypoint (if present) with the DLL_PROCESS_ATTACH parameter.

您可以编写自己的代码来手动加载库。但是,如果您不以与 LoadLibrary 相同的方式加载 dll,则可能存在一些限制。

引用:http://www.codeproject.com/Tips/430684/Loading-Win-DLLs-manually-without-LoadLibrary

关于c++ - 从存档加载 DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31723341/

相关文章:

c# - DLL 大小重要吗?

C++ dll 变量到 vb.net exe

c# - 有没有找到小型开源项目的简单方法?

c++ - C++ FAQ的不安全宏解释?

C++ 类型定义问题

c# - 未从 C# 中找到 C++ COM DLL 中的导出函数

c# - 是否可以在程序集中创建所有类的实例?

c++ - 使用 C++ 打开动态 URL

c++ - 'W' 打印出 W, "W"打印出 $。为什么?

.net - 从 .NET DLL 使用 webservice - app.config 问题