ReactOS 0.4.16-dev-2207-geb15453
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 488 of file userinit.c.

492{
493 SYSTEM_INFO SystemInfo;
494 SIZE_T cchInstallerNameLen;
495 PWSTR ptr;
496 DWORD dwAttribs;
497
498 cchInstallerNameLen = wcslen(lpInstallerName);
499 if (PathSize < cchInstallerNameLen)
500 {
501 /* The buffer is not large enough to contain the installer file name */
502 *lpInstallerPath = UNICODE_NULL;
503 return FALSE;
504 }
505
506 /*
507 * First, try to find the installer using the default drive, under
508 * the directory whose name corresponds to the currently-running
509 * CPU architecture.
510 */
511 GetSystemInfo(&SystemInfo);
512
513 *lpInstallerPath = UNICODE_NULL;
514 /* Alternatively one can use SharedUserData->NtSystemRoot */
515 GetSystemWindowsDirectoryW(lpInstallerPath, PathSize - cchInstallerNameLen - 1);
516 ptr = wcschr(lpInstallerPath, L'\\');
517 if (ptr)
518 *++ptr = UNICODE_NULL;
519 else
520 *lpInstallerPath = UNICODE_NULL;
521
522 /* Append the corresponding CPU architecture */
523 switch (SystemInfo.wProcessorArchitecture)
524 {
526 StringCchCatW(lpInstallerPath, PathSize, L"I386");
527 break;
528
530 StringCchCatW(lpInstallerPath, PathSize, L"MIPS");
531 break;
532
534 StringCchCatW(lpInstallerPath, PathSize, L"ALPHA");
535 break;
536
538 StringCchCatW(lpInstallerPath, PathSize, L"PPC");
539 break;
540
542 StringCchCatW(lpInstallerPath, PathSize, L"SHX");
543 break;
544
546 StringCchCatW(lpInstallerPath, PathSize, L"ARM");
547 break;
548
550 StringCchCatW(lpInstallerPath, PathSize, L"IA64");
551 break;
552
554 StringCchCatW(lpInstallerPath, PathSize, L"ALPHA64");
555 break;
556
558 StringCchCatW(lpInstallerPath, PathSize, L"AMD64");
559 break;
560
561 // case PROCESSOR_ARCHITECTURE_MSIL: /* .NET CPU-independent code */
563 default:
564 WARN("Unknown processor architecture %lu\n", SystemInfo.wProcessorArchitecture);
566 break;
567 }
568
570 StringCchCatW(lpInstallerPath, PathSize, L"\\");
571 StringCchCatW(lpInstallerPath, PathSize, lpInstallerName);
572
573 dwAttribs = GetFileAttributesW(lpInstallerPath);
574 if ((dwAttribs != INVALID_FILE_ATTRIBUTES) &&
575 !(dwAttribs & FILE_ATTRIBUTE_DIRECTORY))
576 {
577 /* We have found the installer */
578 return TRUE;
579 }
580
581 WARN("Couldn't find the installer '%s', trying alternative.\n", debugstr_w(lpInstallerPath));
582
583 /*
584 * We failed. Try to find the installer from either the current
585 * ReactOS installation directory, or from our current directory.
586 */
587 *lpInstallerPath = UNICODE_NULL;
588 /* Alternatively one can use SharedUserData->NtSystemRoot */
589 if (GetSystemWindowsDirectoryW(lpInstallerPath, PathSize - cchInstallerNameLen - 1))
590 StringCchCatW(lpInstallerPath, PathSize, L"\\");
591 StringCchCatW(lpInstallerPath, PathSize, lpInstallerName);
592
593 dwAttribs = GetFileAttributesW(lpInstallerPath);
594 if ((dwAttribs != INVALID_FILE_ATTRIBUTES) &&
595 !(dwAttribs & FILE_ATTRIBUTE_DIRECTORY))
596 {
597 /* We have found the installer */
598 return TRUE;
599 }
600
601 /* Installer not found */
602 ERR("Couldn't find the installer '%s'.\n", debugstr_w(lpInstallerPath));
603 *lpInstallerPath = UNICODE_NULL;
604 return FALSE;
605}
#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:652
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2397
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
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by wWinMain().

◆ ReadRegSzKey()

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

Definition at line 38 of file userinit.c.

42{
43 LONG rc;
44 DWORD dwType;
45 DWORD cbData = 0;
47
48 rc = RegQueryValueExW(hKey, pszKey, NULL, &dwType, NULL, &cbData);
49 if (rc != ERROR_SUCCESS)
50 {
51 WARN("RegQueryValueEx(%s) failed with error %lu\n", debugstr_w(pszKey), rc);
52 return rc;
53 }
54 if (dwType != REG_SZ)
55 {
56 WARN("Wrong registry data type (%u vs %u)\n", dwType, REG_SZ);
58 }
59 Value = (WCHAR*) HeapAlloc(GetProcessHeap(), 0, cbData + sizeof(WCHAR));
60 if (!Value)
61 {
62 WARN("No memory\n");
64 }
65 rc = RegQueryValueExW(hKey, pszKey, NULL, NULL, (LPBYTE)Value, &cbData);
66 if (rc != ERROR_SUCCESS)
67 {
68 WARN("RegQueryValueEx(%s) failed with error %lu\n", debugstr_w(pszKey), rc);
70 return rc;
71 }
72 /* NULL-terminate the string */
73 Value[cbData / sizeof(WCHAR)] = L'\0';
74
75 *pValue = Value;
76 return ERROR_SUCCESS;
77}
#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
_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
__wchar_t WCHAR
Definition: xmlstorage.h:180

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:18
#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:2352
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.