Added initial console setup code.

svn path=/trunk/; revision=3476
This commit is contained in:
Eric Kohl 2002-09-08 18:29:56 +00:00
parent f6ca76b756
commit 5c1d53b4eb
7 changed files with 1452 additions and 1 deletions

View file

@ -74,7 +74,7 @@ STORAGE_DRIVERS = atapi cdrom class2 disk scsiport
# System applications # System applications
# autochk lsass services shell winlogon # autochk lsass services shell winlogon
SYS_APPS = autochk services shell winlogon gstart SYS_APPS = autochk services shell winlogon gstart usetup
# System services # System services
# rpcss eventlog # rpcss eventlog

24
reactos/bootcd.bat Executable file
View file

@ -0,0 +1,24 @@
@echo off
set BOOTCD_DIR=..\bootcd
md %BOOTCD_DIR%
md %BOOTCD_DIR%\disk
md %BOOTCD_DIR%\disk\bootdisk
md %BOOTCD_DIR%\disk\install
md %BOOTCD_DIR%\disk\reactos
md %BOOTCD_DIR%\disk\reactos\system32
copy /Y ntoskrnl\ntoskrnl.exe %BOOTCD_DIR%\disk\reactos
copy /Y hal\halx86\hal.dll %BOOTCD_DIR%\disk\reactos
copy /Y drivers\fs\vfat\vfatfs.sys %BOOTCD_DIR%\disk\reactos
copy /Y drivers\fs\cdfs\cdfs.sys %BOOTCD_DIR%\disk\reactos
copy /Y drivers\fs\ntfs\ntfs.sys %BOOTCD_DIR%\disk\reactos
copy /Y drivers\dd\floppy\floppy.sys %BOOTCD_DIR%\disk\reactos
copy /Y drivers\dd\blue\blue.sys %BOOTCD_DIR%\disk\reactos
copy /Y drivers\input\keyboard\keyboard.sys %BOOTCD_DIR%\disk\reactos
copy /Y drivers\storage\atapi\atapi.sys %BOOTCD_DIR%\disk\reactos
copy /Y drivers\storage\scsiport\scsiport.sys %BOOTCD_DIR%\disk\reactos
copy /Y drivers\storage\cdrom\cdrom.sys %BOOTCD_DIR%\disk\reactos
copy /Y drivers\storage\disk\disk.sys %BOOTCD_DIR%\disk\reactos
copy /Y drivers\storage\class2\class2.sys %BOOTCD_DIR%\disk\reactos
copy /Y lib\ntdll\ntdll.dll %BOOTCD_DIR%\disk\reactos\system32
copy /Y subsys\system\usetup\usetup.exe %BOOTCD_DIR%\disk\reactos\system32\smss.exe

View file

@ -0,0 +1,883 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/misc/console.c
* PURPOSE: Win32 server console functions
* PROGRAMMER: ???
* UPDATE HISTORY:
* 199901?? ?? Created
* 19990204 EA SetConsoleTitleA
* 19990306 EA Stubs
*/
/* INCLUDES ******************************************************************/
#include <ddk/ntddk.h>
#include <ddk/ntddblue.h>
#include <ntos/keyboard.h>
#include "usetup.h"
//#include <windows.h>
//#include <assert.h>
//#include <wchar.h>
/* GLOBALS ******************************************************************/
static HANDLE StdInput = INVALID_HANDLE_VALUE;
static HANDLE StdOutput = INVALID_HANDLE_VALUE;
static SHORT xScreen = 0;
static SHORT yScreen = 0;
NTSTATUS
GetConsoleScreenBufferInfo(PCONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo);
/* FUNCTIONS *****************************************************************/
NTSTATUS
AllocConsole(VOID)
{
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
UNICODE_STRING Name;
NTSTATUS Status;
CONSOLE_SCREEN_BUFFER_INFO csbi;
/* Open the screen */
RtlInitUnicodeString(&Name,
L"\\??\\BlueScreen");
InitializeObjectAttributes(&ObjectAttributes,
&Name,
0,
NULL,
NULL);
Status = NtCreateFile(&StdOutput,
FILE_ALL_ACCESS,
&ObjectAttributes,
&IoStatusBlock,
NULL,
0,
0,
FILE_OPEN,
0,
NULL,
0);
if (!NT_SUCCESS(Status))
return(Status);
/* Open the keyboard */
RtlInitUnicodeString(&Name,
L"\\??\\Keyboard");
InitializeObjectAttributes(&ObjectAttributes,
&Name,
0,
NULL,
NULL);
Status = NtCreateFile(&StdInput,
FILE_ALL_ACCESS,
&ObjectAttributes,
&IoStatusBlock,
NULL,
0,
0,
FILE_OPEN,
0,
NULL,
0);
GetConsoleScreenBufferInfo(&csbi);
xScreen = csbi.dwSize.X;
yScreen = csbi.dwSize.Y;
return(Status);
}
VOID
FreeConsole(VOID)
{
if (StdInput != INVALID_HANDLE_VALUE)
NtClose(StdInput);
if (StdOutput != INVALID_HANDLE_VALUE)
NtClose(StdOutput);
}
NTSTATUS
WriteConsole(PCHAR Buffer,
ULONG NumberOfCharsToWrite,
PULONG NumberOfCharsWritten)
{
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status = STATUS_SUCCESS;
ULONG i;
Status = NtWriteFile(StdOutput,
NULL,
NULL,
NULL,
&IoStatusBlock,
Buffer,
NumberOfCharsToWrite,
NULL,
NULL);
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(StdOutput,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
if (NumberOfCharsWritten != NULL)
{
*NumberOfCharsWritten = IoStatusBlock.Information;
}
return(Status);
}
#if 0
/*--------------------------------------------------------------
* ReadConsoleA
*/
WINBOOL
STDCALL
ReadConsoleA(HANDLE hConsoleInput,
LPVOID lpBuffer,
DWORD nNumberOfCharsToRead,
LPDWORD lpNumberOfCharsRead,
LPVOID lpReserved)
{
KEY_EVENT_RECORD KeyEventRecord;
BOOL stat = TRUE;
PCHAR Buffer = (PCHAR)lpBuffer;
DWORD Result;
int i;
for (i=0; (stat && i<nNumberOfCharsToRead);)
{
stat = ReadFile(hConsoleInput,
&KeyEventRecord,
sizeof(KEY_EVENT_RECORD),
&Result,
NULL);
if (stat && KeyEventRecord.bKeyDown && KeyEventRecord.uChar.AsciiChar != 0)
{
Buffer[i] = KeyEventRecord.uChar.AsciiChar;
i++;
}
}
if (lpNumberOfCharsRead != NULL)
{
*lpNumberOfCharsRead = i;
}
return(stat);
}
#endif
NTSTATUS
ReadConsoleInput(PINPUT_RECORD Buffer,
ULONG Length,
PULONG NumberOfEventsRead)
{
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status = STATUS_SUCCESS;
ULONG i;
for (i=0; (NT_SUCCESS(Status) && i < Length);)
{
Status = NtReadFile(StdInput,
NULL,
NULL,
NULL,
&IoStatusBlock,
&Buffer[i].Event.KeyEvent,
sizeof(KEY_EVENT_RECORD),
NULL,
NULL);
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(StdInput,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
if (NT_SUCCESS(Status))
{
Buffer[i].EventType = KEY_EVENT;
i++;
}
}
if (NumberOfEventsRead != NULL)
{
*NumberOfEventsRead = i;
}
return(Status);
}
NTSTATUS
ReadConsoleOutputCharacters(LPSTR lpCharacter,
ULONG nLength,
COORD dwReadCoord,
PULONG lpNumberOfCharsRead)
{
IO_STATUS_BLOCK IoStatusBlock;
ULONG dwBytesReturned;
OUTPUT_CHARACTER Buffer;
NTSTATUS Status;
Buffer.dwCoord = dwReadCoord;
Status = NtDeviceIoControlFile(StdOutput,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_CONSOLE_READ_OUTPUT_CHARACTER,
&Buffer,
sizeof(OUTPUT_CHARACTER),
(PVOID)lpCharacter,
nLength);
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(StdOutput,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
if (NT_SUCCESS(Status) && lpNumberOfCharsRead != NULL)
{
*lpNumberOfCharsRead = Buffer.dwTransfered;
}
return(Status);
}
NTSTATUS
ReadConsoleOutputAttributes(PUSHORT lpAttribute,
ULONG nLength,
COORD dwReadCoord,
PULONG lpNumberOfAttrsRead)
{
IO_STATUS_BLOCK IoStatusBlock;
ULONG dwBytesReturned;
OUTPUT_ATTRIBUTE Buffer;
NTSTATUS Status;
Buffer.dwCoord = dwReadCoord;
Status = NtDeviceIoControlFile(StdOutput,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE,
&Buffer,
sizeof(OUTPUT_ATTRIBUTE),
(PVOID)lpAttribute,
nLength);
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(StdOutput,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
if (NT_SUCCESS(Status) && lpNumberOfAttrsRead != NULL)
{
*lpNumberOfAttrsRead = Buffer.dwTransfered;
}
return(Status);
}
NTSTATUS
WriteConsoleOutputCharacters(LPCSTR lpCharacter,
ULONG nLength,
COORD dwWriteCoord)
{
IO_STATUS_BLOCK IoStatusBlock;
PCHAR Buffer;
COORD *pCoord;
PCHAR pText;
NTSTATUS Status;
Buffer = RtlAllocateHeap(ProcessHeap,
0,
nLength + sizeof(COORD));
pCoord = (COORD *)Buffer;
pText = (PCHAR)(pCoord + 1);
*pCoord = dwWriteCoord;
memcpy(pText, lpCharacter, nLength);
Status = NtDeviceIoControlFile(StdOutput,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER,
NULL,
0,
Buffer,
nLength + sizeof(COORD));
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(StdOutput,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
RtlFreeHeap(ProcessHeap,
0,
Buffer);
return(Status);
}
NTSTATUS
WriteConsoleOutputAttributes(CONST USHORT *lpAttribute,
ULONG nLength,
COORD dwWriteCoord,
PULONG lpNumberOfAttrsWritten)
{
IO_STATUS_BLOCK IoStatusBlock;
PUSHORT Buffer;
COORD *pCoord;
PUSHORT pAttrib;
NTSTATUS Status;
Buffer = RtlAllocateHeap(ProcessHeap,
0,
nLength * sizeof(USHORT) + sizeof(COORD));
pCoord = (COORD *)Buffer;
pAttrib = (PUSHORT)(pCoord + 1);
*pCoord = dwWriteCoord;
memcpy(pAttrib, lpAttribute, nLength * sizeof(USHORT));
Status = NtDeviceIoControlFile(StdOutput,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE,
NULL,
0,
Buffer,
nLength * sizeof(USHORT) + sizeof(COORD));
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(StdOutput,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
RtlFreeHeap(ProcessHeap,
0,
Buffer);
return(Status);
}
NTSTATUS
FillConsoleOutputAttribute(USHORT wAttribute,
ULONG nLength,
COORD dwWriteCoord,
PULONG lpNumberOfAttrsWritten)
{
IO_STATUS_BLOCK IoStatusBlock;
OUTPUT_ATTRIBUTE Buffer;
ULONG dwBytesReturned;
NTSTATUS Status;
Buffer.wAttribute = wAttribute;
Buffer.nLength = nLength;
Buffer.dwCoord = dwWriteCoord;
Status = NtDeviceIoControlFile(StdOutput,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE,
&Buffer,
sizeof(OUTPUT_ATTRIBUTE),
&Buffer,
sizeof(OUTPUT_ATTRIBUTE));
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(StdOutput,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
if (NT_SUCCESS(Status))
{
*lpNumberOfAttrsWritten = Buffer.dwTransfered;
}
return(Status);
}
NTSTATUS
FillConsoleOutputCharacter(CHAR Character,
ULONG Length,
COORD WriteCoord,
PULONG NumberOfCharsWritten)
{
IO_STATUS_BLOCK IoStatusBlock;
OUTPUT_CHARACTER Buffer;
ULONG dwBytesReturned;
NTSTATUS Status;
Buffer.cCharacter = Character;
Buffer.nLength = Length;
Buffer.dwCoord = WriteCoord;
Status = NtDeviceIoControlFile(StdOutput,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER,
&Buffer,
sizeof(OUTPUT_CHARACTER),
&Buffer,
sizeof(OUTPUT_CHARACTER));
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(StdOutput,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
if (NT_SUCCESS(Status))
{
*NumberOfCharsWritten = Buffer.dwTransfered;
}
return(Status);
}
#if 0
/*--------------------------------------------------------------
* GetConsoleMode
*/
WINBASEAPI
BOOL
WINAPI
GetConsoleMode(
HANDLE hConsoleHandle,
LPDWORD lpMode
)
{
CONSOLE_MODE Buffer;
DWORD dwBytesReturned;
if (DeviceIoControl (hConsoleHandle,
IOCTL_CONSOLE_GET_MODE,
NULL,
0,
&Buffer,
sizeof(CONSOLE_MODE),
&dwBytesReturned,
NULL))
{
*lpMode = Buffer.dwMode;
SetLastError (ERROR_SUCCESS);
return TRUE;
}
SetLastError(0); /* FIXME: What error code? */
return FALSE;
}
/*--------------------------------------------------------------
* GetConsoleCursorInfo
*/
WINBASEAPI
BOOL
WINAPI
GetConsoleCursorInfo(
HANDLE hConsoleOutput,
PCONSOLE_CURSOR_INFO lpConsoleCursorInfo
)
{
DWORD dwBytesReturned;
if (DeviceIoControl (hConsoleOutput,
IOCTL_CONSOLE_GET_CURSOR_INFO,
NULL,
0,
lpConsoleCursorInfo,
sizeof(CONSOLE_CURSOR_INFO),
&dwBytesReturned,
NULL))
return TRUE;
return FALSE;
}
/*--------------------------------------------------------------
* SetConsoleMode
*/
WINBASEAPI
BOOL
WINAPI
SetConsoleMode(
HANDLE hConsoleHandle,
DWORD dwMode
)
{
CONSOLE_MODE Buffer;
DWORD dwBytesReturned;
Buffer.dwMode = dwMode;
if (DeviceIoControl(hConsoleHandle,
IOCTL_CONSOLE_SET_MODE,
&Buffer,
sizeof(CONSOLE_MODE),
NULL,
0,
&dwBytesReturned,
NULL))
{
SetLastError (ERROR_SUCCESS);
return TRUE;
}
SetLastError(0); /* FIXME: What error code? */
return FALSE;
}
#endif
NTSTATUS
GetConsoleScreenBufferInfo(PCONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo)
{
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
Status = NtDeviceIoControlFile(StdOutput,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO,
NULL,
0,
ConsoleScreenBufferInfo,
sizeof(CONSOLE_SCREEN_BUFFER_INFO));
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(StdOutput,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
return(Status);
}
NTSTATUS
SetConsoleCursorInfo(PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
{
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
Status = NtDeviceIoControlFile(StdOutput,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_CONSOLE_SET_CURSOR_INFO,
(PCONSOLE_CURSOR_INFO)lpConsoleCursorInfo,
sizeof(CONSOLE_CURSOR_INFO),
NULL,
0);
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(StdOutput,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
return(Status);
}
NTSTATUS
SetConsoleCursorPosition(COORD dwCursorPosition)
{
CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
Status = GetConsoleScreenBufferInfo(&ConsoleScreenBufferInfo);
if (!NT_SUCCESS(Status))
return(Status);
ConsoleScreenBufferInfo.dwCursorPosition.X = dwCursorPosition.X;
ConsoleScreenBufferInfo.dwCursorPosition.Y = dwCursorPosition.Y;
Status = NtDeviceIoControlFile(StdOutput,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO,
&ConsoleScreenBufferInfo,
sizeof(CONSOLE_SCREEN_BUFFER_INFO),
NULL,
0);
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(StdOutput,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
return(Status);
}
NTSTATUS
SetConsoleTextAttribute(WORD wAttributes)
{
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
Status = NtDeviceIoControlFile(StdOutput,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE,
&wAttributes,
sizeof(WORD),
NULL,
0);
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(StdOutput,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
return(Status);
}
VOID
ConInKey(PINPUT_RECORD Buffer)
{
ULONG KeysRead;
while (TRUE)
{
ReadConsoleInput(Buffer, 1, &KeysRead);
if ((Buffer->EventType == KEY_EVENT) &&
(Buffer->Event.KeyEvent.bKeyDown == TRUE))
break;
}
}
VOID
ConOutChar(CHAR c)
{
ULONG Written;
WriteConsole(&c,
1,
&Written);
}
VOID
ConOutPuts(LPSTR szText)
{
ULONG Written;
WriteConsole(szText,
strlen(szText),
&Written);
WriteConsole("\n",
1,
&Written);
}
VOID
ConOutPrintf(LPSTR szFormat, ...)
{
CHAR szOut[256];
DWORD dwWritten;
va_list arg_ptr;
va_start(arg_ptr, szFormat);
vsprintf(szOut, szFormat, arg_ptr);
va_end(arg_ptr);
WriteConsole(szOut,
strlen(szOut),
&dwWritten);
}
SHORT
GetCursorX(VOID)
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(&csbi);
return(csbi.dwCursorPosition.X);
}
SHORT
GetCursorY(VOID)
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(&csbi);
return(csbi.dwCursorPosition.Y);
}
VOID
GetScreenSize(SHORT *maxx,
SHORT *maxy)
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(&csbi);
if (maxx)
*maxx = csbi.dwSize.X;
if (maxy)
*maxy = csbi.dwSize.Y;
}
VOID
SetCursorType(BOOL bInsert,
BOOL bVisible)
{
CONSOLE_CURSOR_INFO cci;
cci.dwSize = bInsert ? 10 : 99;
cci.bVisible = bVisible;
SetConsoleCursorInfo(&cci);
}
VOID
SetCursorXY(SHORT x,
SHORT y)
{
COORD coPos;
coPos.X = x;
coPos.Y = y;
SetConsoleCursorPosition(coPos);
}
VOID
ClearScreen(VOID)
{
COORD coPos;
ULONG Written;
coPos.X = 0;
coPos.Y = 0;
FillConsoleOutputCharacter(' ',
xScreen * yScreen,
coPos,
&Written);
}
VOID
SetStatusText(PCHAR Text)
{
COORD coPos;
ULONG Written;
coPos.X = 0;
coPos.Y = yScreen - 1;
FillConsoleOutputAttribute(0x70,
xScreen,
coPos,
&Written);
FillConsoleOutputCharacter(' ',
xScreen,
coPos,
&Written);
WriteConsoleOutputCharacters(Text,
strlen(Text),
coPos);
}
VOID
SetTextXY(SHORT x, SHORT y, PCHAR Text)
{
COORD coPos;
coPos.X = x;
coPos.Y = y;
WriteConsoleOutputCharacters(Text,
strlen(Text),
coPos);
}
/* EOF */

View file

@ -0,0 +1,21 @@
# $Id: makefile,v 1.1 2002/09/08 18:28:43 ekohl Exp $
PATH_TO_TOP = ../../..
TARGET_TYPE = program
TARGET_APPTYPE = native
TARGET_NAME = usetup
TARGET_INSTALLDIR = system32
TARGET_CFLAGS = -D__NTAPP__
TARGET_OBJECTS = $(TARGET_NAME).o console.o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,390 @@
/* $Id: usetup.c,v 1.1 2002/09/08 18:28:43 ekohl Exp $
*
* smss.c - Session Manager
*
* ReactOS Operating System
*
* --------------------------------------------------------------------
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING.LIB. If not, write
* to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
* MA 02139, USA.
*
* --------------------------------------------------------------------
*
* 19990529 (Emanuele Aliberti)
* Compiled successfully with egcs 1.1.2
*/
#include <ddk/ntddk.h>
#include <ddk/ntddblue.h>
#include <ntdll/rtl.h>
#include <ntos/keyboard.h>
#include "usetup.h"
HANDLE ProcessHeap;
/* FUNCTIONS ****************************************************************/
void
DisplayString(LPCWSTR lpwString)
{
UNICODE_STRING us;
RtlInitUnicodeString(&us, lpwString);
NtDisplayString(&us);
}
void
PrintString(char* fmt,...)
{
char buffer[512];
va_list ap;
UNICODE_STRING UnicodeString;
ANSI_STRING AnsiString;
va_start(ap, fmt);
vsprintf(buffer, fmt, ap);
va_end(ap);
RtlInitAnsiString(&AnsiString, buffer);
RtlAnsiStringToUnicodeString(&UnicodeString,
&AnsiString,
TRUE);
NtDisplayString(&UnicodeString);
RtlFreeUnicodeString(&UnicodeString);
}
/*
* Confirm quit setup
* RETURNS
* TRUE: Quit setup.
* FALSE: Don't quit setup.
*/
static BOOL
ConfirmQuit(PINPUT_RECORD Ir)
{
SHORT xScreen;
SHORT yScreen;
SHORT yTop;
SHORT xLeft;
BOOL Result = FALSE;
PUSHORT pAttributes = NULL;
PUCHAR pCharacters = NULL;
COORD Pos;
GetScreenSize(&xScreen, &yScreen);
yTop = (yScreen - 10) / 2;
xLeft = (xScreen - 52) / 2;
/* Save screen */
Pos.X = 0;
Pos.Y = 0;
pAttributes = (PUSHORT)RtlAllocateHeap(RtlGetProcessHeap(),
0,
xScreen * yScreen * sizeof(USHORT));
ReadConsoleOutputAttributes(pAttributes,
xScreen * yScreen,
Pos,
NULL);
pCharacters = (PUCHAR)RtlAllocateHeap(RtlGetProcessHeap(),
0,
xScreen * yScreen * sizeof(UCHAR));
ReadConsoleOutputCharacters(pCharacters,
xScreen * yScreen,
Pos,
NULL);
/* Draw popup window */
SetTextXY(xLeft, yTop,
"+----------------------------------------------------+");
SetTextXY(xLeft, yTop + 1,
"| ReactOS 0.0.20 is not completely installed on your |");
SetTextXY(xLeft, yTop + 2,
"| computer. If you quit Setup now, you will need to |");
SetTextXY(xLeft, yTop + 3,
"| run Setup again to install ReactOS. |");
SetTextXY(xLeft, yTop + 4,
"| |");
SetTextXY(xLeft, yTop + 5,
"| * Press ENTER to continue Setup. |");
SetTextXY(xLeft, yTop + 6,
"| * Press F3 to quit Setup. |");
SetTextXY(xLeft, yTop + 7,
"+----------------------------------------------------+");
SetTextXY(xLeft, yTop + 8,
"| F3= Quit ENTER = Continue |");
SetTextXY(xLeft, yTop + 9,
"+----------------------------------------------------+");
while(TRUE)
{
ConInKey(Ir);
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3))
{
Result = TRUE;
break;
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D)
{
Result = FALSE;
break;
}
}
/* Restore screen */
WriteConsoleOutputAttributes(pAttributes,
xScreen * yScreen,
Pos,
NULL);
WriteConsoleOutputCharacters(pCharacters,
xScreen * yScreen,
Pos);
RtlFreeHeap(RtlGetProcessHeap(),
0,
pAttributes);
RtlFreeHeap(RtlGetProcessHeap(),
0,
pCharacters);
return(Result);
}
static BOOL
InstallIntroPage(PINPUT_RECORD Ir)
{
ClearScreen();
SetTextXY(4, 3, " ReactOS 0.0.20 Setup ");
SetTextXY(4, 4, "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD");
SetTextXY(6, 8, "Install intro page");
#if 0
SetTextXY(6, 10, "This part of the setup copies the ReactOS Operating System to your");
SetTextXY(6, 11, "computer and prepairs the second part of the setup.");
SetTextXY(8, 14, "\xf9 Press ENTER to start the ReactOS setup.");
SetTextXY(8, 17, "\xf9 Press F3 to quit without installing ReactOS.");
#endif
SetStatusText(" ENTER = Continue F3 = Quit");
while(TRUE)
{
ConInKey(Ir);
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3))
{
if (ConfirmQuit(Ir) == TRUE)
return(FALSE);
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D)
break;
}
return(TRUE);
}
#if 0
static BOOL
RepairIntroPage(PINPUT_RECORD Ir)
{
ClearScreen();
}
#endif
/*
* First setup page
* RETURNS
* TRUE: setup/repair completed successfully
* FALSE: setup/repair terminated by user
*/
static BOOL
IntroPage(PINPUT_RECORD Ir)
{
CHECKPOINT1;
ClearScreen();
SetTextXY(4, 3, " ReactOS 0.0.20 Setup ");
SetTextXY(4, 4, "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD");
SetTextXY(6, 8, "Welcome to the ReactOS Setup");
SetTextXY(6, 10, "This part of the setup copies the ReactOS Operating System to your");
SetTextXY(6, 11, "computer and prepares the second part of the setup.");
SetTextXY(8, 14, "\xf9 Press ENTER to install ReactOS.");
#if 0
SetTextXY(8, 16, "\xf9 Press R to repair ReactOS.");
#endif
SetTextXY(8, 17, "\xf9 Press F3 to quit without installing ReactOS.");
SetStatusText(" ENTER = Continue F3 = Quit");
CHECKPOINT1;
while(TRUE)
{
CHECKPOINT1;
ConInKey(Ir);
CHECKPOINT1;
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3))
{
if (ConfirmQuit(Ir) == TRUE)
return(FALSE);
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D)
{
return(InstallIntroPage(Ir));
}
#if 0
else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'R')
{
return(RepairIntroPage(Ir));
}
#endif
}
return(FALSE);
}
static VOID
QuitPage(PINPUT_RECORD Ir)
{
ClearScreen();
SetTextXY(4, 3, " ReactOS 0.0.20 Setup ");
SetTextXY(4, 4, "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD");
SetTextXY(6, 10, "ReactOS is not completely installed");
SetTextXY(8, 10, "Remove floppy disk from drive A:.");
SetTextXY(9, 10, "Remove cdrom from cdrom drive.");
SetTextXY(11, 10, "Press ENTER to reboot your computer.");
SetStatusText(" ENTER = Reboot computer");
while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D)
{
return;
}
}
}
static VOID
SuccessPage(PINPUT_RECORD Ir)
{
ClearScreen();
SetTextXY(4, 3, " ReactOS 0.0.20 Setup ");
SetTextXY(4, 4, "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD");
SetTextXY(6, 10, "The basic components of ReactOS have been installed successfully.");
SetTextXY(8, 10, "Remove floppy disk from drive A:.");
SetTextXY(9, 10, "Remove cdrom from cdrom drive.");
SetTextXY(11, 10, "Press ENTER to reboot your computer.");
SetStatusText(" ENTER = Reboot computer");
while(TRUE)
{
ConInKey(Ir);
if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D)
{
return;
}
}
}
VOID
NtProcessStartup(PPEB Peb)
{
NTSTATUS Status;
INPUT_RECORD Ir;
RtlNormalizeProcessParams(Peb->ProcessParameters);
ProcessHeap = Peb->ProcessHeap;
Status = AllocConsole();
if (!NT_SUCCESS(Status))
{
PrintString("Console initialization failed! (Status %lx)\n", Status);
goto ByeBye;
}
CHECKPOINT1;
if (IntroPage(&Ir) == TRUE)
{
/* Display success message */
SetCursorXY(5, 49);
ConOutPrintf("Press any key to continue\n");
ConInKey(&Ir);
// SuccessPage(&Ir)
}
else
{
/* Display termination message */
QuitPage(&Ir);
}
/* Reboot */
ConsoleExit:
FreeConsole();
PrintString("*** System halted ***\n", Status);
for(;;);
ByeBye:
/* Raise a hard error (crash the system/BSOD) */
NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED,
0,0,0,0,0);
// NtTerminateProcess(NtCurrentProcess(), 0);
}
/* EOF */

View file

@ -0,0 +1,95 @@
/*
*/
#ifndef __CONSOLE_H__
#define __CONSOLE_H__
#define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
#define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
#define DPRINT(args...)
#define CHECKPOINT
extern HANDLE ProcessHeap;
/* console.c */
NTSTATUS
AllocConsole(VOID);
VOID
FreeConsole(VOID);
NTSTATUS
ReadConsoleOutputCharacters(LPSTR lpCharacter,
ULONG nLength,
COORD dwReadCoord,
PULONG lpNumberOfCharsRead);
NTSTATUS
ReadConsoleOutputAttributes(PUSHORT lpAttribute,
ULONG nLength,
COORD dwReadCoord,
PULONG lpNumberOfAttrsRead);
NTSTATUS
WriteConsoleOutputCharacters(LPCSTR lpCharacter,
ULONG nLength,
COORD dwWriteCoord);
NTSTATUS
WriteConsoleOutputAttributes(CONST USHORT *lpAttribute,
ULONG nLength,
COORD dwWriteCoord,
PULONG lpNumberOfAttrsWritten);
VOID
ConInKey(PINPUT_RECORD Buffer);
VOID
ConOutChar(CHAR c);
VOID
ConOutPuts(LPSTR szText);
VOID
ConOutPrintf(LPSTR szFormat, ...);
SHORT
GetCursorX(VOID);
SHORT
GetCursorY(VOID);
VOID
GetScreenSize(SHORT *maxx,
SHORT *maxy);
VOID
SetCursorType(BOOL bInsert,
BOOL bVisible);
VOID
SetCursorXY(SHORT x,
SHORT y);
VOID
ClearScreen(VOID);
VOID
SetStatusText(PCHAR Text);
VOID
SetTextXY(SHORT x, SHORT y, PCHAR Text);
#endif /* __CONSOLE_H__*/
/* EOF */

View file

@ -0,0 +1,38 @@
#include <defines.h>
#include <reactos/resource.h>
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
VS_VERSION_INFO VERSIONINFO
FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", RES_STR_COMPANY_NAME
VALUE "FileDescription", "ReactOS Setup\0"
VALUE "FileVersion", RES_STR_FILE_VERSION
VALUE "InternalName", "usetup\0"
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
VALUE "OriginalFilename", "usetup.exe\0"
VALUE "ProductName", RES_STR_PRODUCT_NAME
VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END