ReactOS 0.4.15-dev-8207-gd73a838
ShellHook.cpp File Reference
#include "shelltest.h"
Include dependency graph for ShellHook.cpp:

Go to the source code of this file.

Classes

struct  TEST_ENTRY
 

Macros

#define STYLE_0   WS_POPUP
 
#define STYLE_1   (WS_POPUP | WS_VISIBLE)
 
#define STYLE_2   (WS_OVERLAPPED | WS_VISIBLE)
 
#define EXSTYLE_0   0
 
#define EXSTYLE_1   WS_EX_APPWINDOW
 
#define EXSTYLE_2   WS_EX_TOOLWINDOW
 
#define EXSTYLE_3   (WS_EX_APPWINDOW | WS_EX_TOOLWINDOW)
 
#define TYPE_0   FALSE, FALSE
 
#define TYPE_1   FALSE, TRUE
 
#define TYPE_2   TRUE, TRUE
 
#define ID_TESTSTART   1000
 
#define ID_TESTEND   2000
 

Functions

static HWND DoCreateWindow (HWND hwndParent, DWORD style, DWORD exstyle, BOOL bFullscreen=FALSE)
 
static void DoTestEntryPart1 (const TEST_ENTRY *pEntry)
 
static void DoTestEntryPart2 (const TEST_ENTRY *pEntry)
 
static LRESULT CALLBACK ShellProc (INT nCode, WPARAM wParam, LPARAM lParam)
 
static INT_PTR CALLBACK DialogProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
 START_TEST (ShellHook)
 

Variables

static const TEST_ENTRY s_entries1 []
 
static HHOOK s_hShellHook = NULL
 
static UINT s_cCreated = 0
 
static UINT s_cDestroyed = 0
 
static WCHAR s_szName [] = L"ReactOS ShellHook testcase"
 
static HWND s_hwndParent = NULL
 
static HWND s_hwndTarget = NULL
 
static HWND s_hwndMain = NULL
 

Macro Definition Documentation

◆ EXSTYLE_0

#define EXSTYLE_0   0

Definition at line 26 of file ShellHook.cpp.

◆ EXSTYLE_1

#define EXSTYLE_1   WS_EX_APPWINDOW

Definition at line 27 of file ShellHook.cpp.

◆ EXSTYLE_2

#define EXSTYLE_2   WS_EX_TOOLWINDOW

Definition at line 28 of file ShellHook.cpp.

◆ EXSTYLE_3

Definition at line 29 of file ShellHook.cpp.

◆ ID_TESTEND

#define ID_TESTEND   2000

◆ ID_TESTSTART

#define ID_TESTSTART   1000

◆ STYLE_0

#define STYLE_0   WS_POPUP

Definition at line 22 of file ShellHook.cpp.

◆ STYLE_1

#define STYLE_1   (WS_POPUP | WS_VISIBLE)

Definition at line 23 of file ShellHook.cpp.

◆ STYLE_2

#define STYLE_2   (WS_OVERLAPPED | WS_VISIBLE)

Definition at line 24 of file ShellHook.cpp.

◆ TYPE_0

#define TYPE_0   FALSE, FALSE

Definition at line 31 of file ShellHook.cpp.

◆ TYPE_1

#define TYPE_1   FALSE, TRUE

Definition at line 32 of file ShellHook.cpp.

◆ TYPE_2

#define TYPE_2   TRUE, TRUE

Definition at line 33 of file ShellHook.cpp.

Function Documentation

◆ DialogProc()

static INT_PTR CALLBACK DialogProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 335 of file ShellHook.cpp.

336{
337#define ID_TESTSTART 1000
338#define ID_TESTEND 2000
339 switch (uMsg)
340 {
341 case WM_INITDIALOG:
342 ok_int(s_cCreated, 0);
345 return TRUE;
346
347 case WM_COMMAND:
348 switch (LOWORD(wParam))
349 {
350 case IDOK:
351 case IDCANCEL:
353 break;
354
355 default:
356 {
358 {
360
361 if (i < _countof(s_entries1))
362 {
365 }
366 else
367 {
369 }
370 }
371 else if (ID_TESTEND <= LOWORD(wParam))
372 {
374
375 if (i < _countof(s_entries1))
376 {
379 }
380 }
381 }
382 }
383 break;
384
385 case WM_DESTROY:
387 break;
388 }
389
390 return 0;
391}
#define ID_TESTSTART
static void DoTestEntryPart2(const TEST_ENTRY *pEntry)
Definition: ShellHook.cpp:290
static void DoTestEntryPart1(const TEST_ENTRY *pEntry)
Definition: ShellHook.cpp:270
static UINT s_cCreated
Definition: ShellHook.cpp:249
#define ID_TESTEND
static const TEST_ENTRY s_entries1[]
Definition: ShellHook.cpp:35
static UINT s_cDestroyed
Definition: ShellHook.cpp:250
#define ok_int(expression, result)
Definition: atltest.h:134
WPARAM wParam
Definition: combotst.c:138
#define TRUE
Definition: types.h:120
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define LOWORD(l)
Definition: pedump.c:82
#define _countof(array)
Definition: sndvol32.h:70
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define IDCANCEL
Definition: winuser.h:831
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define IDOK
Definition: winuser.h:830
#define WM_DESTROY
Definition: winuser.h:1609
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by START_TEST().

◆ DoCreateWindow()

static HWND DoCreateWindow ( HWND  hwndParent,
DWORD  style,
DWORD  exstyle,
BOOL  bFullscreen = FALSE 
)
static

Definition at line 257 of file ShellHook.cpp.

258{
259 INT x = CW_USEDEFAULT, y = CW_USEDEFAULT, cx = 300, cy = 100;
260 if (bFullscreen)
261 {
262 x = y = 0;
265 }
266 return CreateWindowExW(exstyle, s_szName, s_szName, style, x, y, cx, cy,
268}
static WCHAR s_szName[]
Definition: ShellHook.cpp:251
Arabic default style
Definition: afstyles.h:94
static HWND hwndParent
Definition: cryptui.c:300
#define NULL
Definition: types.h:112
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
int32_t INT
Definition: typedefs.h:58
#define SM_CYSCREEN
Definition: winuser.h:960
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR 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 CW_USEDEFAULT
Definition: winuser.h:225
#define SM_CXSCREEN
Definition: winuser.h:959
int WINAPI GetSystemMetrics(_In_ int)

Referenced by DoTestEntryPart1().

◆ DoTestEntryPart1()

static void DoTestEntryPart1 ( const TEST_ENTRY pEntry)
static

Definition at line 270 of file ShellHook.cpp.

271{
272 ok(!pEntry->bIsChild || pEntry->bHasOwner,
273 "Line %d: bIsChild && !bHasOwner\n", pEntry->lineno);
274
276 if (pEntry->bIsChild || pEntry->bHasOwner)
277 s_hwndParent = DoCreateWindow(NULL, pEntry->owner_style, pEntry->owner_exstyle);
278
279 DWORD style = pEntry->style;
280 DWORD exstyle = pEntry->exstyle;
281 if (pEntry->bIsChild)
282 style |= WS_CHILD;
283 else
284 style &= ~WS_CHILD;
285
288}
static HWND s_hwndParent
Definition: ShellHook.cpp:252
static HWND DoCreateWindow(HWND hwndParent, DWORD style, DWORD exstyle, BOOL bFullscreen=FALSE)
Definition: ShellHook.cpp:257
static HWND s_hwndTarget
Definition: ShellHook.cpp:253
#define ok(value,...)
Definition: atltest.h:57
unsigned long DWORD
Definition: ntddk_ex.h:95
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define WS_CHILD
Definition: pedump.c:617

Referenced by DialogProc().

◆ DoTestEntryPart2()

static void DoTestEntryPart2 ( const TEST_ENTRY pEntry)
static

Definition at line 290 of file ShellHook.cpp.

291{
294
295 if (pEntry->bIsChild || pEntry->bHasOwner)
296 {
299 }
300
301 ok(s_cCreated == pEntry->cCreated,
302 "Line %d: cCreated expected %u but was %u\n",
303 pEntry->lineno, pEntry->cCreated, s_cCreated);
304
305 ok(s_cDestroyed == pEntry->cDestroyed,
306 "Line %d: cDestroyed expected %u but was %u\n",
307 pEntry->lineno, pEntry->cDestroyed, s_cDestroyed);
308}

Referenced by DialogProc().

◆ ShellProc()

static LRESULT CALLBACK ShellProc ( INT  nCode,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 312 of file ShellHook.cpp.

316{
317 if (nCode < 0)
318 return CallNextHookEx(s_hShellHook, nCode, wParam, lParam);
319
320 switch (nCode)
321 {
323 s_cCreated++;
324 break;
325
327 s_cDestroyed++;
328 break;
329 }
330
331 return CallNextHookEx(s_hShellHook, nCode, wParam, lParam);
332}
static HHOOK s_hShellHook
Definition: ShellHook.cpp:248
LPARAM lParam
Definition: combotst.c:139
#define HSHELL_WINDOWDESTROYED
Definition: winuser.h:1256
#define HSHELL_WINDOWCREATED
Definition: winuser.h:1255
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( ShellHook  )

Definition at line 406 of file ShellHook.cpp.

407{
412 wc.hbrBackground = (HBRUSH)(INT_PTR)(COLOR_3DFACE + 1);
414 if (!RegisterClassW(&wc))
415 {
416 skip("RegisterClassW failed\n");
417 return;
418 }
419
421 if (!s_hShellHook)
422 {
423 skip("!s_hShellHook\n");
424 return;
425 }
426
428 if (!s_hShellHook)
429 {
430 skip("!s_hwndMain\n");
432 return;
433 }
434
437
438 MSG msg;
439 while (GetMessageW(&msg, NULL, 0, 0))
440 {
442 continue;
443
446 }
447
449}
static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ShellHook.cpp:335
static HWND s_hwndMain
Definition: ShellHook.cpp:254
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ShellHook.cpp:394
static LRESULT CALLBACK ShellProc(INT nCode, WPARAM wParam, LPARAM lParam)
Definition: ShellHook.cpp:312
#define skip(...)
Definition: atltest.h:64
#define msg(x)
Definition: auth_time.c:54
#define L(x)
Definition: ntvdm.h:50
LPCWSTR lpszClassName
Definition: winuser.h:3185
HBRUSH hbrBackground
Definition: winuser.h:3183
HICON hIcon
Definition: winuser.h:3181
HINSTANCE hInstance
Definition: winuser.h:3180
HCURSOR hCursor
Definition: winuser.h:3182
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
int32_t INT_PTR
Definition: typedefs.h:64
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define CS_VREDRAW
Definition: winuser.h:658
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI IsDialogMessageW(_In_ HWND, _In_ LPMSG)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define CS_HREDRAW
Definition: winuser.h:653
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
#define SW_SHOWNOACTIVATE
Definition: winuser.h:774
#define WH_SHELL
Definition: winuser.h:40
#define SetWindowsHookEx
Definition: winuser.h:5865
#define IDI_APPLICATION
Definition: winuser.h:704
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
#define LoadIcon
Definition: winuser.h:5822
BOOL WINAPI UpdateWindow(_In_ HWND)
#define LoadCursor
Definition: winuser.h:5821
#define CreateDialogW(h, n, w, f)
Definition: winuser.h:4281
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define COLOR_3DFACE
Definition: winuser.h:929

◆ WindowProc()

static LRESULT CALLBACK WindowProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 394 of file ShellHook.cpp.

395{
396 switch (uMsg)
397 {
398 case WM_CREATE:
399 break;
400 default:
401 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
402 }
403 return 0;
404}
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1608

Referenced by START_TEST().

Variable Documentation

◆ s_cCreated

UINT s_cCreated = 0
static

Definition at line 249 of file ShellHook.cpp.

Referenced by DialogProc(), DoTestEntryPart1(), DoTestEntryPart2(), and ShellProc().

◆ s_cDestroyed

UINT s_cDestroyed = 0
static

Definition at line 250 of file ShellHook.cpp.

Referenced by DialogProc(), DoTestEntryPart1(), DoTestEntryPart2(), and ShellProc().

◆ s_entries1

const TEST_ENTRY s_entries1[]
static

Definition at line 35 of file ShellHook.cpp.

Referenced by DialogProc().

◆ s_hShellHook

HHOOK s_hShellHook = NULL
static

Definition at line 248 of file ShellHook.cpp.

Referenced by ShellProc(), and START_TEST().

◆ s_hwndMain

HWND s_hwndMain = NULL
static

Definition at line 254 of file ShellHook.cpp.

Referenced by START_TEST().

◆ s_hwndParent

HWND s_hwndParent = NULL
static

Definition at line 252 of file ShellHook.cpp.

Referenced by DoTestEntryPart1(), and DoTestEntryPart2().

◆ s_hwndTarget

HWND s_hwndTarget = NULL
static

Definition at line 253 of file ShellHook.cpp.

Referenced by DoTestEntryPart1(), and DoTestEntryPart2().

◆ s_szName

WCHAR s_szName[] = L"ReactOS ShellHook testcase"
static

Definition at line 251 of file ShellHook.cpp.

Referenced by DoCreateWindow(), and START_TEST().