From: Sergei Chernyadyev serg.cherniadjev@gmail.com
--- dlls/shell32/systray.c | 37 ++++++++++++++++++++++--------------- programs/explorer/systray.c | 29 ++++++++++++++++++----------- 2 files changed, 40 insertions(+), 26 deletions(-)
diff --git a/dlls/shell32/systray.c b/dlls/shell32/systray.c index 78717cfcdca..443bf470b2c 100644 --- a/dlls/shell32/systray.c +++ b/dlls/shell32/systray.c @@ -34,12 +34,22 @@
WINE_DEFAULT_DEBUG_CHANNEL(systray);
+struct notify_data_icon +{ + /* data for the icon bitmap */ + UINT width; + UINT height; + UINT planes; + UINT bpp; +}; + struct notify_data /* platform-independent format for NOTIFYICONDATA */ { LONG hWnd; UINT uID; UINT uFlags; UINT uCallbackMessage; + struct notify_data_icon icon_info; /* systray icon bitmap info */ WCHAR szTip[128]; DWORD dwState; DWORD dwStateMask; @@ -51,13 +61,10 @@ struct notify_data /* platform-independent format for NOTIFYICONDATA */ WCHAR szInfoTitle[64]; DWORD dwInfoFlags; GUID guidItem; - /* data for the icon bitmap */ - UINT width; - UINT height; - UINT planes; - UINT bpp; + BYTE icon_data[]; };
+ /************************************************************************* * Shell_NotifyIcon [SHELL32.296] * Shell_NotifyIconA [SHELL32.297] @@ -164,7 +171,7 @@ BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW nid) BITMAP bmColour; LONG cbMaskBits; LONG cbColourBits = 0; - char *buffer; + BYTE *buffer;
if (!GetIconInfo(nid->hIcon, &iconinfo)) goto noicon; @@ -192,21 +199,21 @@ BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW nid)
data = (struct notify_data *)buffer; memset( data, 0, sizeof(*data) ); - buffer += sizeof(*data); + buffer = data->icon_data; GetBitmapBits(iconinfo.hbmMask, cbMaskBits, buffer); if (!iconinfo.hbmColor) { - data->width = bmMask.bmWidth; - data->height = bmMask.bmHeight / 2; - data->planes = 1; - data->bpp = 1; + data->icon_info.width = bmMask.bmWidth; + data->icon_info.height = bmMask.bmHeight / 2; + data->icon_info.planes = 1; + data->icon_info.bpp = 1; } else { - data->width = bmColour.bmWidth; - data->height = bmColour.bmHeight; - data->planes = bmColour.bmPlanes; - data->bpp = bmColour.bmBitsPixel; + data->icon_info.width = bmColour.bmWidth; + data->icon_info.height = bmColour.bmHeight; + data->icon_info.planes = bmColour.bmPlanes; + data->icon_info.bpp = bmColour.bmBitsPixel; buffer += cbMaskBits; GetBitmapBits(iconinfo.hbmColor, cbColourBits, buffer); DeleteObject(iconinfo.hbmColor); diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c index b47c2239abd..6337faad633 100644 --- a/programs/explorer/systray.c +++ b/programs/explorer/systray.c @@ -36,12 +36,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(systray); #define TRAY_MINIMIZE_ALL 419 #define TRAY_MINIMIZE_ALL_UNDO 416
+struct notify_data_icon +{ + /* data for the icon bitmap */ + UINT width; + UINT height; + UINT planes; + UINT bpp; +}; + struct notify_data /* platform-independent format for NOTIFYICONDATA */ { LONG hWnd; UINT uID; UINT uFlags; UINT uCallbackMessage; + struct notify_data_icon icon_info; /* systray icon bitmap info */ WCHAR szTip[128]; DWORD dwState; DWORD dwStateMask; @@ -53,11 +63,7 @@ struct notify_data /* platform-independent format for NOTIFYICONDATA */ WCHAR szInfoTitle[64]; DWORD dwInfoFlags; GUID guidItem; - /* data for the icon bitmap */ - UINT width; - UINT height; - UINT planes; - UINT bpp; + BYTE icon_data[]; };
#define ICON_DISPLAY_HIDDEN -1 @@ -836,11 +842,13 @@ static BOOL handle_incoming(HWND hwndSource, COPYDATASTRUCT *cds) { struct icon *icon = NULL; const struct notify_data *data; + const BYTE *icon_data; NOTIFYICONDATAW nid; int ret = FALSE;
if (cds->cbData < sizeof(*data)) return FALSE; data = cds->lpData; + icon_data = data->icon_data;
nid.cbSize = sizeof(nid); nid.hWnd = LongToHandle( data->hWnd ); @@ -860,22 +868,21 @@ static BOOL handle_incoming(HWND hwndSource, COPYDATASTRUCT *cds)
/* FIXME: if statement only needed because we don't support interprocess * icon handles */ - if ((nid.uFlags & NIF_ICON) && cds->cbData > sizeof(*data)) + if (nid.uFlags & NIF_ICON) { LONG cbMaskBits; LONG cbColourBits; - const char *buffer = (const char *)(data + 1);
- cbMaskBits = (data->width * data->height + 15) / 16 * 2; - cbColourBits = (data->planes * data->width * data->height * data->bpp + 15) / 16 * 2; + cbMaskBits = (data->icon_info.width * data->icon_info.height + 15) / 16 * 2; + cbColourBits = (data->icon_info.planes * data->icon_info.width * data->icon_info.height * data->icon_info.bpp + 15) / 16 * 2;
if (cds->cbData < sizeof(*data) + cbMaskBits + cbColourBits) { ERR( "buffer underflow\n" ); return FALSE; } - nid.hIcon = CreateIcon(NULL, data->width, data->height, data->planes, data->bpp, - buffer, buffer + cbMaskBits); + nid.hIcon = CreateIcon(NULL, data->icon_info.width, data->icon_info.height, data->icon_info.planes, data->icon_info.bpp, + icon_data, icon_data + cbMaskBits); }
/* try forwarding to the display driver first */