M-A's

technology blog

Friday, 10 April 2009

Section synchronization

I was looking at a cleaver way to use interprocess communication and we (chromium) use shared memory with CreateFileMapping(). The main issue is synchronization. I was looking at using the section as an inherent synchronization tool but it fails miserably. I finally found the answer: « File mapping objects do not support the SYNCHRONIZE standard access right. »[1]

That would have been useful, even if it would have been limited to 4kb granularity or even just a global section lock. Sad. Going back to mutex. :(

[1]
http://msdn.microsoft.com/en-us/library/aa366559.aspx

EMF buffer idiocracy

On Windows XP, when creating an HDC from an EMF buffer with CreateEnhMetaFile():
  • SetDCBrushColor() and SetDCPenColor() calls are not recorded. Too bad for you.
  • When using GetStockObject(), DC_BRUSH and DC_PEN are useless and will return a white pen and a black pen respectively. Just don't use them.
  • Expect no-op from ExtTextOut(..., ETO_GLYPH_INDEX, ...) if GDI32!GdiInitializeLanguagePack hasn't been called.