private void SetHook() { Contract.Requires(GetHookType() > 0); Contract.Requires(GetCallback() != null); //IntPtr ptrUser = SSWindowsFunctions.LoadLibrary("User32"); using (ProcessModule module = Process.GetCurrentProcess().MainModule) { _hhook = SSWindowsFunctions.SetWindowsHookEx(GetHookType(), GetCallback(), SSWindowsFunctions.GetModuleHandle(module.ModuleName), 0); } }
public override void StartSystem() { #if LOCAL_DEBUG _mouseHookThread = new Thread(() => { _mouseHookThreadId = (uint)SSWindowsFunctions.GetCurrentThreadId(); using (ProcessModule module = Process.GetCurrentProcess().MainModule) { _hhook = SSWindowsFunctions.SetWindowsHookEx(GetHookType(), GetCallback(), SSWindowsFunctions.GetModuleHandle(module.ModuleName), 0); } uint msg; SSWindowsFunctions.GetMessage(out msg, IntPtr.Zero, 0, 0); }); _mouseHookThread.IsBackground = true; _mouseHookThread.Start(); #endif _selctionAreaToken = InteractionManager.GetCommand <SSSelectionRegionProvider>().Subscribe(OnSelectionArea); }