ReactOS 0.4.16-dev-973-g9a0ff8b
freeldr.c File Reference
#include <freeldr.h>
#include <debug.h>
Include dependency graph for freeldr.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (WARNING)
 
static BOOLEAN LoadRosload (_In_ PCSTR RosloadPath, _Out_ PVOID *ImageBase, _Out_ PLDR_DATA_TABLE_ENTRY *DataTableEntry)
 
static ULONG LaunchSecondStageLoader (VOID)
 
VOID __cdecl BootMain (IN PCCH CmdLine)
 
int __cdecl wctomb (char *mbchar, wchar_t wchar)
 
int __cdecl mbtowc (wchar_t *wchar, const char *mbchar, size_t count)
 
int __cdecl iswctype (wint_t wc, wctype_t wctypeFlags)
 
double pow (double x, double y)
 
double log (double x)
 
double log10 (double x)
 
PCCHAR FrLdrGetBootPath (VOID)
 
UCHAR FrldrGetBootDrive (VOID)
 
ULONG FrldrGetBootPartition (VOID)
 

Variables

CCHAR FrLdrBootPath [MAX_PATH] = ""
 

Function Documentation

◆ BootMain()

VOID __cdecl BootMain ( IN PCCH  CmdLine)

Definition at line 91 of file freeldr.c.

92{
93 /* Load the default settings from the command-line */
95
96 /* Debugger pre-initialization */
98
100
101 TRACE("BootMain() called.\n");
102
103#ifndef UEFIBOOT
104 /* Check if the CPU is new enough */
105 FrLdrCheckCpuCompatibility(); // FIXME: Should be done inside MachInit!
106#endif
107
108 /* UI pre-initialization */
109 if (!UiInitialize(FALSE))
110 {
111 UiMessageBoxCritical("Unable to initialize UI.");
112 goto Quit;
113 }
114
115 /* Initialize memory manager */
117 {
118 UiMessageBoxCritical("Unable to initialize memory manager.");
119 goto Quit;
120 }
121
122 /* Initialize I/O subsystem */
123 FsInit();
124
125 /* Initialize the module list */
127 {
128 UiMessageBoxCritical("Unable to initialize module list.");
129 goto Quit;
130 }
131
133 {
134 UiMessageBoxCritical("Error when detecting hardware.");
135 goto Quit;
136 }
137
138 /* Launch second stage loader */
140 {
141 UiMessageBoxCritical("Unable to load second stage loader.");
142 }
143
144Quit:
145 /* If we reach this point, something went wrong before, therefore reboot */
146 Reboot();
147}
void LoadSettings(void)
Definition: settings.c:53
@ Reboot
Definition: bl.h:891
#define DebugInit(DebugString)
Definition: debug.h:120
VOID FsInit(VOID)
Definition: fs.c:646
#define MachInitializeBootDevices()
Definition: machine.h:127
BOOLEAN MmInitializeMemoryManager(VOID)
Definition: meminit.c:336
BOOTMGRINFO BootMgrInfo
Definition: settings.c:18
VOID UiMessageBoxCritical(_In_ PCSTR MessageText)
Definition: ui.c:372
BOOLEAN UiInitialize(BOOLEAN ShowUi)
Definition: ui.c:92
#define FALSE
Definition: types.h:117
static const WCHAR CmdLine[]
Definition: install.c:48
static ULONG LaunchSecondStageLoader(VOID)
Definition: freeldr.c:69
VOID FrLdrCheckCpuCompatibility(VOID)
Definition: macharm.c:65
VOID MachInit(IN PCCH CommandLine)
Definition: macharm.c:182
BOOLEAN PeLdrInitializeModuleList(VOID)
Definition: peloader.c:525
@ ESUCCESS
Definition: arc.h:32
#define TRACE(s)
Definition: solgame.cpp:4
PCSTR DebugString
Definition: settings.h:12

Referenced by ArmInit(), and RealEntryPoint().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( WARNING  )

◆ FrldrGetBootDrive()

UCHAR FrldrGetBootDrive ( VOID  )

Definition at line 201 of file freeldr.c.

202{
203 return FrldrBootDrive;
204}
UCHAR FrldrBootDrive
Definition: uefidisk.c:47

◆ FrldrGetBootPartition()

ULONG FrldrGetBootPartition ( VOID  )

Definition at line 206 of file freeldr.c.

207{
208 return FrldrBootPartition;
209}
ULONG FrldrBootPartition
Definition: uefidisk.c:48

◆ FrLdrGetBootPath()

PCCHAR FrLdrGetBootPath ( VOID  )

Definition at line 196 of file freeldr.c.

197{
198 return FrLdrBootPath;
199}
CCHAR FrLdrBootPath[MAX_PATH]
Definition: freeldr.c:29

Referenced by BuildArgvForOsLoader(), and LoadBootDeviceDriver().

◆ iswctype()

int __cdecl iswctype ( wint_t  wc,
wctype_t  wctypeFlags 
)

Definition at line 165 of file freeldr.c.

166{
167 return _isctype((char)wc, wctypeFlags);
168}
_Check_return_ _CRTIMP int __cdecl _isctype(_In_ int _C, _In_ int _Type)

Referenced by _wcstoi64_l(), _wcstoui64_l(), _wtoi64_l(), _wtol(), is_wctype(), iswalnum(), iswalpha(), iswblank(), iswcntrl(), iswdigit(), iswgraph(), iswlower(), iswprint(), iswpunct(), iswspace(), iswupper(), iswxdigit(), rangematch(), towlower(), towupper(), wcstol(), and wcstoul().

◆ LaunchSecondStageLoader()

static ULONG LaunchSecondStageLoader ( VOID  )
static

Definition at line 69 of file freeldr.c.

70{
71 PLDR_DATA_TABLE_ENTRY RosloadDTE;
72 PVOID ImageBase;
73 LONG (*EntryPoint)(VOID);
74
75 /* Load the second stage loader */
76 if (!LoadRosload("rosload.exe", &ImageBase, &RosloadDTE))
77 {
78 /* Try in loader directory */
79 if (!LoadRosload("loader\\rosload.exe", &ImageBase, &RosloadDTE))
80 {
81 return ENOENT;
82 }
83 }
84
85 /* Call the entrypoint */
86 printf("Launching rosload.exe...\n");
87 EntryPoint = VaToPa(RosloadDTE->EntryPoint);
88 return (*EntryPoint)();
89}
#define ENOENT
Definition: acclib.h:79
#define VOID
Definition: acefi.h:82
FORCEINLINE PVOID VaToPa(PVOID Va)
Definition: conversion.h:15
static BOOLEAN LoadRosload(_In_ PCSTR RosloadPath, _Out_ PVOID *ImageBase, _Out_ PLDR_DATA_TABLE_ENTRY *DataTableEntry)
Definition: freeldr.c:35
#define printf
Definition: freeldr.h:97
long LONG
Definition: pedump.c:60
Definition: btrfs_drv.h:1876
PVOID EntryPoint
Definition: ntddk_ex.h:203

Referenced by BootMain().

◆ LoadRosload()

static BOOLEAN LoadRosload ( _In_ PCSTR  RosloadPath,
_Out_ PVOID ImageBase,
_Out_ PLDR_DATA_TABLE_ENTRY DataTableEntry 
)
static

Definition at line 35 of file freeldr.c.

39{
40 CHAR FullPath[MAX_PATH];
42
43 /* Create full rosload.exe path */
44 RtlStringCbPrintfA(FullPath,
45 sizeof(FullPath),
46 "%s\\%s",
48 RosloadPath);
49
50 TRACE("Loading second stage loader '%s'\n", FullPath);
51
52 /* Load rosload.exe as a bootloader image. The base name is "scsiport.sys",
53 because it exports ScsiPort* functions for ntbootdd.sys */
54 Success = PeLdrLoadBootImage(FullPath,
55 "scsiport.sys",
56 ImageBase,
57 DataTableEntry);
58 if (!Success)
59 {
60 WARN("Failed to load second stage loader '%s'\n", FullPath);
61 return FALSE;
62 }
63
64 return TRUE;
65}
unsigned char BOOLEAN
#define WARN(fmt,...)
Definition: precomp.h:61
#define TRUE
Definition: types.h:120
#define MAX_PATH
Definition: compat.h:34
@ Success
Definition: eventcreate.c:712
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
BOOLEAN PeLdrLoadBootImage(_In_ PCSTR FilePath, _In_ PCSTR BaseDllName, _Out_ PVOID *ImageBase, _Out_ PLDR_DATA_TABLE_ENTRY *DataTableEntry)
Definition: peloader.c:1052
char CHAR
Definition: xmlstorage.h:175

Referenced by LaunchSecondStageLoader().

◆ log()

double log ( double  x)

Definition at line 184 of file freeldr.c.

185{
186 __debugbreak();
187 return 0.0;
188}
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698

◆ log10()

◆ mbtowc()

int __cdecl mbtowc ( wchar_t wchar,
const char mbchar,
size_t  count 
)

Definition at line 158 of file freeldr.c.

159{
160 *wchar = (wchar_t)*mbchar;
161 return 1;
162}
#define wchar_t
Definition: wchar.h:102
size_t const wchar_t const wchar
Definition: wcrtomb.cpp:53

◆ pow()

◆ wctomb()

int __cdecl wctomb ( char mbchar,
wchar_t  wchar 
)

Definition at line 152 of file freeldr.c.

153{
154 *mbchar = (char)wchar;
155 return 1;
156}
unsigned char
Definition: typeof.h:29

Variable Documentation

◆ FrLdrBootPath