ReactOS  0.4.15-dev-1374-g8d3e80e
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
 

Macros

#define STYLE_0   WS_POPUP
 
#define STYLE_1   (WS_POPUP | 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
 

Functions

static HWND DoCreateWindow (HWND hwndParent, DWORD style, DWORD exstyle)
 
static void DoTestEntryPart1 (const TEST_ENTRY *pEntry)
 
static void DoTestEntryPart2 (const TEST_ENTRY *pEntry)
 
static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
 START_TEST (ShellHook)
 

Variables

static UINT s_uShellHookMsg = 0
 
static HWND s_hwndHookViewer = NULL
 
static HWND s_hwndParent = NULL
 
static HWND s_hwndTarget = NULL
 
static DWORD s_dwFlags = 0
 
static WCHAR s_szName [] = L"ReactOS ShellHook testcase"
 
static const TEST_ENTRY s_entries []
 
static const size_t s_num_entries = sizeof(s_entries) / sizeof(s_entries[0])
 

Macro Definition Documentation

◆ EXSTYLE_0

#define EXSTYLE_0   0

Definition at line 40 of file ShellHook.cpp.

◆ EXSTYLE_1

#define EXSTYLE_1   WS_EX_APPWINDOW

Definition at line 41 of file ShellHook.cpp.

◆ EXSTYLE_2

#define EXSTYLE_2   WS_EX_TOOLWINDOW

Definition at line 42 of file ShellHook.cpp.

◆ EXSTYLE_3

Definition at line 43 of file ShellHook.cpp.

◆ STYLE_0

#define STYLE_0   WS_POPUP

Definition at line 37 of file ShellHook.cpp.

◆ STYLE_1

#define STYLE_1   (WS_POPUP | WS_VISIBLE)

Definition at line 38 of file ShellHook.cpp.

◆ TYPE_0

#define TYPE_0   FALSE, FALSE

Definition at line 45 of file ShellHook.cpp.

◆ TYPE_1

#define TYPE_1   FALSE, TRUE

Definition at line 46 of file ShellHook.cpp.

◆ TYPE_2

#define TYPE_2   TRUE, TRUE

Definition at line 47 of file ShellHook.cpp.

Function Documentation

◆ DoCreateWindow()

static HWND DoCreateWindow ( HWND  hwndParent,
DWORD  style,
DWORD  exstyle 
)
static

Definition at line 18 of file ShellHook.cpp.

19 {
20  return CreateWindowExW(exstyle, s_szName, s_szName, style,
21  CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,
23 }
#define CW_USEDEFAULT
Definition: winuser.h:225
static HWND hwndParent
Definition: cryptui.c:300
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
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
static WCHAR s_szName[]
Definition: ShellHook.cpp:15
Arabic default style
Definition: afstyles.h:93

Referenced by DoTestEntryPart1(), and START_TEST().

◆ DoTestEntryPart1()

static void DoTestEntryPart1 ( const TEST_ENTRY pEntry)
static

Definition at line 318 of file ShellHook.cpp.

319 {
320  ok(!pEntry->bIsChild || pEntry->bHasOwner,
321  "Line %d: bIsChild && !bHasOwner\n", pEntry->lineno);
322 
323  s_hwndParent = NULL;
324  if (pEntry->bIsChild || pEntry->bHasOwner)
325  {
326  s_hwndParent = DoCreateWindow(NULL, pEntry->owner_style, pEntry->owner_exstyle);
327  }
328 
329  DWORD style = pEntry->style;
330  DWORD exstyle = pEntry->exstyle;
331  if (pEntry->bIsChild)
332  style |= WS_CHILD;
333  else
334  style &= ~WS_CHILD;
335 
336  s_dwFlags = 0;
338 }
#define WS_CHILD
Definition: pedump.c:617
static HWND DoCreateWindow(HWND hwndParent, DWORD style, DWORD exstyle)
Definition: ShellHook.cpp:18
static HWND s_hwndTarget
Definition: ShellHook.cpp:13
static HWND s_hwndParent
Definition: ShellHook.cpp:12
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD s_dwFlags
Definition: ShellHook.cpp:14
#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

Referenced by WindowProc().

◆ DoTestEntryPart2()

static void DoTestEntryPart2 ( const TEST_ENTRY pEntry)
static

Definition at line 340 of file ShellHook.cpp.

341 {
342  ok(s_dwFlags == pEntry->dwFlags, "Line %d: s_dwFlags expected 0x%lX but was 0x%lX\n",
343  pEntry->lineno, pEntry->dwFlags, s_dwFlags);
344 
346  s_hwndTarget = NULL;
347 
348  if (pEntry->bIsChild || pEntry->bHasOwner)
349  {
351  s_hwndParent = NULL;
352  }
353 }
static HWND s_hwndTarget
Definition: ShellHook.cpp:13
static HWND s_hwndParent
Definition: ShellHook.cpp:12
#define WM_CLOSE
Definition: winuser.h:1603
static DWORD s_dwFlags
Definition: ShellHook.cpp:14
#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 427 of file ShellHook.cpp.

428 {
429  WNDCLASSW wc;
430 
431  ZeroMemory(&wc, sizeof(wc));
432  wc.lpfnWndProc = WindowProc;
436  wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
437  wc.lpszClassName = s_szName;
438  if (!RegisterClassW(&wc))
439  {
440  skip("RegisterClassW failed\n");
441  return;
442  }
443 
445  if (s_hwndHookViewer == NULL)
446  {
447  skip("CreateWindowExW failed\n");
448  return;
449  }
450 
453 
454  MSG msg;
455  while (GetMessageW(&msg, NULL, 0, 0))
456  {
459  }
460 
464 }
BOOL WINAPI TranslateMessage(_In_ const MSG *)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define ZeroMemory
Definition: winbase.h:1648
#define IDI_APPLICATION
Definition: winuser.h:699
BOOL WINAPI DestroyWindow(_In_ HWND)
static HWND DoCreateWindow(HWND hwndParent, DWORD style, DWORD exstyle)
Definition: ShellHook.cpp:18
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ShellHook.cpp:356
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define COLOR_3DFACE
Definition: winuser.h:919
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
WNDPROC lpfnWndProc
Definition: winuser.h:3152
LPCWSTR lpszClassName
Definition: winuser.h:3160
static HWND s_hwndHookViewer
Definition: ShellHook.cpp:11
HICON hIcon
Definition: winuser.h:3156
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI RegisterShellHookWindow(_In_ HWND)
#define LoadCursor
Definition: winuser.h:5787
HCURSOR hCursor
Definition: winuser.h:3157
UINT WINAPI RegisterWindowMessageW(_In_ LPCWSTR)
HBRUSH hbrBackground
Definition: winuser.h:3158
#define NULL
Definition: types.h:112
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
HINSTANCE hInstance
Definition: winuser.h:3155
#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:15
BOOL WINAPI DeregisterShellHookWindow(_In_ HWND)
#define LoadIcon
Definition: winuser.h:5788
static UINT s_uShellHookMsg
Definition: ShellHook.cpp:10
#define WS_VISIBLE
Definition: pedump.c:620

◆ WindowProc()

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

Definition at line 356 of file ShellHook.cpp.

357 {
358  if (uMsg == s_uShellHookMsg && uMsg != 0)
359  {
360  DWORD style, exstyle, owner_style, owner_exstyle;
361  HWND hwndOwner;
362  DWORD dwFlags;
363  switch (wParam)
364  {
366  if ((HWND)lParam != s_hwndTarget)
367  break;
370  if (style & WS_CHILD)
371  hwndOwner = GetParent(s_hwndTarget);
372  else
373  hwndOwner = GetWindow(s_hwndTarget, GW_OWNER);
374  owner_style = (LONG)GetWindowLongPtrW(hwndOwner, GWL_STYLE);
375  owner_exstyle = (LONG)GetWindowLongPtrW(hwndOwner, GWL_EXSTYLE);
376  dwFlags = (1 << 0);
377  if (style & WS_VISIBLE)
378  dwFlags |= (1 << 1);
379  if (exstyle & WS_EX_TOOLWINDOW)
380  dwFlags |= (1 << 2);
381  if (exstyle & WS_EX_APPWINDOW)
382  dwFlags |= (1 << 3);
383  if (owner_style & WS_VISIBLE)
384  dwFlags |= (1 << 4);
385  if (owner_exstyle & WS_EX_TOOLWINDOW)
386  dwFlags |= (1 << 5);
387  if (owner_exstyle & WS_EX_APPWINDOW)
388  dwFlags |= (1 << 6);
389  s_dwFlags = dwFlags;
390  break;
391  }
392  }
393  switch (uMsg)
394  {
395  case WM_CREATE:
396  PostMessageW(hwnd, WM_COMMAND, 1000, 0);
397  return DefWindowProcW(hwnd, uMsg, wParam, lParam);
398  case WM_COMMAND:
399  if (hwnd == s_hwndHookViewer)
400  {
401  if (1000 <= wParam && wParam < 2000)
402  {
403  INT i = (INT)wParam - 1000;
405  PostMessageW(hwnd, WM_COMMAND, 2000 + i, 0);
406  }
407  else if (2000 <= wParam && wParam < 3000)
408  {
409  INT i = (INT)wParam - 2000;
411  ++i;
412  if (i == s_num_entries)
413  {
414  PostQuitMessage(0);
415  break;
416  }
417  PostMessageW(hwnd, WM_COMMAND, 1000 + i, 0);
418  }
419  }
420  break;
421  default:
422  return DefWindowProcW(hwnd, uMsg, wParam, lParam);
423  }
424  return 0;
425 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
UINT uMsg
Definition: menu.cpp:213
static const size_t s_num_entries
Definition: ShellHook.cpp:316
#define INT
Definition: polytest.cpp:20
#define HSHELL_WINDOWCREATED
Definition: winuser.h:1240
#define GWL_EXSTYLE
Definition: winuser.h:845
static const TEST_ENTRY s_entries[]
Definition: ShellHook.cpp:49
#define WS_CHILD
Definition: pedump.c:617
#define GetWindowLongPtrW
Definition: winuser.h:4804
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
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 HWND s_hwndTarget
Definition: ShellHook.cpp:13
long LONG
Definition: pedump.c:60
static HWND s_hwndHookViewer
Definition: ShellHook.cpp:11
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
static DWORD s_dwFlags
Definition: ShellHook.cpp:14
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define WM_COMMAND
Definition: winuser.h:1722
#define GWL_STYLE
Definition: winuser.h:846
HWND WINAPI GetParent(_In_ HWND)
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 GW_OWNER
Definition: winuser.h:761
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1590
#define WS_EX_APPWINDOW
Definition: winuser.h:383
static UINT s_uShellHookMsg
Definition: ShellHook.cpp:10
static void DoTestEntryPart1(const TEST_ENTRY *pEntry)
Definition: ShellHook.cpp:318
Arabic default style
Definition: afstyles.h:93
#define WS_VISIBLE
Definition: pedump.c:620
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
static void DoTestEntryPart2(const TEST_ENTRY *pEntry)
Definition: ShellHook.cpp:340

Referenced by START_TEST().

Variable Documentation

◆ s_dwFlags

DWORD s_dwFlags = 0
static

Definition at line 14 of file ShellHook.cpp.

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

◆ s_entries

const TEST_ENTRY s_entries[]
static

Definition at line 49 of file ShellHook.cpp.

Referenced by WindowProc().

◆ s_hwndHookViewer

HWND s_hwndHookViewer = NULL
static

Definition at line 11 of file ShellHook.cpp.

Referenced by START_TEST(), and WindowProc().

◆ s_hwndParent

HWND s_hwndParent = NULL
static

Definition at line 12 of file ShellHook.cpp.

Referenced by DoTestEntryPart1(), and DoTestEntryPart2().

◆ s_hwndTarget

HWND s_hwndTarget = NULL
static

Definition at line 13 of file ShellHook.cpp.

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

◆ s_num_entries

const size_t s_num_entries = sizeof(s_entries) / sizeof(s_entries[0])
static

Definition at line 316 of file ShellHook.cpp.

Referenced by WindowProc().

◆ s_szName

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

Definition at line 15 of file ShellHook.cpp.

Referenced by DoCreateWindow(), and START_TEST().

◆ s_uShellHookMsg

UINT s_uShellHookMsg = 0
static

Definition at line 10 of file ShellHook.cpp.

Referenced by START_TEST(), and WindowProc().