DynamoRIO / DynamoRIO/drmemory
false positive GDI USAGE ERROR when using win32 SaveDC/RestoreDC
- Dominant language
- C
- Stars
- 2.7k
- Forks
- 290
- PR merge metrics
- No merged PRs in 30d
Description
_From [bruno.de...@gmail.com](https://code.google.com/u/117401577226317170005/) on May 20, 2014 10:59:54_
the following code gives false positives GDI USAGE ERROR
#
#include
int main(int argc, char\* argv[]) {
```
HDC hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
if(hdc) {
HBRUSH hBrush = CreateSolidBrush(RGB(0xCD,0xCD,0xCD));
int nDC = SaveDC(hdc); // Current
SelectObject(hdc, hBrush);
RestoreDC(hdc, nDC);
DeleteObject(hBrush);
DeleteDC(hdc);
}
return 0;
```
}
============================================================ http://msdn.microsoft.com/en-us/library/dd162945(v=vs.85).aspx The SaveDC function saves the current state of the specified device context (DC) by copying
data describing selected objects and graphic modes (such as the bitmap, brush, palette, font,
pen, region, drawing mode, and mapping mode) to a context stack. http://msdn.microsoft.com/en-us/library/dd162929(v=vs.85).aspx The RestoreDC function restores a device context (DC) to the specified state. The DC is restored
by popping state information off a stack created by earlier calls to the SaveDC function.
Sample report file is attached
**Attachment:** [results.txt](http://code.google.com/p/drmemory/issues/detail?id=1552)
_Original issue: http://code.google.com/p/drmemory/issues/detail?id=1552_
Contributor guide
Assessment
This issue has not been assessed yet.