mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
use alloca() to pass NOTIFYICONDATA structures of any size
svn path=/trunk/; revision=8770
This commit is contained in:
parent
3db0cc5595
commit
820df5cbe5
1 changed files with 20 additions and 21 deletions
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
|
@ -28,17 +29,11 @@
|
||||||
|
|
||||||
|
|
||||||
/* copy data structure for tray notifications */
|
/* copy data structure for tray notifications */
|
||||||
typedef struct TrayNotifyCDSA {
|
typedef struct TrayNotifyCDS_Dummy {
|
||||||
DWORD cookie;
|
DWORD cookie;
|
||||||
DWORD notify_code;
|
DWORD notify_code;
|
||||||
NOTIFYICONDATAA nicon_data;
|
DWORD nicon_data[1]; // placeholder for NOTIFYICONDATA structure
|
||||||
} TrayNotifyCDSA;
|
} TrayNotifyCDS_Dummy;
|
||||||
|
|
||||||
typedef struct TrayNotifyCDSW {
|
|
||||||
DWORD cookie;
|
|
||||||
DWORD notify_code;
|
|
||||||
NOTIFYICONDATAW nicon_data;
|
|
||||||
} TrayNotifyCDSW;
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@ -49,17 +44,19 @@ BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid)
|
||||||
{
|
{
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
COPYDATASTRUCT data;
|
COPYDATASTRUCT data;
|
||||||
TrayNotifyCDSA notify_data;
|
TrayNotifyCDS_Dummy* pnotify_data;
|
||||||
|
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
notify_data.cookie = 1;
|
pnotify_data = (TrayNotifyCDS_Dummy*) alloca(sizeof(TrayNotifyCDS_Dummy)-sizeof(DWORD)+pnid->cbSize);
|
||||||
notify_data.notify_code = dwMessage;
|
|
||||||
memcpy(¬ify_data.nicon_data, pnid, sizeof(NOTIFYICONDATAA));
|
pnotify_data->cookie = 1;
|
||||||
|
pnotify_data->notify_code = dwMessage;
|
||||||
|
memcpy(&pnotify_data->nicon_data, pnid, pnid->cbSize);
|
||||||
|
|
||||||
data.dwData = 1;
|
data.dwData = 1;
|
||||||
data.cbData = sizeof(notify_data);
|
data.cbData = pnid->cbSize;
|
||||||
data.lpData = ¬ify_data;
|
data.lpData = pnotify_data;
|
||||||
|
|
||||||
for(hwnd=0; hwnd=FindWindowExA(0, hwnd, "Shell_TrayWnd", NULL); ) {
|
for(hwnd=0; hwnd=FindWindowExA(0, hwnd, "Shell_TrayWnd", NULL); ) {
|
||||||
if (SendMessageA(hwnd, WM_COPYDATA, (WPARAM)pnid->hWnd, (LPARAM)&data))
|
if (SendMessageA(hwnd, WM_COPYDATA, (WPARAM)pnid->hWnd, (LPARAM)&data))
|
||||||
|
@ -76,17 +73,19 @@ BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW pnid)
|
||||||
{
|
{
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
COPYDATASTRUCT data;
|
COPYDATASTRUCT data;
|
||||||
TrayNotifyCDSW notify_data;
|
TrayNotifyCDS_Dummy* pnotify_data;
|
||||||
|
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
notify_data.cookie = 1;
|
pnotify_data = (TrayNotifyCDS_Dummy*) alloca(sizeof(TrayNotifyCDS_Dummy)-sizeof(DWORD)+pnid->cbSize);
|
||||||
notify_data.notify_code = dwMessage;
|
|
||||||
memcpy(¬ify_data.nicon_data, pnid, sizeof(NOTIFYICONDATAW));
|
pnotify_data->cookie = 1;
|
||||||
|
pnotify_data->notify_code = dwMessage;
|
||||||
|
memcpy(&pnotify_data->nicon_data, pnid, pnid->cbSize);
|
||||||
|
|
||||||
data.dwData = 1;
|
data.dwData = 1;
|
||||||
data.cbData = sizeof(notify_data);
|
data.cbData = pnid->cbSize;
|
||||||
data.lpData = ¬ify_data;
|
data.lpData = pnotify_data;
|
||||||
|
|
||||||
for(hwnd=0; hwnd=FindWindowExW(0, hwnd, L"Shell_TrayWnd", NULL); ) {
|
for(hwnd=0; hwnd=FindWindowExW(0, hwnd, L"Shell_TrayWnd", NULL); ) {
|
||||||
if (SendMessageW(hwnd, WM_COPYDATA, (WPARAM)pnid->hWnd, (LPARAM)&data))
|
if (SendMessageW(hwnd, WM_COPYDATA, (WPARAM)pnid->hWnd, (LPARAM)&data))
|
||||||
|
|
Loading…
Reference in a new issue