简体   繁体   English

作为exe启动DLL

[英]Starting a DLL as a exe

Is it possible to load a native (C++) DLL as an executable? 是否可以将本机(C ++)DLL加载为可执行文件? preferablly straight from the memory without creating EXE on the hard-drive or something similar? 最好直接从内存中而不在硬盘驱动器上创建EXE或类似的东西?

Microsoft提供了Rundll32.exe ,可用于执行已明确编码为支持此用法的DLL函数。

What, specifically, would this mean? 具体来说,这意味着什么? For example, what entry point would it use in the DLL? 例如,它将在DLL中使用哪个入口点?

The only way this would actually work would be if the DLL was specifically written to allow it. 实际可行的唯一方法是,如果DLL是专门为允许DLL而编写的。 And if that were the case, then it's not exactly clear why you would not just create an executable file instead of a DLL in the first place. 如果是这种情况,那么还不清楚为什么您不首先创建可执行文件而不是DLL。

Case in point is the RunDLL32.exe stub. 最好的例子是RunDLL32.exe存根。 It's designed to execute a function from a DLL with a specific signature as the entry point. 它旨在从具有特定签名的DLL执行DLL的功能。 If the DLL wasn't specifically designed to comply with this signature, then things don't go well . 如果DLL不是专门为遵守此签名而设计的,那么事情就不会顺利进行 If you need functionality like this, you might want to consider matching the function signature required by RunDLL32.exe and using it to "execute" your DLL. 如果您需要这样的功能,则可能需要考虑匹配RunDLL32.exe所需的功能签名,并使用它来“执行”您的DLL。

Look up rundll32.exe . 查找rundll32.exe But you'd better know exactly what you're doing. 但是您最好确切地知道自己在做什么。 I'm not sure, honestly. 老实说,我不确定。

您可以使用LoadLibrary WinAPI调用来加载DLL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM