ReactOS  0.4.15-dev-439-g292f67a
broadcast.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "wine/test.h"
Include dependency graph for broadcast.c:

Go to the source code of this file.

Typedefs

typedef LONG(WINAPIPBROADCAST) (DWORD, LPDWORD, UINT, WPARAM, LPARAM)
 
typedef LONG(WINAPIPBROADCASTEX) (DWORD, LPDWORD, UINT, WPARAM, LPARAM, PBSMINFO)
 

Functions

static LRESULT WINAPI main_window_procA (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static BOOL init_procs (void)
 
static void test_parameters (PBROADCAST broadcast, const char *functionname)
 
static void test_parametersEx (PBROADCASTEX broadcastex)
 
 START_TEST (broadcast)
 

Variables

static HANDLE hevent
 

Typedef Documentation

◆ PBROADCAST

typedef LONG(WINAPI * PBROADCAST) (DWORD, LPDWORD, UINT, WPARAM, LPARAM)

Definition at line 32 of file broadcast.c.

◆ PBROADCASTEX

typedef LONG(WINAPI * PBROADCASTEX) (DWORD, LPDWORD, UINT, WPARAM, LPARAM, PBSMINFO)

Definition at line 33 of file broadcast.c.

Function Documentation

◆ init_procs()

static BOOL init_procs ( void  )
static

Definition at line 53 of file broadcast.c.

54 {
55  WNDCLASSA cls;
56 
57  hevent = CreateEventA(NULL, TRUE, FALSE, "Asynchronous checking event");
58 
59  cls.style = CS_DBLCLKS;
61  cls.cbClsExtra = 0;
62  cls.cbWndExtra = 0;
63  cls.hInstance = GetModuleHandleA(0);
64  cls.hIcon = 0;
67  cls.lpszMenuName = NULL;
68  cls.lpszClassName = "MainWindowClass";
69 
70  if (!RegisterClassA(&cls))
71  return FALSE;
72 
73  if (!CreateWindowExA(0, "MainWindowClass", "Main window", WS_CAPTION | WS_SYSMENU |
74  WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP, 100, 100, 200,
75  200, 0, 0, GetModuleHandleA(NULL), NULL))
76  return FALSE;
77  return TRUE;
78 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define TRUE
Definition: types.h:120
int cbClsExtra
Definition: winuser.h:3140
LPCSTR lpszMenuName
Definition: winuser.h:3146
#define WHITE_BRUSH
Definition: wingdi.h:901
HBRUSH hbrBackground
Definition: winuser.h:3145
static HANDLE hevent
Definition: broadcast.c:34
int cbWndExtra
Definition: winuser.h:3141
HCURSOR hCursor
Definition: winuser.h:3144
smooth NULL
Definition: ftsmooth.c:416
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
const char * LPCSTR
Definition: xmlstorage.h:183
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
#define WS_CAPTION
Definition: pedump.c:624
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define CS_DBLCLKS
Definition: winuser.h:646
static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: broadcast.c:36
LPCSTR lpszClassName
Definition: winuser.h:3147
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2059
UINT style
Definition: winuser.h:3138
#define WS_MINIMIZEBOX
Definition: pedump.c:631
HINSTANCE hInstance
Definition: winuser.h:3142
#define WS_POPUP
Definition: pedump.c:616
WNDPROC lpfnWndProc
Definition: winuser.h:3139
#define IDC_ARROW
Definition: winuser.h:682
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define WS_SYSMENU
Definition: pedump.c:629
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
HICON hIcon
Definition: winuser.h:3143

Referenced by START_TEST().

◆ main_window_procA()

static LRESULT WINAPI main_window_procA ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 36 of file broadcast.c.

37 {
38  if (msg == WM_NULL)
39  {
40  trace("main_window_procA: Sleeping for %lu ms\n", wparam);
41  if (wparam)
42  {
45  }
46  trace("main_window_procA: Returning WM_NULL with parameter %08lx\n", lparam);
47  return lparam;
48  }
49 
50  return DefWindowProcA(hwnd, msg, wparam, lparam);
51 }
#define WM_NULL
Definition: winuser.h:1589
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
static HANDLE hevent
Definition: broadcast.c:34
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define trace
Definition: atltest.h:70
#define WAIT_TIMEOUT
Definition: dderror.h:14
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define msg(x)
Definition: auth_time.c:54
static UINT WPARAM wparam
Definition: combo.c:716

Referenced by init_procs().

◆ START_TEST()

START_TEST ( broadcast  )

Definition at line 204 of file broadcast.c.

205 {
206  if (!init_procs())
207  return;
208 
209  trace("Running BroadcastSystemMessageA tests\n");
210  test_parameters(BroadcastSystemMessageA, "BroadcastSystemMessageA");
211 
212  trace("Running BroadcastSystemMessageW tests\n");
213  test_parameters(BroadcastSystemMessageW, "BroadcastSystemMessageW");
214 
215  trace("Running BroadcastSystemMessageExA tests\n");
217 
218  trace("Running BroadcastSystemMessageExW tests\n");
220 }
static void test_parametersEx(PBROADCASTEX broadcastex)
Definition: broadcast.c:147
LONG WINAPI BroadcastSystemMessageW(DWORD dwFlags, LPDWORD lpdwRecipients, UINT uiMessage, WPARAM wParam, LPARAM lParam)
Definition: message.c:3398
LONG WINAPI BroadcastSystemMessageExW(DWORD dwflags, LPDWORD lpdwRecipients, UINT uiMessage, WPARAM wParam, LPARAM lParam, PBSMINFO pBSMInfo)
Definition: message.c:3429
static void test_parameters(PBROADCAST broadcast, const char *functionname)
Definition: broadcast.c:80
#define trace
Definition: atltest.h:70
static BOOL init_procs(void)
Definition: broadcast.c:53
LONG WINAPI BroadcastSystemMessageExA(DWORD dwflags, LPDWORD lpdwRecipients, UINT uiMessage, WPARAM wParam, LPARAM lParam, PBSMINFO pBSMInfo)
Definition: message.c:3413
LONG WINAPI BroadcastSystemMessageA(DWORD dwFlags, LPDWORD lpdwRecipients, UINT uiMessage, WPARAM wParam, LPARAM lParam)
Definition: message.c:3383

◆ test_parameters()

static void test_parameters ( PBROADCAST  broadcast,
const char functionname 
)
static

Definition at line 80 of file broadcast.c.

81 {
82  LONG ret;
83  DWORD recips;
84 
85  SetLastError(0xcafebabe);
86  recips = BSM_APPLICATIONS;
87  ret = broadcast( 0x80000000, &recips, WM_NULL, 0, 0 );
89  {
90  win_skip("%s is not implemented\n", functionname);
91  return;
92  }
93  ok(!ret || broken(ret), "Returned: %d\n", ret);
94  if (!ret) ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error: %08x\n", GetLastError());
95 
96  SetLastError(0xcafebabe);
97  recips = BSM_APPLICATIONS;
98  ret = broadcast( 0x80000000, &recips, WM_NULL, 0, 0 );
99  ok(!ret || broken(ret), "Returned: %d\n", ret);
100  if (!ret) ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error: %08x\n", GetLastError());
101 
102 if (0) /* TODO: Check the hang flags */
103 {
104  SetLastError(0xcafebabe);
105  recips = BSM_APPLICATIONS;
106  ret = broadcast( BSF_QUERY|(BSF_NOHANG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0 );
107  ok(0, "Last error: %08x\n", GetLastError());
108  ok(0, "Returned: %d\n", ret);
109 
110  SetLastError(0xcafebabe);
111  recips = BSM_APPLICATIONS;
112  ret = broadcast( BSF_QUERY|(BSF_NOHANG|BSF_NOTIMEOUTIFNOTHUNG), &recips, WM_NULL, 30000, 0 );
113  ok(0, "Last error: %08x\n", GetLastError());
114  ok(0, "Returned: %d\n", ret);
115 
116  SetLastError(0xcafebabe);
117  recips = BSM_APPLICATIONS;
118  ret = broadcast( BSF_QUERY|(BSF_NOTIMEOUTIFNOTHUNG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0 );
119  ok(0, "Last error: %08x\n", GetLastError());
120  ok(0, "Returned: %d\n", ret);
121 
122  SetLastError(0xcafebabe);
123  recips = BSM_APPLICATIONS;
124  ret = broadcast( BSF_POSTMESSAGE|(BSF_NOTIMEOUTIFNOTHUNG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0 );
125  ok(0, "Last error: %08x\n", GetLastError());
126  ok(0, "Returned: %d\n", ret);
127 }
128 
129  SetLastError( 0xdeadbeef );
130  recips = BSM_APPLICATIONS;
131  ret = broadcast( BSF_POSTMESSAGE|BSF_SENDNOTIFYMESSAGE, &recips, WM_NULL, 100, 0 );
132  ok(ret==1, "Returned: %d\n", ret);
133  ok(WaitForSingleObject(hevent, 0) != WAIT_OBJECT_0, "Synchronous message sent instead\n");
135 
136  recips = BSM_APPLICATIONS;
137  ret = broadcast( BSF_SENDNOTIFYMESSAGE, &recips, WM_NULL, 100, BROADCAST_QUERY_DENY );
138  ok(ret==1, "Returned: %d\n", ret);
139  ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n");
141 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WM_NULL
Definition: winuser.h:1589
#define BSF_FORCEIFHUNG
Definition: dbt.h:54
#define BROADCAST_QUERY_DENY
Definition: winuser.h:178
#define BSF_NOTIMEOUTIFNOTHUNG
Definition: dbt.h:57
#define BSF_QUERY
Definition: dbt.h:59
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define BSF_NOHANG
Definition: dbt.h:56
#define BSF_POSTMESSAGE
Definition: dbt.h:58
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
static HANDLE hevent
Definition: broadcast.c:34
long LONG
Definition: pedump.c:60
BOOL WINAPI DECLSPEC_HOTPATCH PulseEvent(IN HANDLE hEvent)
Definition: synch.c:695
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
#define WAIT_TIMEOUT
Definition: dderror.h:14
int ret
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define win_skip
Definition: test.h:149
#define BSM_APPLICATIONS
Definition: dbt.h:48

Referenced by START_TEST().

◆ test_parametersEx()

static void test_parametersEx ( PBROADCASTEX  broadcastex)
static

Definition at line 147 of file broadcast.c.

148 {
149  LONG ret;
150  DWORD recips;
151 
152  SetLastError(0xcafebabe);
153  recips = BSM_APPLICATIONS;
154  ret = broadcastex( 0x80000000, &recips, WM_NULL, 0, 0, NULL );
155  ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error: %08x\n", GetLastError());
156  ok(!ret, "Returned: %d\n", ret);
157 
158  SetLastError(0xcafebabe);
159  recips = BSM_APPLICATIONS;
160  ret = broadcastex( 0x80000000, &recips, WM_NULL, 0, 0, NULL );
161  ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error: %08x\n", GetLastError());
162  ok(!ret, "Returned: %d\n", ret);
163 
164 if (0) /* TODO: Check the hang flags */
165 {
166  SetLastError(0xcafebabe);
167  recips = BSM_APPLICATIONS;
168  ret = broadcastex( BSF_QUERY|(BSF_NOHANG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0, NULL );
169  ok(0, "Last error: %08x\n", GetLastError());
170  ok(0, "Returned: %d\n", ret);
171 
172  SetLastError(0xcafebabe);
173  recips = BSM_APPLICATIONS;
174  ret = broadcastex( BSF_QUERY|(BSF_NOHANG|BSF_NOTIMEOUTIFNOTHUNG), &recips, WM_NULL, 30000, 0, NULL );
175  ok(0, "Last error: %08x\n", GetLastError());
176  ok(0, "Returned: %d\n", ret);
177 
178  SetLastError(0xcafebabe);
179  recips = BSM_APPLICATIONS;
180  ret = broadcastex( BSF_QUERY|(BSF_NOTIMEOUTIFNOTHUNG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0, NULL );
181  ok(0, "Last error: %08x\n", GetLastError());
182  ok(0, "Returned: %d\n", ret);
183 
184  SetLastError(0xcafebabe);
185  recips = BSM_APPLICATIONS;
186  ret = broadcastex( BSF_POSTMESSAGE|(BSF_NOTIMEOUTIFNOTHUNG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0, NULL );
187  ok(0, "Last error: %08x\n", GetLastError());
188  ok(0, "Returned: %d\n", ret);
189 }
190 
191  recips = BSM_APPLICATIONS;
192  ret = broadcastex( BSF_POSTMESSAGE|BSF_SENDNOTIFYMESSAGE, &recips, WM_NULL, 100, 0, NULL );
193  ok(ret==1, "Returned: %d\n", ret);
194  ok(WaitForSingleObject(hevent, 0) != WAIT_OBJECT_0, "Synchronous message sent instead\n");
196 
197  recips = BSM_APPLICATIONS;
198  ret = broadcastex( BSF_SENDNOTIFYMESSAGE, &recips, WM_NULL, 100, BROADCAST_QUERY_DENY, NULL );
199  ok(ret==1, "Returned: %d\n", ret);
200  ok(WaitForSingleObject(hevent, 0) != WAIT_TIMEOUT, "Asynchronous message sent instead\n");
202 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WM_NULL
Definition: winuser.h:1589
#define BSF_FORCEIFHUNG
Definition: dbt.h:54
#define BROADCAST_QUERY_DENY
Definition: winuser.h:178
#define BSF_NOTIMEOUTIFNOTHUNG
Definition: dbt.h:57
#define BSF_QUERY
Definition: dbt.h:59
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define BSF_NOHANG
Definition: dbt.h:56
#define BSF_POSTMESSAGE
Definition: dbt.h:58
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
static HANDLE hevent
Definition: broadcast.c:34
long LONG
Definition: pedump.c:60
BOOL WINAPI DECLSPEC_HOTPATCH PulseEvent(IN HANDLE hEvent)
Definition: synch.c:695
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
#define WAIT_TIMEOUT
Definition: dderror.h:14
int ret
#define ok(value,...)
Definition: atltest.h:57
#define BSM_APPLICATIONS
Definition: dbt.h:48

Referenced by START_TEST().

Variable Documentation

◆ hevent