ReactOS 0.4.15-dev-6057-gd708c79
ShellHook.cpp File Reference
#include "shelltest.h"
#include "undocshell.h"
Include dependency graph for ShellHook.cpp:

Go to the source code of this file.

Classes

struct  TEST_ENTRY
 
struct  RUDEAPP_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_IGNITION   1000
 
#define ID_BURNING   2000
 
#define ID_RUDEAPPTEST1   3000
 
#define ID_RUDEAPPTEST2   4000
 

Typedefs

typedef struct RUDEAPP_TEST_ENTRY RUDEAPP_TEST_ENTRY
 

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 void DoRudeAppTest1 (const RUDEAPP_TEST_ENTRY *pEntry)
 
static void DoRudeAppTest2 (const RUDEAPP_TEST_ENTRY *pEntry)
 
static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
 START_TEST (ShellHook)
 

Variables

static const TEST_ENTRY s_entries1 []
 
static const RUDEAPP_TEST_ENTRY s_entries2 []
 
static UINT s_uShellHookMsg = 0
 
static HWND s_hwndHookViewer = NULL
 
static HWND s_hwndParent = NULL
 
static HWND s_hwndTarget = NULL
 
static UINT s_nWindowCreatedCount = 0
 
static UINT s_nRudeAppActivated = 0
 
static WCHAR s_szName [] = L"ReactOS ShellHook testcase"
 

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_BURNING

#define ID_BURNING   2000

◆ ID_IGNITION

#define ID_IGNITION   1000

◆ ID_RUDEAPPTEST1

#define ID_RUDEAPPTEST1   3000

◆ ID_RUDEAPPTEST2

#define ID_RUDEAPPTEST2   4000

◆ 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.

Typedef Documentation

◆ RUDEAPP_TEST_ENTRY

Function Documentation

◆ DoCreateWindow()

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

Definition at line 382 of file ShellHook.cpp.

383{
384 INT x = CW_USEDEFAULT, y = CW_USEDEFAULT, cx = 100, cy = 100;
385 if (bFullscreen)
386 {
387 x = y = 0;
390 }
391 return CreateWindowExW(exstyle, s_szName, s_szName, style, x, y, cx, cy,
393}
static WCHAR s_szName[]
Definition: ShellHook.cpp:379
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:954
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:953
int WINAPI GetSystemMetrics(_In_ int)

Referenced by DoRudeAppTest1(), DoTestEntryPart1(), and START_TEST().

◆ DoRudeAppTest1()

static void DoRudeAppTest1 ( const RUDEAPP_TEST_ENTRY pEntry)
static

Definition at line 433 of file ShellHook.cpp.

434{
436
437 DWORD style = pEntry->style;
438 DWORD exstyle = pEntry->exstyle;
439
441 s_hwndTarget = DoCreateWindow(s_hwndParent, style, exstyle, pEntry->bFullscreen);
442 if (pEntry->bSetForeground)
444 if (pEntry->bSetFullscreen)
445 {
448 }
449}
static UINT s_nRudeAppActivated
Definition: ShellHook.cpp:378
static HWND s_hwndParent
Definition: ShellHook.cpp:375
static HWND DoCreateWindow(HWND hwndParent, DWORD style, DWORD exstyle, BOOL bFullscreen=FALSE)
Definition: ShellHook.cpp:382
static HWND s_hwndTarget
Definition: ShellHook.cpp:376
#define TRUE
Definition: types.h:120
unsigned long DWORD
Definition: ntddk_ex.h:95
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
BOOL WINAPI SetForegroundWindow(_In_ HWND)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

Referenced by WindowProc().

◆ DoRudeAppTest2()

static void DoRudeAppTest2 ( const RUDEAPP_TEST_ENTRY pEntry)
static

Definition at line 451 of file ShellHook.cpp.

452{
453 ok(s_nRudeAppActivated == pEntry->nCount,
454 "Line %d: s_nRudeAppActivated expected %u but was %u\n",
455 pEntry->lineno, pEntry->nCount, s_nRudeAppActivated);
456
459}
#define ok(value,...)
Definition: atltest.h:57
#define WM_CLOSE
Definition: winuser.h:1611
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by WindowProc().

◆ DoTestEntryPart1()

static void DoTestEntryPart1 ( const TEST_ENTRY pEntry)
static

Definition at line 395 of file ShellHook.cpp.

396{
397 ok(!pEntry->bIsChild || pEntry->bHasOwner,
398 "Line %d: bIsChild && !bHasOwner\n", pEntry->lineno);
399
401 if (pEntry->bIsChild || pEntry->bHasOwner)
402 {
403 s_hwndParent = DoCreateWindow(NULL, pEntry->owner_style, pEntry->owner_exstyle);
404 }
405
406 DWORD style = pEntry->style;
407 DWORD exstyle = pEntry->exstyle;
408 if (pEntry->bIsChild)
409 style |= WS_CHILD;
410 else
411 style &= ~WS_CHILD;
412
415}
static UINT s_nWindowCreatedCount
Definition: ShellHook.cpp:377
#define WS_CHILD
Definition: pedump.c:617

Referenced by WindowProc().

◆ DoTestEntryPart2()

static void DoTestEntryPart2 ( const TEST_ENTRY pEntry)
static

Definition at line 417 of file ShellHook.cpp.

418{
420 "Line %d: s_nWindowCreatedCount expected %u but was %u\n",
421 pEntry->lineno, pEntry->nCount, s_nWindowCreatedCount);
422
425
426 if (pEntry->bIsChild || pEntry->bHasOwner)
427 {
430 }
431}

Referenced by WindowProc().

◆ START_TEST()

START_TEST ( ShellHook  )

Definition at line 537 of file ShellHook.cpp.

538{
539 WNDCLASSW wc;
540
541 ZeroMemory(&wc, sizeof(wc));
546 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
548 if (!RegisterClassW(&wc))
549 {
550 skip("RegisterClassW failed\n");
551 return;
552 }
553
555 if (s_hwndHookViewer == NULL)
556 {
557 skip("CreateWindowExW failed\n");
558 return;
559 }
560
563
564 MSG msg;
565 while (GetMessageW(&msg, NULL, 0, 0))
566 {
569 }
570
574}
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ShellHook.cpp:462
static UINT s_uShellHookMsg
Definition: ShellHook.cpp:373
static HWND s_hwndHookViewer
Definition: ShellHook.cpp:374
#define skip(...)
Definition: atltest.h:64
#define msg(x)
Definition: auth_time.c:54
#define L(x)
Definition: ntvdm.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
LPCWSTR lpszClassName
Definition: winuser.h:3175
HBRUSH hbrBackground
Definition: winuser.h:3173
HICON hIcon
Definition: winuser.h:3171
HINSTANCE hInstance
Definition: winuser.h:3170
WNDPROC lpfnWndProc
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3172
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define ZeroMemory
Definition: winbase.h:1670
BOOL WINAPI DeregisterShellHookWindow(_In_ HWND)
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI RegisterShellHookWindow(_In_ HWND)
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:682
#define IDI_APPLICATION
Definition: winuser.h:699
#define LoadIcon
Definition: winuser.h:5803
UINT WINAPI RegisterWindowMessageW(_In_ LPCWSTR)
#define LoadCursor
Definition: winuser.h:5802
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define COLOR_3DFACE
Definition: winuser.h:923

◆ WindowProc()

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

Definition at line 462 of file ShellHook.cpp.

463{
464 if (uMsg == s_uShellHookMsg && uMsg != 0)
465 {
466 switch (wParam)
467 {
469 if ((HWND)lParam != s_hwndTarget)
470 break;
472 break;
473
475 if ((HWND)lParam != s_hwndTarget)
476 break;
478 break;
479 }
480 }
481#define ID_IGNITION 1000
482#define ID_BURNING 2000
483#define ID_RUDEAPPTEST1 3000
484#define ID_RUDEAPPTEST2 4000
485 switch (uMsg)
486 {
487 case WM_CREATE:
489 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
490 case WM_COMMAND:
491 if (hwnd != s_hwndHookViewer)
492 break;
493
495 {
499 }
500 else if (ID_BURNING <= wParam && wParam < ID_RUDEAPPTEST1)
501 {
504 ++i;
505 if (i == (INT)_countof(s_entries1))
506 {
508 break;
509 }
511 }
513 {
517 }
518 else if (ID_RUDEAPPTEST2 <= wParam)
519 {
522 ++i;
523 if (i == (INT)_countof(s_entries2))
524 {
526 break;
527 }
529 }
530 break;
531 default:
532 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
533 }
534 return 0;
535}
#define ID_BURNING
static void DoTestEntryPart2(const TEST_ENTRY *pEntry)
Definition: ShellHook.cpp:417
static void DoTestEntryPart1(const TEST_ENTRY *pEntry)
Definition: ShellHook.cpp:395
#define ID_RUDEAPPTEST2
static void DoRudeAppTest1(const RUDEAPP_TEST_ENTRY *pEntry)
Definition: ShellHook.cpp:433
#define ID_IGNITION
static const TEST_ENTRY s_entries1[]
Definition: ShellHook.cpp:35
static const RUDEAPP_TEST_ENTRY s_entries2[]
Definition: ShellHook.cpp:259
#define ID_RUDEAPPTEST1
static void DoRudeAppTest2(const RUDEAPP_TEST_ENTRY *pEntry)
Definition: ShellHook.cpp:451
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
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
#define INT
Definition: polytest.cpp:20
#define _countof(array)
Definition: sndvol32.h:68
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define HSHELL_RUDEAPPACTIVATED
Definition: winuser.h:1271
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1598
#define HSHELL_WINDOWCREATED
Definition: winuser.h:1245
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1730

Referenced by START_TEST().

Variable Documentation

◆ s_entries1

const TEST_ENTRY s_entries1[]
static

Definition at line 35 of file ShellHook.cpp.

Referenced by WindowProc().

◆ s_entries2

const RUDEAPP_TEST_ENTRY s_entries2[]
static

Definition at line 259 of file ShellHook.cpp.

Referenced by WindowProc().

◆ s_hwndHookViewer

HWND s_hwndHookViewer = NULL
static

Definition at line 374 of file ShellHook.cpp.

Referenced by START_TEST(), and WindowProc().

◆ s_hwndParent

HWND s_hwndParent = NULL
static

Definition at line 375 of file ShellHook.cpp.

Referenced by DoRudeAppTest1(), DoTestEntryPart1(), and DoTestEntryPart2().

◆ s_hwndTarget

HWND s_hwndTarget = NULL
static

◆ s_nRudeAppActivated

UINT s_nRudeAppActivated = 0
static

Definition at line 378 of file ShellHook.cpp.

Referenced by DoRudeAppTest1(), DoRudeAppTest2(), and WindowProc().

◆ s_nWindowCreatedCount

UINT s_nWindowCreatedCount = 0
static

Definition at line 377 of file ShellHook.cpp.

Referenced by DoTestEntryPart1(), DoTestEntryPart2(), and WindowProc().

◆ s_szName

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

Definition at line 379 of file ShellHook.cpp.

Referenced by DoCreateWindow(), and START_TEST().

◆ s_uShellHookMsg

UINT s_uShellHookMsg = 0
static

Definition at line 373 of file ShellHook.cpp.

Referenced by START_TEST(), and WindowProc().