setwindowshookex

Unloading an Injected DLL

允我心安 提交于 2019-12-30 10:22:30
问题 I have a DLL I inject into other processes using SetWindowsHookEx . Inside the DLL I increment the module's reference counter by calling GetModuleHandleEx so I can control when the module is unloaded. At this point the module reference count "should be" 2 from both of those API calls. When the calling process shuts down, it calls UnhookWindowsHookEx , decrementing the reference count to 1. The DLL has a thread that waits on a few things, one of them being the handle of the process that called

Using WH_JOURNALRECORD and cancel does seem to return the WM_CANCELJOURNAL

我怕爱的太早我们不能终老 提交于 2019-12-24 06:44:36
问题 I'm using C# and I've got the program successfully recording the journal messages using SetWindowsHookEx with WH_JOURNALRECORD . My problem comes when it's time to stop. The docs show that if the user pressed CTRL-ESC or CTRL-ALT-DELETE a WM_CANCELJOURNAL message will be posted that I can watch to know when to stop. My application gets unhooked but I never seem to get a WM_CANCELJOURNAL . I have two hooks setup. One hook to do the Journal Record and one to check for the cancel message: IntPtr

Disable task switching keys with c++

孤街醉人 提交于 2019-12-23 03:46:15
问题 I've done a lot of searching around with no real solution (to my own problem) so I thought I'd ask here. I'm designing a kiosk-like program that prevents the user from using task keys (alt+tab, alt+esc, ctrl+esc, etc) while the program is running. Note I'm a novice programmer thus I'd want to stay away from separate dll handling if I can. Particularly, I have went to this site http://support.microsoft.com/kb/226359/en-us for the code. A simplified part of my code looks like this at the top:

C# low level mouse hook and form event handling

耗尽温柔 提交于 2019-12-22 05:36:12
问题 I'm using a simple form generated by VS 2010 which contains 2 buttons, start and stop. Start triggers WH_MOUSE_LL using SetWindowsHookEx, and stop stops the hook. The hook works fine and I mange to "replace" middle mouse button click with double click, the only problem I have is clicking on Minimize/Maximize/Close buttons of the form, it seems that there is some sort of "event race" between the hook and events called by buttons mentioned above. It reflects on the fact that when you press one

How to hook an application?

痴心易碎 提交于 2019-12-19 04:44:13
问题 I'm trying to hook the creation of a windows in my C# app. static IntPtr hhook = IntPtr.Zero; static NativeMethods.HookProc hhookProc; static void Main(string[] args) { // Dummy.exe is a form with a button that opens a MessageBox when clicking on it. Process dummy = Process.Start(@"Dummy.exe"); try { hhookProc = new NativeMethods.HookProc(Hook); IntPtr hwndMod = NativeMethods.GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName); hhook = NativeMethods.SetWindowsHookEx(HookType.WH

SetWindowsHookEx() WM_KEYBOARD_LL not coming through with full screen RDC

半腔热情 提交于 2019-12-18 17:56:50
问题 I'm trying to do a away timer style thing like Skype. If the user is 'away' for a period of time I'll trigger something. I have been using SetWindowsHookEx() with WM_KEYBOARD_LL which works fine. That is until you open a RDC connection and have it full screen. Then I never get the keyboard events. Anyone come across this? Or know of a better way to achieve this? I have actually tested skype and with a full screen RDC it will correctly go from Away to Online if I type in the RDC. Thanks EDIT:

High DPI scaling, mouse hooks and WindowFromPoint

随声附和 提交于 2019-12-13 23:01:07
问题 I have a process that sets a SetWindowsHookEx(WH_MOUSE_LL, , ,) right click hook. My process is set to DPI system aware on Window 10.0.10586 at 150% scaling on both monitors. This was set by calling SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE). My problem scenario is e.g. Office 2007 is DPI unaware, so let's place MS Word on the right quarter of the screen. Right click just above the task bar in the bottom right and the mouse hook sends coordinates of 1279, 675 - scaled to Word. Then I

Global hook for WH_GETMESSAGE hooks only to one application (VisualStudio)

空扰寡人 提交于 2019-12-13 03:59:29
问题 I have a C# application that calls an external DLL file for the hook process. The hook process simply 'hijacks' key presses, converting lowercase characters into uppercase. I thought it was working only to find out that only VisualStudio gets hooked successfully. Other applications like chrome and explorer does not seem to perform the hook process. Is there anything I missed from creating global hooks? Any help is greatly appreciated. dllmain.cpp file: // dllmain.cpp : Defines the entry point

Simple way to hook registry access for specific process

瘦欲@ 提交于 2019-12-12 12:23:51
问题 Is there a simple way to hook registry access of a process that my code executes? I know about SetWindowsHookEx and friends, but its just too complex... I still have hopes that there is a way as simple as LD_PRELOAD on Unix ... 回答1: Read up on the theory of DLL Injection here: http://en.wikipedia.org/wiki/DLL_injection However, I will supply you with a DLL Injection snippet here: http://www.dreamincode.net/code/snippet407.htm It's pretty easy to do these types of things once you're in the

Calling SetWindowsHookEx inside VS2008 debugger always returns NULL

别说谁变了你拦得住时间么 提交于 2019-12-12 01:33:52
问题 we're working on a .Net application that does a low level keyboard hook. When we call the SetWindowsHookEx running inside the debugger the call always fail. When running from the compiled executable everything works fine. If we attach to the processs the the SetWindowsHookEx has been called everything works too. I've read somewhere (I can not remember) that VS already does a low level keyboard hook but this shouldn't be a problem as there is the CallNextHook function. Someone knows what's