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. The Lounge
  3. Calling DLL from assembler code?

Calling DLL from assembler code?

Scheduled Pinned Locked Moved The Lounge
data-structureshelpquestion
4 Posts 4 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.
  • M Offline
    M Offline
    mvworld
    wrote on last edited by
    #1

    Hi, My problem is that I have to write a function that will at runtime accept a name of a dll and a name of a function contained in that dll and then call that function. The obvious problem is that a compile time we don't know the return type of a function be be called and the number and types of arguments to be passed to the dll. My guess is that we'd have to use assembler code in __asm blocks to pass any number of parameters of any types by manually pushing them into the stack. But then of what type do I declare the function pointer that will take the adress of function returned by GetProcAddress? Any Answers/Suggestions? Thanks in advance, Mvworld

    L K W 3 Replies Last reply
    0
    • M mvworld

      Hi, My problem is that I have to write a function that will at runtime accept a name of a dll and a name of a function contained in that dll and then call that function. The obvious problem is that a compile time we don't know the return type of a function be be called and the number and types of arguments to be passed to the dll. My guess is that we'd have to use assembler code in __asm blocks to pass any number of parameters of any types by manually pushing them into the stack. But then of what type do I declare the function pointer that will take the adress of function returned by GetProcAddress? Any Answers/Suggestions? Thanks in advance, Mvworld

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      typedef BOOL (WINAPI *TESTFUNCTION)(void); TESTFUNCTION lpfTestFunction=NULL; char *pFunc="TestFunction"; __asm { push pFunc push hLibrary ;Handle from LoadLibrary call GetProcAddress mov lpfTestFunction,eax ;EAX = Function Pointer };

      1 Reply Last reply
      0
      • M mvworld

        Hi, My problem is that I have to write a function that will at runtime accept a name of a dll and a name of a function contained in that dll and then call that function. The obvious problem is that a compile time we don't know the return type of a function be be called and the number and types of arguments to be passed to the dll. My guess is that we'd have to use assembler code in __asm blocks to pass any number of parameters of any types by manually pushing them into the stack. But then of what type do I declare the function pointer that will take the adress of function returned by GetProcAddress? Any Answers/Suggestions? Thanks in advance, Mvworld

        K Offline
        K Offline
        Kamal
        wrote on last edited by
        #3

        I would first suggest you to realastically revisit your requirements. At runtime how do you find out the method signature ?? Without the methoda signature how do you decide what parameters to pass and in what order? Kamal

        1 Reply Last reply
        0
        • M mvworld

          Hi, My problem is that I have to write a function that will at runtime accept a name of a dll and a name of a function contained in that dll and then call that function. The obvious problem is that a compile time we don't know the return type of a function be be called and the number and types of arguments to be passed to the dll. My guess is that we'd have to use assembler code in __asm blocks to pass any number of parameters of any types by manually pushing them into the stack. But then of what type do I declare the function pointer that will take the adress of function returned by GetProcAddress? Any Answers/Suggestions? Thanks in advance, Mvworld

          W Offline
          W Offline
          wParam
          wrote on last edited by
          #4

          Don't even bother making it a function pointer, just take and use it as void *. void *foo; int retval; foo = GetProcAddress (...); //push the things on to the stack here __asm { call foo mov retval, eax } You'll have to decide how to interpret the return value, of course. Also don't forget to push the things onto the stack in reverse order.

          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