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. Hook procedure ( SetWindowHookEx() )

Hook procedure ( SetWindowHookEx() )

Scheduled Pinned Locked Moved C / C++ / MFC
jsontutorialquestion
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.
  • D Offline
    D Offline
    Dody_DK
    wrote on last edited by
    #1

    Hey I am trying to use SetWindowHookEx() API to inject my code into another process, but I am kinda lost with the hook procedure that should be placed in the .dll file is there an explaination about how to build a hook procedure? thanks in advance!

    R H D 3 Replies Last reply
    0
    • D Dody_DK

      Hey I am trying to use SetWindowHookEx() API to inject my code into another process, but I am kinda lost with the hook procedure that should be placed in the .dll file is there an explaination about how to build a hook procedure? thanks in advance!

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      See these CP articles:

      • API hooking revealed[^]
      • Hooks and DLLs[^]
      • Writing a Macro Recorder/Player using Win32 Journal Hooks[^]

      /ravi

      My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      1 Reply Last reply
      0
      • D Dody_DK

        Hey I am trying to use SetWindowHookEx() API to inject my code into another process, but I am kinda lost with the hook procedure that should be placed in the .dll file is there an explaination about how to build a hook procedure? thanks in advance!

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        See API Hooking Revealed [^] and Hooks [^]

        _**


        **_

        WhiteSky


        1 Reply Last reply
        0
        • D Dody_DK

          Hey I am trying to use SetWindowHookEx() API to inject my code into another process, but I am kinda lost with the hook procedure that should be placed in the .dll file is there an explaination about how to build a hook procedure? thanks in advance!

          D Offline
          D Offline
          Dody_DK
          wrote on last edited by
          #4

          thank you for the usefull links, and this is my first try: this is my callback function LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode<0) return CallNextHookEx(0,nCode,wParam,lParam); if (wParam == WM_RBUTTONDOWN) { MessageBox(GetForegroundWindow(), "Yes", "Works", MB_OK); } return CallNextHookEx(0,nCode,wParam,lParam); } and in onbutton function I set: HOOKPROC wlm; HHOOK check; HINSTANCE WLMDLL; WLMDLL = LoadLibrary((LPCTSTR) "MyHook.dll"); wlm = (HOOKPROC)GetProcAddress(WLMDLL, "MouseProc"); check = SetWindowsHookEx(WH_MOUSE,wlm,WLMDLL,0); as you can see I am trying to do a mouse hook, this try is to get any right click, but later when I get it to work, I want it to be for a defined application that when it gets right click the the popup pops up can you see what I am doing wrong in my code? thanks in advance! |) () |) '/

          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