2006-09-18 05:20:11 UTC
My system basic specs is Windows XP, SP2, Intel P4 Hyperthreading.
This problem occurs only if there is more than 1 cpu(hyperthreading or
I am using SetWinEventHook to get notification of console winevents.
After I setup the hook, I run several console applications, let's use
cmd.exe as an example. all is well, notifications are coming from all
windows and I was happy for a while.
When I run CMD.EXE, and then run "chcp", I get the active codepage. if
I try to change it using "chcp 437", the CMD.EXE process hangs.
Same happened if I use a console application of my own and use the api
SetConsoleOutputCP to change the codepage.
If the console process didn't hang for the first time, opening a second
console application(or cmd.exe) and changing the codepage causes it to
Assume the only line of code in the WINEVENTPROC that fires is int i=0;
No global variables, no calls. so the problem is not within the proc.
I tried WINEVENT_OUTOFCONTEXT and WINEVENT_INCONTEXT methods with EXE's
or DLL's, exact same results.
I tried hooking only 4007h event, same results.
The problems occurs only in the console events(4001h-4007h), other
events work great.
If I UnHook the events, change the codepage(works) and hook back, it
works but it's just not supposed to be this way! ! ! and it is not good
for my design.
On single processor systems it works well, on multi processor systems
it only works If I set the affinity of CSRSS to only one CPU and so on
(not a good solution obviously, just for the sake of testing...) then
all is working well.
2. Am I doing something that is not thread safe ?
3. Is this a bug in windows ??????? is their api not thread safe ?
4. Not related to the problem(I am not using VB for the above problem),
does any one know why UnHookWinEvent doesn't work in VB(doesn't unhook)
? while SetWinEventHook is working great.?
Thank you very much for your time,