Message Hook Window is working, Added BAR sendKeys and fixed colon key.
Message Hook Window is working and will allow you to see all messages being processed by a target window. Had to build Message Hook Window inside the native MsgHook.dll was having issues keep a java window's WndProc callback processing.
This commit is contained in:
@@ -78,11 +78,19 @@ extern "C" __declspec(dllexport) BOOL SetMsgHook(HWND callerHWnd, DWORD threadId
|
||||
pData->g_hWnd = callerHWnd; // remember the windows and hook handle for further instances
|
||||
pData->g_CwpHook = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)CwpHookProc, (HINSTANCE)pData->g_hInstance, threadId);
|
||||
//pData->g_MsgHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)MsgHookProc, (HINSTANCE)pData->g_hInstance, threadId);
|
||||
if (pData->g_CwpHook == NULL) {
|
||||
TCHAR tmp[100];
|
||||
_stprintf_s(tmp, _T("Last Error # %ld on threadId %ld"), GetLastError(), threadId);
|
||||
MessageBox(0, tmp, _T("Set Hook Error"), 0);
|
||||
}
|
||||
|
||||
return (pData->g_CwpHook != NULL); //pData->g_CwpHook != NULL &&
|
||||
}
|
||||
else
|
||||
{
|
||||
//MessageBox(0, _T("Error: Not starting process"), _T("Set Hook Error"), 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) BOOL RemoveHook()
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
@@ -141,10 +142,14 @@ copy /Y "$(TargetPath)" "$(ProjectDir)bin\MsgHook$(PlatformArchitecture)$(Target
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<None Include="MsgHookTest.ico" />
|
||||
<None Include="ReadMe.txt" />
|
||||
<None Include="small.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="MsgLookup.h" />
|
||||
<ClInclude Include="org_synthuse_MsgHook.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
@@ -164,6 +169,7 @@ copy /Y "$(TargetPath)" "$(ProjectDir)bin\MsgHook$(PlatformArchitecture)$(Target
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MsgHook.cpp" />
|
||||
<ClCompile Include="MsgHookWindow.cpp" />
|
||||
<ClCompile Include="org_synthuse_MsgHook.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
@@ -172,6 +178,9 @@ copy /Y "$(TargetPath)" "$(ProjectDir)bin\MsgHook$(PlatformArchitecture)$(Target
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="MsgHookTest.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
<None Include="MsgHookTest.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="small.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
@@ -27,6 +33,12 @@
|
||||
<ClInclude Include="org_synthuse_MsgHook.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MsgLookup.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
@@ -41,5 +53,13 @@
|
||||
<ClCompile Include="org_synthuse_MsgHook.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MsgHookWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="MsgHookTest.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
BIN
native/MsgHook/MsgHookTest.aps
Normal file
BIN
native/MsgHook/MsgHookTest.aps
Normal file
Binary file not shown.
BIN
native/MsgHook/MsgHookTest.ico
Normal file
BIN
native/MsgHook/MsgHookTest.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
BIN
native/MsgHook/MsgHookTest.rc
Normal file
BIN
native/MsgHook/MsgHookTest.rc
Normal file
Binary file not shown.
503
native/MsgHook/MsgHookWindow.cpp
Normal file
503
native/MsgHook/MsgHookWindow.cpp
Normal file
@@ -0,0 +1,503 @@
|
||||
/*
|
||||
* Copyright 2014, Synthuse.org
|
||||
* Released under the Apache Version 2.0 License.
|
||||
*
|
||||
* last modified by ejakubowski7@gmail.com
|
||||
*/
|
||||
|
||||
// MsgHookTest.cpp : Defines the entry point for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "resource.h"
|
||||
#include "MsgLookup.h"
|
||||
//#include "MsgHookTest.h"
|
||||
//#include "MsgHook.h"
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
|
||||
// Global Variables:
|
||||
HINSTANCE hInst; // current instance
|
||||
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
|
||||
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
|
||||
HWND mainHwnd = NULL;
|
||||
HMENU mainMenu = NULL;
|
||||
HWND txtbox = NULL;
|
||||
HWND targetHwnd = NULL;
|
||||
const int txtboxSpacing = 2;
|
||||
|
||||
|
||||
bool filterWmCommand = true;
|
||||
bool filterWmNotify = false;
|
||||
bool filterAbove = false;
|
||||
|
||||
|
||||
//#define MAX_TEST_SIZE 100
|
||||
//TCHAR targetClassname[MAX_TEST_SIZE] = _T("Notepad");
|
||||
TCHAR targetClassname[MAX_TEST_SIZE] = _T("WordPadClass");
|
||||
TCHAR testWmSettextL[MAX_TEST_SIZE] = _T("This is a test");
|
||||
TCHAR testWmSettextW[MAX_TEST_SIZE] = _T("0");
|
||||
TCHAR testWmCommandL[MAX_TEST_SIZE] = _T("0");
|
||||
TCHAR testWmCommandW[MAX_TEST_SIZE] = _T("1");
|
||||
|
||||
TCHAR targetHwndStr[MAX_TEST_SIZE] = _T("");
|
||||
|
||||
const int hotkeyIdOffset = 0;
|
||||
const int pauseHotKey = 'P'; //P
|
||||
bool isPaused = false;
|
||||
|
||||
// Forward declarations of functions included in this code module:
|
||||
int APIENTRY StartWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow);
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance);
|
||||
BOOL InitInstance(HINSTANCE, int);
|
||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
INT_PTR CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
void AppendText(HWND txtHwnd, LPCTSTR newText)
|
||||
{
|
||||
if (isPaused)
|
||||
return;
|
||||
DWORD len = GetWindowTextLength(txtHwnd);
|
||||
if (len > 25000)
|
||||
{//need to truncate the beginning so the text doesn't go past it's limit
|
||||
SendMessage(txtHwnd, EM_SETSEL, 0, 10000);
|
||||
SendMessage(txtHwnd, EM_REPLACESEL, 0, (LPARAM)_T(""));
|
||||
len = GetWindowTextLength(txtHwnd);
|
||||
}
|
||||
//DWORD l,r;
|
||||
//SendMessage(txtHwnd, EM_GETSEL,(WPARAM)&l,(LPARAM)&r);
|
||||
SendMessage(txtHwnd, EM_SETSEL, len, len);
|
||||
SendMessage(txtHwnd, EM_REPLACESEL, 0, (LPARAM)newText);
|
||||
len = GetWindowTextLength(txtHwnd);
|
||||
SendMessage(txtHwnd, EM_SETSEL, len, len);
|
||||
//SendMessage(txtHwnd, EM_SETSEL,l,r);
|
||||
}
|
||||
|
||||
void InitMsgFiltersAndLookup()
|
||||
{
|
||||
if (!filterWmCommand && !filterAbove && !filterWmNotify)
|
||||
InitializeMsgLookup();
|
||||
else
|
||||
{
|
||||
int allowList[3];
|
||||
for (int i = 0; i < 3; i ++)
|
||||
allowList[i] = -1;
|
||||
|
||||
if (filterWmCommand) {
|
||||
AppendText(txtbox, _T("filtering on WM_COMMAND & WM_MENUCOMMAND\r\n"));
|
||||
allowList[0] = WM_COMMAND;
|
||||
allowList[1] = WM_MENUCOMMAND;
|
||||
}
|
||||
if (filterWmNotify)
|
||||
{
|
||||
AppendText(txtbox, _T("filtering on WM_NOTIFY\r\n"));
|
||||
allowList[2] = WM_NOTIFY;
|
||||
}
|
||||
//if (filterAbove)
|
||||
// allowList[0] = WM_COMMAND;
|
||||
InitializeMsgLookup(allowList, 3);
|
||||
}
|
||||
}
|
||||
|
||||
void StartMessageHook()
|
||||
{
|
||||
AppendText(txtbox, _T("Starting Message Hook\r\n"));
|
||||
targetHwnd = FindWindow(targetClassname, NULL);
|
||||
|
||||
if (_tcscmp(targetHwndStr, _T("")) != 0) //if target HWND was used then override classname hwnd
|
||||
{
|
||||
TCHAR *stopStr;
|
||||
targetHwnd = (HWND)_tcstol(targetHwndStr, &stopStr, 10);
|
||||
}
|
||||
|
||||
DWORD tid = GetWindowThreadProcessId(targetHwnd, NULL);
|
||||
|
||||
InitMsgFiltersAndLookup();
|
||||
//InitializeMsgLookup();
|
||||
|
||||
TCHAR tmp[50];
|
||||
_stprintf_s(tmp, _T("Target Handle: %ld, and Thread Id: %ld\r\n"), targetHwnd, tid);
|
||||
AppendText(txtbox, tmp);
|
||||
|
||||
//block self/global msg hook
|
||||
if (targetHwnd == NULL || tid == 0) {
|
||||
AppendText(txtbox, _T("Target window not found\r\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
//if (InitMsgHook(mainHwnd, tid))
|
||||
if (SetMsgHook(mainHwnd, tid))
|
||||
{
|
||||
EnableMenuItem(mainMenu, ID_FILE_STOPHOOK, MF_ENABLED);
|
||||
EnableMenuItem(mainMenu, ID_FILE_STARTHOOK, MF_DISABLED | MF_GRAYED);
|
||||
AppendText(txtbox, _T("Hook successfully initialized\r\n"));
|
||||
}
|
||||
else
|
||||
AppendText(txtbox, _T("Hook failed to initialize\r\n"));
|
||||
}
|
||||
|
||||
void StopMessageHook()
|
||||
{
|
||||
EnableMenuItem(mainMenu, ID_FILE_STOPHOOK, MF_DISABLED | MF_GRAYED);
|
||||
EnableMenuItem(mainMenu, ID_FILE_STARTHOOK, MF_ENABLED);
|
||||
AppendText(txtbox, TEXT("Stopping Message Hook\r\n"));
|
||||
//KillHook();
|
||||
RemoveHook();
|
||||
}
|
||||
|
||||
bool OnCopyData(COPYDATASTRUCT* pCopyDataStruct) // WM_COPYDATA lParam will have this struct
|
||||
{
|
||||
if( pCopyDataStruct->cbData!=sizeof(HEVENT))
|
||||
return false;
|
||||
HEVENT Event;
|
||||
memcpy(&Event, (HEVENT*)pCopyDataStruct->lpData, sizeof(HEVENT)); // transfer data to internal variable
|
||||
if (Event.dwHookType == WH_KEYBOARD)
|
||||
{
|
||||
//KBDLLHOOKSTRUCT* pkh = (KBDLLHOOKSTRUCT*) Event.lParam;
|
||||
//char tmp[50];
|
||||
//return wkvn->KeyboardData(pkh->vkCode,Event.wParam);
|
||||
}
|
||||
else if (Event.dwHookType == WH_MOUSE)
|
||||
{
|
||||
//MSLLHOOKSTRUCT* pmh = (MSLLHOOKSTRUCT*) Event.lParam;
|
||||
//char tmp[50];
|
||||
//if (Event.wParam == WM_LBUTTONDOWN)
|
||||
// return wkvn->MouseClickData(1,true);
|
||||
// else
|
||||
// return wkvn->MouseMoveData(pmh->pt.x,pmh->pt.y);
|
||||
}
|
||||
else if (Event.dwHookType == WH_CALLWNDPROC)
|
||||
{
|
||||
TCHAR *msgName = _T("unknown");
|
||||
if (Event.nCode < MAX_MSG_LOOKUP)
|
||||
msgName = MSG_LOOKUP[Event.nCode];
|
||||
else
|
||||
{
|
||||
if (!filterAbove)
|
||||
return false;
|
||||
}
|
||||
if (_tcscmp(msgName, _T("")) != 0)
|
||||
{
|
||||
TCHAR tmp[200];
|
||||
_stprintf_s(tmp, _T("hwnd: %ld, msg: %s (%ld), wparam: '%s'[%ld], lparam: '%s'{%ld}\r\n"), Event.hWnd, msgName, Event.nCode, Event.wParamStr, Event.wParam, Event.lParamStr,Event.lParam);
|
||||
AppendText(txtbox, tmp);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SendWmSettext() //ID_TESTMSGS_WM
|
||||
{
|
||||
//SetWindowText(targetHwnd, _T("This is a test"));
|
||||
//TCHAR txt[] = _T("This is a test");
|
||||
TCHAR *stopStr;
|
||||
long wparam = _tcstol(testWmSettextW, &stopStr, 10);
|
||||
SendMessage(targetHwnd, WM_SETTEXT, wparam, (LPARAM)testWmSettextL);
|
||||
//PostMessage(targetHwnd, WM_SETTEXT, 0 , (LPARAM)txt);
|
||||
}
|
||||
|
||||
|
||||
void SendWmCommand() //ID_TESTMSGS_WM
|
||||
{
|
||||
TCHAR *stopStr;
|
||||
HWND sendHwnd = targetHwnd;
|
||||
if (_tcscmp(targetHwndStr, _T("")) != 0)
|
||||
{
|
||||
sendHwnd = (HWND)_tcstol(targetHwndStr, &stopStr, 10);
|
||||
}
|
||||
long wparam = _tcstol(testWmCommandW, &stopStr, 10);
|
||||
long lparam = _tcstol(testWmCommandL, &stopStr, 10);
|
||||
SendMessage(sendHwnd, WM_COMMAND, wparam, lparam);
|
||||
}
|
||||
|
||||
void HotKeyPressed(WPARAM wParam)
|
||||
{
|
||||
//AppendText(txtbox, _T("hotkey test"));
|
||||
if (wParam == (pauseHotKey + hotkeyIdOffset))
|
||||
{
|
||||
if (!isPaused)
|
||||
{
|
||||
AppendText(txtbox, _T("Paused\r\n"));
|
||||
isPaused = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isPaused = false;
|
||||
AppendText(txtbox, _T("Unpaused\r\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void CreateMsgHookWindow(LPTSTR lpCmdLine)
|
||||
{
|
||||
//StartWinMain(GetModuleHandle(NULL), NULL, lpCmdLine, SW_SHOW);
|
||||
StartWinMain((HINSTANCE)pData->g_hInstance, NULL, lpCmdLine, SW_SHOW);
|
||||
|
||||
}
|
||||
|
||||
int APIENTRY StartWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
// TODO: Place code here.
|
||||
MSG msg;
|
||||
HACCEL hAccelTable;
|
||||
|
||||
// Initialize global strings
|
||||
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
||||
LoadString(hInstance, IDC_MSGHOOKTEST, szWindowClass, MAX_LOADSTRING);
|
||||
MyRegisterClass(hInstance);
|
||||
|
||||
// Perform application initialization:
|
||||
if (!InitInstance (hInstance, nCmdShow))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MSGHOOKTEST));
|
||||
|
||||
// Main message loop:
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
//if (msg.message == WM_HOTKEY)
|
||||
// HotKeyPressed(msg.wParam);
|
||||
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
UnregisterHotKey(mainHwnd, pauseHotKey + hotkeyIdOffset);
|
||||
|
||||
return (int) msg.wParam;
|
||||
}
|
||||
|
||||
//
|
||||
// FUNCTION: MyRegisterClass()
|
||||
//
|
||||
// PURPOSE: Registers the window class.
|
||||
//
|
||||
// COMMENTS:
|
||||
//
|
||||
// This function and its usage are only necessary if you want this code
|
||||
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
|
||||
// function that was added to Windows 95. It is important to call this function
|
||||
// so that the application will get 'well formed' small icons associated
|
||||
// with it.
|
||||
//
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASSEX wcex;
|
||||
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = WndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = hInstance;
|
||||
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MSGHOOKTEST));
|
||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_MSGHOOKTEST);
|
||||
wcex.lpszClassName = szWindowClass;
|
||||
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
||||
|
||||
return RegisterClassEx(&wcex);
|
||||
}
|
||||
|
||||
//
|
||||
// FUNCTION: InitInstance(HINSTANCE, int)
|
||||
//
|
||||
// PURPOSE: Saves instance handle and creates main window
|
||||
//
|
||||
// COMMENTS:
|
||||
//
|
||||
// In this function, we save the instance handle in a global variable and
|
||||
// create and display the main program window.
|
||||
//
|
||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
HWND hWnd;
|
||||
|
||||
hInst = hInstance; // Store instance handle in our global variable
|
||||
|
||||
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, 0, 700, 300, NULL, NULL, hInstance, NULL);
|
||||
|
||||
if (!hWnd) {
|
||||
DWORD lastErr = GetLastError();
|
||||
printf("Error Creating Window %d\n", lastErr);
|
||||
return FALSE;
|
||||
}
|
||||
mainHwnd = hWnd;
|
||||
|
||||
RECT rect;
|
||||
GetClientRect(hWnd, &rect);
|
||||
// make the txtbox edit control almost the same size as the parent window
|
||||
//WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL
|
||||
txtbox = CreateWindow(TEXT("Edit"),TEXT(""), WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL | ES_READONLY,
|
||||
txtboxSpacing, txtboxSpacing,rect.right-(txtboxSpacing*2), rect.bottom-(txtboxSpacing*2), hWnd, NULL, NULL, NULL);
|
||||
|
||||
HFONT hFont = CreateFont(14, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
||||
OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
||||
DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"));
|
||||
SendMessage(txtbox, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||
|
||||
mainMenu = GetMenu(mainHwnd);
|
||||
EnableMenuItem(mainMenu, ID_FILE_STOPHOOK, MF_DISABLED | MF_GRAYED);
|
||||
|
||||
RegisterHotKey(mainHwnd, pauseHotKey + hotkeyIdOffset, MOD_NOREPEAT | MOD_SHIFT | MOD_CONTROL, pauseHotKey);
|
||||
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
UpdateWindow(hWnd);
|
||||
|
||||
//set always on top
|
||||
SetWindowPos(mainHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE| SWP_NOMOVE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
|
||||
//
|
||||
// PURPOSE: Processes messages for the main window.
|
||||
//
|
||||
// WM_COMMAND - process the application menu
|
||||
// WM_PAINT - Paint the main window
|
||||
// WM_DESTROY - post a quit message and return
|
||||
//
|
||||
//
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int wmId, wmEvent;
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
//appendText(txtbox, TEXT("test\r\n"));
|
||||
break;
|
||||
case WM_COPYDATA:
|
||||
return (OnCopyData((COPYDATASTRUCT *) lParam));
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
wmId = LOWORD(wParam);
|
||||
wmEvent = HIWORD(wParam);
|
||||
// Parse the menu selections:
|
||||
switch (wmId)
|
||||
{
|
||||
case ID_FILE_STARTHOOK:
|
||||
StartMessageHook();
|
||||
break;
|
||||
case ID_FILE_STOPHOOK:
|
||||
StopMessageHook();
|
||||
break;
|
||||
case ID_TESTMSGS_WM:
|
||||
SendWmSettext();
|
||||
break;
|
||||
case ID_TESTMSGS_WMCOM:
|
||||
SendWmCommand();
|
||||
break;
|
||||
case ID_FILE_SETTINGS:
|
||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, DlgProc);
|
||||
break;
|
||||
case IDM_ABOUT:
|
||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, DlgProc);
|
||||
break;
|
||||
case ID_FILE_CLEAR:
|
||||
SetWindowText(txtbox, _T(""));
|
||||
break;
|
||||
case IDM_EXIT:
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
break;
|
||||
case WM_HOTKEY:
|
||||
HotKeyPressed(wParam);
|
||||
break;
|
||||
case WM_PAINT:
|
||||
hdc = BeginPaint(hWnd, &ps);
|
||||
// TODO: Add any drawing code here...
|
||||
EndPaint(hWnd, &ps);
|
||||
break;
|
||||
case WM_SIZE:
|
||||
{ //resize the txtbox when the parent window size changes
|
||||
int nWidth = LOWORD(lParam);
|
||||
int nHeight = HIWORD(lParam);
|
||||
SetWindowPos(txtbox, HWND_NOTOPMOST, txtboxSpacing, txtboxSpacing, nWidth-(txtboxSpacing*2), nHeight-(txtboxSpacing*2), SWP_NOZORDER|SWP_NOMOVE);
|
||||
}
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Message handler for about box.
|
||||
INT_PTR CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
//IDC_EDIT1
|
||||
SendDlgItemMessage(hDlg, IDC_EDIT1, WM_SETTEXT, 0 , (LPARAM)targetClassname);
|
||||
if (filterWmCommand)
|
||||
SendDlgItemMessage(hDlg, IDC_CHECK_CMD, BM_SETCHECK, BST_CHECKED, 0);
|
||||
if (filterWmNotify)
|
||||
SendDlgItemMessage(hDlg, IDC_CHECK_NOT, BM_SETCHECK, BST_CHECKED, 0);
|
||||
if (filterAbove)
|
||||
SendDlgItemMessage(hDlg, IDC_CHECK_ABO, BM_SETCHECK, BST_CHECKED, 0);
|
||||
SendDlgItemMessage(hDlg, IDC_WMCOMW, WM_SETTEXT, 0 , (LPARAM)testWmCommandW);
|
||||
SendDlgItemMessage(hDlg, IDC_WMCOML, WM_SETTEXT, 0 , (LPARAM)testWmCommandL);
|
||||
SendDlgItemMessage(hDlg, IDC_WMSETW, WM_SETTEXT, 0 , (LPARAM)testWmSettextW);
|
||||
SendDlgItemMessage(hDlg, IDC_WMSETL, WM_SETTEXT, 0 , (LPARAM)testWmSettextL);
|
||||
SendDlgItemMessage(hDlg, IDC_HWND, WM_SETTEXT, 0 , (LPARAM)targetHwndStr);
|
||||
|
||||
}
|
||||
return (INT_PTR)TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK) //only save on OK
|
||||
{
|
||||
GetDlgItemText(hDlg, IDC_EDIT1, targetClassname, 100);
|
||||
GetDlgItemText(hDlg, IDC_WMCOMW, testWmCommandW, MAX_TEST_SIZE);
|
||||
GetDlgItemText(hDlg, IDC_WMCOML, testWmCommandL, MAX_TEST_SIZE);
|
||||
GetDlgItemText(hDlg, IDC_WMSETW, testWmSettextW, MAX_TEST_SIZE);
|
||||
GetDlgItemText(hDlg, IDC_WMSETL, testWmSettextL, MAX_TEST_SIZE);
|
||||
GetDlgItemText(hDlg, IDC_HWND, targetHwndStr, MAX_TEST_SIZE);
|
||||
// check filter options
|
||||
if (SendDlgItemMessage(hDlg, IDC_CHECK_CMD, BM_GETCHECK, 0, 0) == BST_CHECKED) // the hard way
|
||||
filterWmCommand = true;
|
||||
else
|
||||
filterWmCommand = false;
|
||||
if (IsDlgButtonChecked(hDlg, IDC_CHECK_NOT) == BST_CHECKED) // the easy way
|
||||
filterWmNotify = true;
|
||||
else
|
||||
filterWmNotify = false;
|
||||
if (IsDlgButtonChecked(hDlg, IDC_CHECK_ABO) == BST_CHECKED)
|
||||
filterAbove = true;
|
||||
else
|
||||
filterAbove = false;
|
||||
|
||||
InitMsgFiltersAndLookup();
|
||||
}
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||
{
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
return (INT_PTR)TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (INT_PTR)FALSE;
|
||||
}
|
||||
247
native/MsgHook/MsgLookup.h
Normal file
247
native/MsgHook/MsgLookup.h
Normal file
@@ -0,0 +1,247 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// MSG Array LOOKUP
|
||||
const int MAX_MSG_LOOKUP = 1024;
|
||||
const int MAX_MSG_NAME = 21;
|
||||
TCHAR MSG_LOOKUP[MAX_MSG_LOOKUP][MAX_MSG_NAME] = {
|
||||
};
|
||||
|
||||
|
||||
//void InitializeMsgLookup() below
|
||||
void InitializeMsgLookup(int allowList[], int allowSize)
|
||||
{
|
||||
for (int i = 0 ; i < MAX_MSG_LOOKUP ; i++)
|
||||
{
|
||||
bool allowFlg = true;
|
||||
if (allowSize > 0)
|
||||
allowFlg = false;
|
||||
for (int a = 0 ; a < allowSize ; a++)
|
||||
if (allowList[a] == i)
|
||||
allowFlg = true;
|
||||
if (!allowFlg)
|
||||
continue;
|
||||
switch (i)
|
||||
{
|
||||
case WM_NULL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NULL")); break;
|
||||
case WM_CREATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CREATE")); break;
|
||||
case WM_DESTROY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DESTROY")); break;
|
||||
case WM_MOVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOVE")); break;
|
||||
case WM_SIZE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SIZE")); break;
|
||||
case WM_ACTIVATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ACTIVATE")); break;
|
||||
case WM_SETFOCUS: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETFOCUS")); break;
|
||||
case WM_KILLFOCUS: _tcscpy_s(MSG_LOOKUP[i], _T("WM_KILLFOCUS")); break;
|
||||
case WM_ENABLE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ENABLE")); break;
|
||||
case WM_SETREDRAW: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETREDRAW")); break;
|
||||
case WM_SETTEXT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETTEXT")); break;
|
||||
case WM_GETTEXT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETTEXT")); break;
|
||||
case WM_GETTEXTLENGTH: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETTEXTLENGTH")); break;
|
||||
case WM_PAINT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PAINT")); break;
|
||||
case WM_CLOSE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CLOSE")); break;
|
||||
case WM_QUERYENDSESSION: _tcscpy_s(MSG_LOOKUP[i], _T("WM_QUERYENDSESSION")); break;
|
||||
case WM_QUIT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_QUIT")); break;
|
||||
case WM_QUERYOPEN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_QUERYOPEN")); break;
|
||||
case WM_ERASEBKGND: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ERASEBKGND")); break;
|
||||
case WM_SYSCOLORCHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSCOLORCHANGE")); break;
|
||||
case WM_ENDSESSION: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ENDSESSION")); break;
|
||||
case 0x17: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSTEMERROR")); break;
|
||||
case WM_SHOWWINDOW: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SHOWWINDOW")); break;
|
||||
case 0x19: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLOR")); break;
|
||||
case WM_WININICHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_WININICHANGE")); break;
|
||||
//case WM_SETTINGCHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETTINGCHANGE")); break;
|
||||
case WM_DEVMODECHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DEVMODECHANGE")); break;
|
||||
case WM_ACTIVATEAPP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ACTIVATEAPP")); break;
|
||||
case WM_FONTCHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_FONTCHANGE")); break;
|
||||
case WM_TIMECHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_TIMECHANGE")); break;
|
||||
case WM_CANCELMODE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CANCELMODE")); break;
|
||||
case WM_SETCURSOR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETCURSOR")); break;
|
||||
case WM_MOUSEACTIVATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSEACTIVATE")); break;
|
||||
case WM_CHILDACTIVATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CHILDACTIVATE")); break;
|
||||
case WM_QUEUESYNC: _tcscpy_s(MSG_LOOKUP[i], _T("WM_QUEUESYNC")); break;
|
||||
case WM_GETMINMAXINFO: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETMINMAXINFO")); break;
|
||||
case WM_PAINTICON: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PAINTICON")); break;
|
||||
case WM_ICONERASEBKGND: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ICONERASEBKGND")); break;
|
||||
case WM_NEXTDLGCTL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NEXTDLGCTL")); break;
|
||||
case WM_SPOOLERSTATUS: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SPOOLERSTATUS")); break;
|
||||
case WM_DRAWITEM: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DRAWITEM")); break;
|
||||
case WM_MEASUREITEM: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MEASUREITEM")); break;
|
||||
case WM_DELETEITEM: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DELETEITEM")); break;
|
||||
case WM_VKEYTOITEM: _tcscpy_s(MSG_LOOKUP[i], _T("WM_VKEYTOITEM")); break;
|
||||
case WM_CHARTOITEM: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CHARTOITEM")); break;
|
||||
case WM_SETFONT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETFONT")); break;
|
||||
case WM_GETFONT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETFONT")); break;
|
||||
case WM_SETHOTKEY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETHOTKEY")); break;
|
||||
case WM_GETHOTKEY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETHOTKEY")); break;
|
||||
case WM_QUERYDRAGICON: _tcscpy_s(MSG_LOOKUP[i], _T("WM_QUERYDRAGICON")); break;
|
||||
case WM_COMPAREITEM: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COMPAREITEM")); break;
|
||||
case WM_COMPACTING: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COMPACTING")); break;
|
||||
case WM_WINDOWPOSCHANGING: _tcscpy_s(MSG_LOOKUP[i], _T("WM_WINDOWPOSCHANGING")); break;
|
||||
case WM_WINDOWPOSCHANGED: _tcscpy_s(MSG_LOOKUP[i], _T("WM_WINDOWPOSCHANGED")); break;
|
||||
case WM_POWER: _tcscpy_s(MSG_LOOKUP[i], _T("WM_POWER")); break;
|
||||
case WM_COPYDATA: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COPYDATA")); break;
|
||||
case WM_CANCELJOURNAL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CANCELJOURNAL")); break;
|
||||
case WM_NOTIFY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NOTIFY")); break;
|
||||
case WM_INPUTLANGCHANGEREQUEST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_INPUTLANGCHANGERE")); break;
|
||||
case WM_INPUTLANGCHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_INPUTLANGCHANGE")); break;
|
||||
case WM_TCARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_TCARD")); break;
|
||||
case WM_HELP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_HELP")); break;
|
||||
case WM_USERCHANGED: _tcscpy_s(MSG_LOOKUP[i], _T("WM_USERCHANGED")); break;
|
||||
case WM_NOTIFYFORMAT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NOTIFYFORMAT")); break;
|
||||
case WM_CONTEXTMENU: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CONTEXTMENU")); break;
|
||||
case WM_STYLECHANGING: _tcscpy_s(MSG_LOOKUP[i], _T("WM_STYLECHANGING")); break;
|
||||
case WM_STYLECHANGED: _tcscpy_s(MSG_LOOKUP[i], _T("WM_STYLECHANGED")); break;
|
||||
case WM_DISPLAYCHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DISPLAYCHANGE")); break;
|
||||
case WM_GETICON: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETICON")); break;
|
||||
case WM_SETICON: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETICON")); break;
|
||||
case WM_NCCREATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCCREATE")); break;
|
||||
case WM_NCDESTROY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCDESTROY")); break;
|
||||
case WM_NCCALCSIZE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCCALCSIZE")); break;
|
||||
case WM_NCHITTEST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCHITTEST")); break;
|
||||
case WM_NCPAINT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCPAINT")); break;
|
||||
case WM_NCACTIVATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCACTIVATE")); break;
|
||||
case WM_GETDLGCODE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETDLGCODE")); break;
|
||||
case WM_NCMOUSEMOVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCMOUSEMOVE")); break;
|
||||
case WM_NCLBUTTONDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCLBUTTONDOWN")); break;
|
||||
case WM_NCLBUTTONUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCLBUTTONUP")); break;
|
||||
case WM_NCLBUTTONDBLCLK: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCLBUTTONDBLCLK")); break;
|
||||
case WM_NCRBUTTONDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCRBUTTONDOWN")); break;
|
||||
case WM_NCRBUTTONUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCRBUTTONUP")); break;
|
||||
case WM_NCRBUTTONDBLCLK: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCRBUTTONDBLCLK")); break;
|
||||
case WM_NCMBUTTONDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCMBUTTONDOWN")); break;
|
||||
case WM_NCMBUTTONUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCMBUTTONUP")); break;
|
||||
case WM_NCMBUTTONDBLCLK: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCMBUTTONDBLCLK")); break;
|
||||
//case WM_KEYFIRST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_KEYFIRST")); break;
|
||||
case WM_KEYDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_KEYDOWN")); break;
|
||||
case WM_KEYUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_KEYUP")); break;
|
||||
case WM_CHAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CHAR")); break;
|
||||
case WM_DEADCHAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DEADCHAR")); break;
|
||||
case WM_SYSKEYDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSKEYDOWN")); break;
|
||||
case WM_SYSKEYUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSKEYUP")); break;
|
||||
case WM_SYSCHAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSCHAR")); break;
|
||||
case WM_SYSDEADCHAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSDEADCHAR")); break;
|
||||
case WM_KEYLAST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_KEYLAST")); break;
|
||||
case WM_IME_STARTCOMPOSITION: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_STARTCOMPOSIT")); break;
|
||||
case WM_IME_ENDCOMPOSITION: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_ENDCOMPOSITIO")); break;
|
||||
case WM_IME_COMPOSITION: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_COMPOSITION")); break;
|
||||
//case WM_IME_KEYLAST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_KEYLAST")); break;
|
||||
case WM_INITDIALOG: _tcscpy_s(MSG_LOOKUP[i], _T("WM_INITDIALOG")); break;
|
||||
case WM_COMMAND: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COMMAND")); break;
|
||||
case WM_SYSCOMMAND: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSCOMMAND")); break;
|
||||
case WM_TIMER: _tcscpy_s(MSG_LOOKUP[i], _T("WM_TIMER")); break;
|
||||
case WM_HSCROLL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_HSCROLL")); break;
|
||||
case WM_VSCROLL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_VSCROLL")); break;
|
||||
case WM_INITMENU: _tcscpy_s(MSG_LOOKUP[i], _T("WM_INITMENU")); break;
|
||||
case WM_INITMENUPOPUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_INITMENUPOPUP")); break;
|
||||
case WM_MENUSELECT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MENUSELECT")); break;
|
||||
case WM_MENUCHAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MENUCHAR")); break;
|
||||
case WM_ENTERIDLE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ENTERIDLE")); break;
|
||||
case WM_CTLCOLORMSGBOX: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLORMSGBOX")); break;
|
||||
case WM_CTLCOLOREDIT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLOREDIT")); break;
|
||||
case WM_CTLCOLORLISTBOX: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLORLISTBOX")); break;
|
||||
case WM_CTLCOLORBTN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLORBTN")); break;
|
||||
case WM_CTLCOLORDLG: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLORDLG")); break;
|
||||
case WM_CTLCOLORSCROLLBAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLORSCROLLBAR")); break;
|
||||
case WM_CTLCOLORSTATIC: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLORSTATIC")); break;
|
||||
//case WM_MOUSEFIRST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSEFIRST")); break;
|
||||
case WM_MOUSEMOVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSEMOVE")); break;
|
||||
case WM_LBUTTONDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_LBUTTONDOWN")); break;
|
||||
case WM_LBUTTONUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_LBUTTONUP")); break;
|
||||
case WM_LBUTTONDBLCLK: _tcscpy_s(MSG_LOOKUP[i], _T("WM_LBUTTONDBLCLK")); break;
|
||||
case WM_RBUTTONDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_RBUTTONDOWN")); break;
|
||||
case WM_RBUTTONUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_RBUTTONUP")); break;
|
||||
case WM_RBUTTONDBLCLK: _tcscpy_s(MSG_LOOKUP[i], _T("WM_RBUTTONDBLCLK")); break;
|
||||
case WM_MBUTTONDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MBUTTONDOWN")); break;
|
||||
case WM_MBUTTONUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MBUTTONUP")); break;
|
||||
case WM_MBUTTONDBLCLK: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MBUTTONDBLCLK")); break;
|
||||
case WM_MOUSEWHEEL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSEWHEEL")); break;
|
||||
case WM_MOUSEHWHEEL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSEHWHEEL")); break;
|
||||
case WM_PARENTNOTIFY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PARENTNOTIFY")); break;
|
||||
case WM_ENTERMENULOOP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ENTERMENULOOP")); break;
|
||||
case WM_EXITMENULOOP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_EXITMENULOOP")); break;
|
||||
case WM_NEXTMENU: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NEXTMENU")); break;
|
||||
case WM_SIZING: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SIZING")); break;
|
||||
case WM_CAPTURECHANGED: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CAPTURECHANGED")); break;
|
||||
case WM_MOVING: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOVING")); break;
|
||||
case WM_POWERBROADCAST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_POWERBROADCAST")); break;
|
||||
case WM_DEVICECHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DEVICECHANGE")); break;
|
||||
case WM_MDICREATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDICREATE")); break;
|
||||
case WM_MDIDESTROY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIDESTROY")); break;
|
||||
case WM_MDIACTIVATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIACTIVATE")); break;
|
||||
case WM_MDIRESTORE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIRESTORE")); break;
|
||||
case WM_MDINEXT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDINEXT")); break;
|
||||
case WM_MDIMAXIMIZE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIMAXIMIZE")); break;
|
||||
case WM_MDITILE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDITILE")); break;
|
||||
case WM_MDICASCADE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDICASCADE")); break;
|
||||
case WM_MDIICONARRANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIICONARRANGE")); break;
|
||||
case WM_MDIGETACTIVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIGETACTIVE")); break;
|
||||
case WM_MDISETMENU: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDISETMENU")); break;
|
||||
case WM_ENTERSIZEMOVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ENTERSIZEMOVE")); break;
|
||||
case WM_EXITSIZEMOVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_EXITSIZEMOVE")); break;
|
||||
case WM_DROPFILES: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DROPFILES")); break;
|
||||
case WM_MDIREFRESHMENU: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIREFRESHMENU")); break;
|
||||
case WM_IME_SETCONTEXT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_SETCONTEXT")); break;
|
||||
case WM_IME_NOTIFY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_NOTIFY")); break;
|
||||
case WM_IME_CONTROL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_CONTROL")); break;
|
||||
case WM_IME_COMPOSITIONFULL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_COMPOSITIONFU")); break;
|
||||
case WM_IME_SELECT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_SELECT")); break;
|
||||
case WM_IME_CHAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_CHAR")); break;
|
||||
case WM_IME_KEYDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_KEYDOWN")); break;
|
||||
case WM_IME_KEYUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_KEYUP")); break;
|
||||
case WM_MOUSEHOVER: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSEHOVER")); break;
|
||||
case WM_NCMOUSELEAVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCMOUSELEAVE")); break;
|
||||
case WM_MOUSELEAVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSELEAVE")); break;
|
||||
case WM_CUT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CUT")); break;
|
||||
case WM_COPY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COPY")); break;
|
||||
case WM_PASTE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PASTE")); break;
|
||||
case WM_CLEAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CLEAR")); break;
|
||||
case WM_UNDO: _tcscpy_s(MSG_LOOKUP[i], _T("WM_UNDO")); break;
|
||||
case WM_RENDERFORMAT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_RENDERFORMAT")); break;
|
||||
case WM_RENDERALLFORMATS: _tcscpy_s(MSG_LOOKUP[i], _T("WM_RENDERALLFORMATS")); break;
|
||||
case WM_DESTROYCLIPBOARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DESTROYCLIPBOARD")); break;
|
||||
case WM_DRAWCLIPBOARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DRAWCLIPBOARD")); break;
|
||||
case WM_PAINTCLIPBOARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PAINTCLIPBOARD")); break;
|
||||
case WM_VSCROLLCLIPBOARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_VSCROLLCLIPBOARD")); break;
|
||||
case WM_SIZECLIPBOARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SIZECLIPBOARD")); break;
|
||||
case WM_ASKCBFORMATNAME: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ASKCBFORMATNAME")); break;
|
||||
case WM_CHANGECBCHAIN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CHANGECBCHAIN")); break;
|
||||
case WM_HSCROLLCLIPBOARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_HSCROLLCLIPBOARD")); break;
|
||||
case WM_QUERYNEWPALETTE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_QUERYNEWPALETTE")); break;
|
||||
case WM_PALETTEISCHANGING: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PALETTEISCHANGING")); break;
|
||||
case WM_PALETTECHANGED: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PALETTECHANGED")); break;
|
||||
case WM_HOTKEY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_HOTKEY")); break;
|
||||
case WM_PRINT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PRINT")); break;
|
||||
case WM_PRINTCLIENT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PRINTCLIENT")); break;
|
||||
case WM_HANDHELDFIRST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_HANDHELDFIRST")); break;
|
||||
case WM_HANDHELDLAST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_HANDHELDLAST")); break;
|
||||
case WM_PENWINFIRST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PENWINFIRST")); break;
|
||||
case WM_PENWINLAST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PENWINLAST")); break;
|
||||
case 0x390: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COALESCE_FIRST")); break;
|
||||
case 0x39F: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COALESCE_LAST")); break;
|
||||
case 0x3E0: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_FIRST")); break;
|
||||
//case 0x3E0: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_INITIATE")); break;
|
||||
case 0x3E1: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_TERMINATE")); break;
|
||||
case 0x3E2: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_ADVISE")); break;
|
||||
case 0x3E3: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_UNADVISE")); break;
|
||||
case 0x3E4: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_ACK")); break;
|
||||
case 0x3E5: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_DATA")); break;
|
||||
case 0x3E6: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_REQUEST")); break;
|
||||
case 0x3E7: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_POKE")); break;
|
||||
case 0x3E8: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_EXECUTE")); break;
|
||||
//case 0x3E8: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_LAST")); break;
|
||||
|
||||
//case : _tcscpy_s(MSG_LOOKUP[i], _T("")); break;
|
||||
default:
|
||||
memset((void *)&MSG_LOOKUP[i], '\0', sizeof(TCHAR) * MAX_MSG_NAME);
|
||||
//_tcscpy_s(MSG_LOOKUP[i], 20, _T(""));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeMsgLookup()
|
||||
{
|
||||
int allowList[1];
|
||||
allowList[0] = -1;
|
||||
InitializeMsgLookup(allowList, 0);
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -8,12 +8,53 @@
|
||||
#include "stdafx.h"
|
||||
#include "org_synthuse_MsgHook.h"
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_synthuse_MsgHook
|
||||
* Method: createMsgHookWindow
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_createMsgHookWindow(JNIEnv *env, jobject obj)
|
||||
{
|
||||
CreateMsgHookWindow(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_synthuse_MsgHook
|
||||
* Method: setMsgHookWindowTargetHwnd
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMsgHookWindowTargetHwnd(JNIEnv *env, jobject obj, jint jhwnd)
|
||||
{
|
||||
_stprintf_s(targetHwndStr, _T("%ld"), (long)jhwnd);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_synthuse_MsgHook
|
||||
* Method: setMsgHookWindowTargetClass
|
||||
* Signature: (Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMsgHookWindowTargetClass(JNIEnv *env, jobject obj, jstring jclassname)
|
||||
{
|
||||
const char *classname = env->GetStringUTFChars(jclassname, 0);//convert string
|
||||
|
||||
memset((void *)&targetClassname, '\0', sizeof(TCHAR) * MAX_TEST_SIZE); // set TCHAR array to all 0
|
||||
int tstrLen = MultiByteToWideChar(CP_UTF8, 0, classname, (int)strlen(classname), NULL, 0); //get t len
|
||||
MultiByteToWideChar(CP_UTF8, 0, classname, (int)strlen(classname), targetClassname, tstrLen); // convert char to tchar
|
||||
|
||||
env->ReleaseStringUTFChars(jclassname, classname); //release string
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_synthuse_MsgHook
|
||||
* Method: setMessageHook
|
||||
* Signature: (JJ)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMessageHook(JNIEnv *env, jobject obj, jlong jhWnd, jlong jthreadId)
|
||||
//JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMessageHook(JNIEnv *env, jobject obj, jlong jhWnd, jlong jthreadId)
|
||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMessageHook(JNIEnv *env, jobject obj, jint jhWnd, jint jthreadId)
|
||||
{
|
||||
return SetMsgHook((HWND)jhWnd, (DWORD)jthreadId);
|
||||
}
|
||||
|
||||
@@ -7,13 +7,37 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_synthuse_MsgHook
|
||||
* Method: createMsgHookWindow
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_createMsgHookWindow
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_synthuse_MsgHook
|
||||
* Method: setMsgHookWindowTargetHwnd
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMsgHookWindowTargetHwnd
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
/*
|
||||
* Class: org_synthuse_MsgHook
|
||||
* Method: setMsgHookWindowTargetClass
|
||||
* Signature: (Ljava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMsgHookWindowTargetClass
|
||||
(JNIEnv *, jobject, jstring);
|
||||
|
||||
/*
|
||||
* Class: org_synthuse_MsgHook
|
||||
* Method: setMessageHook
|
||||
* Signature: (JJ)Z
|
||||
* Signature: (II)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMessageHook
|
||||
(JNIEnv *, jobject, jlong, jlong);
|
||||
(JNIEnv *, jobject, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_synthuse_MsgHook
|
||||
|
||||
BIN
native/MsgHook/resource.h
Normal file
BIN
native/MsgHook/resource.h
Normal file
Binary file not shown.
BIN
native/MsgHook/small.ico
Normal file
BIN
native/MsgHook/small.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
@@ -9,6 +9,7 @@
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
// Windows Header Files:
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <Psapi.h>
|
||||
@@ -41,6 +42,7 @@ typedef struct
|
||||
#ifndef GLOBAL_VARS_H // header guards
|
||||
#define GLOBAL_VARS_H
|
||||
|
||||
extern "C" __declspec(dllexport) void CreateMsgHookWindow(LPTSTR lpCmdLine);
|
||||
extern "C" __declspec(dllexport) BOOL SetMsgHook(HWND callerHWnd, DWORD threadId);
|
||||
extern "C" __declspec(dllexport) BOOL RemoveHook();
|
||||
|
||||
@@ -49,4 +51,8 @@ extern HANDLE hMappedFile;
|
||||
extern GLOBALDATA* pData;
|
||||
extern bool bStartingProcess;
|
||||
|
||||
#define MAX_TEST_SIZE 100
|
||||
extern TCHAR targetHwndStr[MAX_TEST_SIZE];
|
||||
extern TCHAR targetClassname[MAX_TEST_SIZE];
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user