mirror of
https://github.com/zserge/fenster.git
synced 2025-04-12 10:48:41 +03:00
Fix BITMAPINFO out of bounds access. Revert to BI_BITFIELDS.
Replace BITMAPINFO with custom struct because BITMAPINFO doesn't have 3 RGBQUADs. BI_BITFIELDS is the correct format for what we are doing.
This commit is contained in:
@ -168,6 +168,10 @@ FENSTER_API int fenster_loop(struct fenster *f) {
|
||||
// clang-format off
|
||||
static const uint8_t FENSTER_KEYCODES[] = {0,27,49,50,51,52,53,54,55,56,57,48,45,61,8,9,81,87,69,82,84,89,85,73,79,80,91,93,10,0,65,83,68,70,71,72,74,75,76,59,39,96,0,92,90,88,67,86,66,78,77,44,46,47,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,17,3,0,20,0,19,0,5,18,4,26,127};
|
||||
// clang-format on
|
||||
typedef struct BINFO{
|
||||
BITMAPINFOHEADER bmiHeader;
|
||||
RGBQUAD bmiColors[3];
|
||||
}BINFO;
|
||||
static LRESULT CALLBACK fenster_wndproc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
struct fenster *f = (struct fenster *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
@ -178,7 +182,7 @@ static LRESULT CALLBACK fenster_wndproc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
HDC memdc = CreateCompatibleDC(hdc);
|
||||
HBITMAP hbmp = CreateCompatibleBitmap(hdc, f->width, f->height);
|
||||
HBITMAP oldbmp = SelectObject(memdc, hbmp);
|
||||
BITMAPINFO bi = {{sizeof(bi), f->width, -f->height, 1, 32, BI_RGB}};
|
||||
BINFO bi = {{sizeof(bi), f->width, -f->height, 1, 32, BI_RGB}};
|
||||
bi.bmiColors[0].rgbRed = 0xff;
|
||||
bi.bmiColors[1].rgbGreen = 0xff;
|
||||
bi.bmiColors[2].rgbBlue = 0xff;
|
||||
|
Reference in New Issue
Block a user