#include "userinit.h"
#include <userenv.h>
Go to the source code of this file.
◆ CMP_MAGIC
◆ PCMP_REPORT_LOGON
◆ EnablePrivilege()
| static BOOL EnablePrivilege |
( |
LPCWSTR |
lpszPrivilegeName, |
|
|
BOOL |
bEnablePrivilege |
|
) |
| |
|
static |
Definition at line 514 of file userinit.c.
515{
519
522 &hToken);
524
526 lpszPrivilegeName,
527 &
tp.Privileges[0].Luid);
529
530 tp.PrivilegeCount = 1;
532
534
535Quit:
538}
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
#define GetCurrentProcess()
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
#define TOKEN_ADJUST_PRIVILEGES
#define SE_PRIVILEGE_ENABLED
Referenced by wWinMain().
◆ GetShell()
Definition at line 133 of file userinit.c.
136{
142
143 rc =
RegOpenKeyExW(hRootKey,
L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
146 {
147 WARN(
"RegOpenKeyEx() failed with error %lu\n", rc);
149 }
150
153 ConsoleShell ?
L"ConsoleShell" :
L"Shell",
159
161 {
162 WARN(
"RegQueryValueEx() failed with error %lu\n", rc);
164 }
165
167 {
171 }
172 else
173 {
176 }
177}
#define RegCloseKey(hKey)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
static BOOL IsConsoleShell(VOID)
static int Shell(const char **args)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Referenced by StartShell().
◆ IsConsoleShell()
Definition at line 81 of file userinit.c.
82{
88
91 0,
93 &ControlKey);
95 {
96 WARN(
"RegOpenKeyEx() failed with error %lu\n", rc);
98 }
99
100 rc =
ReadRegSzKey(ControlKey,
L"SystemStartOptions", &SystemStartOptions);
102 {
103 WARN(
"ReadRegSzKey() failed with error %lu\n", rc);
105 }
106
107
108 CurrentOption = SystemStartOptions;
109 while (CurrentOption)
110 {
114 if (
_wcsicmp(CurrentOption,
L"CONSOLE") == 0)
115 {
116 TRACE(
"Found 'CONSOLE' boot option\n");
119 }
121 }
122
124 if (ControlKey !=
NULL)
127
128 TRACE(
"IsConsoleShell() returning %u\n",
ret);
130}
#define HeapFree(x, y, z)
static void cleanup(void)
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
static char * NextOption(const char *const ostr)
#define REGSTR_PATH_CURRENT_CONTROL_SET
LONG ReadRegSzKey(IN HKEY hKey, IN LPCWSTR pszKey, OUT LPWSTR *pValue)
#define HKEY_LOCAL_MACHINE
Referenced by GetShell(), and StartShell().
◆ NotifyLogon()
Definition at line 474 of file userinit.c.
475{
478
481 {
483 return;
484 }
485
489 else
490 WARN(
"GetProcAddress() failed\n");
491
493}
CONFIGRET WINAPI CMP_Report_LogOn(_In_ DWORD dwMagic, _In_ DWORD dwProcessId)
#define GetProcAddress(x, y)
DWORD(WINAPI * PCMP_REPORT_LOGON)(DWORD, DWORD)
DWORD WINAPI GetLastError(void)
DWORD WINAPI GetCurrentProcessId(void)
Referenced by wWinMain().
◆ ReadRegSzKey()
Definition at line 39 of file userinit.c.
43{
48
51 {
52 WARN(
"RegQueryValueEx(%s) failed with error %lu\n",
debugstr_w(pszKey), rc);
53 return rc;
54 }
56 {
57 WARN(
"Wrong registry data type (%u vs %u)\n", dwType,
REG_SZ);
59 }
62 {
65 }
68 {
69 WARN(
"RegQueryValueEx(%s) failed with error %lu\n",
debugstr_w(pszKey), rc);
71 return rc;
72 }
73
75
78}
#define ERROR_NOT_ENOUGH_MEMORY
#define ERROR_FILE_NOT_FOUND
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Referenced by IsConsoleShell().
◆ SetUserSettings()
Definition at line 464 of file userinit.c.
465{
469}
DWORD WINAPI UpdatePerUserSystemParameters(DWORD dw1, DWORD dw2)
static VOID SetUserWallpaper(VOID)
static VOID SetUserSysColors(VOID)
Referenced by wWinMain().
◆ SetUserSysColors()
Definition at line 385 of file userinit.c.
386{
393
397 {
398 WARN(
"RegOpenKeyEx() failed with error %lu\n", rc);
399 return;
400 }
401
403 {
404 Size =
sizeof(szColor);
408 {
411 }
412 else
413 {
414 WARN(
"RegQueryValueEx(%s) failed with error %lu\n",
416 }
417 }
418
420}
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
BOOL WINAPI SetSysColors(_In_ int cElements, _In_reads_(cElements) CONST INT *lpaElements, _In_reads_(cElements) CONST COLORREF *lpaRgbValues)
#define REGSTR_PATH_COLORS
const WCHAR g_RegColorNames[][32]
static COLORREF StrToColorref(IN LPWSTR lpszCol)
#define HKEY_CURRENT_USER
Referenced by SetUserSettings().
◆ SetUserWallpaper()
Definition at line 423 of file userinit.c.
424{
429
433 {
434 WARN(
"RegOpenKeyEx() failed with error %lu\n", rc);
435 return;
436 }
437
438 Size =
sizeof(szWallpaper);
446
448 {
451
452
454 }
455 else
456 {
457
458 TRACE(
"No wallpaper set in registry (error %lu)\n", rc);
460 }
461}
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
#define SPI_SETDESKWALLPAPER
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define REGSTR_PATH_DESKTOP
Referenced by SetUserSettings().
◆ StartInstaller()
Definition at line 496 of file userinit.c.
497{
500
501
504
505
510}
#define RC_STRING_MAX_SIZE
#define IDS_INSTALLER_FAIL
WCHAR Installer[MAX_PATH]
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
static BOOL StartProcess(_In_ PCWSTR CommandLine, _In_opt_ PVOID pEnvironment)
Referenced by wWinMain().
◆ StartProcess()
Definition at line 180 of file userinit.c.
183{
189
191
197
199 {
204 }
205
207 ExpandedCmdLine,
212 pEnvironment,
216 {
219 }
220
224}
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
static const WCHAR WorkingDir[]
BOOL WINAPI GetUserProfileDirectoryW(_In_ HANDLE hToken, _Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
static PROCESS_INFORMATION pi
#define NORMAL_PRIORITY_CLASS
#define STARTF_USESHOWWINDOW
#define CREATE_UNICODE_ENVIRONMENT
Referenced by StartInstaller(), and StartShell().
◆ StartShell()
Definition at line 227 of file userinit.c.
229{
236
237
239 L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option",
242 {
247
249 {
251 {
253 {
254
256 L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot",
259 {
264
266 {
268 {
270
271
273 {
274 TRACE(
"Alternate shell started (Safe Mode)\n");
276 }
277 }
278 else
279 {
280 WARN(
"Wrong type %lu (expected %u or %u)\n",
282 }
283 }
284 else
285 {
286 WARN(
"Alternate shell in Safe Mode required but not specified.\n");
287 }
288 }
289 }
290 }
291 else
292 {
294 }
295 }
296 }
297
298
300 {
301 TRACE(
"Started shell from HKEY_CURRENT_USER\n");
303 }
304
305
307 {
308 TRACE(
"Started shell from HKEY_LOCAL_MACHINE\n");
310 }
311
312
314 {
319 }
320 else
321 {
326 }
327
330
331
336}
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
static BOOL GetShell(OUT WCHAR *CommandLine, IN HKEY hRootKey)
Referenced by wWinMain().
◆ StrToColorref()
Definition at line 373 of file userinit.c.
375{
377
382}
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
_In_ ULONG _In_ ULONG rgb
Referenced by SetUserSysColors().
◆ wWinMain()
Definition at line 542 of file userinit.c.
546{
549
551
553
556
557 if (bIsLiveCD)
558 {
561 }
562 else
563 {
566 }
567
569 {
571 }
572
574 {
576 {
577
578
580 if (bIsLiveCD &&
582 {
583 WARN(
"CreateEnvironmentBlock() failed, fall back to default (error %lu)\n",
585 }
587 if (pEnvironment)
591 break;
592 }
593
596 break;
597
599 {
604 break;
605 }
606
607 default:
609 break;
610 }
611
612
613
614
615
618
619 return 0;
620}
BOOL WINAPI DestroyEnvironmentBlock(IN LPVOID lpEnvironment)
BOOL WINAPI CreateEnvironmentBlock(OUT LPVOID *lpEnvironment, IN HANDLE hToken, IN BOOL bInherit)
VOID RunLiveCD(PSTATE pState)
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
static BOOL IsMiniNT(VOID)
Check whether we are running in MiniNT mode (e.g. live medium).
static VOID SetUserSettings(VOID)
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
static BOOL StartInstaller(VOID)
static BOOL StartShell(_In_opt_ PVOID pEnvironment)
static VOID NotifyLogon(VOID)
◆ g_RegColorNames
◆ hInstance