From: Scott Seligman on
"Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com> wrote:
>I'm certain they worked as I had them working in managed code and
>Mike Salamone told me he had them working in native. Send me an email
>directly and I'll see what I can find and ship back to you.

You might have been using QASetWindowsJournalHook and
QAUnhookWindowsJournalHook. But these functions aren't perfect, but I
suppose they might work for some uses.


--
--------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
The trouble with computers, of course, is that they're very
sophisticated idiots.
-- The Doctor in Doctor Who:"The Robot"
From: Robert Burdick on
Doesn't seem to work. The hook gets set, but the callback never gets called.

Any real sample code would be very helpful.

"Scott Seligman" wrote:

> "Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com> wrote:
> >I'm certain they worked as I had them working in managed code and
> >Mike Salamone told me he had them working in native. Send me an email
> >directly and I'll see what I can find and ship back to you.
>
> You might have been using QASetWindowsJournalHook and
> QAUnhookWindowsJournalHook. But these functions aren't perfect, but I
> suppose they might work for some uses.
>
>
> --
> --------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
> The trouble with computers, of course, is that they're very
> sophisticated idiots.
> -- The Doctor in Doctor Who:"The Robot"
>
From: Scott Seligman on
=?Utf-8?B?Um9iZXJ0IEJ1cmRpY2s=?= <RobertBurdick(a)discussions.microsoft.com> wrote:
>
>Doesn't seem to work. The hook gets set, but the callback never gets called.
>
>Any real sample code would be very helpful.

Here you go. Mostly untested code, without any error handling,
follows:

typedef struct tagEVENTMSG {
UINT message;
UINT paramL;
UINT paramH;
DWORD time;
HWND hwnd;
} EVENTMSG;

typedef HHOOK PQASetWindowsJournalHook(int, LPVOID, EVENTMSG*);
typedef HHOOK PQAUnhookWindowsJournalHook(int);
typedef LRESULT PCallNextHookEx(HHOOK, int, WPARAM, LPARAM);

#define WH_JOURNALRECORD 0

HHOOK g_hook;
EVENTMSG g_eventmsg;
HMODULE hCoreDLL;
PQASetWindowsJournalHook* fnQASetWindowsJournalHook;
PQAUnhookWindowsJournalHook* fnQAUnhookWindowsJournalHook;
PCallNextHookEx* fnCallNextHookEx;

LRESULT CALLBACK QASetWindowsJournalHookProc(
int code,
WPARAM wParam,
LPARAM lParam)
{
if (code < 0)
{
return fnCallNextHookEx(g_hook, code, wParam, lParam);
}
else
{
EVENTMSG * eventmsg = (EVENTMSG*) lParam;
// Do something with eventmsg
return fnCallNextHookEx(g_hook, code, wParam, lParam);
}
}

void BeginHook()
{
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,
QASetWindowsJournalHookProc, &g_eventmsg);
}

// If this isn't called, the device will hard-lock when
// the hook procedure is no longer in memory
void EndHook()
{
fnQAUnhookWindowsJournalHook(WH_JOURNALRECORD);
}

--
--------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
The avalanche has already started. It is too late for the pebbles to
vote. -- Ambassador Kosh Naranek in Babylon 5:"Believers"
From: Robert Burdick on
Thanks for the code. But just like the code I wrote, this sets the hook, but
the hook callback never gets called. I'm trying to run this on a Windows
Mobile 6 device. Perhaps the undocumented journal hook support is different
on WinMob6.

"Scott Seligman" wrote:

> =?Utf-8?B?Um9iZXJ0IEJ1cmRpY2s=?= <RobertBurdick(a)discussions.microsoft.com> wrote:
> >
> >Doesn't seem to work. The hook gets set, but the callback never gets called.
> >
> >Any real sample code would be very helpful.
>
> Here you go. Mostly untested code, without any error handling,
> follows:
>
> typedef struct tagEVENTMSG {
> UINT message;
> UINT paramL;
> UINT paramH;
> DWORD time;
> HWND hwnd;
> } EVENTMSG;
>
> typedef HHOOK PQASetWindowsJournalHook(int, LPVOID, EVENTMSG*);
> typedef HHOOK PQAUnhookWindowsJournalHook(int);
> typedef LRESULT PCallNextHookEx(HHOOK, int, WPARAM, LPARAM);
>
> #define WH_JOURNALRECORD 0
>
> HHOOK g_hook;
> EVENTMSG g_eventmsg;
> HMODULE hCoreDLL;
> PQASetWindowsJournalHook* fnQASetWindowsJournalHook;
> PQAUnhookWindowsJournalHook* fnQAUnhookWindowsJournalHook;
> PCallNextHookEx* fnCallNextHookEx;
>
> LRESULT CALLBACK QASetWindowsJournalHookProc(
> int code,
> WPARAM wParam,
> LPARAM lParam)
> {
> if (code < 0)
> {
> return fnCallNextHookEx(g_hook, code, wParam, lParam);
> }
> else
> {
> EVENTMSG * eventmsg = (EVENTMSG*) lParam;
> // Do something with eventmsg
> return fnCallNextHookEx(g_hook, code, wParam, lParam);
> }
> }
>
> void BeginHook()
> {
> 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,
> QASetWindowsJournalHookProc, &g_eventmsg);
> }
>
> // If this isn't called, the device will hard-lock when
> // the hook procedure is no longer in memory
> void EndHook()
> {
> fnQAUnhookWindowsJournalHook(WH_JOURNALRECORD);
> }
>
> --
> --------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
> The avalanche has already started. It is too late for the pebbles to
> vote. -- Ambassador Kosh Naranek in Babylon 5:"Believers"
>
From: Scott Seligman on
=?Utf-8?B?Um9iZXJ0IEJ1cmRpY2s=?= <RobertBurdick(a)discussions.microsoft.com> wrote:
>
>Thanks for the code. But just like the code I wrote, this sets the hook, but
>the hook callback never gets called. I'm trying to run this on a Windows
>Mobile 6 device. Perhaps the undocumented journal hook support is different
>on WinMob6.

The one device I tested on was a WM6 device.

As it is, it is undocumented, so it's probably fragile, and IIRC, it
doesn't play well with some things like Transcriber.

--
--------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
They who would give up an essential liberty for temporary security,
deserve neither liberty or security.
-- Ben Franklin