Prev: TAPI Conference
Next: USB Host on Windows Mobile 6 Pro?
From: PaulH on 28 Oct 2008 18:38 I'm working on a Windows Mobile 6 macro recording tool using the undocumented coredll exported API QASetWindowsJournalHook(). I can get the hook installed without any errors, but I do not get any response from the callback function. I've read several threads in this group regarding this call and people have had mixed results. In looking at similar hooking functions, I note that occasionally some parts of the code need to be in a DLL and exported. Is that the case here? I've tried some combinations, but perhaps I just haven't hit the right one. Some of my code (error checks removed for brevity) is posted below. If anybody could take a peek and let me know where I may be going wrong, I would appreciate it. #define WH_JOURNALRECORD 0 typedef LRESULT ( CALLBACK* HOOKPROC )( int code, WPARAM wParam, LPARAM lParam ); typedef struct tagEVENTMSG { UINT message; UINT paramL; UINT paramH; DWORD time; HWND hwnd; } EVENTMSG; typedef HHOOK PQASetWindowsJournalHook( int, HOOKPROC, EVENTMSG* ); typedef HHOOK PQAUnhookWindowsJournalHook( int ); typedef LRESULT PCallNextHookEx( HHOOK, int, WPARAM, LPARAM ); HHOOK g_hook; EVENTMSG g_eventmsg; HMODULE hCoreDLL; PQASetWindowsJournalHook* fnQASetWindowsJournalHook; PQAUnhookWindowsJournalHook* fnQAUnhookWindowsJournalHook; PCallNextHookEx* fnCallNextHookEx; BOOL CMyDialog::ActivateHook( HOOKPROC pfnCallback ) { hCoreDLL = LoadLibrary( _T( "coredll.dll" ) ); fnQASetWindowsJournalHook = ( PQASetWindowsJournalHook* )GetProcAddress( hCoreDLL, _T( "QASetWindowsJournalHook" ) ); fnQAUnhookWindowsJournalHook = ( PQAUnhookWindowsJournalHook* )GetProcAddress( hCoreDLL, _T( "QAUnhookWindowsJournalHook" ) ); fnCallNextHookEx = ( PCallNextHookEx* )GetProcAddress( hCoreDLL, _T( "CallNextHookEx" ) ); g_hook = fnQASetWindowsJournalHook( WH_JOURNALRECORD, pfnCallback, &g_eventmsg ); return true; } /*static*/ LRESULT CMyDialog::QAJournalHookProc( int nCode, WPARAM wParam, LPARAM lParam ) { ::MessageBox( NULL, _T( "Test" ), _T( "test" ), MB_OK ); switch( nCode ) { case HC_ACTION: { EVENTMSG* pMsg = reinterpret_cast< EVENTMSG* >( lParam ); // ... } // ... } return fnCallNextHookEx( g_hook, nCode, wParam, lParam ); } Thanks, PaulH
|
Pages: 1 Prev: TAPI Conference Next: USB Host on Windows Mobile 6 Pro? |