locked
Metro Mode IE on Windows 8 - SetWindowsHookEx doesn't work RRS feed

  • Question

  • Hi,

      I have created a 64 bit exe and 64 bit dll (both VC++).  I am setting global key/mouse hooks in dll (WH_Mouse/WH_Keyboard).

    • Both have embedded manifest with UIAccess=true.  
    • Both have been signed with digital certificate and added to Trusted Root.  
    • Both have been copied under "Program files".  

    Observation

    • Hooks work on all apps except Metro Mode IE 10 (Windows 8).  Hooks on Desktop Mode IE also works.
    • Hooks work even for the IE address bar of Metro Mode (which is part of the Manager process? & not content).
    • Hook messages from Content process which is Metro Mode process are not received.

    While trying several combinations, I tried creating 32 bit versions of the same exe/dll which were also having manifest & signed.  Here, the hook works even on Metro Mode IE but they are out-of-process (behavior as per documentation).

    Question:- Why 64 bit exe/dll unable to hook to Metro mode IE?  What am I missing?

    Regards,

    IndTech

    Wednesday, November 5, 2014 7:17 AM

Answers

  • I was writing to a log file in user's temp folder which wasn't working for metro mode apps.  The hooks have been working actually (without me knowing).  Constraints are more to do with file writing & inter-process communication.

    Conclusion: All hooks work even on metro mode apps including IE the same way they work on non-metro apps.  And this behavior is true for 32 and 64 bit apps.

    Special thanks to Marc Durdin (from the other post) for asking me all the right questions and Ranta.

    • Marked as answer by IndTech Tuesday, November 18, 2014 8:45 AM
    Tuesday, November 18, 2014 8:44 AM

All replies

  • Perhaps the Metro Mode IE 10 disables window hooks with PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY::DisableExtensionPoints or PROCESS_CREATION_MITIGATION_POLICY_EXTENSION_POINT_DISABLE_ALWAYS_ON. And perhaps 32-bit window hooks bypass this restriction by not attempting to load the hook DLL in-process. I don't know but it seems plausible.

    Your hook works in Metro Mode apps other than IE 10, right? If you can get PROCESS_QUERY_INFORMATION access to the processes, you could perhaps verify my hypothesis by calling GetProcessMitigationPolicy and checking whether the DisableExtensionPoints flag is set in the Metro Mode IE 10 process and clear in others.

    Does the 32-bit hook work in Metro Mode IE 10 on 32-bit Windows 8? I'd expect that to fail as well.

    Wednesday, November 5, 2014 3:53 PM
  • Thanks ranta for responding.  Please see response to your queries.

    • It's not just IE10, 64bit hook dll isn't working for any Metro Mode app.
    • Verified that the Manifest with uiaccess=true is embedded and signed.  As, I also have a window that appears on top the Metro Mode IE.  This is possible only with the manifest & binary signing.
    • I queried Metro Mode IE10 (PROCESS_QUERY_INFORMATION access available) and DisableExtensionPoints flag is not set.
    • When trying with 64bit hook dll I can see it mapped into the address space of Metro Mode IE10.
    • SetWindowsHookEx also returns non-null handle.
    • I don't have a 32bit Windows 8 right now.  Will try 32bit hook on it once I get it.

    Anything else that I can try?


    Thursday, November 6, 2014 6:08 AM
  • BTW, I checked with 32 bit Windows 8.  You were right, 32 bit hook doesn't work on Metro Mode apps there too.

    It seems some one has had success ( a few years back ) with setting hooks but facing some other issue. So, it is possible, wondering how?

    Related Post: https://social.msdn.microsoft.com/Forums/fr-FR/7d0163ad-0310-47c2-9160-48090ac76286/can-a-windows-hook-dll-read-registry-settings-when-in-a-metro-app-process?forum=winappswithnativecode

    Thursday, November 6, 2014 8:33 AM
  • Anything else I can try? Anyone?  Would appreciate any hints on getting this working.

    Sunday, November 9, 2014 2:20 PM
  • I was writing to a log file in user's temp folder which wasn't working for metro mode apps.  The hooks have been working actually (without me knowing).  Constraints are more to do with file writing & inter-process communication.

    Conclusion: All hooks work even on metro mode apps including IE the same way they work on non-metro apps.  And this behavior is true for 32 and 64 bit apps.

    Special thanks to Marc Durdin (from the other post) for asking me all the right questions and Ranta.

    • Marked as answer by IndTech Tuesday, November 18, 2014 8:45 AM
    Tuesday, November 18, 2014 8:44 AM