{"id":34303,"date":"2005-09-07T10:00:22","date_gmt":"2005-09-07T10:00:22","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2005\/09\/07\/why-arent-low-level-hooks-injected\/"},"modified":"2005-09-07T10:00:22","modified_gmt":"2005-09-07T10:00:22","slug":"why-arent-low-level-hooks-injected","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20050907-22\/?p=34303","title":{"rendered":"Why aren&#8217;t low-level hooks injected?"},"content":{"rendered":"<p>When I described <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2005\/04\/25\/411741.aspx\"> what the HINSTANCE parameter to the <code>SetWindowsHookEx<\/code> function is for<\/a>, I neglected to mention why the low-level hooks are not injected.<\/p>\n<p> But then again, it should be obvious. <\/p>\n<p> The low-level hooks let you see input as it arrives at the window manager. At this low level of processing, the window manager hasn&#8217;t yet decided what window will receive the message. After all, that&#8217;s the whole point of the low-level hook: to filter the input before the window manager does anything with it. &#8220;Deciding what window should get the message&#8221; counts as &#8220;anything&#8221;. Consequently, it can&#8217;t inject the call into the destination window&#8217;s context even if it wanted to. There is no destination window yet! <\/p>\n<p> So, for lack of a better choice, it uses the context that registered the hook. Of course, all this context-switching does come at a cost. Low-level hooks are consequently very expensive; don&#8217;t leave them installed when you don&#8217;t need them. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>When I described what the HINSTANCE parameter to the SetWindowsHookEx function is for, I neglected to mention why the low-level hooks are not injected. But then again, it should be obvious. The low-level hooks let you see input as it arrives at the window manager. At this low level of processing, the window manager hasn&#8217;t [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-34303","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>When I described what the HINSTANCE parameter to the SetWindowsHookEx function is for, I neglected to mention why the low-level hooks are not injected. But then again, it should be obvious. The low-level hooks let you see input as it arrives at the window manager. At this low level of processing, the window manager hasn&#8217;t [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/34303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=34303"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/34303\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=34303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=34303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=34303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}