http://bugs.winehq.org/show_bug.cgi?id=2127
------- Additional Comments From julliard@winehq.com 2005-03-10 07:07 ------- I don't know if there's already a bug for it, but basically we need to map the GENERIC_* access rights to object-specific rights, and then always use the object rights.
If you remove the critical section, are you able to reproduce the problem with your test app? I don't see it here, and I suspect it happens because there's a race condition somewhere else in your real app that makes it use a bad handle (my theory is that a race in the server handle cache causes it to report the bad handle error on the wrong handle, but this requires that the app causes a bad handle error in the first place).