windows 我如何执行 *.dll 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3044395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:24:01  来源:igfitidea点击:

How do I execute a *.dll file

windowsdll

提问by vs4vijay

I have a DLL file and want to execute it on Windows. I obtained this DLL from a Challenge site which alleges the DLL should be executed independently.

我有一个 DLL 文件,想在 Windows 上执行它。我从挑战站点获得了这个 DLL,该站点声称 DLL 应该独立执行。

回答by

To run the functions in a DLL, first find out what those functions are using any PE (Portable Executable) analysis program (e.g. Dependency Walker). Then use RUNDLL32.EXEwith this syntax:

要在 DLL 中运行这些函数,首先要找出这些函数正在使用任何 PE(可移植可执行文件)分析程序(例如Dependency Walker)。然后使用具有以下语法的RUNDLL32.EXE

 RUNDLL32.EXE <dllname>,<entrypoint> <optional arguments>

dllname is the path and name of your dll file, entrypoint is the function name, and optional arguments are the function arguments

dllname 是你的 dll 文件的路径和名称,入口点是函数名,可选参数是函数参数

回答by Krumelur

You can execute a function defined in a DLL file by using the rundllcommand. You can explore the functions available by using Dependency Walker.

您可以使用rundll命令执行 DLL 文件中定义的函数。您可以使用Dependency Walker探索可用的功能。

回答by Timur Nuriyasov

While many people have pointed out that you can't execute dlls directly and should use rundll32.exe to execute exported functions instead, here is a screenshot of an actual dll file running just like an executable:

虽然很多人指出你不能直接执行 dll,而应该使用 rundll32.exe 来执行导出的函数,但这里是一个像可执行文件一样运行的实际 dll 文件的屏幕截图:

enter image description here

在此处输入图片说明

While you cannot run dll files directly, I suspect it is possible to run them from another process using a WinAPI function CreateProcess:

虽然您不能直接运行 dll 文件,但我怀疑可以使用 WinAPI 函数 CreateProcess 从另一个进程运行它们:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx

回答by not2qubit

It should be mentioned that since it is entirely possible to run DLL's just as any other executable, it has long been considered a security issue. As such, there have been a number of security improvements and registry hacks (sorry no longer have ref-links) that prevents running DLL's from regular user space without extra privileges.

应该提到的是,由于完全有可能像运行任何其他可执行文件一样运行 DLL,因此长期以来它一直被认为是一个安全问题。因此,有许多安全改进和注册表黑客(抱歉不再有引用链接)可以防止在没有额外权限的情况下从常规用户空间运行 DLL。

As a good example. I recall making these hacks, but since I no longer remember what exactly I did. I can no longer run any DLLs from normal user shell environment, even though starting various Win apps from GUI works just fine.

作为一个很好的例子。我记得做过这些黑客,但因为我不再记得我到底做了什么。我无法再从普通用户 shell 环境运行任何 DLL,即使从 GUI 启动各种 Win 应用程序工作正常。

That said, one should definitely read "Dynamic-Link Library Security" and "Best Practices to Prevent DLL HiHymaning".

也就是说,绝对应该阅读“动态链接库安全性”和“防止 DLL 劫持的最佳实践”。

回答by Zenilogix

You can't "execute" a DLL. You can execute functions within the DLL, as explained in the other answers. Although .EXE files and .DLL files are essentially identical in terms of format, the distinguishing feature of an .EXE is that it contains a designated "entry point" to go and do the thing the EXE was created to do. DLLs actually have something similar, but the purpose of the "dll main" is just to perform initialization and not fulfill the primary purpose of the DLL; that is for the (presumably) various other functions it contains.

你不能“执行”一个 DLL。您可以在 DLL 中执行函数,如其他答案中所述。尽管 .EXE 文件和 .DLL 文件在格式上基本相同,但 .EXE 的显着特征是它包含一个指定的“入口点”,可以执行创建 EXE 要做的事情。DLL 实际上也有类似的东西,但“dll main”的目的只是执行初始化,而不是实现 DLL 的主要目的;那是为了(大概)它包含的各种其他功能。

You can execute any of the functions exported by a DLL, assuming you know which one you want to execute; an EXE may contain a whole lot of functions, but one and only one is specially designated to be executed simply by "running" it.

您可以执行 DLL 导出的任何函数,假设您知道要执行哪个函数;一个 EXE 可能包含很多功能,但只有一个是专门指定的,只需“运行”它即可执行。

回答by pavithran G

To Run a .dll file..First find out what are functions it is exporting..Dll files will excecute the functions specified in the Export Category..To know what function it is Exporting refer "filealyzer" Application..It will show you the export function under "PE EXPORT" Category..Notedown the function name-- Then open the command prompt,Type Rundll32 dllname,functionname (dllname--name of your dll) (Functionname-- name of the function you found under the PE Export) Note:Makesure that your command prompt location is your dll file location

要运行 .dll 文件..首先找出它导出的功能..dll 文件将执行导出类别中指定的功能..要知道它导出的是什么功能,请参阅“filealyzer”应用程序..它会告诉你"PE EXPORT" Category下的导出函数..记下函数名--然后打开命令提示符,输入Rundll32 dllname,functionname(dllname--你的dll的名称)(Functionname--你在PE下找到的函数名导出)注意:确保您的命令提示符位置是您的 dll 文件位置

回答by William Leara

.DLL files are not executable in the sense that .EXE/.COM/.BAT files are executable, so I'm not sure what you mean.

.DLL 文件在 .EXE/.COM/.BAT 文件可执行的意义上是不可执行的,所以我不确定你的意思。

You can use the Dependency Walker application that comes with the Windows SDK to interrogate a .DLL and see what functions are exported by the file.

您可以使用 Windows SDK 附带的 Dependency Walker 应用程序来查询 .DLL 并查看文件导出了哪些函数。

回答by Nobody

The following series of steps might be helpful:

以下一系列步骤可能会有所帮助:

  1. Open Windows Explorer
  2. In the top-left corner, click "Organize"
  3. select "Folder and Search Options"
  4. Switch to the "View" tab
  5. Scroll down and uncheck "Hide file extensions for known file types"
  6. Click OK
  7. Now find the dllfile
  8. Right-click on it and select "Rename"
  9. Change the extension(what comes after the last .) and change it to .exe
  1. 打开 Windows 资源管理器
  2. 在左上角,单击“组织”
  3. 选择“文件夹和搜索选项”
  4. 切换到“查看”选项卡
  5. 向下滚动并取消选中“隐藏已知文件类型的文件扩展名”
  6. 单击确定
  7. 现在找到dll文件
  8. 右键单击它并选择“重命名”
  9. 更改扩展名(最后一个之后的内容.)并将其更改为.exe