1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
// elocker32.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include <windows.h>
//Global Hook
HHOOK m_hDllKbdHook;
//Internal Callback function that fires everytime a key is touched
LRESULT CALLBACK wireKeyboardProc(int code,WPARAM wParam,LPARAM lParam)
{
//KBDLLHOOKSTRUCT Structure contains information about the key pressed
DWORD vkCode = ((KBDLLHOOKSTRUCT *) lParam)->vkCode;
DWORD scanCode = ((KBDLLHOOKSTRUCT *) lParam)->scanCode;
DWORD flags = ((KBDLLHOOKSTRUCT *) lParam)->flags;
DWORD time = ((KBDLLHOOKSTRUCT *) lParam)->time;
ULONG_PTR dwExtraInfo = ((KBDLLHOOKSTRUCT *) lParam)->dwExtraInfo;
if(code = HC_ACTION)
{
//If both the Alt and TAB keys are pressed, block?
if((vkCode==VK_MENU) && (vkCode==VK_TAB))
{
MessageBox(0, L"Alt+Tab Blocked!", L"Notice", 0 );
return 1; // Exit function
}
}
//Call next hook
return CallNextHookEx(m_hDllKbdHook, code, wParam, lParam);
}
//External Function
HHOOK LockWindows (HWND appHandle)
{
MessageBox( appHandle, L"Warning: Windows is about to get locked", L"Greetings", 0 );
long appInstance = GetWindowLong(appHandle,-6);
m_hDllKbdHook = SetWindowsHookEx(WH_KEYBOARD_LL, &wireKeyboardProc, (HINSTANCE)appInstance,0);
return m_hDllKbdHook;
}
|