vendredi 6 mars 2015

Can't catch events using SetWinEventHook. Will get event after using accevent32.exe


Does anyone get the following problem? I write a dll to load into another process to get EVENT_OBJECT_VALUECHANGE event for a window in that process. The code looks like as below.



void CALLBACK WinEventProc(
HWINEVENTHOOK hWinEventHook,
DWORD event,
HWND hwnd,
LONG idObject,
LONG idChild,
DWORD dwEventThread,
DWORD dwmsEventTime)
{
if(event == EVENT_OBJECT_NAMECHANGE && hwnd)
{
.....
}
}

SetWinEventHook(1u, 0x7FFFFFFFu,
ModuleFromAddress(PIURouter),
WinEventProc,
dwProcess, //the window in that process
dwThread, //the window in that thread
WINEVENT_INCONTEXT|WINEVENT_SKIPOWNPROCESS);


I am sure that the DLL is loaded into that process and WinEventProc is called, just can not catch the event I want. I'm sure that event is happened in every half second.


But right after I use accevent32.exe and include the events only for that window. I can see the EVENT_OBJECT_NAMECHANGE. Close accevent32.exe and run my app again. Now EVENT_OBJECT_NAMECHANGE is caught by WinEventProc.


I decompile the event32.dll from accevent32.exe. Don't see any special functions called. Also the windows properties, styles and procedure are not changed after running accevent32.exe.


Any advice?




Aucun commentaire:

Enregistrer un commentaire