Commit in reactos/lib/shell32 on MAIN
ros-systray.c+20-211.1 -> 1.2
use alloca() to pass NOTIFYICONDATA structures of any size

reactos/lib/shell32
ros-systray.c 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- ros-systray.c	16 Mar 2004 10:07:38 -0000	1.1
+++ ros-systray.c	16 Mar 2004 22:49:29 -0000	1.2
@@ -20,6 +20,7 @@
  */
 
 #include <stdarg.h>
+#include <malloc.h>
 
 #include "windef.h"
 #include "winbase.h"
@@ -28,17 +29,11 @@
 
 
  /* copy data structure for tray notifications */
-typedef struct TrayNotifyCDSA {
+typedef struct TrayNotifyCDS_Dummy {
 	DWORD	cookie;
 	DWORD	notify_code;
-	NOTIFYICONDATAA	nicon_data;
-} TrayNotifyCDSA;
-
-typedef struct TrayNotifyCDSW {
-	DWORD	cookie;
-	DWORD	notify_code;
-	NOTIFYICONDATAW	nicon_data;
-} TrayNotifyCDSW;
+	DWORD	nicon_data[1];	// placeholder for NOTIFYICONDATA structure
+} TrayNotifyCDS_Dummy;
 
 
 /*************************************************************************
@@ -49,17 +44,19 @@
 {
 	HWND hwnd;
 	COPYDATASTRUCT data;
-	TrayNotifyCDSnotify_data;
+	TrayNotifyCDS_Dummy* pnotify_data;
 
 	BOOL ret = FALSE;
 
-	notify_data.cookie = 1;
-	notify_data.notify_code = dwMessage;
-	memcpy(&notify_data.nicon_data, pnid, sizeof(NOTIFYICONDATAA));
+	pnotify_data = (TrayNotifyCDS_Dummy*) alloca(sizeof(TrayNotifyCDS_Dummy)-sizeof(DWORD)+pnid->cbSize);
+
+	pnotify_data->cookie = 1;
+	pnotify_data->notify_code = dwMessage;
+	memcpy(&pnotify_data->nicon_data, pnid, pnid->cbSize);
 
 	data.dwData = 1;
-	data.cbData = sizeof(notify_data);
-	data.lpData = &notify_data;
+	data.cbData = pnid->cbSize;
+	data.lpData = pnotify_data;
 
 	for(hwnd=0; hwnd=FindWindowExA(0, hwnd, "Shell_TrayWnd", NULL); ) {
 		if (SendMessageA(hwnd, WM_COPYDATA, (WPARAM)pnid->hWnd, (LPARAM)&data))
@@ -76,17 +73,19 @@
 {
 	HWND hwnd;
 	COPYDATASTRUCT data;
-	TrayNotifyCDSnotify_data;
+	TrayNotifyCDS_Dummy* pnotify_data;
 
 	BOOL ret = FALSE;
 
-	notify_data.cookie = 1;
-	notify_data.notify_code = dwMessage;
-	memcpy(&notify_data.nicon_data, pnid, sizeof(NOTIFYICONDATAW));
+	pnotify_data = (TrayNotifyCDS_Dummy*) alloca(sizeof(TrayNotifyCDS_Dummy)-sizeof(DWORD)+pnid->cbSize);
+
+	pnotify_data->cookie = 1;
+	pnotify_data->notify_code = dwMessage;
+	memcpy(&pnotify_data->nicon_data, pnid, pnid->cbSize);
 
 	data.dwData = 1;
-	data.cbData = sizeof(notify_data);
-	data.lpData = &notify_data;
+	data.cbData = pnid->cbSize;
+	data.lpData = pnotify_data;
 
 	for(hwnd=0; hwnd=FindWindowExW(0, hwnd, L"Shell_TrayWnd", NULL); ) {
 		if (SendMessageW(hwnd, WM_COPYDATA, (WPARAM)pnid->hWnd, (LPARAM)&data))
CVSspam 0.2.8