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. Hooking

Hooking

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

    Hi all, i found this example on MSDN. Im trying to find out how i can accomplish what im trying to do, and thats monitor the events of a application. So here's the code... #include int main(){ HOOKPROC hkprcSysMsg; static HINSTANCE hinstDLL; static HHOOK hhookSysMsg; hinstDLL = LoadLibrary((LPCTSTR) "c:\\windows\\notepad.dll"); hkprcSysMsg = (HOOKPROC)GetProcAddress(hinstDLL, "SysMessageProc"); hhookSysMsg = SetWindowsHookEx(WH_SYSMSGFILTER,hkprcSysMsg,hinstDLL,0); return 0; } I've noticed that i dont have notepad.dll - It may not be new to some but it is to me seeing how i've never had to look for it. So what would i have to do to monitor notepads events? Also, what char would i dump the messages from to a fstream .txt file? Thanx in advance!

    CPalliniC 1 Reply Last reply
    0
    • D dellthinker

      Hi all, i found this example on MSDN. Im trying to find out how i can accomplish what im trying to do, and thats monitor the events of a application. So here's the code... #include int main(){ HOOKPROC hkprcSysMsg; static HINSTANCE hinstDLL; static HHOOK hhookSysMsg; hinstDLL = LoadLibrary((LPCTSTR) "c:\\windows\\notepad.dll"); hkprcSysMsg = (HOOKPROC)GetProcAddress(hinstDLL, "SysMessageProc"); hhookSysMsg = SetWindowsHookEx(WH_SYSMSGFILTER,hkprcSysMsg,hinstDLL,0); return 0; } I've noticed that i dont have notepad.dll - It may not be new to some but it is to me seeing how i've never had to look for it. So what would i have to do to monitor notepads events? Also, what char would i dump the messages from to a fstream .txt file? Thanx in advance!

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

      dellthinker wrote:

      I've noticed that i dont have notepad.dll

      You have to build it (of course you don't need to call it notepad.dll): if you need a global hook (and you need a global one to hook another process like notepad) the you have to create a DLL hosting your hook procedure. I strongly suggest you to read MSDN documentation about hooks [^]. :)

      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.
      [my articles]

      In testa che avete, signor di Ceprano?

      N 1 Reply Last reply
      0
      • CPalliniC CPallini

        dellthinker wrote:

        I've noticed that i dont have notepad.dll

        You have to build it (of course you don't need to call it notepad.dll): if you need a global hook (and you need a global one to hook another process like notepad) the you have to create a DLL hosting your hook procedure. I strongly suggest you to read MSDN documentation about hooks [^]. :)

        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.
        [my articles]

        N Offline
        N Offline
        Nitheesh George
        wrote on last edited by
        #3

        Hi CPallini, I developing an application that hooks the Open/Save dialog for getting the selected file path. currently am able to hook the common dialog but it's not working on office Open/Save dialog. On Searching i found that Office is using separate Open/Save dialog. Can anyone help me to identify the Office Open/Save dialog messags equivalent that of common dialog's CDN_INITDONE CDN_FILEOK CDM_GETFILEPATH CDM_GETFOLDERIDLIST CDM_GETFOLDERPATH CDM_GETSPEC CDM_HIDECONTROL CDM_SETCONTROLTEXT CDM_SETDEFEXT . I think you can help me to solve this out. thanks Nitheesh

        CPalliniC 1 Reply Last reply
        0
        • N Nitheesh George

          Hi CPallini, I developing an application that hooks the Open/Save dialog for getting the selected file path. currently am able to hook the common dialog but it's not working on office Open/Save dialog. On Searching i found that Office is using separate Open/Save dialog. Can anyone help me to identify the Office Open/Save dialog messags equivalent that of common dialog's CDN_INITDONE CDN_FILEOK CDM_GETFILEPATH CDM_GETFOLDERIDLIST CDM_GETFOLDERPATH CDM_GETSPEC CDM_HIDECONTROL CDM_SETCONTROLTEXT CDM_SETDEFEXT . I think you can help me to solve this out. thanks Nitheesh

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

          Well I'm not an expert, but I read some time ago that Office rolls its own controls and maybe the controls themselveles don't even use messages as communication mechanism (but I maybe wrong). :)

          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.
          [my articles]

          In testa che avete, signor di Ceprano?

          N 1 Reply Last reply
          0
          • CPalliniC CPallini

            Well I'm not an expert, but I read some time ago that Office rolls its own controls and maybe the controls themselveles don't even use messages as communication mechanism (but I maybe wrong). :)

            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.
            [my articles]

            N Offline
            N Offline
            Nitheesh George
            wrote on last edited by
            #5

            Hi CPallini, thank you for you reply. Nitheesh

            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