现在的位置: 首页 > 综合 > 正文

Rundll32

2013年03月31日 ⁄ 综合 ⁄ 共 2359字 ⁄ 字号 评论关闭

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
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 window
  HINSTANCE hinst,  // instance handle for the DLL
  LPTSTR lpCmdLine, // string the DLL will parse
  int 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.

 

抱歉!评论已关闭.