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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. w32 api (hooking) : Problem with GetProcAddress and callback (__stdcall) function

w32 api (hooking) : Problem with GetProcAddress and callback (__stdcall) function

Scheduled Pinned Locked Moved C / C++ / MFC
questionjsonhelp
4 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.
  • I Offline
    I Offline
    INA_ctive
    wrote on last edited by
    #1

    I have a function inside a DLL that acts as a hook procedure. it has an __stdcall attribute. When i tried to retrieve the function pointer via another exe with GetProcAddress it always fails, and it only works after i remove the __stdcall attribute. How can i retrieve the function pointer of this callback function properly? Is there any difference in the way of retriving function pointer of regular function and callback function? *** code *** this is the hookproc function: LRESULT CALLBACK HookProc(int nCode, WPARAM w, LPARAM l) { return CallNextHookEx(NULL, nCode, w, l); } and this is how i call it in another exe: FARPROC HookProc = NULL; HookProc = GetProcAddress(HookDLL, "HookProc"); *** end of code *** thank you very much. - Ganeshwara

    J B 2 Replies Last reply
    0
    • I INA_ctive

      I have a function inside a DLL that acts as a hook procedure. it has an __stdcall attribute. When i tried to retrieve the function pointer via another exe with GetProcAddress it always fails, and it only works after i remove the __stdcall attribute. How can i retrieve the function pointer of this callback function properly? Is there any difference in the way of retriving function pointer of regular function and callback function? *** code *** this is the hookproc function: LRESULT CALLBACK HookProc(int nCode, WPARAM w, LPARAM l) { return CallNextHookEx(NULL, nCode, w, l); } and this is how i call it in another exe: FARPROC HookProc = NULL; HookProc = GetProcAddress(HookDLL, "HookProc"); *** end of code *** thank you very much. - Ganeshwara

      J Offline
      J Offline
      James Brown
      wrote on last edited by
      #2

      goto www.dependencywalker.com [^]and download the tool - use it to see how your function is being exported. You can use a .DEF file to control how your function is being exported (see MSDN for details). You can also use the /EXPORT linker switch if you are using visual-c james
      http://www.catch22.net

      I 1 Reply Last reply
      0
      • J James Brown

        goto www.dependencywalker.com [^]and download the tool - use it to see how your function is being exported. You can use a .DEF file to control how your function is being exported (see MSDN for details). You can also use the /EXPORT linker switch if you are using visual-c james
        http://www.catch22.net

        I Offline
        I Offline
        INA_ctive
        wrote on last edited by
        #3

        thank you, i'll try it =)

        1 Reply Last reply
        0
        • I INA_ctive

          I have a function inside a DLL that acts as a hook procedure. it has an __stdcall attribute. When i tried to retrieve the function pointer via another exe with GetProcAddress it always fails, and it only works after i remove the __stdcall attribute. How can i retrieve the function pointer of this callback function properly? Is there any difference in the way of retriving function pointer of regular function and callback function? *** code *** this is the hookproc function: LRESULT CALLBACK HookProc(int nCode, WPARAM w, LPARAM l) { return CallNextHookEx(NULL, nCode, w, l); } and this is how i call it in another exe: FARPROC HookProc = NULL; HookProc = GetProcAddress(HookDLL, "HookProc"); *** end of code *** thank you very much. - Ganeshwara

          B Offline
          B Offline
          Blake Miller
          wrote on last edited by
          #4

          I also STRONGLY reocmmend you call your HookProc something ELSE. That name is too common and might also get you into trouble with other linkage and project dependencies later. No shirt, no shoes, no brains, no service.

          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