A forum for reverse engineering, OS internals and malware analysis 

Ask your beginner questions here.
 #9718  by Vrtule
 Wed Nov 16, 2011 8:11 pm
Hello,

I have read about critical section synchronization primitive in Windows Internals book. On page 194 of the 5the edition, there is written that a critical section can be acquired either in shared or in exclusive mode. This implies to me that it can replace reader-writer locks. However, MSDN tells me that cirtical section can be used only for mutual exclusion purposes. Additionally, I did not see anything about shared/exlusive mode of cirtical sections anywhere, only in the Windows Internals book.

So, my question is: where is the truth? Can critical sections really be acquired in shared and exclusive modes as reader-writer locks do?

Thanks in advance.
 #13363  by Vrtule
 Tue May 22, 2012 2:49 pm
Hello,

well, half a year later, I came accross the answer to this question. It seems that there was an error in the 5th edition of the Windows Internals book, saying that critical sections can be acquired also in shared mode. The authors probably wanted to say that there is another primitive, called User-Mode Resource, that can be understood as a port of Executive Resources to usermode.

More info about User-Mode Resources can be found here (look at RtlInitializeResource for example):
http://undoc.airesoft.co.uk/index.php

9the edition of the Windows Internals book seems to fix this mistake.

I am sorry to reopen this old topic, however, I think that the answer might be very useful to someone else.