ReactOS 0.4.16-dev-1520-gb558596
misc.c File Reference
#include "precomp.h"
#include <ndk/sefuncs.h>
#include "resources.h"
#include <debug.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Classes

struct  _TIMERDLG_BUTTON
 
struct  _TIMERDLG_INFO
 
struct  _ERRORDLG_PARAMS
 

Macros

#define NDEBUG
 
#define IDT_DLGTIMER   1
 

Typedefs

typedef struct _TIMERDLG_BUTTON TIMERDLG_BUTTON
 
typedef struct _TIMERDLG_BUTTONPTIMERDLG_BUTTON
 
typedef struct _TIMERDLG_INFO TIMERDLG_INFO
 
typedef struct _TIMERDLG_INFOPTIMERDLG_INFO
 
typedef struct _ERRORDLG_PARAMS ERRORDLG_PARAMS
 
typedef struct _ERRORDLG_PARAMSPERRORDLG_PARAMS
 

Functions

LPWSTR AppendBackslash (LPWSTR String)
 
PSECURITY_DESCRIPTOR CreateDefaultSecurityDescriptor (VOID)
 
LONG GetPolicyValues (_In_ HKEY hRootKey, _Inout_ PPOLICY_VALUES QueryTable)
 
LONG GetPolicyValue (_In_ HKEY hRootKey, _In_ PCWSTR ValueName, _In_ DWORD Type, _Out_opt_ PVOID pData, _Inout_opt_ PDWORD pcbData)
 
static INT_PTR CALLBACK TimerDlgProc (_Inout_ PTIMERDLG_INFO Info, _In_ HWND hDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static INT_PTR CALLBACK ErrorDlgProc (_In_ HWND hDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
VOID ErrorDialogEx (_In_ ULONG ulTimeout, _In_ PCWSTR pszString)
 
VOID ReportErrorWorker (_In_ DWORD dwFlags, _In_ PCWSTR pszStr)
 
VOID ReportErrorV (_In_ DWORD dwFlags, _In_ PCWSTR pszStr, _In_ va_list args)
 
VOID __cdecl ReportError (_In_ DWORD dwFlags, _In_ PCWSTR pszStr,...)
 
BOOL LoadDynamicImports (PDYN_MODULE Module, PDYN_FUNCS DynFuncs)
 
VOID UnloadDynamicImports (PDYN_FUNCS DynFuncs)
 

Variables

SID_IDENTIFIER_AUTHORITY LocalSystemAuthority = {SECURITY_NT_AUTHORITY}
 
SID_IDENTIFIER_AUTHORITY WorldAuthority = {SECURITY_WORLD_SID_AUTHORITY}
 
static TIMERDLG_INFO ErrorDlg
 
DYN_MODULE DynOle32
 

Macro Definition Documentation

◆ IDT_DLGTIMER

#define IDT_DLGTIMER   1

Definition at line 282 of file misc.c.

◆ NDEBUG

#define NDEBUG

Definition at line 32 of file misc.c.

Typedef Documentation

◆ ERRORDLG_PARAMS

◆ PERRORDLG_PARAMS

◆ PTIMERDLG_BUTTON

◆ PTIMERDLG_INFO

◆ TIMERDLG_BUTTON

◆ TIMERDLG_INFO

Function Documentation

◆ AppendBackslash()

LPWSTR AppendBackslash ( LPWSTR  String)

Definition at line 41 of file misc.c.

42{
44
46 if (String[Length - 1] != L'\\')
47 {
48 String[Length] = L'\\';
49 Length++;
50 String[Length] = (WCHAR)0;
51 }
52
53 return &String[Length];
54}
#define lstrlenW
Definition: compat.h:750
#define L(x)
Definition: resources.c:13
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CopyDirectory().

◆ CreateDefaultSecurityDescriptor()

PSECURITY_DESCRIPTOR CreateDefaultSecurityDescriptor ( VOID  )

Definition at line 57 of file misc.c.

58{
60 PSID AdministratorsSid = NULL;
61 PSID EveryoneSid = NULL;
62 PACL Dacl;
65
66 /* create the SYSTEM, Administrators and Everyone SIDs */
68 1,
70 0,
71 0,
72 0,
73 0,
74 0,
75 0,
76 0,
79 2,
82 0,
83 0,
84 0,
85 0,
86 0,
87 0,
88 &AdministratorsSid) ||
90 1,
92 0,
93 0,
94 0,
95 0,
96 0,
97 0,
98 0,
99 &EveryoneSid))
100 {
101 DPRINT1("Failed initializing the SIDs for the default security descriptor (0x%p, 0x%p, 0x%p)\n",
102 LocalSystemSid, AdministratorsSid, EveryoneSid);
103 goto Cleanup;
104 }
105
106 /* allocate the security descriptor and DACL */
107 DaclSize = sizeof(ACL) +
109 GetLengthSid(AdministratorsSid) +
110 GetLengthSid(EveryoneSid)) +
112 SidStart)));
113
116 if (pSD == NULL)
117 {
118 DPRINT1("Failed to allocate the default security descriptor and ACL\n");
119 goto Cleanup;
120 }
121
124 {
125 DPRINT1("Failed to initialize the default security descriptor\n");
126 goto Cleanup;
127 }
128
129 /* initialize and build the DACL */
130 Dacl = (PACL)((ULONG_PTR)pSD + sizeof(SECURITY_DESCRIPTOR));
131 if (!InitializeAcl(Dacl,
134 {
135 DPRINT1("Failed to initialize the DACL of the default security descriptor\n");
136 goto Cleanup;
137 }
138
139 /* add the SYSTEM Ace */
144 {
145 DPRINT1("Failed to add the SYSTEM ACE\n");
146 goto Cleanup;
147 }
148
149 /* add the Administrators Ace */
153 AdministratorsSid))
154 {
155 DPRINT1("Failed to add the Administrators ACE\n");
156 goto Cleanup;
157 }
158
159 /* add the Everyone Ace */
163 EveryoneSid))
164 {
165 DPRINT1("Failed to add the Everyone ACE\n");
166 goto Cleanup;
167 }
168
169 /* set the DACL */
171 TRUE,
172 Dacl,
173 FALSE))
174 {
175 DPRINT1("Failed to set the DACL of the default security descriptor\n");
176
177Cleanup:
178 if (pSD != NULL)
179 {
180 LocalFree((HLOCAL)pSD);
181 pSD = NULL;
182 }
183 }
184
185 if (LocalSystemSid != NULL)
186 {
188 }
189 if (AdministratorsSid != NULL)
190 {
191 FreeSid(AdministratorsSid);
192 }
193 if (EveryoneSid != NULL)
194 {
195 FreeSid(EveryoneSid);
196 }
197
198 return pSD;
199}
#define DPRINT1
Definition: precomp.h:8
PSID LocalSystemSid
Definition: globals.c:16
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:674
BOOL WINAPI InitializeAcl(PACL pAcl, DWORD nAclLength, DWORD dwAclRevision)
Definition: security.c:1006
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:929
BOOL WINAPI AddAccessAllowedAce(PACL pAcl, DWORD dwAceRevision, DWORD AccessMask, PSID pSid)
Definition: security.c:1039
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:919
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
SID_IDENTIFIER_AUTHORITY WorldAuthority
Definition: misc.c:36
SID_IDENTIFIER_AUTHORITY LocalSystemAuthority
Definition: misc.c:35
static const WCHAR Cleanup[]
Definition: register.c:80
unsigned long DWORD
Definition: ntddk_ex.h:95
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
struct _SECURITY_DESCRIPTOR * PSECURITY_DESCRIPTOR
Definition: security.c:98
struct _ACL ACL
struct _SECURITY_DESCRIPTOR SECURITY_DESCRIPTOR
struct _ACL * PACL
Definition: security.c:105
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1617
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG DaclSize
Definition: rtlfuncs.h:1618
#define GENERIC_ALL
Definition: nt_native.h:92
#define GENERIC_EXECUTE
Definition: nt_native.h:91
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted)
Definition: sec.c:262
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define LMEM_FIXED
Definition: winbase.h:401
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:581
#define SECURITY_WORLD_RID
Definition: setypes.h:541
#define SECURITY_LOCAL_SYSTEM_RID
Definition: setypes.h:574
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
#define ACL_REVISION
Definition: setypes.h:39
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:652

Referenced by EnterCriticalPolicySection(), and RegisterGPNotification().

◆ ErrorDialogEx()

VOID ErrorDialogEx ( _In_ ULONG  ulTimeout,
_In_ PCWSTR  pszString 
)

Definition at line 436 of file misc.c.

439{
440 ERRORDLG_PARAMS Params = {ulTimeout, pszString};
443}
HINSTANCE hInstance
Definition: charmap.c:19
static INT_PTR CALLBACK ErrorDlgProc(_In_ HWND hDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: misc.c:409
#define IDD_ERRORDLG
Definition: resources.h:17
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308
LONG_PTR LPARAM
Definition: windef.h:208
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by ReportErrorWorker().

◆ ErrorDlgProc()

static INT_PTR CALLBACK ErrorDlgProc ( _In_ HWND  hDlg,
_In_ UINT  uMsg,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 409 of file misc.c.

414{
415 if (uMsg == WM_INITDIALOG)
416 {
418
419 /* Position and focus the dialog */
420 // CenterWindow(hDlg); // Already done with the DS_CENTER style.
422
423 /* Display the message */
424 SetDlgItemTextW(hDlg, IDC_ERRORDESC, Params->pszString);
425
426 /* Setup the timeout and display the countdown */
427 ErrorDlg.ulTimeout = Params->ulTimeout;
428 // SetWindowLongPtrW(hDlg, DWLP_USER, &ErrorDlg);
430 return TRUE;
431 }
432 return TimerDlgProc(&ErrorDlg, hDlg, uMsg, wParam, lParam);
433}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static INT_PTR CALLBACK TimerDlgProc(_Inout_ PTIMERDLG_INFO Info, _In_ HWND hDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: misc.c:300
static TIMERDLG_INFO ErrorDlg
Definition: misc.c:400
struct _ERRORDLG_PARAMS * PERRORDLG_PARAMS
#define IDC_ERRORDESC
Definition: resources.h:18
ULONG ulTimeout
Dialog timeout.
Definition: misc.c:292
BOOL WINAPI SetForegroundWindow(_In_ HWND)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_INITDIALOG
Definition: winuser.h:1767

Referenced by ErrorDialogEx().

◆ GetPolicyValue()

LONG GetPolicyValue ( _In_ HKEY  hRootKey,
_In_ PCWSTR  ValueName,
_In_ DWORD  Type,
_Out_opt_ PVOID  pData,
_Inout_opt_ PDWORD  pcbData 
)

Definition at line 261 of file misc.c.

267{
269 {
270 {ValueName, Type, pData, pcbData ? *pcbData : 0},
271 {NULL, 0, NULL, 0}
272 };
273 LONG ret = GetPolicyValues(hRootKey, QueryTable);
274 if ((ret == ERROR_SUCCESS) && pcbData)
275 *pcbData = QueryTable[0].Length;
276
277 return ret;
278}
Type
Definition: Type.h:7
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG GetPolicyValues(_In_ HKEY hRootKey, _Inout_ PPOLICY_VALUES QueryTable)
Definition: misc.c:204
return ret
Definition: mutex.c:146
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:4203
long LONG
Definition: pedump.c:60
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243

Referenced by ReportErrorWorker().

◆ GetPolicyValues()

LONG GetPolicyValues ( _In_ HKEY  hRootKey,
_Inout_ PPOLICY_VALUES  QueryTable 
)

Definition at line 204 of file misc.c.

207{
208 static PCWSTR PolicyKeys[] =
209 {
210 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
211 L"Software\\Policies\\Microsoft\\Windows\\System"
212 };
213
214 /* Retrieve the sought policy values in each of the policy keys */
215 DWORD i;
216 for (i = 0; i < _countof(PolicyKeys); ++i)
217 {
218 HKEY hKey;
220 DWORD dwType, cbData;
221
222 if (RegOpenKeyExW(hRootKey, PolicyKeys[i], 0,
224 {
225 continue;
226 }
227
228 for (Value = QueryTable; Value->ValueName || Value->Data; ++Value)
229 {
230 /* Retrieve the type and data length for validation checks */
231 if (RegQueryValueExW(hKey, Value->ValueName, NULL,
232 &dwType, NULL, &cbData) != ERROR_SUCCESS)
233 {
234 continue;
235 }
236
237 /* Verify for compatible types */
238 if ( ((Value->Type == REG_SZ || Value->Type == REG_EXPAND_SZ) &&
239 (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) ||
240 (Value->Type == REG_DWORD && dwType == REG_DWORD) ||
241 (Value->Type == REG_QWORD && dwType == REG_QWORD) ||
242 (Value->Type == REG_MULTI_SZ && dwType == REG_MULTI_SZ) ||
243 (Value->Type == REG_NONE || Value->Type == REG_BINARY) )
244 {
245 /* Verify whether the given buffer can hold the data;
246 * if so, retrieve the actual data */
247 if (Value->Length >= cbData)
248 {
249 RegQueryValueExW(hKey, Value->ValueName, NULL,
250 &dwType, Value->Data, &cbData);
251 }
252 }
253 }
255 }
256
257 return ERROR_SUCCESS;
258}
#define RegCloseKey(hKey)
Definition: registry.h:49
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
FxAutoRegKey hKey
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 REG_SZ
Definition: layer.c:22
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define REG_NONE
Definition: nt_native.h:1492
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define REG_QWORD
Definition: sdbapi.c:597
#define REG_DWORD
Definition: sdbapi.c:596
#define _countof(array)
Definition: sndvol32.h:70
const uint16_t * PCWSTR
Definition: typedefs.h:57
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by GetPolicyValue().

◆ LoadDynamicImports()

BOOL LoadDynamicImports ( PDYN_MODULE  Module,
PDYN_FUNCS  DynFuncs 
)

Definition at line 515 of file misc.c.

517{
518 LPSTR *fname;
519 PVOID *fn;
520
521 ZeroMemory(DynFuncs, sizeof(DYN_FUNCS));
522
523 DynFuncs->hModule = LoadLibraryW(Module->Library);
524 if (!DynFuncs->hModule)
525 {
526 return FALSE;
527 }
528
529 fn = &DynFuncs->fn.foo;
530
531 /* load the imports */
532 for (fname = Module->Functions; *fname != NULL; fname++)
533 {
534 *fn = GetProcAddress(DynFuncs->hModule, *fname);
535 if (*fn == NULL)
536 {
537 FreeLibrary(DynFuncs->hModule);
538 DynFuncs->hModule = (HMODULE)0;
539
540 return FALSE;
541 }
542
543 fn++;
544 }
545
546 return TRUE;
547}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
union _DYN_FUNCS::@636 fn
HMODULE hModule
Definition: internal.h:49
PVOID foo
Definition: internal.h:52
LPWSTR Library
Definition: internal.h:64
LPSTR Functions[]
Definition: internal.h:65
HANDLE HMODULE
Definition: typedefs.h:77
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
#define ZeroMemory
Definition: winbase.h:1753
char * LPSTR
Definition: xmlstorage.h:182

Referenced by AddDesktopItemW(), and AddItemW().

◆ ReportError()

VOID __cdecl ReportError ( _In_ DWORD  dwFlags,
_In_ PCWSTR  pszStr,
  ... 
)

Definition at line 481 of file misc.c.

485{
487
488 va_start(args, pszStr);
489 ReportErrorV(dwFlags, pszStr, args);
490 va_end(args);
491}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
VOID ReportErrorV(_In_ DWORD dwFlags, _In_ PCWSTR pszStr, _In_ va_list args)
Definition: misc.c:469
LPCWSTR LPCWSTR LPCWSTR DWORD dwFlags
Definition: env.c:37
#define args
Definition: format.c:66
Definition: match.c:390

Referenced by LoadUserProfileW().

◆ ReportErrorV()

VOID ReportErrorV ( _In_ DWORD  dwFlags,
_In_ PCWSTR  pszStr,
_In_ va_list  args 
)

Definition at line 469 of file misc.c.

473{
474 WCHAR Buffer[4096];
477}
Definition: bufpool.h:45
VOID ReportErrorWorker(_In_ DWORD dwFlags, _In_ PCWSTR pszStr)
Definition: misc.c:446
_CRTIMP int __cdecl _vsnwprintf(wchar_t *_Dest, size_t _Count, const wchar_t *_Format, va_list _Args)

Referenced by ReportError().

◆ ReportErrorWorker()

VOID ReportErrorWorker ( _In_ DWORD  dwFlags,
_In_ PCWSTR  pszStr 
)

Definition at line 446 of file misc.c.

449{
450 // TODO: Report event to Application log, "Userenv" source.
451 DPRINT1("%S", pszStr);
452
453 if (!(dwFlags & PI_NOUI))
454 {
455 /* Retrieve the "Profile Dialog Time Out" policy value,
456 * defaulting to 30 seconds timeout */
457 ULONG ulTimeout = 30;
458 DWORD cbData = sizeof(ulTimeout);
460 L"ProfileDlgTimeOut",
461 REG_DWORD,
462 &ulTimeout,
463 &cbData);
464 ErrorDialogEx(ulTimeout, pszStr);
465 }
466}
LONG GetPolicyValue(_In_ HKEY hRootKey, _In_ PCWSTR ValueName, _In_ DWORD Type, _Out_opt_ PVOID pData, _Inout_opt_ PDWORD pcbData)
Definition: misc.c:261
VOID ErrorDialogEx(_In_ ULONG ulTimeout, _In_ PCWSTR pszString)
Definition: misc.c:436
#define PI_NOUI
Definition: userenv.h:8
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ReportErrorV().

◆ TimerDlgProc()

static INT_PTR CALLBACK TimerDlgProc ( _Inout_ PTIMERDLG_INFO  Info,
_In_ HWND  hDlg,
_In_ UINT  uMsg,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 300 of file misc.c.

306{
307 switch (uMsg)
308 {
309 case WM_INITDIALOG:
310 {
311 /* Setup the timeout */
312 if (Info->ulTimeout)
313 {
314 /* Display the countdown */
315 WCHAR szTimeout[10];
316 StringCchPrintfW(szTimeout, _countof(szTimeout), L"%d", Info->ulTimeout);
317 SetDlgItemTextW(hDlg, IDC_TIMEOUT, szTimeout);
318
319 /* Set a 1-second timer */
320 SetTimer(hDlg, IDT_DLGTIMER, 1000, NULL);
321 }
322 break;
323 }
324
325 case WM_COMMAND:
326 {
327 PTIMERDLG_BUTTON ButtonMap = Info->ButtonMap;
328 WORD wDefBtnOnTimeout = min(Info->wDefBtnOnTimeout, _countof(Info->ButtonMap)-1);
329 WORD i;
330
331 if (LOWORD(wParam) == IDCANCEL)
332 {
333 /* ESC or CANCEL button pressed: stop the timeout,
334 * close the dialog and return the default result */
335 WORD wDefBtnOnCancel = min(Info->wDefBtnOnCancel, _countof(Info->ButtonMap)-1);
336 KillTimer(hDlg, IDT_DLGTIMER);
337 EndDialog(hDlg, ButtonMap[wDefBtnOnCancel].nResult);
338 break;
339 }
340
341 for (i = 0; i < _countof(Info->ButtonMap); ++i)
342 {
343 if (LOWORD(wParam) == ButtonMap[i].uID)
344 {
345 if (HIWORD(wParam) == BN_CLICKED)
346 {
347 /* Button pressed: stop the timeout, close the
348 * dialog and return the corresponding result */
349 KillTimer(hDlg, IDT_DLGTIMER);
350 EndDialog(hDlg, ButtonMap[i].nResult);
351 }
352 else if (HIWORD(wParam) == BN_KILLFOCUS)
353 {
354 /* Button lost the focus: stop the timeout
355 * only if this isn't the default action */
356 if (i != wDefBtnOnTimeout)
357 break;
358 KillTimer(hDlg, IDT_DLGTIMER);
361 }
362 break;
363 }
364 }
365 break;
366 }
367
368 case WM_TIMER:
369 {
370 if (Info->ulTimeout < 1)
371 {
372 /* Timeout ended, close the dialog */
373 WORD wDefBtnOnTimeout = min(Info->wDefBtnOnTimeout, _countof(Info->ButtonMap)-1);
375 MAKEWPARAM(Info->ButtonMap[wDefBtnOnTimeout].uID, BN_CLICKED),
376 0);
377 }
378 else
379 {
380 /* Decrement and display the countdown */
381 WCHAR szTimeout[10];
382 StringCchPrintfW(szTimeout, _countof(szTimeout), L"%d", --(Info->ulTimeout));
383 SetDlgItemTextW(hDlg, IDC_TIMEOUT, szTimeout);
384 }
385 break;
386 }
387 }
388
389 return FALSE;
390}
#define IDT_DLGTIMER
Definition: misc.c:282
#define IDC_TIMEOUTSTATIC
Definition: resources.h:19
#define IDC_TIMEOUT
Definition: resources.h:20
unsigned short WORD
Definition: ntddk_ex.h:93
#define min(a, b)
Definition: monoChain.cc:55
#define LOWORD(l)
Definition: pedump.c:82
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define HIWORD(l)
Definition: typedefs.h:247
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
#define MAKEWPARAM(l, h)
Definition: winuser.h:4111
#define SW_HIDE
Definition: winuser.h:779
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IDCANCEL
Definition: winuser.h:842
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_COMMAND
Definition: winuser.h:1768
#define BN_KILLFOCUS
Definition: winuser.h:1959
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_TIMER
Definition: winuser.h:1770
#define BN_CLICKED
Definition: winuser.h:1954
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by ErrorDlgProc().

◆ UnloadDynamicImports()

VOID UnloadDynamicImports ( PDYN_FUNCS  DynFuncs)

Definition at line 550 of file misc.c.

551{
552 if (DynFuncs->hModule)
553 {
554 FreeLibrary(DynFuncs->hModule);
555 DynFuncs->hModule = (HMODULE)0;
556 }
557}

Referenced by AddDesktopItemW(), and AddItemW().

Variable Documentation

◆ DynOle32

DYN_MODULE DynOle32
Initial value:
=
{
L"ole32.dll",
{
"CoInitialize",
"CoCreateInstance",
"CoUninitialize",
}
}

Definition at line 497 of file misc.c.

Referenced by AddDesktopItemW(), and AddItemW().

◆ ErrorDlg

TIMERDLG_INFO ErrorDlg
static
Initial value:
=
{
0,
0, 1,
}
#define IDOK
Definition: winuser.h:841

Definition at line 400 of file misc.c.

Referenced by ErrorDlgProc().

◆ LocalSystemAuthority

Definition at line 35 of file misc.c.

Referenced by CheckForGuestsAndAdmins(), and CreateDefaultSecurityDescriptor().

◆ WorldAuthority

Definition at line 36 of file misc.c.

Referenced by CreateDefaultSecurityDescriptor().