I wanted to catch CBT notifications of a specific process main thread that I've just created with:
STARTUPINFO startupInformation;
PROCESS_INFORMATION processInformation;
CreateProcess(strWantedEXEPath,
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&startupInformation,
&processInformation);
And then if the creation was successful I tried to register with:
SetWindowsHookEx(WH_CBT, CBTProc, GetCurrentModule(), processInformation.dwThreadId);
Which fails with error code ERROR_INVALID_PARAMETER
.
Nevertheless, if I tried to register for all threads with:
SetWindowsHookEx(WH_CBT, CBTProc, GetCurrentModule(), 0);
It will work and catch the notifications from the created process main thread, but I don't want to use this because it will also catch notifications from other processes (and inject the dll I think). So any tips on this problem?