1.概述

winddows的DLL中的函数是可以直接用Rundll32.exe 运行的。但dll导出函数要符合一定格式。

英文原版本如下:

Rundll32
The Run DLL utility (Rundll32.exe) included in Windows enables you to call functions exported from a 32-bit DLL. These functions must have the following syntax:void CALLBACK EntryPoint(HWND hwnd,        // handle to owner windowHINSTANCE hinst,  // instance handle for the DLLLPTSTR lpCmdLine, // string the DLL will parseint nCmdShow      // show state
);
Note that EntryPoint is a placeholder for the actual function name. For a list of possible show states, see WinMain.The following is the command-line syntax for Rundll32:rundll32 DllName,FunctionName [Arguments]
DllName
Specifies the name of the DLL. The name cannot contain spaces, commas, or quotation marks. The utility searches for the DLL using the search criteria documented for the LoadLibrary function. Therefore, it is best to use the short name and provide a full path for the DLL.
FunctionName
Specifies the name of the function to call in DllName. Requires a comma (without no spaces) between DllName and FunctionName.
Arguments
Optional arguments for FunctionName.
Rundll32 loads the specified DLL using LoadLibrary, obtains the address of the function using the GetProcAddress function, and calls the function with the specified arguments, if any. When the function returns, Rundll32 unloads the DLL and exits.Windows NT/2000: It is possible to create a Unicode version of the function. Rundll32 first tries to find a function named EntryPointW. If it cannot find this function, it tries EntryPointA, then EntryPoint. To create a DLL that supports ANSI on Windows 95/98/Me and Unicode otherwise, export two functions: EntryPointW and EntryPoint.

译文:(网上找的)

Rundll32
这个运行DLL的实用工具(Rundll32.exe)是包含在Windows中的,它能让你去调用从一个32位DLL中导出的函数。但是那些被调用的函数必须遵循以下语法规则:void CALLBACK EntryPoint(HWND hwnd,        // 父窗口的句柄HINSTANCE hinst,  // DLL的实例句柄LPTSTR lpCmdLine, // DLL将要解析的字符串int nCmdShow      // 显示状态
);
请注意那个EntryPoint仅仅是一个为了表示真实函数名的一个占位符。对于一系列可能的显示状态,请参见WinMain。下面是Rundll32在命令行下的语法:
rundll32 DllName,FunctionName [Arguments]
DllName
指定这个DLL的名字。这个名字不能包含空格,逗号,或引号。这个实用工具为了LoadLibrary这个函数,将会用搜索标准文件记录的方式来搜索这个DLL。因此,对于这个DLL,最好使用短文件名并且提供一个完整路径。
FunctionName
指定这个在DllName中被调用的函数的名字。要求在DllName和FunctionName之间有一个逗号(不带任何空格)。
Arguments
对于FunctionName的可选参数。
Rundll32使用LoadLibrary来载入这个指定的DLL,使用GetProcAddress函数来获取函数地址,然后带着这个指定的参数(如果有这个参数的话)去调用函数。当这个函数返回时,Rundll32将卸载这个DLL并退出。Windows NT/2000:为这个函数创建一个Unicode版本是可能的。Rundll32首先尝试去查找一个命名为EntryPointW的函数。如果无法找到该函数,则会接着尝试EntryPointA,再然后是EntryPoint。为了创建一个在Windows 95/98/Me上支持ANSI和Unicode的DLL,需要导出两个函数:EntryPointW和EntryPoint。

调用方法

在命令行中  rundll32.exe projectname.dll,dllfun 即可

例子:(网上找的)

// dllmain.cpp : Defines the entry point for the DLL application.#include "stdafx.h"
#include <stdio.h>
#include "fun.h"
extern "C" _declspec(dllexport) void __cdecl dllfun(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);
BOOL APIENTRY DllMain( HMODULE hModule,DWORD  ul_reason_for_call,LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
extern "C" _declspec(dllexport) void __cdecl dllfun(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow){// MessageBox(NULL,L"lll",L"lllkk",MB_OK);
StartWork(NULL);return;}

Rundll32.exe 如何运行dll中的函数相关推荐

  1. 【转】rundll32 运行 dll 中的函数

    https://blog.csdn.net/xuq09/article/details/100094112

  2. 天马行空W:在C++中调用DLL中的函数

    1.dll的优点 代码复用是提高软件开发效率的重要途径.一般而言,只要某部分代码具有通用性,就可将它构造成相对独立的功能模块并在之后的项目中重复使用.比较常见的例子是各种应用程序框架,ATL.MFC等 ...

  3. 10.4.4 使用ctypes调用kernel32.dll中的函数

    10.4.4 使用ctypes调用kernel32.dll中的函数 2007-10-17 14:41 孙广磊 人民邮电出版社 字号:T | T 综合评级: 想读(5)  在读(0)  已读(6)   ...

  4. 在C++中调用DLL中的函数

    1.dll的优点 代码复用是提高软件开发效率的重要途径.一般而言,只要某部分代码具有通用性,就可将它构造成相对独立的功能模块并在之后的项目中重复使用.比较常见的例子是各种应用程序框架,ATL.MFC等 ...

  5. AutoCAD.NET 不使用P/Invoke方式调用acad.exe或accore.dll中的接口(如acedCommand、acedPostCommand等)...

    使用C#进行AutoCAD二次开发,有时候由于C#接口不够完善,或者低版本AutoCAD中的接口缺少,有些工作不能直接通过C#接口来实现,所以需要通过P/Invoke的方式调用AutoCAD的其他DL ...

  6. C#调用dll中的函数

    C#调用dll中的函数 文章分类:操作系统 文章来源:http://blog.csdn.net/strmagic/archive/2007/11/02/1863462.aspx 大家在实际工作学习C# ...

  7. 通过GetProcAddress函数动态调用dll中地函数,是否必须通过extern C声明导出函数?(转)...

    通过GetProcAddress函数动态调用dll中的函数,是否必须通过extern "C"声明导出函数? [已结贴,结贴人:darongtou] 如题,网上搜了N多资料,一直找不 ...

  8. 在C++中调用DLL中的函数(2)

    本文转自:http://blog.sina.com.cn/s/blog_53004b4901009h3b.html 应用程序使用DLL可以采用两种方式: 一种是隐式链接,另一种是显式链接.在使用DLL ...

  9. GetProcAddress()函数动态调用DLL中的函数,是否必须通过extern C声明导出函数?

    GetProcAddress()函数动态调用DLL中的函数,是否必须通过extern C声明导出函数? 通过GetProcAddress函数动态调用dll中的函数,是否必须通过extern " ...

  10. 打印出ntdll.dll中所有函数名字和地址

    0x01 打印出ntdll.dll中所有函数名字和地址 0x02 在任何进程中都可以找到ntdll.dll和kernel32.dll这个动态链接库的基地址,另外每一个动态链接库基地址实际上都存放在一个 ...

最新文章

  1. 从 ACM 训练领悟坚持之道
  2. 【Android 逆向】ART 脱壳 ( InMemoryDexClassLoader 脱壳 | BaseDexClassLoader 构造函数 | DexPathList 构造函数及后续调用 )
  3. 实现Windows Phone、Android和iOS平台的统一硬件访问
  4. Axis,axis2,Xfire以及cxf对比 (转)
  5. 折纸机器人的步骤图解_折纸图解老虎
  6. 软件工程第三次作业-功能测试
  7. 在 ASP.NET 使用 jQuery BlockUI 插件
  8. (JAVA)Map集合
  9. 课程设计哈夫曼编/译码系统
  10. 怎么安装winubuntu双系统_U盘安装ubuntu双系统及如何恢复Windows MBR教程
  11. 2020广西电子设计竞赛题目
  12. android 不限速迅雷,安卓iOS,Windows和Mac四大系统迅雷不限速神器,今天全部解决了...
  13. linux 调节风扇速度命令,ubuntu系统调节GPU风扇转速
  14. Echarts饼状图空心圆技巧 | 爱骇客 | 骇客
  15. 传奇3单机服务器怎么修改器,自己是GM并架设了传奇3单机版,如何改变装备属性?...
  16. 项目管理要分解目标,明确每个人的任务
  17. Efficientnet笔记:各个框架最适合的图像尺寸
  18. 七大步教你征服丈母娘
  19. 2022群发邮件软件有哪些?哪个好用呢?解读如何大量群发邮件及单显功能
  20. turtle的函数及使用

热门文章

  1. wsl2 局域网访问_超轻巧局域网传输神器,用手机看电脑上的小电影
  2. Robotframework(三)常用API介绍
  3. H5标签input标签上传文件(图片)
  4. 杂文笔记(一):博弈论在网络安全中的应用
  5. 读书笔记:《遇见未知的自己》
  6. 2022南京商业贷款提前还款
  7. dbm与mysql区别_dbm数据库
  8. 【LeetCode】975. Odd Even Jump 解题报告(C++)
  9. 【LeetCode - 317】离建筑物最近的距离
  10. 当Apple TV+的生态化反梦,撞上一个“日渐昂贵”的流媒体市场