Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to run dll using Rundll32.exe [modified]

how to run dll using Rundll32.exe [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nitin3
    wrote on last edited by
    #1

    i have 2 exprted functions in a dll ( Win32 dynamiclink dll project )

    void __stdcall MsgBox()
    {
    MessageBox( NULL , "Hello" , "" , MB_OK ) ;
    }
    void __stdcall MsgBox1( LPSTR a )
    {
    MessageBox( NULL , a , "" , MB_OK ) ;
    }

    //i tried following commands , the first one works but the not the secnd one, can any one tell where is the problem ? //{ rundll32.exe mydll.dll,MsgBox rundll32.exe mydll.dll,MsgBox1 "hi" //} //def file //{ LIBRARY MyDll EXPORTS MsgBox MsgBox1 //} Thanks

    modified on Monday, April 7, 2008 3:35 AM

    CPalliniC 1 Reply Last reply
    0
    • N nitin3

      i have 2 exprted functions in a dll ( Win32 dynamiclink dll project )

      void __stdcall MsgBox()
      {
      MessageBox( NULL , "Hello" , "" , MB_OK ) ;
      }
      void __stdcall MsgBox1( LPSTR a )
      {
      MessageBox( NULL , a , "" , MB_OK ) ;
      }

      //i tried following commands , the first one works but the not the secnd one, can any one tell where is the problem ? //{ rundll32.exe mydll.dll,MsgBox rundll32.exe mydll.dll,MsgBox1 "hi" //} //def file //{ LIBRARY MyDll EXPORTS MsgBox MsgBox1 //} Thanks

      modified on Monday, April 7, 2008 3:35 AM

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      nitin3 wrote:

      MessageBox( NULL , T , "" , MB_OK ) ;

      And what is the output you're expecting from?

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

      In testa che avete, signor di Ceprano?

      N T 2 Replies Last reply
      0
      • CPalliniC CPallini

        nitin3 wrote:

        MessageBox( NULL , T , "" , MB_OK ) ;

        And what is the output you're expecting from?

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

        N Offline
        N Offline
        nitin3
        wrote on last edited by
        #3

        sorry that was a mistake, i modified the code. my problem is the second function MsgBox1 function does not displays the text i entered, or its shows a message "An exception occured while trying to run "mydllfile.dll"

        Thanks & Regards

        CPalliniC 1 Reply Last reply
        0
        • CPalliniC CPallini

          nitin3 wrote:

          MessageBox( NULL , T , "" , MB_OK ) ;

          And what is the output you're expecting from?

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          you have eyes of vulture.. :)

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
          Never mind - my own stupidity is the source of every "problem" - Mixture

          cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>

          1 Reply Last reply
          0
          • N nitin3

            sorry that was a mistake, i modified the code. my problem is the second function MsgBox1 function does not displays the text i entered, or its shows a message "An exception occured while trying to run "mydllfile.dll"

            Thanks & Regards

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            To exploit the rundll32.exe your exported function must follow some rules, for instance the prototype must be like the following

            void CALLBACK MsgBoxW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow);

            then a working sample (at least, on XP it works...) will be

            void CALLBACK MsgBoxW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
            {
            MessageBox(hwnd, lpszCmdLine, L"MyMessageBox", MB_OK);
            }

            with def file

            LIBRARY "MyDLL"
            EXPORTS
            MsgBoxW @1

            for a complete discussion see [^] :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

            In testa che avete, signor di Ceprano?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups