I got tired of trying to find a way to post a bug to the VC team. I saw before you could submit a bug but I cannot find it now. So here it is what I think is a bug:
I have a program that I am making using VC 2005 and ATL. The process starts out impersonating on the main thread. When I run the program in release all is good, but in debug mode it behaves weirdly. I have traced the issue to a call that happens only with the debug version of ATL.
The code is in:
\Microsoft Visual Studio 8\VC\atlmfc\src\atl\atls
BOOL bOpen = OpenThreadToken(GetCurrentThrea
if( !bOpen || hThreadToken != NULL )
{
if( !RevertToSelf() )
{
CloseHandle(hThreadToken);
hThreadToken = NULL;
__leave;
}
}
Note that the if (!bOpen..) block executes in all cases because OpenThreadToken sets the last parameter (hThreadToken) to NULL when it fails. At this point it all goes bad since the if block assumes that it has a non-NULL hThreadToken.
Basicall ATL calling ReverToSelf even when the OpenThreadToken failed is a bug. I assume the developer meant:
if ( bOpen && (NULL != hThreadToken))
Regards
Carlos