ReactOS  0.4.15-dev-3440-g915569a
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 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int32_t INT
Definition: typedefs.h:58
#define SM_CXSCREEN
Definition: winuser.h:953
#define CW_USEDEFAULT
Definition: winuser.h:225
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:585
static HWND hwndParent
Definition: cryptui.c:300
#define SM_CYSCREEN
Definition: winuser.h:954
int WINAPI GetSystemMetrics(_In_ int)
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 NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_Out_opt_ int * cx
Definition: commctrl.h:585
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
static WCHAR s_szName[]
Definition: ShellHook.cpp:379
Arabic default style
Definition: afstyles.h:93

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 {
435  s_hwndParent = NULL;
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  {
446  MoveWindow(s_hwndTarget, 0, 0,
448  }
449 }
#define TRUE
Definition: types.h:120
#define SM_CXSCREEN
Definition: winuser.h:953
static HWND s_hwndTarget
Definition: ShellHook.cpp:376
#define SM_CYSCREEN
Definition: winuser.h:954
static HWND s_hwndParent
Definition: ShellHook.cpp:375
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define NULL
Definition: types.h:112
BOOL WINAPI SetForegroundWindow(_In_ HWND)
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
static UINT s_nRudeAppActivated
Definition: ShellHook.cpp:378
Arabic default style
Definition: afstyles.h:93
static HWND DoCreateWindow(HWND hwndParent, DWORD style, DWORD exstyle, BOOL bFullscreen=FALSE)
Definition: ShellHook.cpp:382

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 
458  s_hwndTarget = NULL;
459 }
static HWND s_hwndTarget
Definition: ShellHook.cpp:376
#define WM_CLOSE
Definition: winuser.h:1608
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
static UINT s_nRudeAppActivated
Definition: ShellHook.cpp:378

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 
400  s_hwndParent = NULL;
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 }
#define WS_CHILD
Definition: pedump.c:617
static UINT s_nWindowCreatedCount
Definition: ShellHook.cpp:377
static HWND s_hwndTarget
Definition: ShellHook.cpp:376
static HWND s_hwndParent
Definition: ShellHook.cpp:375
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
Arabic default style
Definition: afstyles.h:93
static HWND DoCreateWindow(HWND hwndParent, DWORD style, DWORD exstyle, BOOL bFullscreen=FALSE)
Definition: ShellHook.cpp:382

Referenced by WindowProc().

◆ DoTestEntryPart2()

static void DoTestEntryPart2 ( const TEST_ENTRY pEntry)
static

Definition at line 417 of file ShellHook.cpp.

418 {
419  ok(s_nWindowCreatedCount == pEntry->nCount,
420  "Line %d: s_nWindowCreatedCount expected %u but was %u\n",
421  pEntry->lineno, pEntry->nCount, s_nWindowCreatedCount);
422 
424  s_hwndTarget = NULL;
425 
426  if (pEntry->bIsChild || pEntry->bHasOwner)
427  {
429  s_hwndParent = NULL;
430  }
431 }
static UINT s_nWindowCreatedCount
Definition: ShellHook.cpp:377
static HWND s_hwndTarget
Definition: ShellHook.cpp:376
static HWND s_hwndParent
Definition: ShellHook.cpp:375
#define WM_CLOSE
Definition: winuser.h:1608
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484

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));
542  wc.lpfnWndProc = WindowProc;
546  wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
547  wc.lpszClassName = s_szName;
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 }
BOOL WINAPI TranslateMessage(_In_ const MSG *)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define ZeroMemory
Definition: winbase.h:1664
#define IDI_APPLICATION
Definition: winuser.h:699
BOOL WINAPI DestroyWindow(_In_ HWND)
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ShellHook.cpp:462
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define L(x)
Definition: ntvdm.h:50
#define COLOR_3DFACE
Definition: winuser.h:923
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
WNDPROC lpfnWndProc
Definition: winuser.h:3157
LPCWSTR lpszClassName
Definition: winuser.h:3165
static HWND s_hwndHookViewer
Definition: ShellHook.cpp:374
HICON hIcon
Definition: winuser.h:3161
BOOL WINAPI RegisterShellHookWindow(_In_ HWND)
#define LoadCursor
Definition: winuser.h:5792
HCURSOR hCursor
Definition: winuser.h:3162
UINT WINAPI RegisterWindowMessageW(_In_ LPCWSTR)
HBRUSH hbrBackground
Definition: winuser.h:3163
#define NULL
Definition: types.h:112
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
HINSTANCE hInstance
Definition: winuser.h:3160
#define skip(...)
Definition: atltest.h:64
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
static WCHAR s_szName[]
Definition: ShellHook.cpp:379
BOOL WINAPI DeregisterShellHookWindow(_In_ HWND)
#define LoadIcon
Definition: winuser.h:5793
static UINT s_uShellHookMsg
Definition: ShellHook.cpp:373
#define WS_VISIBLE
Definition: pedump.c:620
static HWND DoCreateWindow(HWND hwndParent, DWORD style, DWORD exstyle, BOOL bFullscreen=FALSE)
Definition: ShellHook.cpp:382

◆ 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 
494  if (ID_IGNITION <= wParam && wParam < ID_BURNING)
495  {
496  INT i = (INT)wParam - ID_IGNITION;
499  }
500  else if (ID_BURNING <= wParam && wParam < ID_RUDEAPPTEST1)
501  {
502  INT i = (INT)wParam - ID_BURNING;
504  ++i;
505  if (i == (INT)_countof(s_entries1))
506  {
508  break;
509  }
511  }
512  else if (ID_RUDEAPPTEST1 <= wParam && wParam < ID_RUDEAPPTEST2)
513  {
517  }
518  else if (ID_RUDEAPPTEST2 <= wParam)
519  {
522  ++i;
523  if (i == (INT)_countof(s_entries2))
524  {
525  PostQuitMessage(0);
526  break;
527  }
529  }
530  break;
531  default:
532  return DefWindowProcW(hwnd, uMsg, wParam, lParam);
533  }
534  return 0;
535 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define ID_IGNITION
static const RUDEAPP_TEST_ENTRY s_entries2[]
Definition: ShellHook.cpp:259
UINT uMsg
Definition: menu.cpp:213
#define INT
Definition: polytest.cpp:20
#define HSHELL_WINDOWCREATED
Definition: winuser.h:1245
int32_t INT
Definition: typedefs.h:58
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static UINT s_nWindowCreatedCount
Definition: ShellHook.cpp:377
static HWND s_hwndTarget
Definition: ShellHook.cpp:376
static HWND s_hwndHookViewer
Definition: ShellHook.cpp:374
static const TEST_ENTRY s_entries1[]
Definition: ShellHook.cpp:35
#define _countof(array)
Definition: sndvol32.h:68
#define ID_RUDEAPPTEST2
#define WM_COMMAND
Definition: winuser.h:1727
static void DoRudeAppTest2(const RUDEAPP_TEST_ENTRY *pEntry)
Definition: ShellHook.cpp:451
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 HSHELL_RUDEAPPACTIVATED
Definition: winuser.h:1268
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1595
#define ID_RUDEAPPTEST1
static UINT s_uShellHookMsg
Definition: ShellHook.cpp:373
static void DoTestEntryPart1(const TEST_ENTRY *pEntry)
Definition: ShellHook.cpp:395
static UINT s_nRudeAppActivated
Definition: ShellHook.cpp:378
static void DoRudeAppTest1(const RUDEAPP_TEST_ENTRY *pEntry)
Definition: ShellHook.cpp:433
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define ID_BURNING
static void DoTestEntryPart2(const TEST_ENTRY *pEntry)
Definition: ShellHook.cpp:417

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().