https://bugs.winehq.org/show_bug.cgi?id=51899
--- Comment #5 from Bruni earns.61@gmail.com --- Try to forbid a compiler to reorder instructions using mutex locks (by inserting memory barriers) with something like
... #include <pthread.h> ...
DC_ATTR *get_dc_attr( HDC hdc ) { pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_lock( &lock ); DWORD type = gdi_handle_type( hdc ); DC_ATTR *dc_attr; if ((type & 0x1f0000) != NTGDI_OBJ_DC || !(dc_attr = get_gdi_client_ptr( hdc, 0 ))) { SetLastError( ERROR_INVALID_HANDLE ); return NULL; } pthread_mutex_unlock( &lock ); return dc_attr->disabled ? NULL : dc_attr; }