Knowledge Base

BUG: CRITICAL_SECTION is Defined Incorrectly in API Text Viewer

Article ID: 197569

Article Last Modified on 7/15/2004


APPLIES TO


This article was previously published under Q197569

SYMPTOMS

The API Text Viewer definition for CRITICAL_SECTION is incorrect and will cause an access violation or corrupt the memory directly following any variables of this type.

CAUSE

The API Text Viewer defines CRITICAL_SECTION as follows:
   Type CRITICAL_SECTION
      dummy As Long
   End Type
				
If you use this definition, you may receive access violations or you may notice that the variables declared directly after a critical section are overwritten or corrupted when you call any of the critical section APIs.

RESOLUTION

The following is a proper definition for CRITICAL_SECTION:
   Type CRITICAL_SECTION
      Reserved1 As Long
      Reserved2 As Long
      Reserved3 As Long
      Reserved4 As Long
      Reserved5 As Long
      Reserved6 As Long
   End Type
				

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

MORE INFORMATION

You should never access the members of the CRITICAL_SECTION structure directly. An object of this type is designed to be manipulated through the following Win32 APIs:
   InitializeCriticalSection()
   EnterCriticalSection()
   LeaveCriticalSection()
   DeleteCriticalSection()
				
For more information, refer to the MSDN documentation for critical sections.

Keywords: kbbug kbthread kbkernbase kbpending KB197569