Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a crash due to the access violation when DialogBoxIndirectParamA is called #419

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions user/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ static BOOL DIALOG_CreateControls16Ex(HWND hwnd, LPCSTR template,
INT items = dlgTemplate->nbItems;
dlgItemTemplate32 = (BYTE*) (((DWORD)dlgItemTemplate32 + 3) & ~((DWORD)3));
WORD *dlgItemTemplatew;
BOOL rscIdWorkaround;
TRACE(" BEGIN\n");
while (items--)
{
Expand All @@ -416,13 +417,16 @@ static BOOL DIALOG_CreateControls16Ex(HWND hwnd, LPCSTR template,
dlgItemTemplatew = (WORD*)(dlgItemTemplate32 + 1);
info.className = win32classname(hInst, info.className);
copy_widestr(info.className, &dlgItemTemplatew);
rscIdWorkaround = FALSE;
if (!HIWORD(info.windowName))
{
char buffer[512];
if (((dlgItemTemplate32->style & 0xF) == SS_ICON || (dlgItemTemplate32->style & 0xF) == SS_BITMAP) && stricmp(info.className, "STATIC") == 0)
{
sprintf(buffer, "#%d", (int)info.windowName);
copy_widestr(buffer, &dlgItemTemplatew);
rscIdWorkaround = TRUE;
*dlgItemTemplatew++ = 0x0000;
*dlgItemTemplatew++ = sizeof(WORD) * 2;
*dlgItemTemplatew++ = LOWORD(info.windowName);
}
else
{
Expand All @@ -444,7 +448,7 @@ static BOOL DIALOG_CreateControls16Ex(HWND hwnd, LPCSTR template,
*((LPCVOID*)dlgItemTemplatew) = MAKESEGPTR(SELECTOROF(base16), OFFSETOF(base16) + (WORD)((SIZE_T)info.data - base32));
dlgItemTemplatew += 2;
}
else
else if (!rscIdWorkaround)
{
*dlgItemTemplatew++ = 0;
}
Expand Down
10 changes: 7 additions & 3 deletions user/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -4388,17 +4388,21 @@ LRESULT CALLBACK WndProcRetHook(int code, WPARAM wParam, LPARAM lParam)
{
case SS_ICON:
{
char rsc_id[32];
sprintf(rsc_id, "#%d", (int)cs->lpCreateParams);
SetWindowTextA(hwnd, "");
HICON16 icon = LoadIcon16(HINSTANCE_16(cs->hInstance), cs->lpszName);
if (!icon) icon = LoadCursor16(HINSTANCE_16(cs->hInstance), cs->lpszName);
HICON16 icon = LoadIcon16(HINSTANCE_16(cs->hInstance), rsc_id);
if (!icon) icon = LoadCursor16(HINSTANCE_16(cs->hInstance), rsc_id);
if (icon) wow_handlers32.static_proc(hwnd, STM_SETIMAGE, IMAGE_ICON,
(LPARAM)get_icon_32(icon), FALSE);
break;
}
case SS_BITMAP:
{
char rsc_id[32];
sprintf(rsc_id, "#%d", (int)cs->lpCreateParams);
SetWindowTextA(hwnd, "");
HBITMAP16 bitmap = LoadBitmap16(HINSTANCE_16(cs->hInstance), cs->lpszName);
HBITMAP16 bitmap = LoadBitmap16(HINSTANCE_16(cs->hInstance), rsc_id);
if (bitmap) wow_handlers32.static_proc(hwnd, STM_SETIMAGE, IMAGE_BITMAP,
(LPARAM)HBITMAP_32(bitmap), FALSE);
break;
Expand Down