[FREELDR]
[reactos.git] / reactos / boot / freeldr / freeldr / freeldr.c
index 77a164a..01af41e 100644 (file)
@@ -40,13 +40,13 @@ VOID BootMain(LPSTR CmdLine)
        if (!UiInitialize(FALSE))
        {
                UiMessageBoxCritical("Unable to initialize UI.\n");
-               return;
+               goto quit;
        }
 
        if (!MmInitializeMemoryManager())
        {
                UiMessageBoxCritical("Unable to initialize memory manager");
-               return;
+               goto quit;
        }
 
 #ifdef _M_IX86
@@ -54,9 +54,16 @@ VOID BootMain(LPSTR CmdLine)
        HalpInitBusHandler();
 #endif
        RunLoader();
+
+quit:
+       /* If we reach this point, something went wrong before, therefore reboot */
+       DiskStopFloppyMotor();
+       Reboot();
 }
 
 // We need to emulate these, because the original ones don't work in freeldr
+// These functions are here, because they need to be in the main compilation unit
+// and cannot be in a library.
 int __cdecl wctomb(char *mbchar, wchar_t wchar)
 {
     *mbchar = (char)wchar;
@@ -68,3 +75,10 @@ int __cdecl mbtowc (wchar_t *wchar, const char *mbchar, size_t count)
     *wchar = (wchar_t)*mbchar;
     return 1;
 }
+
+// The wctype table is 144 KB, too much for poor freeldr
+int iswctype(wint_t wc, wctype_t wctypeFlags)
+{
+    return _isctype((char)wc, wctypeFlags);
+}
+