I am trying to get a paste event from the clipboard using Windows Hooks.
It is built from 2 dll's/
The first one registers the hook and the code goes like this:

#include "stdafx.h"
#include <windows.h>
#include "SystemHookCore.h"
#include "MessageFilter.h"
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>


#pragma data_seg(".SHARED")


HOOKPROC hkprcSysMsg;
static HINSTANCE hinstDLL;
static HHOOK hookOther;


#pragma data_seg()


#pragma comment(linker, "/section:SHARED,RWS")


bool InitializeHook(UINT hookID, int threadID)
{
if (hookID == WH_CALLWNDPROC)
{
hinstDLL = LoadLibrary((LPCTSTR) "C:\\\windows\\system32\
\SystemHookCore.dll");
hkprcSysMsg = (HOOKPROC)GetProcAddress(hinstDLL,
"InternalOtherHookCallback");
hookOther = SetWindowsHookEx(hookID,hkprcSysMsg,hinstDLL,0);
return hookOther != NULL;
}


return false;



}


void UninitializeHook(UINT hookID)
{
if (hookID == WH_CALLWNDPROC)
{
if (hookOther != NULL)
{
UnhookWindowsHookEx(hookOther);
}
hookOther = NULL;
}


}


void Dispose(UINT hookID)
{
if (hookID == WH_CALLWNDPROC)
{
UninitializeHook(hookID);
}


}


The second one is the one that handles the event:

#include "stdafx.h"
#include <windows.h>
#include "SystemHookCore.h"
#include "MessageFilter.h"
#include <stdio.h>
#include <string>
#include <windows.h>
#include <conio.h>


LRESULT CALLBACK InternalOtherHookCallback(int code, WPARAM wparam,
LPARAM lparam)
{
// ?????????????????????????
HHOOK data = 0;


if (code < 0)
{
return CallNextHookEx((HHOOK)data, code, wparam, lparam);
}


CWPSTRUCT *cwp;
cwp = (CWPSTRUCT *)lparam;


if(cwp->message == 0x302)
{
char str[255];
ZeroMemory(str, 255);
sprintf(str, "%ld", (HHOOK)data);
MessageBox(NULL, str, "", 0);
}


return CallNextHookEx((HHOOK)data, code, wparam, lparam);



}


I have two problems:

1. I don't know how to get the first parameter i should
pass to the CallNextHookEx. The parameter should be passed from the activating dll. How can i do that? shared memory?
2. Not all events are catched. For example when you run this code (from system32) and you open notepad, i get an event when i choose paste from the menu but not when i press ctrl+v. I don't catch any of Word events and i catch all of explorer paste event.

Does anyone have an idea???

Thank you so much.