Partager via


GdipDrawImageRect and other GDI+ functions may return GenericError (-1) on Windows 7

I came across an anyoing issue where GDI plus functions returned Status code –1 GenericError after 1000 calls on Systems running Windows 7 or Windows Server 2008 R2.

It turned out that the function call to kernel NtGdiSaveDC(hdc); Returns 0x0 after 999 iterations or at the 1000th call that is.

The public callstack subset looks like this:

gdiplus!MfEnumState::MfEnumState+0x85
gdiplus!WmfEnumState::WmfEnumState+0x25
gdiplus!MetafilePlayer::EnumerateWmfRecords+0x6e
gdiplus!GpGraphics::EnumEmf+0x282
gdiplus!GpMetafile::EnumerateForPlayback+0x5a7
gdiplus!GpGraphics::DrawImage+0x3f5
gdiplus!GpGraphics::DrawImage+0x51
gdiplus!GdipDrawImageRect+0x114

 

In the knowledge base I found that there is a Hotfix indeed to adress such issues in Win7 and Win Server 2008 R2.

https://support.microsoft.com/kb/2525949

 

It helped for my problem and I hope it will help you too!

 

Sebastian