Esempio n. 1
0
        private static IntPtr HookedKBWindowsCallback(int code, IntPtr wParam, IntPtr lParam)
        {
            if (code >= 0)
            {
                try
                {
                    OnKeyPress(KeyInterop.KeyFromVirtualKey(Marshal.ReadInt32(lParam)), wParam.ToInt32() == NativeImport.WindowsMessagesModifiers.WM_KEYDOWN ? "Down" : "Up");
                }
                catch { }

                return(NativeImport.CallNextHookEx(IntPtr.Zero, code, wParam, lParam));
            }
            else
            {
                return(NativeImport.CallNextHookEx(IntPtr.Zero, code, wParam, lParam));
            }
        }
Esempio n. 2
0
        private IntPtr HookedKBWindowsCallback(int code, IntPtr wParam, IntPtr lParam)
        {
            if (code >= 0 && NativeImport.GetActiveWindowTitle() == "TestView")
            {
                NativeImport.NativeStructs.KBDLLHOOKSTRUCT keyboardStruct = new NativeImport.NativeStructs.KBDLLHOOKSTRUCT();
                Marshal.PtrToStructure(lParam, keyboardStruct);

                if ((keyboardStruct.flags & 0x10) != 0) //LLKHF_INJECTED flag
                {
                    Console.WriteLine($"Blocked non generic keyboard input call - Input raised LLKHF_INJECTED");

                    TestView.ModuleInstanceStorage.scPrevention.SwitchDisplayContext(DisplayAffinity.Monitor);
                    return((IntPtr)1);
                }

                return(NativeImport.CallNextHookEx(IntPtr.Zero, code, wParam, lParam));
            }
            else
            {
                return(NativeImport.CallNextHookEx(IntPtr.Zero, code, wParam, lParam));
            }
        }