ReactOS 0.4.17-dev-243-g1369312
userinit.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winreg.h>
#include <regstr.h>
#include <winnls.h>
#include <winuser.h>
#include <undocuser.h>
#include <strsafe.h>
#include <ndk/exfuncs.h>
#include <wine/debug.h>
#include "resource.h"
Include dependency graph for userinit.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _IMGINFO
 
struct  STATE
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 

Typedefs

typedef struct _IMGINFO IMGINFO
 
typedef struct _IMGINFOPIMGINFO
 
typedef struct STATEPSTATE
 

Enumerations

enum  PAGESTATE { LOCALEPAGE , STARTPAGE , DONE }
 
enum  RUN { SHELL , INSTALLER , REBOOT }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (userinit)
 
LONG ReadRegSzKey (IN HKEY hKey, IN LPCWSTR pszKey, OUT LPWSTR *pValue)
 
BOOL ExpandInstallerPath (IN LPCWSTR lpInstallerName, OUT LPWSTR lpInstallerPath, IN SIZE_T PathSize)
 
BOOL IsLiveCD (VOID)
 
VOID RunLiveCD (PSTATE State)
 

Variables

HINSTANCE hInstance
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 12 of file userinit.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 13 of file userinit.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 11 of file userinit.h.

Typedef Documentation

◆ IMGINFO

◆ PIMGINFO

◆ PSTATE

typedef struct STATE * PSTATE

Enumeration Type Documentation

◆ PAGESTATE

Enumerator
LOCALEPAGE 
STARTPAGE 
DONE 

Definition at line 33 of file userinit.h.

34{
37 DONE
38} PAGESTATE;
PAGESTATE
Definition: userinit.h:34
@ LOCALEPAGE
Definition: userinit.h:35
@ DONE
Definition: userinit.h:37
@ STARTPAGE
Definition: userinit.h:36

◆ RUN

Enumerator
SHELL 
INSTALLER 
REBOOT 

Definition at line 40 of file userinit.h.

41{
42 SHELL,
44 REBOOT
45} RUN;
RUN
Definition: userinit.h:41
@ REBOOT
Definition: userinit.h:44
@ INSTALLER
Definition: userinit.h:43
@ SHELL
Definition: userinit.h:42

Function Documentation

◆ ExpandInstallerPath()

BOOL ExpandInstallerPath ( IN LPCWSTR  lpInstallerName,
OUT LPWSTR  lpInstallerPath,
IN SIZE_T  PathSize 
)

Definition at line 491 of file userinit.c.

495{
496 SYSTEM_INFO SystemInfo;
497 SIZE_T cchInstallerNameLen;
498 PWSTR ptr;
499 DWORD dwAttribs;
500
501 cchInstallerNameLen = wcslen(lpInstallerName);
502 if (PathSize < cchInstallerNameLen)
503 {
504 /* The buffer is not large enough to contain the installer file name */
505 *lpInstallerPath = UNICODE_NULL;
506 return FALSE;
507 }
508
509 /*
510 * First, try to find the installer using the default drive, under
511 * the directory whose name corresponds to the currently-running
512 * CPU architecture.
513 */
514 GetSystemInfo(&SystemInfo);
515
516 *lpInstallerPath = UNICODE_NULL;
517 /* Alternatively one can use SharedUserData->NtSystemRoot */
518 GetSystemWindowsDirectoryW(lpInstallerPath, PathSize - cchInstallerNameLen - 1);
519 ptr = wcschr(lpInstallerPath, L'\\');
520 if (ptr)
521 *++ptr = UNICODE_NULL;
522 else
523 *lpInstallerPath = UNICODE_NULL;
524
525 /* Append the corresponding CPU architecture */
526 switch (SystemInfo.wProcessorArchitecture)
527 {
529 StringCchCatW(lpInstallerPath, PathSize, L"I386");
530 break;
531
533 StringCchCatW(lpInstallerPath, PathSize, L"MIPS");
534 break;
535
537 StringCchCatW(lpInstallerPath, PathSize, L"ALPHA");
538 break;
539
541 StringCchCatW(lpInstallerPath, PathSize, L"PPC");
542 break;
543
545 StringCchCatW(lpInstallerPath, PathSize, L"SHX");
546 break;
547
549 StringCchCatW(lpInstallerPath, PathSize, L"ARM");
550 break;
551
553 StringCchCatW(lpInstallerPath, PathSize, L"IA64");
554 break;
555
557 StringCchCatW(lpInstallerPath, PathSize, L"ALPHA64");
558 break;
559
561 StringCchCatW(lpInstallerPath, PathSize, L"AMD64");
562 break;
563
564 // case PROCESSOR_ARCHITECTURE_MSIL: /* .NET CPU-independent code */
566 default:
567 WARN("Unknown processor architecture %lu\n", SystemInfo.wProcessorArchitecture);
569 break;
570 }
571
573 StringCchCatW(lpInstallerPath, PathSize, L"\\");
574 StringCchCatW(lpInstallerPath, PathSize, lpInstallerName);
575
576 dwAttribs = GetFileAttributesW(lpInstallerPath);
577 if ((dwAttribs != INVALID_FILE_ATTRIBUTES) &&
578 !(dwAttribs & FILE_ATTRIBUTE_DIRECTORY))
579 {
580 /* We have found the installer */
581 return TRUE;
582 }
583
584 WARN("Couldn't find the installer '%s', trying alternative.\n", debugstr_w(lpInstallerPath));
585
586 /*
587 * We failed. Try to find the installer from either the current
588 * ReactOS installation directory, or from our current directory.
589 */
590 *lpInstallerPath = UNICODE_NULL;
591 /* Alternatively one can use SharedUserData->NtSystemRoot */
592 if (GetSystemWindowsDirectoryW(lpInstallerPath, PathSize - cchInstallerNameLen - 1))
593 StringCchCatW(lpInstallerPath, PathSize, L"\\");
594 StringCchCatW(lpInstallerPath, PathSize, lpInstallerName);
595
596 dwAttribs = GetFileAttributesW(lpInstallerPath);
597 if ((dwAttribs != INVALID_FILE_ATTRIBUTES) &&
598 !(dwAttribs & FILE_ATTRIBUTE_DIRECTORY))
599 {
600 /* We have found the installer */
601 return TRUE;
602 }
603
604 /* Installer not found */
605 ERR("Couldn't find the installer '%s'\n", debugstr_w(lpInstallerPath));
606 *lpInstallerPath = UNICODE_NULL;
607 return FALSE;
608}
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define wcschr
Definition: compat.h:17
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:636
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2316
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
#define debugstr_w
Definition: kernel32.h:32
static PVOID ptr
Definition: dispmode.c:27
#define PROCESSOR_ARCHITECTURE_IA64
Definition: ketypes.h:111
#define PROCESSOR_ARCHITECTURE_ALPHA64
Definition: ketypes.h:112
#define PROCESSOR_ARCHITECTURE_ALPHA
Definition: ketypes.h:107
#define PROCESSOR_ARCHITECTURE_ARM
Definition: ketypes.h:110
#define PROCESSOR_ARCHITECTURE_UNKNOWN
Definition: ketypes.h:115
#define PROCESSOR_ARCHITECTURE_SHX
Definition: ketypes.h:109
#define PROCESSOR_ARCHITECTURE_MIPS
Definition: ketypes.h:106
#define PROCESSOR_ARCHITECTURE_PPC
Definition: ketypes.h:108
#define PROCESSOR_ARCHITECTURE_AMD64
Definition: ketypes.h:114
#define PROCESSOR_ARCHITECTURE_INTEL
Definition: ketypes.h:105
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define UNICODE_NULL
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
WORD wProcessorArchitecture
Definition: winbase.h:894
uint16_t * PWSTR
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

Referenced by StartInstaller().

◆ IsLiveCD()

BOOL IsLiveCD ( VOID  )

Definition at line 106 of file livecd.c.

107{
108 HKEY ControlKey = NULL;
109 LPWSTR SystemStartOptions = NULL;
110 LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */
111 LONG rc;
112 BOOL ret = FALSE;
113
116 0,
118 &ControlKey);
119 if (rc != ERROR_SUCCESS)
120 {
121 WARN("RegOpenKeyEx() failed with error %lu\n", rc);
122 goto cleanup;
123 }
124
125 rc = ReadRegSzKey(ControlKey, L"SystemStartOptions", &SystemStartOptions);
126 if (rc != ERROR_SUCCESS)
127 {
128 WARN("ReadRegSzKey() failed with error %lu\n", rc);
129 goto cleanup;
130 }
131
132 /* Check for CONSOLE switch in SystemStartOptions */
133 CurrentOption = SystemStartOptions;
134 while (CurrentOption)
135 {
136 NextOption = wcschr(CurrentOption, L' ');
137 if (NextOption)
138 *NextOption = L'\0';
139 if (_wcsicmp(CurrentOption, L"MININT") == 0)
140 {
141 TRACE("Found 'MININT' boot option\n");
142 ret = TRUE;
143 goto cleanup;
144 }
145 CurrentOption = NextOption ? NextOption + 1 : NULL;
146 }
147
148cleanup:
149 if (ControlKey != NULL)
150 RegCloseKey(ControlKey);
151 HeapFree(GetProcessHeap(), 0, SystemStartOptions);
152
153 TRACE("IsLiveCD() returning %u\n", ret);
154 return ret;
155}
static LONG ReadRegSzKey(IN HKEY hKey, IN LPCWSTR pszKey, OUT LPWSTR *pValue)
Definition: install.c:253
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
static void cleanup(void)
Definition: main.c:1335
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:159
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
static char * NextOption(const char *const ostr)
Definition: getopt.c:31
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
long LONG
Definition: pedump.c:60
#define REGSTR_PATH_CURRENT_CONTROL_SET
Definition: regstr.h:564
#define TRACE(s)
Definition: solgame.cpp:4
uint16_t * LPWSTR
Definition: typedefs.h:56
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by wWinMain().

◆ ReadRegSzKey()

LONG ReadRegSzKey ( IN HKEY  hKey,
IN LPCWSTR  pszKey,
OUT LPWSTR pValue 
)

Definition at line 39 of file userinit.c.

43{
44 LONG rc;
45 DWORD dwType;
46 DWORD cbData = 0;
48
49 rc = RegQueryValueExW(hKey, pszKey, NULL, &dwType, NULL, &cbData);
50 if (rc != ERROR_SUCCESS)
51 {
52 WARN("RegQueryValueEx(%s) failed with error %lu\n", debugstr_w(pszKey), rc);
53 return rc;
54 }
55 if (dwType != REG_SZ)
56 {
57 WARN("Wrong registry data type (%u vs %u)\n", dwType, REG_SZ);
59 }
60 Value = (WCHAR*) HeapAlloc(GetProcessHeap(), 0, cbData + sizeof(WCHAR));
61 if (!Value)
62 {
63 WARN("No memory\n");
65 }
66 rc = RegQueryValueExW(hKey, pszKey, NULL, NULL, (LPBYTE)Value, &cbData);
67 if (rc != ERROR_SUCCESS)
68 {
69 WARN("RegQueryValueEx(%s) failed with error %lu\n", debugstr_w(pszKey), rc);
71 return rc;
72 }
73 /* NULL-terminate the string */
74 Value[cbData / sizeof(WCHAR)] = L'\0';
75
76 *pValue = Value;
77 return ERROR_SUCCESS;
78}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
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 HeapAlloc
Definition: compat.h:733
FxAutoRegKey hKey
PWCHAR pValue
#define REG_SZ
Definition: layer.c:22
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
short WCHAR
Definition: pedump.c:58
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
Definition: shlwapi.h:761
unsigned char * LPBYTE
Definition: typedefs.h:53
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by IsConsoleShell().

◆ RunLiveCD()

VOID RunLiveCD ( PSTATE  State)

Definition at line 892 of file livecd.c.

894{
895 LIVECD_UNATTEND Unattend = {0};
896 WCHAR UnattendInf[MAX_PATH];
897
898 InitLogo(&pState->ImageInfo, NULL);
899
900 GetWindowsDirectoryW(UnattendInf, _countof(UnattendInf));
901 wcscat(UnattendInf, L"\\unattend.inf");
902 ParseUnattend(UnattendInf, &Unattend);
903 pState->Unattend = &Unattend;
904
905 while (pState->NextPage != DONE)
906 {
907 switch (pState->NextPage)
908 {
909 case LOCALEPAGE:
912 NULL,
914 (LPARAM)pState);
915 break;
916
917 case STARTPAGE:
920 NULL,
922 (LPARAM)pState);
923 break;
924
925 default:
926 break;
927 }
928 }
929
930 DeleteObject(pState->ImageInfo.hBitmap);
931}
#define IDD_STARTPAGE
Definition: resource.h:27
#define IDD_LOCALEPAGE
Definition: resource.h:13
HINSTANCE hInstance
Definition: charmap.c:19
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2271
pKey DeleteObject()
static INT_PTR CALLBACK LocaleDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: livecd.c:619
VOID ParseUnattend(LPCWSTR UnattendInf, LIVECD_UNATTEND *pUnattend)
Definition: livecd.c:852
static INT_PTR CALLBACK StartDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: livecd.c:757
static VOID InitLogo(PIMGINFO pImgInfo, HWND hwndDlg)
Definition: livecd.c:25
LONG_PTR LPARAM
Definition: minwindef.h:175
#define DONE
Definition: rnr20lib.h:14
wcscat
#define _countof(array)
Definition: sndvol32.h:70
#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 wWinMain().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( userinit  )

Variable Documentation

◆ hInstance

HINSTANCE hInstance
extern

Definition at line 19 of file charmap.c.