ReactOS 0.4.16-dev-1948-gd260c1d
wlntfytests.c File Reference
#include <stdlib.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <winuser.h>
#include <windowsx.h>
#include <winwlx.h>
#include <ndk/rtlfuncs.h>
#include <strsafe.h>
#include "minitest.h"
Include dependency graph for wlntfytests.c:

Go to the source code of this file.

Classes

struct  _SYSTEM_USER_INFO
 
struct  _TEST_ENTRY
 

Macros

#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 
#define STANDALONE
 
#define WINE_DEFAULT_DEBUG_CHANNEL_EX(ch, flags)
 
#define NOTIFY_PKG_NAME   L"WLNotifyTests"
 
#define NOTIFY_REG_PATH   L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Notify\\" NOTIFY_PKG_NAME
 
#define DEFAULT_WINSTA0   L"WinSta0"
 
#define DESKTOP_WINLOGON   L"Winlogon"
 
#define DESKTOP_DEFAULT   L"Default"
 
#define DESKTOP_SCRSAVE   L"Screen-saver"
 
#define DUMP_WLX_NOTIFICATION(SysUserInfo, pInfo)    DumpNotificationState(__RELFILE__, __LINE__, __FUNCTION__, (SysUserInfo), (pInfo))
 
#define CHANGE_STATE(bChange, NewState)    ChangeNotificationState(__RELFILE__, __LINE__, __FUNCTION__, (bChange), (NewState))
 
#define BEGIN_TEST
 
#define END_TEST
 
#define ok_state_1(state1)
 
#define ok_state_2(state1, state2)
 
#define ok_state_3(state1, state2, state3)
 
#define __HANDLER_PARAM(pNotifInfo)   (_In_ PWLX_NOTIFICATION_INFO pNotifInfo)
 
#define WLNOTIFY_HANDLER(name)    VOID WINAPI name __HANDLER_PARAM
 
#define BEGIN_HANDLER
 
#define END_HANDLER(bChangeState, NewState)
 

Typedefs

typedef enum _WLNOTIFY_STATE WLNOTIFY_STATE
 
typedef struct _SYSTEM_USER_INFO SYSTEM_USER_INFO
 
typedef struct _SYSTEM_USER_INFOPSYSTEM_USER_INFO
 
typedef struct _TEST_ENTRY TEST_ENTRY
 
typedef struct _TEST_ENTRYPTEST_ENTRY
 

Enumerations

enum  _WLNOTIFY_STATE {
  WLNotify_NonInitialized = -1 , WLNotify_Startup , WLNotify_Shutdown , WLNotify_Logon ,
  WLNotify_Logoff , WLNotify_StartShell , WLNotify_PostShell , WLNotify_Lock ,
  WLNotify_Unlock , WLNotify_StartScreenSaver , WLNotify_StopScreenSaver , WLNotify_Disconnect ,
  WLNotify_Reconnect , WLNotify_MaxState
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL_EX (wlnotify_tests,(1<< __WINE_DBCL_TRACE)|(1<< __WINE_DBCL_WARN)|(1<< __WINE_DBCL_ERR)|(1<< __WINE_DBCL_FIXME))
 
FORCEINLINE BOOL IsUserLoggedIn (_In_ WLNOTIFY_STATE State)
 
FORCEINLINE VOID DbgBreakOnEvent (VOID)
 
static PCSTR NotifyStateToName (_In_ WLNOTIFY_STATE State)
 Maps a WLNOTIFY_STATE value to its human-readable name.
 
static VOID GetSettings (VOID)
 Retrieves the notification settings from the registry.
 
static PWSTR GetUserObjectName (_In_ HANDLE hObj, _Out_writes_opt_z_(cchBufLength) PWSTR PreAllocBuffer, _In_range_(0, MAXDWORD/sizeof(WCHAR)) DWORD cchBufLength)
 Retrieves the name of the specified window station or desktop object.
 
static BOOL GetUserAndDomainName (_In_ HANDLE hToken, _Out_ PWSTR *UserName, _Out_ PWSTR *DomainName)
 Retrieves the user and domain names corresponding to the given token.
 
static PSYSTEM_USER_INFO GetSystemUserInfo (_In_ HANDLE hNotifToken, _In_ HDESK hNotifDesktop)
 
static VOID FreeSystemUserInfo (_Inout_ PSYSTEM_USER_INFO SysUserInfo)
 
static VOID DumpNotificationState (_In_ PCSTR FileName, _In_ INT LineNum, _In_ PCSTR FuncName, _In_ PSYSTEM_USER_INFO SysUserInfo, _In_ PWLX_NOTIFICATION_INFO pInfo)
 
static VOID ChangeNotificationState (_In_ PCSTR FileName, _In_ INT LineNum, _In_ PCSTR FuncName, _In_ BOOL bChange, _In_ WLNOTIFY_STATE NewState)
 
static DWORD DisplayWlxMessageW (_In_opt_ PFNMSGECALLBACK pStatusCallback, _In_ BOOL bVerbose, _In_ PCWSTR pMessage)
 
static DWORD DisplayWlxMessageA (_In_opt_ PFNMSGECALLBACK pStatusCallback, _In_ BOOL bVerbose, _In_ PCSTR pMessage)
 
static void DoTest (const char *file, int line, const char *funcname, _In_ PSYSTEM_USER_INFO SysUserInfo, _In_ PWLX_NOTIFICATION_INFO pInfo, _In_ PTEST_ENTRY pTest)
 
WLNOTIFY_HANDLER() WLEventStartup (pInfo)
 Invoked at system startup.
 
WLNOTIFY_HANDLER() WLEventShutdown (pInfo)
 Invoked at system shutdown.
 
WLNOTIFY_HANDLER() WLEventLogon (pInfo)
 Invoked at user logon.
 
WLNOTIFY_HANDLER() WLEventLogoff (pInfo)
 Invoked at user logoff.
 
WLNOTIFY_HANDLER() WLEventStartShell (pInfo)
 Invoked just before starting the user shell.
 
WLNOTIFY_HANDLER() WLEventPostShell (pInfo)
 Invoked just after starting the user shell.
 
WLNOTIFY_HANDLER() WLEventLock (pInfo)
 Invoked at workstation locking.
 
WLNOTIFY_HANDLER() WLEventUnlock (pInfo)
 Invoked at workstation unlocking.
 
WLNOTIFY_HANDLER() WLEventStartScreenSaver (pInfo)
 Invoked at screensaver start.
 
WLNOTIFY_HANDLER() WLEventStopScreenSaver (pInfo)
 Invoked at screensaver stop.
 
WLNOTIFY_HANDLER() WLEventDisconnect (pInfo)
 Invoked at workstation disconnect (Terminal Services).
 
WLNOTIFY_HANDLER() WLEventReconnect (pInfo)
 Invoked at workstation reconnect (Terminal Services).
 
BOOL WINAPI DllMain (_In_ HINSTANCE hInstance, _In_ DWORD dwReason, _In_ PVOID pReserved)
 
HRESULT WINAPI DllRegisterServer (VOID)
 
HRESULT WINAPI DllUnregisterServer (VOID)
 

Variables

static const PCSTR NotifyStateName []
 
static WLNOTIFY_STATE g_CurrentState = WLNotify_NonInitialized
 
static WLNOTIFY_STATE g_PreviousState = WLNotify_NonInitialized
 
static ULONG g_fLogoffShutdownFlags = EWX_LOGOFF
 
static HMODULE g_hModule = NULL
 
static BOOL g_bInitialized = FALSE
 TRUE when the flags have been initialized.
 
struct {
   UINT8   bAsync: 1
 
   UINT8   bImpersonate: 1
 
   UINT8   Reserved: 6
 
g_fFlags = {0}
 
struct {
   PCWSTR   ValueName
 
   PCWSTR   Value
 
NotifyEvents []
 

Macro Definition Documentation

◆ __HANDLER_PARAM

#define __HANDLER_PARAM (   pNotifInfo)    (_In_ PWLX_NOTIFICATION_INFO pNotifInfo)

Definition at line 918 of file wlntfytests.c.

◆ BEGIN_HANDLER

#define BEGIN_HANDLER
Value:
/*(SysUserInfo, pInfo)*/ \
PSYSTEM_USER_INFO SysUserInfo; \
SysUserInfo = GetSystemUserInfo(pInfo->hToken, pInfo->hDesktop); \
DUMP_WLX_NOTIFICATION(SysUserInfo, pInfo); \
DisplayWlxMessageA(pInfo->pStatusCallback, FALSE, __FUNCTION__); \
DbgBreakOnEvent();
#define FALSE
Definition: types.h:117
#define __FUNCTION__
Definition: types.h:116
static PSYSTEM_USER_INFO GetSystemUserInfo(_In_ HANDLE hNotifToken, _In_ HDESK hNotifDesktop)
Definition: wlntfytests.c:431

Definition at line 922 of file wlntfytests.c.

◆ BEGIN_TEST

#define BEGIN_TEST
Value:
do { \
static const struct test winetest_testlist[] = { { __FUNCTION__, NULL } }; \
init_test( &winetest_testlist[0] ); \
winetest_push_context("**** %s", __FUNCTION__); \
{
#define NULL
Definition: types.h:112
#define test
Definition: rosglue.h:37
const struct test winetest_testlist[]
Definition: testlist.c:7

Definition at line 727 of file wlntfytests.c.

◆ CHANGE_STATE

#define CHANGE_STATE (   bChange,
  NewState 
)     ChangeNotificationState(__RELFILE__, __LINE__, __FUNCTION__, (bChange), (NewState))

Definition at line 675 of file wlntfytests.c.

◆ DEFAULT_WINSTA0

#define DEFAULT_WINSTA0   L"WinSta0"

Definition at line 50 of file wlntfytests.c.

◆ DESKTOP_DEFAULT

#define DESKTOP_DEFAULT   L"Default"

Definition at line 52 of file wlntfytests.c.

◆ DESKTOP_SCRSAVE

#define DESKTOP_SCRSAVE   L"Screen-saver"

Definition at line 53 of file wlntfytests.c.

◆ DESKTOP_WINLOGON

#define DESKTOP_WINLOGON   L"Winlogon"

Definition at line 51 of file wlntfytests.c.

◆ DUMP_WLX_NOTIFICATION

#define DUMP_WLX_NOTIFICATION (   SysUserInfo,
  pInfo 
)     DumpNotificationState(__RELFILE__, __LINE__, __FUNCTION__, (SysUserInfo), (pInfo))

Definition at line 650 of file wlntfytests.c.

◆ END_HANDLER

#define END_HANDLER (   bChangeState,
  NewState 
)
Value:
FreeSystemUserInfo(SysUserInfo); \
/* Change (bChangeState == TRUE) or Restore previous (FALSE) state */ \
CHANGE_STATE(bChangeState, NewState);
static VOID FreeSystemUserInfo(_Inout_ PSYSTEM_USER_INFO SysUserInfo)
Definition: wlntfytests.c:591

Definition at line 929 of file wlntfytests.c.

◆ END_TEST

#define END_TEST
Value:
} \
winetest_pop_context(); \
(void)fini_test(); \
} while(0);

Definition at line 734 of file wlntfytests.c.

◆ NOTIFY_PKG_NAME

#define NOTIFY_PKG_NAME   L"WLNotifyTests"

Definition at line 47 of file wlntfytests.c.

◆ NOTIFY_REG_PATH

#define NOTIFY_REG_PATH   L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Notify\\" NOTIFY_PKG_NAME

Definition at line 48 of file wlntfytests.c.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 27 of file wlntfytests.c.

◆ ok_state_1

#define ok_state_1 (   state1)
Value:
ok(g_CurrentState == (state1), \
"ERROR: Wrong state %s, expected %s\n", \
#define ok(value,...)
Definition: atltest.h:57
static WLNOTIFY_STATE g_CurrentState
Definition: wlntfytests.c:90
static PCSTR NotifyStateToName(_In_ WLNOTIFY_STATE State)
Maps a WLNOTIFY_STATE value to its human-readable name.
Definition: wlntfytests.c:164

Definition at line 740 of file wlntfytests.c.

◆ ok_state_2

#define ok_state_2 (   state1,
  state2 
)
Value:
ok(g_CurrentState == (state1) || g_CurrentState == (state2), \
"ERROR: Wrong state %s, expected %s or %s\n", \
NotifyStateToName(state1), \

Definition at line 746 of file wlntfytests.c.

◆ ok_state_3

#define ok_state_3 (   state1,
  state2,
  state3 
)
Value:
ok(g_CurrentState == (state1) || g_CurrentState == (state2) || g_CurrentState == (state3), \
"ERROR: Wrong state %s, expected %s or %s or %s\n", \
NotifyStateToName(state1), \
NotifyStateToName(state2), \

Definition at line 753 of file wlntfytests.c.

◆ STANDALONE

#define STANDALONE

Definition at line 32 of file wlntfytests.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 19 of file wlntfytests.c.

◆ WINE_DEFAULT_DEBUG_CHANNEL_EX

#define WINE_DEFAULT_DEBUG_CHANNEL_EX (   ch,
  flags 
)
Value:
static struct __wine_debug_channel __wine_dbch_##ch = { (unsigned char)(flags), #ch }; \
static struct __wine_debug_channel * const __wine_dbch___default = &__wine_dbch_##ch
unsigned char
Definition: typeof.h:29
GLbitfield flags
Definition: glext.h:7161

Definition at line 35 of file wlntfytests.c.

◆ WLNOTIFY_HANDLER

#define WLNOTIFY_HANDLER (   name)     VOID WINAPI name __HANDLER_PARAM

Definition at line 919 of file wlntfytests.c.

Typedef Documentation

◆ PSYSTEM_USER_INFO

◆ PTEST_ENTRY

◆ SYSTEM_USER_INFO

◆ TEST_ENTRY

◆ WLNOTIFY_STATE

Enumeration Type Documentation

◆ _WLNOTIFY_STATE

Enumerator
WLNotify_NonInitialized 
WLNotify_Startup 
WLNotify_Shutdown 
WLNotify_Logon 
WLNotify_Logoff 
WLNotify_StartShell 
WLNotify_PostShell 
WLNotify_Lock 
WLNotify_Unlock 
WLNotify_StartScreenSaver 
WLNotify_StopScreenSaver 
WLNotify_Disconnect 
WLNotify_Reconnect 
WLNotify_MaxState 

Definition at line 55 of file wlntfytests.c.

56{
@ WLNotify_StartShell
Definition: wlntfytests.c:62
@ WLNotify_Disconnect
Definition: wlntfytests.c:68
@ WLNotify_Logoff
Definition: wlntfytests.c:61
@ WLNotify_PostShell
Definition: wlntfytests.c:63
@ WLNotify_StopScreenSaver
Definition: wlntfytests.c:67
@ WLNotify_Lock
Definition: wlntfytests.c:64
@ WLNotify_StartScreenSaver
Definition: wlntfytests.c:66
@ WLNotify_Startup
Definition: wlntfytests.c:58
@ WLNotify_Unlock
Definition: wlntfytests.c:65
@ WLNotify_NonInitialized
Definition: wlntfytests.c:57
@ WLNotify_Logon
Definition: wlntfytests.c:60
@ WLNotify_MaxState
Definition: wlntfytests.c:70
@ WLNotify_Shutdown
Definition: wlntfytests.c:59
@ WLNotify_Reconnect
Definition: wlntfytests.c:69
enum _WLNOTIFY_STATE WLNOTIFY_STATE

Function Documentation

◆ ChangeNotificationState()

static VOID ChangeNotificationState ( _In_ PCSTR  FileName,
_In_ INT  LineNum,
_In_ PCSTR  FuncName,
_In_ BOOL  bChange,
_In_ WLNOTIFY_STATE  NewState 
)
static

Definition at line 655 of file wlntfytests.c.

661{
662 // TRACE(
663 ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default,
664 FileName, FuncName, LineNum,
665 "**** %s: %s state %s %s %s\n",
666 FuncName,
667 bChange ? "Changing" : "Restoring",
669 bChange ? "to" : "back to",
670 NotifyStateToName(NewState));
671
673}
#define InterlockedExchange
Definition: armddk.h:54
macro IMPORT Name endm macro EXPORT Name global &Name endm macro TEXTAREA section rx align endm macro DATAAREA section rw endm macro RODATAAREA section rw endm macro NESTED_ENTRY Name FuncName equ &Name PrologName equ &Name &_Prolog FuncEndName equ &Name &_end global &FuncName align func &FuncName & FuncName
Definition: kxarm.h:221
@ __WINE_DBCL_ERR
Definition: debug.h:52
const char int int int ros_dbg_log(enum __wine_debug_class cls, struct __wine_debug_channel *ch, const char *file, const char *func, const int line, const char *format,...) __WINE_PRINTF_ATTR(6
int32_t * PLONG
Definition: typedefs.h:58
static WLNOTIFY_STATE g_PreviousState
Definition: wlntfytests.c:91

◆ DbgBreakOnEvent()

FORCEINLINE VOID DbgBreakOnEvent ( VOID  )

Definition at line 147 of file wlntfytests.c.

148{
149 if (IsDebuggerPresent())
151}
BOOL WINAPI IsDebuggerPresent(void)
Definition: debug.c:167
NTSYSAPI void WINAPI DbgBreakPoint(void)

◆ DisplayWlxMessageA()

static DWORD DisplayWlxMessageA ( _In_opt_ PFNMSGECALLBACK  pStatusCallback,
_In_ BOOL  bVerbose,
_In_ PCSTR  pMessage 
)
static

Definition at line 699 of file wlntfytests.c.

703{
705 DWORD dwRet;
706 ANSI_STRING MessageA;
707 UNICODE_STRING MessageU;
708
709 if (!pStatusCallback)
710 return (DWORD)(-1);
711
712 RtlInitAnsiString(&MessageA, pMessage);
713 Status = RtlAnsiStringToUnicodeString(&MessageU, &MessageA, TRUE);
714 if (!NT_SUCCESS(Status))
715 return (DWORD)(-1);
716
717 dwRet = DisplayWlxMessageW(pStatusCallback, bVerbose, MessageU.Buffer);
718
719 RtlFreeUnicodeString(&MessageU);
720
721 return dwRet;
722}
LONG NTSTATUS
Definition: precomp.h:26
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
BOOL bVerbose
Definition: logoff.c:26
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
static DWORD DisplayWlxMessageW(_In_opt_ PFNMSGECALLBACK pStatusCallback, _In_ BOOL bVerbose, _In_ PCWSTR pMessage)
Definition: wlntfytests.c:680

◆ DisplayWlxMessageW()

static DWORD DisplayWlxMessageW ( _In_opt_ PFNMSGECALLBACK  pStatusCallback,
_In_ BOOL  bVerbose,
_In_ PCWSTR  pMessage 
)
static

Definition at line 680 of file wlntfytests.c.

684{
685 DWORD dwRet;
686
687 if (!pStatusCallback)
688 return (DWORD)(-1);
689
690 dwRet = pStatusCallback(bVerbose, (LPWSTR)pMessage);
691
692 /* Do a 1-second delay so that the message can be seen while testing */
693 Sleep(1000);
694
695 return dwRet;
696}
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DisplayWlxMessageA().

◆ DllMain()

BOOL WINAPI DllMain ( _In_ HINSTANCE  hInstance,
_In_ DWORD  dwReason,
_In_ PVOID  pReserved 
)

Definition at line 1284 of file wlntfytests.c.

1288{
1289 // DPRINTF
1290 TRACE("\nWLNOTIFY(%lx.%lx): Entering `%s`(hInst: 0x%p, dwReason: 0x%x, pReserved: 0x%p)\n",
1291 GetCurrentProcessId(), // NtCurrentTeb()->ClientId.UniqueProcess
1292 GetCurrentThreadId(), // NtCurrentTeb()->ClientId.UniqueThread
1294
1295 switch (dwReason)
1296 {
1297 case DLL_PROCESS_ATTACH:
1301
1302 case DLL_PROCESS_DETACH:
1303 {
1304 // DPRINTF
1305 ERR("\nWLNOTIFY(%lx.%lx): Entering `%s`(hInst: 0x%p, dwReason: 0x%x, pReserved: 0x%p)\n",
1306 GetCurrentProcessId(), // NtCurrentTeb()->ClientId.UniqueProcess
1307 GetCurrentThreadId(), // NtCurrentTeb()->ClientId.UniqueThread
1309
1310 /* Reset to detect any unwanted reloads */
1312 break;
1313 }
1314 }
1315
1316 return TRUE;
1317}
#define ERR(fmt,...)
Definition: precomp.h:57
DWORD dwReason
Definition: misc.cpp:135
HINSTANCE hInstance
Definition: charmap.c:19
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
_Out_ PVOID pReserved
Definition: netsh.h:77
#define __fallthrough
Definition: sal_old.h:314
#define TRACE(s)
Definition: solgame.cpp:4
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
#define GetInstanceModule(hInstance)
Definition: windowsx.h:303
static HMODULE g_hModule
Definition: wlntfytests.c:93

◆ DllRegisterServer()

HRESULT WINAPI DllRegisterServer ( VOID  )

Definition at line 1344 of file wlntfytests.c.

1345{
1346 HKEY hNotifyKey;
1347 LSTATUS lError;
1348 UINT i;
1349 DWORD dwValue;
1350 DWORD dwPathSize;
1351 WCHAR szModule[MAX_PATH];
1352
1353 dwPathSize = GetModuleFileNameW(g_hModule, szModule, _countof(szModule));
1354 szModule[_countof(szModule) - 1] = UNICODE_NULL; // Ensure NULL-termination (see WinXP bug)
1355
1356 if ( !((dwPathSize != 0) && (dwPathSize < _countof(szModule)) &&
1358 {
1359 /* Failed to retrieve the module path */
1360 return E_FAIL; // Cannot register.
1361 }
1362
1365 0,
1366 NULL,
1369 NULL,
1370 &hNotifyKey,
1371 NULL);
1372 if (lError != ERROR_SUCCESS)
1373 {
1374 ERR("RegCreateKeyExW() failed; error %lu\n", lError);
1375 return HRESULT_FROM_WIN32(lError); // Cannot register.
1376 }
1377
1378 RegSetValueExW(hNotifyKey, L"DllName", 0, REG_EXPAND_SZ,
1379 (PBYTE)szModule, (DWORD)(wcslen(szModule) + 1) * sizeof(WCHAR));
1380
1381 /* Make the notifications synchronous by default */
1382 dwValue = 0;
1383 RegSetValueExW(hNotifyKey, L"Asynchronous", 0, REG_DWORD, (PBYTE)&dwValue, sizeof(dwValue));
1384
1385 /* Don't impersonate the user when being invoked */
1386 dwValue = 0;
1387 RegSetValueExW(hNotifyKey, L"Impersonate", 0, REG_DWORD, (PBYTE)&dwValue, sizeof(dwValue));
1388
1389 /* Can be invoked also in SafeMode */
1390 dwValue = 1;
1391 RegSetValueExW(hNotifyKey, L"SafeMode", 0, REG_DWORD, (PBYTE)&dwValue, sizeof(dwValue));
1392
1393 // dwValue = 600;
1394 // RegSetValueExW(hNotifyKey, L"MaxWait", 0, REG_DWORD, (PBYTE)&dwValue, sizeof(dwValue));
1395
1396 for (i = 0; i < _countof(NotifyEvents); ++i)
1397 {
1399 0, REG_SZ,
1401 (DWORD)(wcslen(NotifyEvents[i].Value) + 1) * sizeof(WCHAR));
1402 }
1403
1404 RegCloseKey(hNotifyKey);
1405
1406 return S_OK; // Registration successful.
1407}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define E_FAIL
Definition: ddrawi.h:102
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
#define L(x)
Definition: resources.c:13
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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define S_OK
Definition: intsafe.h:52
#define REG_SZ
Definition: layer.c:22
unsigned int UINT
Definition: ndis.h:50
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1060
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
#define KEY_SET_VALUE
Definition: nt_native.h:1020
#define UNICODE_NULL
BYTE * PBYTE
Definition: pedump.c:66
#define REG_DWORD
Definition: sdbapi.c:615
#define _countof(array)
Definition: sndvol32.h:70
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define NOTIFY_REG_PATH
Definition: wlntfytests.c:48
static const struct @1774 NotifyEvents[]
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ DllUnregisterServer()

HRESULT WINAPI DllUnregisterServer ( VOID  )

Definition at line 1409 of file wlntfytests.c.

1410{
1411 LSTATUS lError;
1412
1414 if (lError == ERROR_FILE_NOT_FOUND)
1415 return S_FALSE; // Nothing to unregister, not a failure per se.
1416 if (lError != ERROR_SUCCESS)
1417 {
1418 ERR("RegDeleteKeyW() failed; error %lu\n", lError);
1419 return HRESULT_FROM_WIN32(lError);
1420 }
1421 return S_OK; // Unregistration successful.
1422}
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define S_FALSE
Definition: winerror.h:3451

◆ DoTest()

static void DoTest ( const char file,
int  line,
const char funcname,
_In_ PSYSTEM_USER_INFO  SysUserInfo,
_In_ PWLX_NOTIFICATION_INFO  pInfo,
_In_ PTEST_ENTRY  pTest 
)
static

Definition at line 774 of file wlntfytests.c.

778{
781 UNREFERENCED_PARAMETER(funcname); // Displayed via winetest_push_context()
782
783 if (pTest->NumStates == 1)
784 ok_state_1(pTest->AllowedStates[0]);
785 else if (pTest->NumStates == 2)
786 ok_state_2(pTest->AllowedStates[0], pTest->AllowedStates[1]);
787 else if (pTest->NumStates == 3)
788 ok_state_3(pTest->AllowedStates[0], pTest->AllowedStates[1], pTest->AllowedStates[2]);
789 else
790 skip("Unsupported number of allowed notify states: %lu\n", pTest->NumStates);
791
792 ok(SysUserInfo->hProcToken != NULL, "Expected hProcToken != NULL\n");
793 ok(SysUserInfo->pProcDomainName != NULL, "Expected pProcDomainName != NULL\n");
794 ok(SysUserInfo->pProcUserName != NULL, "Expected pProcUserName != NULL\n");
795
796 if (pTest->bThrdToken)
797 {
798 ok(SysUserInfo->hThrdToken != NULL, "Expected hThrdToken != NULL\n");
799
800 ok(SysUserInfo->pThrdDomainName != NULL, "Expected pThrdDomainName != NULL\n");
801 if (!SysUserInfo->pThrdDomainName || !SysUserInfo->pNotifDomainName)
802 skip("Skipped pThrdDomainName/pNotifDomainName test\n");
803 else
804 ok_wstr(SysUserInfo->pThrdDomainName, SysUserInfo->pNotifDomainName);
805
806 ok(SysUserInfo->pThrdUserName != NULL, "Expected pThrdUserName != NULL\n");
807 if (!SysUserInfo->pThrdUserName || !SysUserInfo->pNotifUserName)
808 skip("Skipped pThrdUserName/pNotifUserName test\n");
809 else
810 ok_wstr(SysUserInfo->pThrdUserName, SysUserInfo->pNotifUserName);
811 }
812 else
813 {
814 ok(SysUserInfo->hThrdToken == NULL, "Expected hThrdToken == NULL\n");
815 ok(SysUserInfo->pThrdDomainName == NULL, "Expected pThrdDomainName == NULL\n");
816 ok(SysUserInfo->pThrdUserName == NULL, "Expected pThrdUserName == NULL\n");
817 }
818
819 if (pTest->bUserLoggedIn)
820 {
821 /* See also pInfo->UserName and pInfo->Domain below */
822 ok(pInfo->hToken != NULL, "Expected pInfo->hToken != NULL\n");
823 ok(SysUserInfo->pNotifDomainName != NULL, "Expected pNotifDomainName != NULL\n");
824 ok(SysUserInfo->pNotifUserName != NULL, "Expected pNotifUserName != NULL\n");
825 }
826 else
827 {
828 ok(pInfo->hToken == NULL, "Expected pInfo->hToken == NULL\n");
829 ok(SysUserInfo->pNotifDomainName == NULL, "Expected pNotifDomainName == NULL\n");
830 ok(SysUserInfo->pNotifUserName == NULL, "Expected pNotifUserName == NULL\n");
831 }
832
833 // if (pTest->pszWinSta) // Expected winsta -- DEFAULT_WINSTA0
834 ok(SysUserInfo->hWinSta != NULL, "Expected hProcWinSta != NULL\n");
835 ok(SysUserInfo->pszWinSta != NULL, "Expected pszWinSta != NULL\n");
836 if (!SysUserInfo->pszWinSta)
837 skip("Skipped pszWinSta test\n");
838 else
839 ok_wstr(SysUserInfo->pszWinSta, /*pTest->pszWinSta*/ DEFAULT_WINSTA0);
840
841 // if (pTest->pszThreadDesk) // Expected thread desk -- DESKTOP_WINLOGON
842 ok(SysUserInfo->hThreadDesk != NULL, "Expected hThreadDesk != NULL\n");
843 ok(SysUserInfo->pszThreadDesk != NULL, "Expected pszThreadDesk != NULL\n");
844 if (!SysUserInfo->pszThreadDesk)
845 skip("Skipped pszThreadDesk test\n");
846 else
847 ok_wstr(SysUserInfo->pszThreadDesk, DESKTOP_WINLOGON);
848
849 if (pTest->pszInputDesk)
850 {
851 ok(SysUserInfo->hInputDesk != NULL, "Expected hInputDesk != NULL\n");
852 ok(SysUserInfo->pszInputDesk != NULL, "Expected pszInputDesk != NULL\n");
853 if (!SysUserInfo->pszInputDesk)
854 skip("Skipped pszInputDesk test\n");
855 else
856 ok_wstr(SysUserInfo->pszInputDesk, pTest->pszInputDesk);
857 }
858 else
859 {
860 ok(SysUserInfo->hInputDesk == NULL, "Expected hInputDesk == NULL\n");
861 ok(SysUserInfo->pszInputDesk == NULL, "Expected pszInputDesk == NULL\n");
862 }
863
864 // if (pTest->pszNotifDesk)
865 ok(pInfo->hDesktop != NULL, "Expected pInfo->hDesktop != NULL\n");
866 ok(SysUserInfo->pszNotifDesk != NULL, "Expected pszNotifDesk != NULL\n");
867 if (!SysUserInfo->pszNotifDesk)
868 skip("Skipped pszNotifDesk test\n");
869 else
870 ok_wstr(SysUserInfo->pszNotifDesk, pTest->pszNotifDesk);
871
872 ok_int(pInfo->Size, sizeof(*pInfo)); // == sizeof(WLX_NOTIFICATION_INFO);
873 // ok_int(pInfo->Flags, 0); // This is tested separately: more than one flag is possible.
874
875 if (pTest->bUserLoggedIn)
876 {
877 ok(pInfo->UserName != NULL, "Expected pInfo->UserName != NULL\n");
878 ok(pInfo->Domain != NULL, "Expected pInfo->Domain != NULL\n");
879 // ok(pInfo->hToken != NULL, "Expected pInfo->hToken != NULL\n");
880
881 if (!pInfo->UserName || !SysUserInfo->pNotifUserName)
882 skip("Skipped UserName/pNotifUserName test\n");
883 else
884 ok_wstr(pInfo->UserName, SysUserInfo->pNotifUserName);
885
886 if (!pInfo->Domain || !SysUserInfo->pNotifDomainName)
887 skip("Skipped Domain/pNotifDomainName test\n");
888 else
889 ok_wstr(pInfo->Domain, SysUserInfo->pNotifDomainName);
890 }
891 else
892 {
893 ok(pInfo->UserName == NULL, "Expected pInfo->UserName == NULL\n");
894 ok(pInfo->Domain == NULL, "Expected pInfo->Domain == NULL\n");
895 // ok(pInfo->hToken == NULL, "Expected pInfo->hToken == NULL\n");
896 }
897
898 ok(pInfo->WindowStation != NULL, "Expected pInfo->WindowStation != NULL\n");
899 if (!pInfo->WindowStation || !SysUserInfo->pszWinSta)
900 skip("Skipped WindowStation/pszWinSta test\n");
901 else
902 ok_wstr(pInfo->WindowStation, SysUserInfo->pszWinSta);
903
904 if (wcscmp(pTest->pszNotifDesk, /*pTest->pszThreadDesk*/ DESKTOP_WINLOGON) == 0)
905 ok(pInfo->hDesktop == SysUserInfo->hThreadDesk, "Expected pInfo->hDesktop == hThreadDesk\n");
906 else
907 ok(pInfo->hDesktop != SysUserInfo->hThreadDesk, "Expected pInfo->hDesktop != hThreadDesk\n");
908
909 if (g_fFlags.bAsync)
910 ok(pInfo->pStatusCallback == NULL, "Expected pStatusCallback == NULL, was: 0x%p\n", pInfo->pStatusCallback);
911 else
912 ok(pInfo->pStatusCallback != NULL, "Expected pStatusCallback != NULL\n");
913}
#define skip(...)
Definition: atltest.h:64
#define ok_wstr(x, y)
Definition: atltest.h:130
#define ok_int(expression, result)
Definition: atltest.h:134
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define funcname
Definition: shellext.h:96
Definition: fci.c:127
Definition: parser.c:49
#define ok_state_2(state1, state2)
Definition: wlntfytests.c:746
#define ok_state_1(state1)
Definition: wlntfytests.c:740
static struct @1773 g_fFlags
#define DESKTOP_WINLOGON
Definition: wlntfytests.c:51
#define DEFAULT_WINSTA0
Definition: wlntfytests.c:50
#define ok_state_3(state1, state2, state3)
Definition: wlntfytests.c:753

Referenced by WLEventLock(), WLEventLogoff(), WLEventLogon(), WLEventPostShell(), WLEventShutdown(), WLEventStartScreenSaver(), WLEventStartShell(), WLEventStartup(), WLEventStopScreenSaver(), and WLEventUnlock().

◆ DumpNotificationState()

static VOID DumpNotificationState ( _In_ PCSTR  FileName,
_In_ INT  LineNum,
_In_ PCSTR  FuncName,
_In_ PSYSTEM_USER_INFO  SysUserInfo,
_In_ PWLX_NOTIFICATION_INFO  pInfo 
)
static

Definition at line 602 of file wlntfytests.c.

608{
609 /*
610 * Dump the information and the WLX_NOTIFICATION_INFO structure.
611 */
612 // TRACE(
613 ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default,
614 FileName, FuncName, LineNum,
615 "\nWLNOTIFY(%lx.%lx) [Async: %s, Impers: %s]: Entering `%s`\n"
616 "\tProcess Token : 0x%p - User: '%S\\%S'\n"
617 "\tThread Token : 0x%p - User: '%S\\%S'\n"
618 "\tNotif Token : 0x%p - User: '%S\\%S'\n"
619 "\tProcess WinSta : 0x%p '%S'\n"
620 "\tThread Desktop : 0x%p '%S'\n"
621 "\tInput Desktop : 0x%p '%S'\n"
622 "\tNotif Desktop : 0x%p '%S'\n",
623 GetCurrentProcessId(), // NtCurrentTeb()->ClientId.UniqueProcess
624 GetCurrentThreadId(), // NtCurrentTeb()->ClientId.UniqueThread
625 g_fFlags.bAsync ? "TRUE" : "FALSE",
626 g_fFlags.bImpersonate ? "TRUE" : "FALSE",
627 FuncName,
628 SysUserInfo->hProcToken, SysUserInfo->pProcDomainName, SysUserInfo->pProcUserName,
629 SysUserInfo->hThrdToken, SysUserInfo->pThrdDomainName, SysUserInfo->pThrdUserName,
630 pInfo->hToken, SysUserInfo->pNotifDomainName, SysUserInfo->pNotifUserName,
631 SysUserInfo->hWinSta, SysUserInfo->pszWinSta,
632 SysUserInfo->hThreadDesk, SysUserInfo->pszThreadDesk,
633 SysUserInfo->hInputDesk, SysUserInfo->pszInputDesk,
634 pInfo->hDesktop, SysUserInfo->pszNotifDesk);
635 // if (__WINE_IS_DEBUG_ON(_ERR, __wine_dbch___default))
636 DPRINTF(
637 "\tInfo.Size : %lu\n"
638 "\tInfo.Flags : 0x%lx\n"
639 "\tInfo.UserName : '%S'\n"
640 "\tInfo.Domain : '%S'\n"
641 "\tInfo.WindowStation : '%S'\n"
642 "\tInfo.hToken : 0x%p\n"
643 "\tInfo.hDesktop : 0x%p\n"
644 "\tInfo.pStatusCallback: 0x%p\n",
645 pInfo->Size, pInfo->Flags, pInfo->UserName,
646 pInfo->Domain, pInfo->WindowStation, pInfo->hToken,
647 pInfo->hDesktop, pInfo->pStatusCallback);
648}
#define DPRINTF
Definition: debug.h:414

◆ FreeSystemUserInfo()

static VOID FreeSystemUserInfo ( _Inout_ PSYSTEM_USER_INFO  SysUserInfo)
static

Definition at line 591 of file wlntfytests.c.

593{
594 CloseHandle(SysUserInfo->hProcToken);
595 CloseHandle(SysUserInfo->hThrdToken);
596 CloseDesktop(SysUserInfo->hInputDesk);
597 LocalFree(SysUserInfo);
598}
#define CloseHandle
Definition: compat.h:739
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
BOOL WINAPI CloseDesktop(_In_ HDESK)

◆ GetSettings()

static VOID GetSettings ( VOID  )
static

Retrieves the notification settings from the registry.

Definition at line 185 of file wlntfytests.c.

186{
187 HKEY hNotifyKey;
188 LSTATUS lError;
189 DWORD dwValue, dwSize, dwType;
190
192 return;
193
196 0,
198 &hNotifyKey);
199 if (lError != ERROR_SUCCESS)
200 {
201 ERR("RegOpenKeyExW() failed; error %lu\n", lError);
202 return; // HRESULT_FROM_WIN32(lError);
203 }
204
205 dwSize = sizeof(dwValue);
206 lError = RegQueryValueExW(hNotifyKey,
207 L"Asynchronous",
208 NULL,
209 &dwType,
210 (PBYTE)&dwValue,
211 &dwSize);
212 if ((lError == ERROR_SUCCESS) && (dwType == REG_DWORD) && (dwSize == sizeof(dwValue)))
213 g_fFlags.bAsync = !!dwValue;
214
215 dwSize = sizeof(dwValue);
216 lError = RegQueryValueExW(hNotifyKey,
217 L"Impersonate",
218 NULL,
219 &dwType,
220 (PBYTE)&dwValue,
221 &dwSize);
222 if ((lError == ERROR_SUCCESS) && (dwType == REG_DWORD) && (dwSize == sizeof(dwValue)))
223 g_fFlags.bImpersonate = !!dwValue;
224
225#if 0
226 dwSize = sizeof(dwValue);
227 lError = RegQueryValueExW(hNotifyKey,
228 L"MaxWait",
229 NULL,
230 &dwType,
231 (PBYTE)&dwValue,
232 &dwSize);
233 if ((lError == ERROR_SUCCESS) && (dwType == REG_DWORD) && (dwSize == sizeof(dwValue)))
234 g_dwMaxWait = !!dwValue;
235#endif
236
237 RegCloseKey(hNotifyKey);
238
239 return; // S_OK;
240}
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define InterlockedCompareExchange
Definition: interlocked.h:119
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
static BOOL g_bInitialized
TRUE when the flags have been initialized.
Definition: wlntfytests.c:94

Referenced by WLEventStartup().

◆ GetSystemUserInfo()

static PSYSTEM_USER_INFO GetSystemUserInfo ( _In_ HANDLE  hNotifToken,
_In_ HDESK  hNotifDesktop 
)
static

Definition at line 431 of file wlntfytests.c.

434{
435 SYSTEM_USER_INFO LocalInfo = {NULL}, *pSysUserInfo;
438 WCHAR szBuffer0[MAX_PATH], szBuffer1[MAX_PATH], szBuffer2[MAX_PATH], szBuffer3[MAX_PATH];
439
440 /* Retrieve the process' token and the corresponding user/domain */
442 {
443 GetUserAndDomainName(LocalInfo.hProcToken, &LocalInfo.pProcUserName, &LocalInfo.pProcDomainName);
444 // CloseHandle(LocalInfo.hProcToken);
445 }
446
447 /* Retrieve the current thread's impersonation token, if any (otherwise
448 * no impersonation occurs), and the corresponding user/domain */
450 {
451 GetUserAndDomainName(LocalInfo.hThrdToken, &LocalInfo.pThrdUserName, &LocalInfo.pThrdDomainName);
452 // CloseHandle(LocalInfo.hThrdToken);
453 }
454
455 /* Retrieve the notification's corresponding user/domain */
456 GetUserAndDomainName(hNotifToken, &LocalInfo.pNotifUserName, &LocalInfo.pNotifDomainName);
457
458 /* Retrieve the process' window station name */
459 LocalInfo.hWinSta = GetProcessWindowStation();
460 LocalInfo.pszWinSta = GetUserObjectName(LocalInfo.hWinSta, szBuffer0, _countof(szBuffer0));
461
462 /* Retrieve the thread desktop name */
464 LocalInfo.pszThreadDesk = GetUserObjectName(LocalInfo.hThreadDesk, szBuffer1, _countof(szBuffer1));
465
466 /* Retrieve the input desktop name */
468 LocalInfo.pszInputDesk = GetUserObjectName(LocalInfo.hInputDesk, szBuffer2, _countof(szBuffer2));
469 // CloseDesktop(LocalInfo.hInputDesk);
470
471 /* Retrieve the notification desktop name */
472 LocalInfo.pszNotifDesk = GetUserObjectName(hNotifDesktop, szBuffer3, _countof(szBuffer3));
473
474
475 /* Allocate a single buffer to hold all the retrieved information */
476 BufSize = sizeof(*pSysUserInfo) +
477 ((LocalInfo.pProcUserName ? wcslen(LocalInfo.pProcUserName) + 1 : 0) +
478 (LocalInfo.pProcDomainName ? wcslen(LocalInfo.pProcDomainName) + 1 : 0) +
479 (LocalInfo.pThrdUserName ? wcslen(LocalInfo.pThrdUserName) + 1 : 0) +
480 (LocalInfo.pThrdDomainName ? wcslen(LocalInfo.pThrdDomainName) + 1 : 0) +
481 (LocalInfo.pNotifUserName ? wcslen(LocalInfo.pNotifUserName) + 1 : 0) +
482 (LocalInfo.pNotifDomainName ? wcslen(LocalInfo.pNotifDomainName) + 1 : 0) +
483 (LocalInfo.pszWinSta ? wcslen(LocalInfo.pszWinSta) + 1 : 0) +
484 (LocalInfo.pszThreadDesk ? wcslen(LocalInfo.pszThreadDesk) + 1 : 0) +
485 (LocalInfo.pszInputDesk ? wcslen(LocalInfo.pszInputDesk) + 1 : 0) +
486 (LocalInfo.pszNotifDesk ? wcslen(LocalInfo.pszNotifDesk) + 1 : 0)) * sizeof(WCHAR);
487 pSysUserInfo = LocalAlloc(LMEM_FIXED, BufSize);
488 if (!pSysUserInfo)
489 goto Done;
490
491 /* Copy the fixed part of the structure */
492 *pSysUserInfo = LocalInfo;
493
494 /* Copy the strings and adjust the pointers */
495 pString = (PWSTR)(pSysUserInfo + 1);
496 if (LocalInfo.pProcUserName)
497 {
498 wcscpy(pString, LocalInfo.pProcUserName);
499 pSysUserInfo->pProcUserName = pString;
500 pString += wcslen(pString) + 1;
501 }
502 if (LocalInfo.pProcDomainName)
503 {
504 wcscpy(pString, LocalInfo.pProcDomainName);
505 pSysUserInfo->pProcDomainName = pString;
506 pString += wcslen(pString) + 1;
507 }
508 if (LocalInfo.pThrdUserName)
509 {
510 wcscpy(pString, LocalInfo.pThrdUserName);
511 pSysUserInfo->pThrdUserName = pString;
512 pString += wcslen(pString) + 1;
513 }
514 if (LocalInfo.pThrdDomainName)
515 {
516 wcscpy(pString, LocalInfo.pThrdDomainName);
517 pSysUserInfo->pThrdDomainName = pString;
518 pString += wcslen(pString) + 1;
519 }
520 if (LocalInfo.pNotifUserName)
521 {
522 wcscpy(pString, LocalInfo.pNotifUserName);
523 pSysUserInfo->pNotifUserName = pString;
524 pString += wcslen(pString) + 1;
525 }
526 if (LocalInfo.pNotifDomainName)
527 {
528 wcscpy(pString, LocalInfo.pNotifDomainName);
529 pSysUserInfo->pNotifDomainName = pString;
530 pString += wcslen(pString) + 1;
531 }
532 if (LocalInfo.pszWinSta)
533 {
534 wcscpy(pString, LocalInfo.pszWinSta);
535 pSysUserInfo->pszWinSta = pString;
536 pString += wcslen(pString) + 1;
537 }
538 if (LocalInfo.pszThreadDesk)
539 {
540 wcscpy(pString, LocalInfo.pszThreadDesk);
541 pSysUserInfo->pszThreadDesk = pString;
542 pString += wcslen(pString) + 1;
543 }
544 if (LocalInfo.pszInputDesk)
545 {
546 wcscpy(pString, LocalInfo.pszInputDesk);
547 pSysUserInfo->pszInputDesk = pString;
548 pString += wcslen(pString) + 1;
549 }
550 if (LocalInfo.pszNotifDesk)
551 {
552 wcscpy(pString, LocalInfo.pszNotifDesk);
553 pSysUserInfo->pszNotifDesk = pString;
554 }
555
556Done:
557 if (LocalInfo.pszNotifDesk != szBuffer3)
558 LocalFree(LocalInfo.pszNotifDesk);
559 if (LocalInfo.pszInputDesk != szBuffer2)
560 LocalFree(LocalInfo.pszInputDesk);
561 if (LocalInfo.pszThreadDesk != szBuffer1)
562 LocalFree(LocalInfo.pszThreadDesk);
563 if (LocalInfo.pszWinSta != szBuffer0)
564 LocalFree(LocalInfo.pszWinSta);
565
566 if (LocalInfo.pNotifUserName)
567 LocalFree(LocalInfo.pNotifUserName);
568 if (LocalInfo.pNotifDomainName)
569 LocalFree(LocalInfo.pNotifDomainName);
570 if (LocalInfo.pThrdUserName)
571 LocalFree(LocalInfo.pThrdUserName);
572 if (LocalInfo.pThrdDomainName)
573 LocalFree(LocalInfo.pThrdDomainName);
574 if (LocalInfo.pProcUserName)
575 LocalFree(LocalInfo.pProcUserName);
576 if (LocalInfo.pProcDomainName)
577 LocalFree(LocalInfo.pProcDomainName);
578
579 /* If we failed to allocate the buffer, close the opened handles */
580 if (!pSysUserInfo)
581 {
582 CloseDesktop(LocalInfo.hInputDesk);
583 CloseHandle(LocalInfo.hThrdToken);
584 CloseHandle(LocalInfo.hProcToken);
585 }
586
587 return pSysUserInfo;
588}
#define BufSize
Definition: FsRtlTunnel.c:28
wcscpy
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
BOOL WINAPI OpenThreadToken(HANDLE ThreadHandle, DWORD DesiredAccess, BOOL OpenAsSelf, HANDLE *TokenHandle)
Definition: security.c:336
#define GetCurrentProcess()
Definition: compat.h:759
FxString * pString
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
#define LMEM_FIXED
Definition: minwinbase.h:81
#define STANDARD_RIGHTS_READ
Definition: nt_native.h:65
uint16_t * PWSTR
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
HWINSTA WINAPI GetProcessWindowStation(void)
Definition: ntwrapper.h:124
HDESK WINAPI GetThreadDesktop(_In_ DWORD)
HDESK WINAPI OpenInputDesktop(_In_ DWORD, _In_ BOOL, _In_ DWORD)
static PWSTR GetUserObjectName(_In_ HANDLE hObj, _Out_writes_opt_z_(cchBufLength) PWSTR PreAllocBuffer, _In_range_(0, MAXDWORD/sizeof(WCHAR)) DWORD cchBufLength)
Retrieves the name of the specified window station or desktop object.
Definition: wlntfytests.c:266
static BOOL GetUserAndDomainName(_In_ HANDLE hToken, _Out_ PWSTR *UserName, _Out_ PWSTR *DomainName)
Retrieves the user and domain names corresponding to the given token.
Definition: wlntfytests.c:335
#define TOKEN_QUERY
Definition: setypes.h:940

◆ GetUserAndDomainName()

static BOOL GetUserAndDomainName ( _In_ HANDLE  hToken,
_Out_ PWSTR UserName,
_Out_ PWSTR DomainName 
)
static

Retrieves the user and domain names corresponding to the given token.

Parameters
[in]hTokenHandle to the user token, for which to retrieve the user and domain names.
[out]UserNameReceives in output, a pointer to an allocated string representing the user name. The string is allocated with LocalAlloc(). After usage, free the pointer with LocalFree().
[out]DomainNameReceives in output, a pointer to an allocated string representing the domain name. The string is allocated with LocalAlloc(). After usage, free the pointer with LocalFree().
Returns
TRUE if the information has been retrieved successfully; FALSE if not.
See also
Copied and adapted from dll/win32/userenv/environment.c!GetUserAndDomainName See also base/shell/progman/main.c!GetUserAndDomainName

Definition at line 335 of file wlntfytests.c.

339{
340 BOOL bRet = FALSE;
341 DWORD cbTokenBuffer = 0;
342 PTOKEN_USER pUserToken;
343
345 PWSTR pDomainName = NULL;
346 DWORD cbUserName = 0;
347 DWORD cbDomainName = 0;
348
349 SID_NAME_USE SidNameUse;
350
351 /* Retrieve token's information */
352 if (!GetTokenInformation(hToken, TokenUser, NULL, 0, &cbTokenBuffer))
353 {
355 return FALSE;
356 }
357
358 pUserToken = LocalAlloc(LMEM_FIXED, cbTokenBuffer);
359 if (!pUserToken)
360 return FALSE;
361
362 if (!GetTokenInformation(hToken, TokenUser, pUserToken, cbTokenBuffer, &cbTokenBuffer))
363 {
364 LocalFree(pUserToken);
365 return FALSE;
366 }
367
368 /* Retrieve the domain and user name */
370 pUserToken->User.Sid,
371 NULL,
372 &cbUserName,
373 NULL,
374 &cbDomainName,
375 &SidNameUse))
376 {
378 goto done;
379 }
380
381 pUserName = LocalAlloc(LPTR, cbUserName * sizeof(WCHAR));
382 if (!pUserName)
383 goto done;
384
385 pDomainName = LocalAlloc(LPTR, cbDomainName * sizeof(WCHAR));
386 if (!pDomainName)
387 goto done;
388
390 pUserToken->User.Sid,
391 pUserName,
392 &cbUserName,
393 pDomainName,
394 &cbDomainName,
395 &SidNameUse))
396 {
397 goto done;
398 }
399
400 *UserName = pUserName;
401 *DomainName = pDomainName;
402 bRet = TRUE;
403
404done:
405 if (bRet == FALSE)
406 {
407 if (pUserName)
409 if (pDomainName)
410 LocalFree(pDomainName);
411 }
412 LocalFree(pUserToken);
413
414 return bRet;
415}
static LPWSTR pUserName
BOOL WINAPI LookupAccountSidW(LPCWSTR pSystemName, PSID pSid, LPWSTR pAccountName, LPDWORD pdwAccountName, LPWSTR pDomainName, LPDWORD pdwDomainName, PSID_NAME_USE peUse)
Definition: misc.c:537
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
unsigned int BOOL
Definition: ntddk_ex.h:94
enum _SID_NAME_USE SID_NAME_USE
#define LPTR
Definition: minwinbase.h:93
SID_AND_ATTRIBUTES User
Definition: setypes.h:1022
@ TokenUser
Definition: setypes.h:978

Referenced by GetSystemUserInfo().

◆ GetUserObjectName()

static PWSTR GetUserObjectName ( _In_ HANDLE  hObj,
_Out_writes_opt_z_(cchBufLength) PWSTR  PreAllocBuffer,
_In_range_(0, MAXDWORD/sizeof(WCHAR)) DWORD  cchBufLength 
)
static

Retrieves the name of the specified window station or desktop object.

Parameters
[in]hObjA handle to the window station or desktop object.
[out]PreAllocBufferOptional pointer to an existing caller pre-allocated buffer.
[in]cchBufLengthLength in number of WCHARs of the caller pre-allocated buffer, if any.
Returns
If the function succeeds, it returns:
  • either a pointer to the same buffer pointed by PreAllocBuffer, if this user-given buffer was large enough to store the entire object name;
  • or, a pointer to a new buffer, allocated with LocalAlloc(). After usage, the caller will have to distinguish these two cases, and free the buffer with LocalFree() in the second case.

If the function fails, the return value is NULL.

Definition at line 266 of file wlntfytests.c.

270{
271 PWSTR pszBuffer = (cchBufLength ? PreAllocBuffer : NULL);
272 DWORD dwBufSize = (pszBuffer ? cchBufLength * sizeof(WCHAR) : 0);
273 DWORD dwReqSize = 0;
274
276 UOI_NAME,
277 pszBuffer,
278 dwBufSize,
279 &dwReqSize))
280 {
281 return pszBuffer;
282 }
283
284 if (dwReqSize > dwBufSize)
285 {
286 /* The call failed because the buffer was too small: reallocate it */
287 dwBufSize = dwReqSize;
288 pszBuffer = LocalAlloc(LMEM_FIXED, dwBufSize);
289 }
290 else
291 {
292 /* The call failed but the buffer was large enough: something else
293 * failed and we won't retrieve the object name */
294 pszBuffer = NULL;
295 }
296 if (!pszBuffer ||
298 UOI_NAME,
299 pszBuffer,
300 dwBufSize,
301 &dwReqSize))
302 {
303 if (pszBuffer)
304 LocalFree(pszBuffer);
305 pszBuffer = NULL;
306 }
307 return pszBuffer;
308}
#define UOI_NAME
Definition: winuser.h:1095
BOOL WINAPI GetUserObjectInformationW(_In_ HANDLE hObj, _In_ int nIndex, _Out_writes_bytes_opt_(nLength) PVOID pvInfo, _In_ DWORD nLength, _Out_opt_ LPDWORD lpnLengthNeeded)

Referenced by GetSystemUserInfo().

◆ IsUserLoggedIn()

FORCEINLINE BOOL IsUserLoggedIn ( _In_ WLNOTIFY_STATE  State)

Definition at line 103 of file wlntfytests.c.

105{
106 /*
107 * - The user is not logged in when State is either of:
108 * WLNotify_NonInitialized, WLNotify_Startup, WLNotify_Shutdown,
109 * WLNotify_Logoff, and perhaps (TODO TBD.): WLNotify_Disconnect,
110 * WLNotify_Reconnect.
111 *
112 * - The user is logged in when State is either of:
113 * WLNotify_Logon, WLNotify_StartShell, WLNotify_PostShell,
114 * WLNotify_Lock, WLNotify_Unlock.
115 *
116 * Note that WLNotify_StartScreenSaver and WLNotify_StopScreenSaver
117 * are not reliable for this test, because they can be invoked from
118 * either a logged-off or a logged-on state.
119 */
120 return ((State == WLNotify_Logon) ||
122}

Referenced by WLEventStartScreenSaver(), and WLEventStopScreenSaver().

◆ NotifyStateToName()

static PCSTR NotifyStateToName ( _In_ WLNOTIFY_STATE  State)
static

Maps a WLNOTIFY_STATE value to its human-readable name.

Parameters
[in]StateThe WLNOTIFY_STATE value for which to retrieve its name.
Returns
A pointer to the corresponding ANSI string name.

Definition at line 164 of file wlntfytests.c.

166{
167 UINT i;
168
170 i = State;
171 else
173
174 return NotifyStateName[i];
175}
static const PCSTR NotifyStateName[]
Definition: wlntfytests.c:73

Referenced by ChangeNotificationState(), and WLEventDisconnect().

◆ WINE_DEFAULT_DEBUG_CHANNEL_EX()

WINE_DEFAULT_DEBUG_CHANNEL_EX ( wlnotify_tests  ,
(1<< __WINE_DBCL_TRACE)|(1<< __WINE_DBCL_WARN)|(1<< __WINE_DBCL_ERR)|(1<< __WINE_DBCL_FIXME  
)

◆ WLEventDisconnect()

WLNOTIFY_HANDLER() WLEventDisconnect ( pInfo  )

Invoked at workstation disconnect (Terminal Services).

Definition at line 1246 of file wlntfytests.c.

1247{
1249
1251 {
1252 ERR("**** %s: Previous state %s\n",
1254 }
1255 END_TEST
1256
1257 /* Change state */
1259}
#define BEGIN_TEST
Definition: wlntfytests.c:727
#define END_HANDLER(bChangeState, NewState)
Definition: wlntfytests.c:929
#define BEGIN_HANDLER
Definition: wlntfytests.c:922
#define END_TEST
Definition: wlntfytests.c:734

◆ WLEventLock()

WLNOTIFY_HANDLER() WLEventLock ( pInfo  )

Invoked at workstation locking.

Definition at line 1129 of file wlntfytests.c.

1130{
1132
1134 {
1135 /* We must be called from PostShell */
1137 PWSTR pszInputDesk = (g_fFlags.bImpersonate ? NULL : DESKTOP_WINLOGON);
1138 TEST_ENTRY LockTest =
1139 { States, _countof(States), g_fFlags.bImpersonate, TRUE,
1141
1142 DoTest(__RELFILE__, __LINE__, __FUNCTION__, SysUserInfo, pInfo, &LockTest);
1143
1144 ok_int(pInfo->Flags, 0);
1145 }
1146 END_TEST
1147
1148 /* Change state */
1150}
#define __RELFILE__
Definition: debug.h:11
Definition: cmd.c:13
static void DoTest(const char *file, int line, const char *funcname, _In_ PSYSTEM_USER_INFO SysUserInfo, _In_ PWLX_NOTIFICATION_INFO pInfo, _In_ PTEST_ENTRY pTest)
Definition: wlntfytests.c:774

◆ WLEventLogoff()

WLNOTIFY_HANDLER() WLEventLogoff ( pInfo  )

Invoked at user logoff.

Definition at line 1040 of file wlntfytests.c.

1041{
1043
1044 /* Save the flags for comparison with those in WLEventShutdown */
1046
1048 {
1049 /* We must be called from PostShell, or StartShell if we failed to start
1050 * the shell (the PostShell notification isn't emitted in this case) */
1052 TEST_ENTRY LogoffTest =
1053 { States, _countof(States), g_fFlags.bImpersonate, TRUE,
1055
1056 DoTest(__RELFILE__, __LINE__, __FUNCTION__, SysUserInfo, pInfo, &LogoffTest);
1057
1058 ok(pInfo->Flags == EWX_LOGOFF ||
1059 pInfo->Flags == EWX_SHUTDOWN ||
1060 pInfo->Flags == (EWX_SHUTDOWN | EWX_REBOOT),
1061 "Expected pInfo->Flags == EWX_LOGOFF (0) or EWX_SHUTDOWN (1) or EWX_SHUTDOWN|EWX_REBOOT (3), got %lu\n",
1062 pInfo->Flags);
1063 }
1064 END_TEST
1065
1066 /* Change state */
1068}
#define EWX_SHUTDOWN
Definition: winuser.h:647
#define EWX_LOGOFF
Definition: winuser.h:644
#define EWX_REBOOT
Definition: winuser.h:646
static ULONG g_fLogoffShutdownFlags
Definition: wlntfytests.c:92
#define DESKTOP_DEFAULT
Definition: wlntfytests.c:52

◆ WLEventLogon()

WLNOTIFY_HANDLER() WLEventLogon ( pInfo  )

Invoked at user logon.

Definition at line 1014 of file wlntfytests.c.

1015{
1017
1019 {
1020 /* We must be called from either Startup or previous Logoff */
1022 PWSTR pszInputDesk = (g_fFlags.bImpersonate ? NULL : DESKTOP_WINLOGON);
1023 TEST_ENTRY LogonTest =
1024 { States, _countof(States), g_fFlags.bImpersonate, TRUE,
1026
1027 DoTest(__RELFILE__, __LINE__, __FUNCTION__, SysUserInfo, pInfo, &LogonTest);
1028
1029 ok_int(pInfo->Flags, 0);
1030 }
1031 END_TEST
1032
1033 /* Change state */
1035}

◆ WLEventPostShell()

WLNOTIFY_HANDLER() WLEventPostShell ( pInfo  )

Invoked just after starting the user shell.

Definition at line 1100 of file wlntfytests.c.

1101{
1103
1105 {
1106 /* We must be called from StartShell */
1108 PWSTR pszInputDesk =
1109 (g_fFlags.bAsync ? DESKTOP_DEFAULT
1110 : (g_fFlags.bImpersonate ? NULL : DESKTOP_WINLOGON));
1111 TEST_ENTRY PostShellTest =
1112 { States, _countof(States), g_fFlags.bImpersonate, TRUE,
1114
1115 DoTest(__RELFILE__, __LINE__, __FUNCTION__, SysUserInfo, pInfo, &PostShellTest);
1116
1117 ok_int(pInfo->Flags, 0);
1118 }
1119 END_TEST
1120
1121 /* Change state */
1123}

◆ WLEventReconnect()

WLNOTIFY_HANDLER() WLEventReconnect ( pInfo  )

Invoked at workstation reconnect (Terminal Services).

Definition at line 1264 of file wlntfytests.c.

1265{
1267
1269 {
1270 /* We must be called from Disconnect */
1272 }
1273 END_TEST
1274
1275 /* Restore previous state */
1277}

◆ WLEventShutdown()

WLNOTIFY_HANDLER() WLEventShutdown ( pInfo  )

Invoked at system shutdown.

Definition at line 966 of file wlntfytests.c.

967{
969
971 {
972 /* We must be called from either Startup or previous Logoff */
974 TEST_ENTRY ShutdownTest =
975 { States, _countof(States), FALSE, FALSE, DEFAULT_WINSTA0,
977
978 DoTest(__RELFILE__, __LINE__, __FUNCTION__, SysUserInfo, pInfo, &ShutdownTest);
979
980 /* Compare these flags with those from WLEventLogoff */
981 ok_int(pInfo->Flags, g_fLogoffShutdownFlags);
982 /*
983 * - If the logged-on user chooses to shutdown or reboot the computer,
984 * WLEventLogoff() is first invoked with pInfo->Flags == EWX_SHUTDOWN
985 * or EWX_SHUTDOWN | EWX_REBOOT (stored in g_fLogoffShutdownFlags),
986 * then WLEventShutdown() is invoked with the same values.
987 *
988 * - If the logged-on user chooses to log off only, WLEventLogoff()
989 * is invoked with pInfo->Flags == 0 (== EWX_LOGOFF).
990 *
991 * - Independently of whether the user chose to shutdown or reboot
992 * the computer at the SAS dialog before logging in first (thus,
993 * g_CurrentState == WLNotify_Startup), or when coming back at the
994 * SAS dialog after logged off (g_CurrentState == WLNotify_Logoff),
995 * WLEventShutdown() is invoked with pInfo->Flags == 0.
996 * (In both these cases, g_fLogoffShutdownFlags == 0 too.)
997 */
998 ok(pInfo->Flags == EWX_LOGOFF ||
999 pInfo->Flags == EWX_SHUTDOWN ||
1000 pInfo->Flags == (EWX_SHUTDOWN | EWX_REBOOT),
1001 "Expected pInfo->Flags == EWX_LOGOFF (0) or EWX_SHUTDOWN (1) or EWX_SHUTDOWN|EWX_REBOOT (3), got %lu\n",
1002 pInfo->Flags);
1003 }
1004 END_TEST
1005
1006 /* Change state */
1008}

◆ WLEventStartScreenSaver()

WLNOTIFY_HANDLER() WLEventStartScreenSaver ( pInfo  )

Invoked at screensaver start.

Definition at line 1184 of file wlntfytests.c.

1185{
1187
1189 {
1190 /* We must be called from Startup, Logoff, PostShell.
1191 * In case of Startup or Logoff, no user is logged in,
1192 * therefore no notification user token is present. */
1194 BOOL bUserLoggedIn = IsUserLoggedIn(g_CurrentState);
1195 BOOL bImpersonate = (g_fFlags.bImpersonate && bUserLoggedIn);
1196 TEST_ENTRY StartScreenSaverTest =
1197 { States, _countof(States), bImpersonate, bUserLoggedIn,
1199
1200 DoTest(__RELFILE__, __LINE__, __FUNCTION__, SysUserInfo, pInfo, &StartScreenSaverTest);
1201
1202 ok_int(pInfo->Flags, 0);
1203 }
1204 END_TEST
1205
1206 /* Change state */
1208}
UINT8 bImpersonate
Definition: wlntfytests.c:97
#define DESKTOP_SCRSAVE
Definition: wlntfytests.c:53
FORCEINLINE BOOL IsUserLoggedIn(_In_ WLNOTIFY_STATE State)
Definition: wlntfytests.c:103

◆ WLEventStartShell()

WLNOTIFY_HANDLER() WLEventStartShell ( pInfo  )

Invoked just before starting the user shell.

Definition at line 1074 of file wlntfytests.c.

1075{
1077
1079 {
1080 /* We must be called from Logon */
1081 WLNOTIFY_STATE States[] = {WLNotify_Logon};
1082 PWSTR pszInputDesk = (g_fFlags.bImpersonate ? NULL : DESKTOP_WINLOGON);
1083 TEST_ENTRY StartShellTest =
1084 { States, _countof(States), g_fFlags.bImpersonate, TRUE,
1086
1087 DoTest(__RELFILE__, __LINE__, __FUNCTION__, SysUserInfo, pInfo, &StartShellTest);
1088
1089 ok_int(pInfo->Flags, 0);
1090 }
1091 END_TEST
1092
1093 /* Change state */
1095}

◆ WLEventStartup()

WLNOTIFY_HANDLER() WLEventStartup ( pInfo  )

Invoked at system startup.

Definition at line 938 of file wlntfytests.c.

939{
940 /* Initially retrieve the notification registry settings */
941 GetSettings();
942
944
946 {
947 /* We must be called from the non-initialized state */
949 TEST_ENTRY StartupTest =
950 { States, _countof(States), FALSE, FALSE, DEFAULT_WINSTA0,
952
953 DoTest(__RELFILE__, __LINE__, __FUNCTION__, SysUserInfo, pInfo, &StartupTest);
954
955 ok_int(pInfo->Flags, 0);
956 }
958
959 /* Change state */
961}
static VOID GetSettings(VOID)
Retrieves the notification settings from the registry.
Definition: wlntfytests.c:185

◆ WLEventStopScreenSaver()

WLNOTIFY_HANDLER() WLEventStopScreenSaver ( pInfo  )

Invoked at screensaver stop.

Definition at line 1213 of file wlntfytests.c.

1214{
1216
1218 {
1219 /* We must be called from StartScreenSaver.
1220 * In case StartScreenSaver was called originally from Startup or Logoff,
1221 * no user is logged in, therefore no notification user token is present. */
1223 BOOL bUserLoggedIn = IsUserLoggedIn(g_PreviousState);
1224 BOOL bImpersonate = (g_fFlags.bImpersonate && bUserLoggedIn);
1225 PWSTR pszInputDesk =
1227 : DESKTOP_SCRSAVE);
1228 TEST_ENTRY StopScreenSaverTest =
1229 { States, _countof(States), bImpersonate, bUserLoggedIn,
1231
1232 DoTest(__RELFILE__, __LINE__, __FUNCTION__, SysUserInfo, pInfo, &StopScreenSaverTest);
1233
1234 ok_int(pInfo->Flags, 0);
1235 }
1236 END_TEST
1237
1238 /* Restore previous state */
1240}

◆ WLEventUnlock()

WLNOTIFY_HANDLER() WLEventUnlock ( pInfo  )

Invoked at workstation unlocking.

Definition at line 1155 of file wlntfytests.c.

1156{
1158
1160 {
1161 /* We must be called from Lock */
1162 WLNOTIFY_STATE States[] = {WLNotify_Lock};
1163 PWSTR pszInputDesk =
1164 (g_fFlags.bAsync ? DESKTOP_DEFAULT
1165 : (g_fFlags.bImpersonate ? NULL : DESKTOP_WINLOGON));
1166 TEST_ENTRY UnlockTest =
1167 { States, _countof(States), g_fFlags.bImpersonate, TRUE,
1169
1170 DoTest(__RELFILE__, __LINE__, __FUNCTION__, SysUserInfo, pInfo, &UnlockTest);
1171
1172 ok_int(pInfo->Flags, 0);
1173 }
1174 END_TEST
1175
1176 /* Restore previous state */
1178}

Variable Documentation

◆ bAsync

◆ bImpersonate

UINT8 bImpersonate

Definition at line 97 of file wlntfytests.c.

Referenced by WLEventStartScreenSaver(), and WLEventStopScreenSaver().

◆ g_bInitialized

BOOL g_bInitialized = FALSE
static

TRUE when the flags have been initialized.

Definition at line 94 of file wlntfytests.c.

Referenced by GetSettings().

◆ g_CurrentState

◆ 

◆ g_fLogoffShutdownFlags

ULONG g_fLogoffShutdownFlags = EWX_LOGOFF
static

Definition at line 92 of file wlntfytests.c.

Referenced by WLEventLogoff(), and WLEventShutdown().

◆ g_hModule

HMODULE g_hModule = NULL
static

Definition at line 93 of file wlntfytests.c.

Referenced by DllMain(), and DllRegisterServer().

◆ g_PreviousState

◆ 

const struct { ... } NotifyEvents[]
Initial value:
=
{
{L"Startup" , L"WLEventStartup"},
{L"Shutdown", L"WLEventShutdown"},
{L"Logon" , L"WLEventLogon"},
{L"Logoff", L"WLEventLogoff"},
{L"StartShell", L"WLEventStartShell"},
{L"PostShell" , L"WLEventPostShell"},
{L"Lock" , L"WLEventLock"},
{L"Unlock", L"WLEventUnlock"},
{L"StartScreenSaver", L"WLEventStartScreenSaver"},
{L"StopScreenSaver" , L"WLEventStopScreenSaver"},
{L"Disconnect", L"WLEventDisconnect"},
{L"Reconnect" , L"WLEventReconnect"},
}
See also
https://learn.microsoft.com/en-us/windows/win32/secauthn/registering-a-winlogon-notification-package https://learn.microsoft.com/en-us/windows/win32/secauthn/registry-entries

Referenced by DllRegisterServer().

◆ NotifyStateName

const PCSTR NotifyStateName[]
static
Initial value:
=
{
"Startup",
"Shutdown",
"Logon",
"Logoff",
"StartShell",
"PostShell",
"Lock",
"Unlock",
"StartScreenSaver",
"StopScreenSaver",
"Disconnect",
"Reconnect",
"NON-INITIALIZED",
}

Definition at line 73 of file wlntfytests.c.

Referenced by NotifyStateToName().

◆ Reserved

Definition at line 98 of file wlntfytests.c.

◆ Value

Definition at line 1327 of file wlntfytests.c.

◆ ValueName

Definition at line 1326 of file wlntfytests.c.