Using Rundll32.exe to run DLL functions __ functions

Source: Internet
Author: User
Tags function prototype

We know that Windows DLL is not able to run independently, but Microsoft provides rundll32.exe for running DLLs.

First Test: Run "Rundll32.exe Shell32.dll,restartdialog", will pop up the restart dialog box. This same way you can turn on other features of the Windows system.

Here's how to define your own DLL to let Rundll32.exe run.

The DLL function prototype given by Microsoft is as follows:

  void CALLBACK
  EntryPoint (HWND hwnd, HINSTANCE hinst, LPSTR lpszcmdline, int ncmdshow);

   Hwnd-window handle that should to used as the owner window for any
          windows your DLL creates
   hinst-your dll ' s I  Nstance handle
   lpszcmdline-asciiz command line your DLL should parse ncmdshow-describes the how
   your DLL ' s windows should be displayed

The custom test DLL is as follows:

extern "C" _declspec (dllexport) void __cdecl Rundll32dllfun (HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine,

int nCmdShow)
{
MessageBox (NULL, "TEST", LPSZCMDLINE,MB_OK);
Return
}

Generate Dynamic Library Rundll32dll.dll.

Run:

Rundll32.exe "E:\demo\rudll32dll\Release\rudll32dll.dll", Rundll32dllfun

A familiar dialog box pops up, stating that the call was successful.

You can also pass in parameters and run:

Rundll32.exe "E:\demo\rudll32dll\Release\rudll32dll.dll", Rundll32dllfun 888

The dialog box pops up, and 888 shows the dialog box above, indicating that the parameter can also be passed, where the parameters are obtained in lpszCmdLine.

Run command description: rundll32.exe "Xxx.dll", dllfun parameter

This allows us to develop DLLs to run as applications, to see only rundll32.exe in the process, and to see which DLLs are running through the Process Viewer tool.


rundll32.exe where the location of the 4-bit system is described:

Windows/system32/rundll32.exe call 64-bit DLL

Windows/syswow64/rundll32.exe call 32-bit DLL

Microsoft's reference article is as follows: http://support2.microsoft.com/kb/164787

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.