Cleanup in .inf file handling of usetup:

- Equivalent setupapi functions have the same protoype as in Win32 API
- Extra functions have the INF_* prefix

svn path=/trunk/; revision=23836
This commit is contained in:
Hervé Poussineau 2006-08-31 09:13:03 +00:00
parent f52bca045b
commit cc2684d474
21 changed files with 906 additions and 542 deletions

View file

@ -24,7 +24,7 @@
* PROGRAMMER: Eric Kohl * PROGRAMMER: Eric Kohl
*/ */
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>

View file

@ -8,7 +8,7 @@
* CSH 15/08-2003 Created * CSH 15/08-2003 Created
*/ */
#include <usetup.h> #include "usetup.h"
#include <zlib.h> #include <zlib.h>
#define NDEBUG #define NDEBUG

View file

@ -26,15 +26,15 @@
/* INCLUDES ******************************************************************/ /* INCLUDES ******************************************************************/
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
/* GLOBALS ******************************************************************/ /* GLOBALS ******************************************************************/
static HANDLE StdInput = INVALID_HANDLE_VALUE; HANDLE StdInput = INVALID_HANDLE_VALUE;
static HANDLE StdOutput = INVALID_HANDLE_VALUE; HANDLE StdOutput = INVALID_HANDLE_VALUE;
static SHORT xScreen = 0; static SHORT xScreen = 0;
static SHORT yScreen = 0; static SHORT yScreen = 0;
@ -436,138 +436,133 @@ ConSetConsoleTextAttribute(
return NT_SUCCESS(Status); return NT_SUCCESS(Status);
} }
VOID VOID
CONSOLE_ConInKey(PINPUT_RECORD Buffer) CONSOLE_ConInKey(
OUT PINPUT_RECORD Buffer)
{ {
ULONG Read; ULONG Read;
while (TRUE) while (TRUE)
{ {
ReadConsoleInput(StdInput, Buffer, 1, &Read); ReadConsoleInput(StdInput, Buffer, 1, &Read);
if ((Buffer->EventType == KEY_EVENT) && if ((Buffer->EventType == KEY_EVENT)
(Buffer->Event.KeyEvent.bKeyDown == TRUE)) && (Buffer->Event.KeyEvent.bKeyDown == TRUE))
break; break;
} }
} }
VOID VOID
CONSOLE_ConOutChar(CHAR c) CONSOLE_ConOutChar(
IN CHAR c)
{ {
ULONG Written; ULONG Written;
WriteConsole(StdOutput, WriteConsole(
&c, StdOutput,
1, &c,
&Written, 1,
NULL); &Written,
NULL);
} }
VOID VOID
CONSOLE_ConOutPuts(LPSTR szText) CONSOLE_ConOutPuts(
IN LPCSTR szText)
{ {
ULONG Written; ULONG Written;
WriteConsole(StdOutput, WriteConsole(
szText, StdOutput,
strlen(szText), szText,
&Written, strlen(szText),
NULL); &Written,
WriteConsole(StdOutput, NULL);
"\n", WriteConsole(
1, StdOutput,
&Written, "\n",
NULL); 1,
&Written,
NULL);
} }
VOID VOID
CONSOLE_ConOutPrintf(LPSTR szFormat, ...) CONSOLE_ConOutPrintf(
IN LPCSTR szFormat, ...)
{ {
CHAR szOut[256]; CHAR szOut[256];
DWORD dwWritten; DWORD dwWritten;
va_list arg_ptr; va_list arg_ptr;
va_start(arg_ptr, szFormat); va_start(arg_ptr, szFormat);
vsprintf(szOut, szFormat, arg_ptr); vsprintf(szOut, szFormat, arg_ptr);
va_end(arg_ptr); va_end(arg_ptr);
WriteConsole(StdOutput, WriteConsole(
szOut, StdOutput,
strlen(szOut), szOut,
&dwWritten, strlen(szOut),
NULL); &dwWritten,
NULL);
} }
SHORT SHORT
CONSOLE_GetCursorX(VOID) CONSOLE_GetCursorX(VOID)
{ {
CONSOLE_SCREEN_BUFFER_INFO csbi; CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(StdOutput, &csbi); GetConsoleScreenBufferInfo(StdOutput, &csbi);
return(csbi.dwCursorPosition.X); return csbi.dwCursorPosition.X;
} }
SHORT SHORT
CONSOLE_GetCursorY(VOID) CONSOLE_GetCursorY(VOID)
{ {
CONSOLE_SCREEN_BUFFER_INFO csbi; CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(StdOutput, &csbi); GetConsoleScreenBufferInfo(StdOutput, &csbi);
return(csbi.dwCursorPosition.Y); return csbi.dwCursorPosition.Y;
} }
VOID VOID
CONSOLE_GetScreenSize(SHORT *maxx, CONSOLE_GetScreenSize(
SHORT *maxy) OUT SHORT *maxx,
OUT SHORT *maxy)
{ {
CONSOLE_SCREEN_BUFFER_INFO csbi; CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(StdOutput, &csbi); GetConsoleScreenBufferInfo(StdOutput, &csbi);
if (maxx) *maxx = csbi.dwSize.X;
*maxx = csbi.dwSize.X;
if (maxy) *maxy = csbi.dwSize.Y;
*maxy = csbi.dwSize.Y;
} }
VOID VOID
CONSOLE_SetCursorType(BOOL bInsert, CONSOLE_SetCursorType(
BOOL bVisible) IN BOOL bInsert,
IN BOOL bVisible)
{ {
CONSOLE_CURSOR_INFO cci; CONSOLE_CURSOR_INFO cci;
cci.dwSize = bInsert ? 10 : 99; cci.dwSize = bInsert ? 10 : 99;
cci.bVisible = bVisible; cci.bVisible = bVisible;
SetConsoleCursorInfo(StdOutput, &cci); SetConsoleCursorInfo(StdOutput, &cci);
} }
VOID VOID
CONSOLE_SetCursorXY(SHORT x, CONSOLE_SetCursorXY(
SHORT y) IN SHORT x,
IN SHORT y)
{ {
COORD coPos; COORD coPos;
coPos.X = x; coPos.X = x;
coPos.Y = y; coPos.Y = y;
SetConsoleCursorPosition(StdOutput, coPos); SetConsoleCursorPosition(StdOutput, coPos);
} }
VOID VOID
@ -594,284 +589,321 @@ CONSOLE_ClearScreen(VOID)
&Written); &Written);
} }
VOID VOID
CONSOLE_SetStatusText(char* fmt, ...) CONSOLE_SetStatusText(
IN LPCSTR fmt, ...)
{ {
char Buffer[128]; CHAR Buffer[128];
va_list ap; va_list ap;
COORD coPos; COORD coPos;
ULONG Written; ULONG Written;
va_start(ap, fmt); va_start(ap, fmt);
vsprintf(Buffer, fmt, ap); vsprintf(Buffer, fmt, ap);
va_end(ap); va_end(ap);
coPos.X = 0; coPos.X = 0;
coPos.Y = yScreen - 1; coPos.Y = yScreen - 1;
FillConsoleOutputAttribute(StdOutput, FillConsoleOutputAttribute(
BACKGROUND_WHITE, StdOutput,
xScreen, BACKGROUND_WHITE,
coPos, xScreen,
&Written); coPos,
&Written);
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(
' ', StdOutput,
xScreen, ' ',
coPos, xScreen,
&Written); coPos,
&Written);
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(
Buffer, StdOutput,
strlen(Buffer), Buffer,
coPos, strlen(Buffer),
&Written); coPos,
&Written);
} }
VOID VOID
CONSOLE_InvertTextXY(SHORT x, SHORT y, SHORT col, SHORT row) CONSOLE_InvertTextXY(
IN SHORT x,
IN SHORT y,
IN SHORT col,
IN SHORT row)
{ {
COORD coPos; COORD coPos;
ULONG Written; ULONG Written;
for (coPos.Y = y; coPos.Y < y + row; coPos.Y++) for (coPos.Y = y; coPos.Y < y + row; coPos.Y++)
{ {
coPos.X = x; coPos.X = x;
FillConsoleOutputAttribute(StdOutput, FillConsoleOutputAttribute(
FOREGROUND_BLUE | BACKGROUND_WHITE, StdOutput,
col, FOREGROUND_BLUE | BACKGROUND_WHITE,
coPos, col,
&Written); coPos,
} &Written);
}
} }
VOID VOID
CONSOLE_NormalTextXY(SHORT x, SHORT y, SHORT col, SHORT row) CONSOLE_NormalTextXY(
IN SHORT x,
IN SHORT y,
IN SHORT col,
IN SHORT row)
{ {
COORD coPos; COORD coPos;
ULONG Written; ULONG Written;
for (coPos.Y = y; coPos.Y < y + row; coPos.Y++) for (coPos.Y = y; coPos.Y < y + row; coPos.Y++)
{ {
coPos.X = x; coPos.X = x;
FillConsoleOutputAttribute(StdOutput, FillConsoleOutputAttribute(
FOREGROUND_BLUE | BACKGROUND_WHITE, StdOutput,
col, FOREGROUND_BLUE | BACKGROUND_WHITE,
coPos, col,
&Written); coPos,
} &Written);
}
} }
VOID VOID
CONSOLE_SetTextXY(SHORT x, SHORT y, PCHAR Text) CONSOLE_SetTextXY(
IN SHORT x,
IN SHORT y,
IN LPCSTR Text)
{ {
COORD coPos; COORD coPos;
ULONG Written; ULONG Written;
coPos.X = x; coPos.X = x;
coPos.Y = y; coPos.Y = y;
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(
Text, StdOutput,
strlen(Text), Text,
coPos, strlen(Text),
&Written); coPos,
&Written);
} }
VOID VOID
CONSOLE_SetInputTextXY(SHORT x, SHORT y, SHORT len, PWCHAR Text) CONSOLE_SetInputTextXY(
IN SHORT x,
IN SHORT y,
IN SHORT len,
IN LPCWSTR Text)
{ {
COORD coPos; COORD coPos;
ULONG Length; ULONG Length;
ULONG Written; ULONG Written;
coPos.X = x; coPos.X = x;
coPos.Y = y; coPos.Y = y;
Length = wcslen(Text); Length = wcslen(Text);
if (Length > (ULONG)len - 1) if (Length > (ULONG)len - 1)
{ Length = len - 1;
Length = len - 1;
}
FillConsoleOutputAttribute(StdOutput, FillConsoleOutputAttribute(
BACKGROUND_WHITE, StdOutput,
len, BACKGROUND_WHITE,
coPos, len,
&Written); coPos,
&Written);
WriteConsoleOutputCharacterW(StdOutput, WriteConsoleOutputCharacterW(
Text, StdOutput,
Length, Text,
coPos, Length,
&Written); coPos,
&Written);
coPos.X += Length; coPos.X += Length;
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(
'_', StdOutput,
1, '_',
coPos, 1,
&Written); coPos,
&Written);
if ((ULONG)len > Length + 1) if ((ULONG)len > Length + 1)
{ {
coPos.X++; coPos.X++;
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(
' ', StdOutput,
len - Length - 1, ' ',
coPos, len - Length - 1,
&Written); coPos,
} &Written);
}
} }
VOID VOID
CONSOLE_SetUnderlinedTextXY(SHORT x, SHORT y, PCHAR Text) CONSOLE_SetUnderlinedTextXY(
IN SHORT x,
IN SHORT y,
IN LPCSTR Text)
{ {
COORD coPos; COORD coPos;
ULONG Length; ULONG Length;
ULONG Written; ULONG Written;
coPos.X = x; coPos.X = x;
coPos.Y = y; coPos.Y = y;
Length = strlen(Text); Length = strlen(Text);
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(
Text, StdOutput,
Length, Text,
coPos, Length,
&Written); coPos,
&Written);
coPos.Y++; coPos.Y++;
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(
0xCD, StdOutput,
Length, 0xCD,
coPos, Length,
&Written); coPos,
&Written);
} }
VOID VOID
CONSOLE_SetInvertedTextXY(SHORT x, SHORT y, PCHAR Text) CONSOLE_SetInvertedTextXY(
IN SHORT x,
IN SHORT y,
IN LPCSTR Text)
{ {
COORD coPos; COORD coPos;
ULONG Length; ULONG Length;
ULONG Written; ULONG Written;
coPos.X = x; coPos.X = x;
coPos.Y = y; coPos.Y = y;
Length = strlen(Text); Length = strlen(Text);
FillConsoleOutputAttribute(StdOutput, FillConsoleOutputAttribute(
FOREGROUND_BLUE | BACKGROUND_WHITE, StdOutput,
Length, FOREGROUND_BLUE | BACKGROUND_WHITE,
coPos, Length,
&Written); coPos,
&Written);
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(
Text, StdOutput,
Length, Text,
coPos, Length,
&Written); coPos,
&Written);
} }
VOID VOID
CONSOLE_SetHighlightedTextXY(SHORT x, SHORT y, PCHAR Text) CONSOLE_SetHighlightedTextXY(
IN SHORT x,
IN SHORT y,
IN LPCSTR Text)
{ {
COORD coPos; COORD coPos;
ULONG Length; ULONG Length;
ULONG Written; ULONG Written;
coPos.X = x; coPos.X = x;
coPos.Y = y; coPos.Y = y;
Length = strlen(Text); Length = strlen(Text);
FillConsoleOutputAttribute(StdOutput, FillConsoleOutputAttribute(
FOREGROUND_WHITE | FOREGROUND_INTENSITY | BACKGROUND_BLUE, StdOutput,
Length, FOREGROUND_WHITE | FOREGROUND_INTENSITY | BACKGROUND_BLUE,
coPos, Length,
&Written); coPos,
&Written);
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(
Text, StdOutput,
Length, Text,
coPos, Length,
&Written); coPos,
&Written);
} }
VOID VOID
CONSOLE_PrintTextXY(SHORT x, SHORT y, char* fmt, ...) CONSOLE_PrintTextXY(
IN SHORT x,
IN SHORT y,
IN LPCSTR fmt, ...)
{ {
char buffer[512]; CHAR buffer[512];
va_list ap; va_list ap;
COORD coPos; COORD coPos;
ULONG Written; ULONG Written;
va_start(ap, fmt); va_start(ap, fmt);
vsprintf(buffer, fmt, ap); vsprintf(buffer, fmt, ap);
va_end(ap); va_end(ap);
coPos.X = x; coPos.X = x;
coPos.Y = y; coPos.Y = y;
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(
buffer, StdOutput,
strlen(buffer), buffer,
coPos, strlen(buffer),
&Written); coPos,
&Written);
} }
VOID VOID
CONSOLE_PrintTextXYN(SHORT x, SHORT y, SHORT len, char* fmt, ...) CONSOLE_PrintTextXYN(
IN SHORT x,
IN SHORT y,
IN SHORT len,
IN LPCSTR fmt, ...)
{ {
char buffer[512]; CHAR buffer[512];
va_list ap; va_list ap;
COORD coPos; COORD coPos;
ULONG Length; ULONG Length;
ULONG Written; ULONG Written;
va_start(ap, fmt); va_start(ap, fmt);
vsprintf(buffer, fmt, ap); vsprintf(buffer, fmt, ap);
va_end(ap); va_end(ap);
coPos.X = x; coPos.X = x;
coPos.Y = y; coPos.Y = y;
Length = strlen(buffer); Length = strlen(buffer);
if (Length > (ULONG)len - 1) if (Length > (ULONG)len - 1)
{ Length = len - 1;
Length = len - 1;
}
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(
buffer, StdOutput,
Length, buffer,
coPos, Length,
&Written); coPos,
&Written);
coPos.X += Length; coPos.X += Length;
if ((ULONG)len > Length) if ((ULONG)len > Length)
{ {
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(
' ', StdOutput,
len - Length, ' ',
coPos, len - Length,
&Written); coPos,
} &Written);
}
} }
/* EOF */ /* EOF */

View file

@ -48,6 +48,8 @@
#define FOREGROUND_YELLOW (FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN) #define FOREGROUND_YELLOW (FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN)
#define BACKGROUND_WHITE (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE) #define BACKGROUND_WHITE (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE)
extern HANDLE StdInput, StdOutput;
BOOL WINAPI BOOL WINAPI
ConAllocConsole( ConAllocConsole(
IN DWORD dwProcessId); IN DWORD dwProcessId);
@ -123,18 +125,24 @@ ConWriteConsoleOutputCharacterA(
OUT LPDWORD lpNumberOfCharsWritten); OUT LPDWORD lpNumberOfCharsWritten);
VOID
CONSOLE_ClearScreen(VOID);
VOID VOID
CONSOLE_ConInKey(PINPUT_RECORD Buffer); CONSOLE_ConInKey(
OUT PINPUT_RECORD Buffer);
VOID VOID
CONSOLE_ConOutChar(CHAR c); CONSOLE_ConOutChar(
IN CHAR c);
VOID VOID
CONSOLE_ConOutPuts(LPSTR szText); CONSOLE_ConOutPrintf(
IN LPCSTR szFormat, ...);
VOID VOID
CONSOLE_ConOutPrintf(LPSTR szFormat, ...); CONSOLE_ConOutPuts(
IN LPCSTR szText);
SHORT SHORT
CONSOLE_GetCursorX(VOID); CONSOLE_GetCursorX(VOID);
@ -143,49 +151,93 @@ SHORT
CONSOLE_GetCursorY(VOID); CONSOLE_GetCursorY(VOID);
VOID VOID
CONSOLE_GetScreenSize(SHORT *maxx, CONSOLE_GetScreenSize(
SHORT *maxy); OUT SHORT *maxx,
OUT SHORT *maxy);
VOID VOID
CONSOLE_SetCursorType(BOOL bInsert, CONSOLE_InvertTextXY(
BOOL bVisible); IN SHORT x,
IN SHORT y,
IN SHORT col,
IN SHORT row);
VOID VOID
CONSOLE_SetCursorXY(SHORT x, CONSOLE_NormalTextXY(
SHORT y); IN SHORT x,
IN SHORT y,
IN SHORT col,
IN SHORT row);
VOID VOID
CONSOLE_ClearScreen(VOID); CONSOLE_PrintTextXY(
IN SHORT x,
IN SHORT y,
IN LPCSTR fmt, ...);
VOID VOID
CONSOLE_SetStatusText(char* fmt, ...); CONSOLE_PrintTextXYN(
IN SHORT x,
IN SHORT y,
IN SHORT len,
IN LPCSTR fmt, ...);
VOID VOID
CONSOLE_InvertTextXY(SHORT x, SHORT y, SHORT col, SHORT row); CONSOLE_SetCursorType(
IN BOOL bInsert,
IN BOOL bVisible);
VOID VOID
CONSOLE_NormalTextXY(SHORT x, SHORT y, SHORT col, SHORT row); CONSOLE_SetCursorXY(
IN SHORT x,
IN SHORT y);
VOID VOID
CONSOLE_SetTextXY(SHORT x, SHORT y, PCHAR Text); CONSOLE_SetCursorXY(
IN SHORT x,
IN SHORT y);
VOID VOID
CONSOLE_SetInputTextXY(SHORT x, SHORT y, SHORT len, PWCHAR Text); CONSOLE_SetHighlightedTextXY(
IN SHORT x,
IN SHORT y,
IN LPCSTR Text);
VOID VOID
CONSOLE_SetUnderlinedTextXY(SHORT x, SHORT y, PCHAR Text); CONSOLE_SetInputTextXY(
IN SHORT x,
IN SHORT y,
IN SHORT len,
IN LPCWSTR Text);
VOID VOID
CONSOLE_SetInvertedTextXY(SHORT x, SHORT y, PCHAR Text); CONSOLE_SetInputTextXY(
IN SHORT x,
IN SHORT y,
IN SHORT len,
IN LPCWSTR Text);
VOID VOID
CONSOLE_SetHighlightedTextXY(SHORT x, SHORT y, PCHAR Text); CONSOLE_SetInvertedTextXY(
IN SHORT x,
IN SHORT y,
IN LPCSTR Text);
VOID VOID
CONSOLE_PrintTextXY(SHORT x, SHORT y, char* fmt, ...); CONSOLE_SetStatusText(
IN LPCSTR fmt, ...);
VOID VOID
CONSOLE_PrintTextXYN(SHORT x, SHORT y, SHORT len, char* fmt, ...); CONSOLE_SetTextXY(
IN SHORT x,
IN SHORT y,
IN LPCSTR Text);
VOID
CONSOLE_SetUnderlinedTextXY(
IN SHORT x,
IN SHORT y,
IN LPCSTR Text);
#endif /* __CONSOLE_H__*/ #endif /* __CONSOLE_H__*/

View file

@ -26,7 +26,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>

View file

@ -27,7 +27,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>

View file

@ -27,7 +27,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>

View file

@ -26,7 +26,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>

View file

@ -25,7 +25,7 @@
* Casper S. Hornstrup (chorns@users.sourceforge.net) * Casper S. Hornstrup (chorns@users.sourceforge.net)
*/ */
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>

View file

@ -26,7 +26,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>

View file

@ -0,0 +1,197 @@
/*
* ReactOS kernel
* Copyright (C) 2002 ReactOS Team
*
* This program 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 program 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 program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup
* FILE: subsys/system/usetup/inffile.c
* PURPOSE: .inf files support functions
* PROGRAMMER: Hervé Poussineau
*/
/* INCLUDES ******************************************************************/
#include "usetup.h"
#include <infros.h>
#define NDEBUG
#include <debug.h>
/* FUNCTIONS *****************************************************************/
VOID WINAPI
InfpCloseInfFile(
IN HINF InfHandle)
{
InfCloseFile(InfHandle);
}
BOOL WINAPI
InfpFindFirstLineW(
IN HINF InfHandle,
IN PCWSTR Section,
IN PCWSTR Key,
IN OUT PINFCONTEXT Context)
{
PINFCONTEXT pContext;
BOOL ret;
ret = InfFindFirstLine(InfHandle, Section, Key, &pContext);
if (!ret)
return FALSE;
memcpy(Context, pContext, sizeof(INFCONTEXT));
InfFreeContext(pContext);
return TRUE;
}
BOOL WINAPI
InfpFindNextLine(
IN PINFCONTEXT ContextIn,
OUT PINFCONTEXT ContextOut)
{
return InfFindNextLine(ContextIn, ContextOut);
}
BOOL WINAPI
InfpGetBinaryField(
IN PINFCONTEXT Context,
IN DWORD FieldIndex,
IN OUT BYTE* ReturnBuffer,
IN DWORD ReturnBufferSize,
OUT LPDWORD RequiredSize)
{
return InfGetBinaryField(Context, FieldIndex, ReturnBuffer, ReturnBufferSize, RequiredSize);
}
DWORD WINAPI
InfpGetFieldCount(
IN PINFCONTEXT Context)
{
return (DWORD)InfGetFieldCount(Context);
}
BOOL WINAPI
InfpGetIntField(
IN PINFCONTEXT Context,
IN DWORD FieldIndex,
OUT PINT IntegerValue)
{
LONG IntegerValueL;
BOOL ret;
ret = InfGetIntField(Context, FieldIndex, &IntegerValueL);
*IntegerValue = (INT)IntegerValueL;
return ret;
}
BOOL WINAPI
InfpGetMultiSzFieldW(
IN PINFCONTEXT Context,
IN DWORD FieldIndex,
IN OUT PWSTR ReturnBuffer,
IN DWORD ReturnBufferSize,
OUT LPDWORD RequiredSize)
{
return InfGetMultiSzField(Context, FieldIndex, ReturnBuffer, ReturnBufferSize, RequiredSize);
}
BOOL WINAPI
InfpGetStringFieldW(
IN PINFCONTEXT Context,
IN DWORD FieldIndex,
IN OUT PWSTR ReturnBuffer,
IN DWORD ReturnBufferSize,
OUT PDWORD RequiredSize)
{
return InfGetStringField(Context, FieldIndex, ReturnBuffer, ReturnBufferSize, RequiredSize);
}
HINF WINAPI
InfpOpenInfFileW(
IN PCWSTR FileName,
IN PCWSTR InfClass,
IN DWORD InfStyle,
OUT PUINT ErrorLine)
{
HINF hInf = NULL;
UNICODE_STRING FileNameU;
ULONG ErrorLineUL;
NTSTATUS Status;
RtlInitUnicodeString(&FileNameU, FileName);
Status = InfOpenFile(
&hInf,
&FileNameU,
&ErrorLineUL);
*ErrorLine = (UINT)ErrorLineUL;
if (!NT_SUCCESS(Status))
return NULL;
return hInf;
}
BOOLEAN
INF_GetData(
IN PINFCONTEXT Context,
OUT PWCHAR *Key,
OUT PWCHAR *Data)
{
return InfGetData(Context, Key, Data);
}
BOOLEAN
INF_GetDataField(
IN PINFCONTEXT Context,
IN ULONG FieldIndex,
OUT PWCHAR *Data)
{
return InfGetDataField(Context, FieldIndex, Data);
}
HINF WINAPI
INF_OpenBufferedFileA(
IN PSTR FileBuffer,
IN ULONG FileSize,
IN PCSTR InfClass,
IN DWORD InfStyle,
OUT PUINT ErrorLine)
{
HINF hInf = NULL;
ULONG ErrorLineUL;
NTSTATUS Status;
Status = InfOpenBufferedFile(
&hInf,
FileBuffer,
FileSize,
&ErrorLineUL);
*ErrorLine = (UINT)ErrorLineUL;
if (!NT_SUCCESS(Status))
return NULL;
return hInf;
}
VOID INF_SetHeap(
IN PVOID Heap)
{
InfSetHeap(Heap);
}
/* EOF */

View file

@ -0,0 +1,135 @@
/*
* ReactOS kernel
* Copyright (C) 2002 ReactOS Team
*
* This program 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 program 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 program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup
* FILE: subsys/system/usetup/inffile.h
* PURPOSE: .inf files support functions
* PROGRAMMER: Hervé Poussineau
*/
#ifndef __INFFILE_H__
#define __INFFILE_H__
#include <infcommon.h>
#define SetupCloseInfFile InfpCloseInfFile
#define SetupFindFirstLineW InfpFindFirstLineW
#define SetupFindNextLine InfpFindNextLine
#define SetupGetBinaryField InfpGetBinaryField
#define SetupGetFieldCount InfpGetFieldCount
#define SetupGetIntField InfpGetIntField
#define SetupGetMultiSzFieldW InfpGetMultiSzFieldW
#define SetupGetStringFieldW InfpGetStringFieldW
#define SetupOpenInfFileW InfpOpenInfFileW
#define INF_STYLE_WIN4 0x00000002
/* FIXME: this structure is the one used in inflib, not in setupapi
* Delete it once we don't use inflib anymore */
typedef struct _INFCONTEXT
{
PVOID Inf;
PVOID Section;
PVOID Line;
} INFCONTEXT;
VOID WINAPI
InfpCloseInfFile(
IN HINF InfHandle);
BOOL WINAPI
InfpFindFirstLineW(
IN HINF InfHandle,
IN PCWSTR Section,
IN PCWSTR Key,
IN OUT PINFCONTEXT Context);
BOOL WINAPI
InfpFindNextLine(
IN PINFCONTEXT ContextIn,
OUT PINFCONTEXT ContextOut);
BOOL WINAPI
InfpGetBinaryField(
IN PINFCONTEXT Context,
IN DWORD FieldIndex,
IN OUT BYTE* ReturnBuffer,
IN DWORD ReturnBufferSize,
OUT LPDWORD RequiredSize);
DWORD WINAPI
InfpGetFieldCount(
IN PINFCONTEXT Context);
BOOL WINAPI
InfpGetIntField(
IN PINFCONTEXT Context,
IN DWORD FieldIndex,
OUT PINT IntegerValue);
BOOL WINAPI
InfpGetMultiSzFieldW(
IN PINFCONTEXT Context,
IN DWORD FieldIndex,
IN OUT PWSTR ReturnBuffer,
IN DWORD ReturnBufferSize,
OUT LPDWORD RequiredSize);
BOOL WINAPI
InfpGetStringFieldW(
IN PINFCONTEXT Context,
IN DWORD FieldIndex,
IN OUT PWSTR ReturnBuffer,
IN DWORD ReturnBufferSize,
OUT PDWORD RequiredSize);
HINF WINAPI
InfpOpenInfFileW(
IN PCWSTR FileName,
IN PCWSTR InfClass,
IN DWORD InfStyle,
OUT PUINT ErrorLine);
BOOLEAN
INF_GetData(
IN PINFCONTEXT Context,
OUT PWCHAR *Key,
OUT PWCHAR *Data);
BOOLEAN
INF_GetDataField(
IN PINFCONTEXT Context,
IN ULONG FieldIndex,
OUT PWCHAR *Data);
HINF WINAPI
INF_OpenBufferedFileA(
IN PSTR FileBuffer,
IN ULONG FileSize,
IN PCSTR InfClass,
IN DWORD InfStyle,
OUT PUINT ErrorLine);
VOID INF_SetHeap(
IN PVOID Heap);
#endif /* __INFFILE_H__*/
/* EOF */

View file

@ -27,7 +27,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>

View file

@ -25,7 +25,7 @@
* *
* NB: Hardcoded to US keyboard * NB: Hardcoded to US keyboard
*/ */
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>

View file

@ -25,7 +25,7 @@
* Casper S. Hornstrup (chorns@users.sourceforge.net) * Casper S. Hornstrup (chorns@users.sourceforge.net)
*/ */
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -1237,7 +1237,7 @@ PrintDiskData (PPARTLIST List,
ULONG Written; ULONG Written;
USHORT Width; USHORT Width;
USHORT Height; USHORT Height;
ULONGLONG DiskSize; ULARGE_INTEGER DiskSize;
PCHAR Unit; PCHAR Unit;
Width = List->Right - List->Left - 1; Width = List->Right - List->Left - 1;
@ -1250,35 +1250,35 @@ PrintDiskData (PPARTLIST List,
#if 0 #if 0
if (DiskEntry->DiskSize >= 0x280000000ULL) /* 10 GB */ if (DiskEntry->DiskSize >= 0x280000000ULL) /* 10 GB */
{ {
DiskSize = (DiskEntry->DiskSize + (1 << 29)) >> 30; DiskSize.QuadPart = (DiskEntry->DiskSize + (1 << 29)) >> 30;
Unit = "GB"; Unit = "GB";
} }
else else
#endif #endif
{ {
DiskSize = (DiskEntry->DiskSize + (1 << 19)) >> 20; DiskSize.QuadPart = (DiskEntry->DiskSize + (1 << 19)) >> 20;
if (DiskSize == 0) if (DiskSize.QuadPart == 0)
DiskSize = 1; DiskSize.QuadPart = 1;
Unit = "MB"; Unit = "MB";
} }
if (DiskEntry->DriverName.Length > 0) if (DiskEntry->DriverName.Length > 0)
{ {
sprintf (LineBuffer, sprintf (LineBuffer,
"%6I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ", "%6lu %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %S",
DiskSize, DiskSize.u.LowPart,
Unit, Unit,
DiskEntry->DiskNumber, DiskEntry->DiskNumber,
DiskEntry->Port, DiskEntry->Port,
DiskEntry->Bus, DiskEntry->Bus,
DiskEntry->Id, DiskEntry->Id,
&DiskEntry->DriverName); DiskEntry->DriverName.Buffer);
} }
else else
{ {
sprintf (LineBuffer, sprintf (LineBuffer,
"%6I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu)", "%6lu %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu)",
DiskSize, DiskSize.u.LowPart,
Unit, Unit,
DiskEntry->DiskNumber, DiskEntry->DiskNumber,
DiskEntry->Port, DiskEntry->Port,

View file

@ -1,7 +1,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>

View file

@ -26,7 +26,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -257,13 +257,13 @@ do_reg_operation(HANDLE KeyHandle,
} }
if (!(Flags & FLG_ADDREG_BINVALUETYPE) || if (!(Flags & FLG_ADDREG_BINVALUETYPE) ||
(Type == REG_DWORD && InfGetFieldCount (Context) == 5)) (Type == REG_DWORD && SetupGetFieldCount (Context) == 5))
{ {
PWCHAR Str = NULL; PWCHAR Str = NULL;
if (Type == REG_MULTI_SZ) if (Type == REG_MULTI_SZ)
{ {
if (!InfGetMultiSzField (Context, 5, NULL, 0, &Size)) if (!SetupGetMultiSzFieldW (Context, 5, NULL, 0, &Size))
Size = 0; Size = 0;
if (Size) if (Size)
@ -272,7 +272,7 @@ do_reg_operation(HANDLE KeyHandle,
if (Str == NULL) if (Str == NULL)
return FALSE; return FALSE;
InfGetMultiSzField (Context, 5, Str, Size, NULL); SetupGetMultiSzFieldW (Context, 5, Str, Size, NULL);
} }
if (Flags & FLG_ADDREG_APPEND) if (Flags & FLG_ADDREG_APPEND)
@ -289,7 +289,7 @@ do_reg_operation(HANDLE KeyHandle,
} }
else else
{ {
if (!InfGetStringField (Context, 5, NULL, 0, &Size)) if (!SetupGetStringFieldW (Context, 5, NULL, 0, &Size))
Size = 0; Size = 0;
if (Size) if (Size)
@ -298,7 +298,7 @@ do_reg_operation(HANDLE KeyHandle,
if (Str == NULL) if (Str == NULL)
return FALSE; return FALSE;
InfGetStringField (Context, 5, Str, Size, NULL); SetupGetStringFieldW (Context, 5, Str, Size, NULL);
} }
} }
@ -344,7 +344,7 @@ do_reg_operation(HANDLE KeyHandle,
{ {
PUCHAR Data = NULL; PUCHAR Data = NULL;
if (!InfGetBinaryField (Context, 5, NULL, 0, &Size)) if (!SetupGetBinaryField (Context, 5, NULL, 0, &Size))
Size = 0; Size = 0;
if (Size) if (Size)
@ -354,7 +354,7 @@ do_reg_operation(HANDLE KeyHandle,
return FALSE; return FALSE;
DPRINT("setting binary data %wZ len %lu\n", ValueName, Size); DPRINT("setting binary data %wZ len %lu\n", ValueName, Size);
InfGetBinaryField (Context, 5, Data, Size, NULL); SetupGetBinaryField (Context, 5, Data, Size, NULL);
} }
NtSetValueKey (KeyHandle, NtSetValueKey (KeyHandle,
@ -481,35 +481,35 @@ registry_callback (HINF hInf, PCWSTR Section, BOOLEAN Delete)
UNICODE_STRING Value; UNICODE_STRING Value;
PUNICODE_STRING ValuePtr; PUNICODE_STRING ValuePtr;
NTSTATUS Status; NTSTATUS Status;
ULONG Flags; UINT Flags;
ULONG Length; ULONG Length;
PINFCONTEXT Context; INFCONTEXT Context;
HANDLE KeyHandle; HANDLE KeyHandle;
BOOLEAN Ok; BOOLEAN Ok;
Ok = InfFindFirstLine (hInf, Section, NULL, &Context); Ok = SetupFindFirstLineW (hInf, Section, NULL, &Context);
if (Ok) if (Ok)
{ {
for (;Ok; Ok = InfFindNextLine (Context, Context)) for (;Ok; Ok = SetupFindNextLine (&Context, &Context))
{ {
/* get root */ /* get root */
if (!InfGetStringField (Context, 1, Buffer, MAX_INF_STRING_LENGTH, NULL)) if (!SetupGetStringFieldW (&Context, 1, Buffer, MAX_INF_STRING_LENGTH, NULL))
continue; continue;
if (!GetRootKey (Buffer)) if (!GetRootKey (Buffer))
continue; continue;
/* get key */ /* get key */
Length = wcslen (Buffer); Length = wcslen (Buffer);
if (!InfGetStringField (Context, 2, Buffer + Length, MAX_INF_STRING_LENGTH - Length, NULL)) if (!SetupGetStringFieldW (&Context, 2, Buffer + Length, MAX_INF_STRING_LENGTH - Length, NULL))
*Buffer = 0; *Buffer = 0;
DPRINT("KeyName: <%S>\n", Buffer); DPRINT("KeyName: <%S>\n", Buffer);
/* get flags */ /* get flags */
if (!InfGetIntField (Context, 4, (PLONG)&Flags)) if (!SetupGetIntField (&Context, 4, (PINT)&Flags))
Flags = 0; Flags = 0;
DPRINT("Flags: %lx\n", Flags); DPRINT("Flags: %lx\n", Flags);
@ -547,7 +547,7 @@ registry_callback (HINF hInf, PCWSTR Section, BOOLEAN Delete)
} }
/* get value name */ /* get value name */
if (InfGetStringField (Context, 3, Buffer, MAX_INF_STRING_LENGTH, NULL)) if (SetupGetStringFieldW (&Context, 3, Buffer, MAX_INF_STRING_LENGTH, NULL))
{ {
RtlInitUnicodeString (&Value, RtlInitUnicodeString (&Value,
Buffer); Buffer);
@ -559,7 +559,7 @@ registry_callback (HINF hInf, PCWSTR Section, BOOLEAN Delete)
} }
/* and now do it */ /* and now do it */
if (!do_reg_operation (KeyHandle, ValuePtr, Context, Flags)) if (!do_reg_operation (KeyHandle, ValuePtr, &Context, Flags))
{ {
NtClose (KeyHandle); NtClose (KeyHandle);
return FALSE; return FALSE;
@ -567,7 +567,6 @@ registry_callback (HINF hInf, PCWSTR Section, BOOLEAN Delete)
NtClose (KeyHandle); NtClose (KeyHandle);
} }
InfFreeContext(Context);
} }
return TRUE; return TRUE;
@ -580,25 +579,22 @@ ImportRegistryFile(PWSTR Filename,
BOOLEAN Delete) BOOLEAN Delete)
{ {
WCHAR FileNameBuffer[MAX_PATH]; WCHAR FileNameBuffer[MAX_PATH];
UNICODE_STRING FileName;
HINF hInf; HINF hInf;
NTSTATUS Status; UINT ErrorLine;
ULONG ErrorLine;
/* Load inf file from install media. */ /* Load inf file from install media. */
wcscpy(FileNameBuffer, SourceRootPath.Buffer); wcscpy(FileNameBuffer, SourceRootPath.Buffer);
wcscat(FileNameBuffer, L"\\reactos\\"); wcscat(FileNameBuffer, L"\\reactos\\");
wcscat(FileNameBuffer, Filename); wcscat(FileNameBuffer, Filename);
RtlInitUnicodeString(&FileName, hInf = SetupOpenInfFileW(
FileNameBuffer); FileNameBuffer,
NULL,
Status = InfOpenFile(&hInf, INF_STYLE_WIN4,
&FileName,
&ErrorLine); &ErrorLine);
if (!NT_SUCCESS(Status)) if (hInf == INVALID_HANDLE_VALUE)
{ {
DPRINT1("InfOpenFile() failed (Status %lx)\n", Status); DPRINT1("SetupOpenInfFile() failed\n");
return FALSE; return FALSE;
} }
@ -607,7 +603,7 @@ ImportRegistryFile(PWSTR Filename,
DPRINT1("registry_callback() failed\n"); DPRINT1("registry_callback() failed\n");
} }
InfCloseFile (hInf); SetupCloseInfFile (hInf);
return TRUE; return TRUE;
} }

View file

@ -25,7 +25,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -121,7 +121,7 @@ CreateComputerTypeList(HINF InfFile)
{ {
CHAR Buffer[128]; CHAR Buffer[128];
PGENERIC_LIST List; PGENERIC_LIST List;
PINFCONTEXT Context; INFCONTEXT Context;
PWCHAR KeyName; PWCHAR KeyName;
PWCHAR KeyValue; PWCHAR KeyValue;
PWCHAR UserData; PWCHAR UserData;
@ -137,7 +137,7 @@ CreateComputerTypeList(HINF InfFile)
DPRINT("Computer identifier: '%S'\n", ComputerIdentifier); DPRINT("Computer identifier: '%S'\n", ComputerIdentifier);
/* Search for matching device identifier */ /* Search for matching device identifier */
if (!InfFindFirstLine(InfFile, L"Map.Computer", NULL, &Context)) if (!SetupFindFirstLineW(InfFile, L"Map.Computer", NULL, &Context))
{ {
/* FIXME: error message */ /* FIXME: error message */
return NULL; return NULL;
@ -145,20 +145,20 @@ CreateComputerTypeList(HINF InfFile)
do do
{ {
if (!InfGetDataField(Context, 1, &KeyValue)) if (!INF_GetDataField(&Context, 1, &KeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetDataField() failed\n"); DPRINT("INF_GetDataField() failed\n");
return NULL; return NULL;
} }
DPRINT("KeyValue: %S\n", KeyValue); DPRINT("KeyValue: %S\n", KeyValue);
if (wcsstr(ComputerIdentifier, KeyValue)) if (wcsstr(ComputerIdentifier, KeyValue))
{ {
if (!InfGetDataField(Context, 0, &KeyName)) if (!INF_GetDataField(&Context, 0, &KeyName))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetDataField() failed\n"); DPRINT("INF_GetDataField() failed\n");
return NULL; return NULL;
} }
@ -166,14 +166,13 @@ CreateComputerTypeList(HINF InfFile)
wcscpy(ComputerKey, KeyName); wcscpy(ComputerKey, KeyName);
} }
} }
while (InfFindNextLine(Context, Context)); while (SetupFindNextLine(&Context, &Context));
InfFreeContext(Context);
List = CreateGenericList(); List = CreateGenericList();
if (List == NULL) if (List == NULL)
return NULL; return NULL;
if (!InfFindFirstLine (InfFile, L"Computer", NULL, &Context)) if (!SetupFindFirstLineW (InfFile, L"Computer", NULL, &Context))
{ {
DestroyGenericList(List, FALSE); DestroyGenericList(List, FALSE);
return NULL; return NULL;
@ -181,10 +180,10 @@ CreateComputerTypeList(HINF InfFile)
do do
{ {
if (!InfGetData (Context, &KeyName, &KeyValue)) if (!INF_GetData (&Context, &KeyName, &KeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetData() failed\n"); DPRINT("INF_GetData() failed\n");
break; break;
} }
@ -202,8 +201,7 @@ CreateComputerTypeList(HINF InfFile)
AppendGenericListEntry(List, Buffer, UserData, AppendGenericListEntry(List, Buffer, UserData,
_wcsicmp(KeyName, ComputerKey) ? FALSE : TRUE); _wcsicmp(KeyName, ComputerKey) ? FALSE : TRUE);
} }
while (InfFindNextLine(Context, Context)); while (SetupFindNextLine(&Context, &Context));
InfFreeContext(Context);
return List; return List;
} }
@ -373,7 +371,7 @@ CreateDisplayDriverList(HINF InfFile)
{ {
CHAR Buffer[128]; CHAR Buffer[128];
PGENERIC_LIST List; PGENERIC_LIST List;
PINFCONTEXT Context; INFCONTEXT Context;
PWCHAR KeyName; PWCHAR KeyName;
PWCHAR KeyValue; PWCHAR KeyValue;
PWCHAR UserData; PWCHAR UserData;
@ -389,7 +387,7 @@ CreateDisplayDriverList(HINF InfFile)
DPRINT("Display identifier: '%S'\n", DisplayIdentifier); DPRINT("Display identifier: '%S'\n", DisplayIdentifier);
/* Search for matching device identifier */ /* Search for matching device identifier */
if (!InfFindFirstLine(InfFile, L"Map.Display", NULL, &Context)) if (!SetupFindFirstLineW(InfFile, L"Map.Display", NULL, &Context))
{ {
/* FIXME: error message */ /* FIXME: error message */
return NULL; return NULL;
@ -397,20 +395,20 @@ CreateDisplayDriverList(HINF InfFile)
do do
{ {
if (!InfGetDataField(Context, 1, &KeyValue)) if (!INF_GetDataField(&Context, 1, &KeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetDataField() failed\n"); DPRINT("INF_GetDataField() failed\n");
return NULL; return NULL;
} }
DPRINT("KeyValue: %S\n", KeyValue); DPRINT("KeyValue: %S\n", KeyValue);
if (wcsstr(DisplayIdentifier, KeyValue)) if (wcsstr(DisplayIdentifier, KeyValue))
{ {
if (!InfGetDataField(Context, 0, &KeyName)) if (!INF_GetDataField(&Context, 0, &KeyName))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetDataField() failed\n"); DPRINT("INF_GetDataField() failed\n");
return NULL; return NULL;
} }
@ -418,15 +416,14 @@ CreateDisplayDriverList(HINF InfFile)
wcscpy(DisplayKey, KeyName); wcscpy(DisplayKey, KeyName);
} }
} }
while (InfFindNextLine(Context, Context)); while (SetupFindNextLine(&Context, &Context));
InfFreeContext(Context);
List = CreateGenericList(); List = CreateGenericList();
if (List == NULL) if (List == NULL)
return NULL; return NULL;
if (!InfFindFirstLine (InfFile, L"Display", NULL, &Context)) if (!SetupFindFirstLineW (InfFile, L"Display", NULL, &Context))
{ {
DestroyGenericList(List, FALSE); DestroyGenericList(List, FALSE);
return NULL; return NULL;
@ -434,15 +431,15 @@ CreateDisplayDriverList(HINF InfFile)
do do
{ {
if (!InfGetDataField(Context, 0, &KeyName)) if (!INF_GetDataField(&Context, 0, &KeyName))
{ {
DPRINT1("InfGetDataField() failed\n"); DPRINT1("INF_GetDataField() failed\n");
break; break;
} }
if (!InfGetDataField(Context, 1, &KeyValue)) if (!INF_GetDataField(&Context, 1, &KeyValue))
{ {
DPRINT1("InfGetDataField() failed\n"); DPRINT1("INF_GetDataField() failed\n");
break; break;
} }
@ -464,8 +461,7 @@ CreateDisplayDriverList(HINF InfFile)
UserData, UserData,
_wcsicmp(KeyName, DisplayKey) ? FALSE : TRUE); _wcsicmp(KeyName, DisplayKey) ? FALSE : TRUE);
} }
while (InfFindNextLine(Context, Context)); while (SetupFindNextLine(&Context, &Context));
InfFreeContext(Context);
#if 0 #if 0
AppendGenericListEntry(List, "Other display driver", NULL, TRUE); AppendGenericListEntry(List, "Other display driver", NULL, TRUE);
@ -501,7 +497,7 @@ BOOLEAN
ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List) ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List)
{ {
PGENERIC_LIST_ENTRY Entry; PGENERIC_LIST_ENTRY Entry;
PINFCONTEXT Context; INFCONTEXT Context;
PWCHAR ServiceName; PWCHAR ServiceName;
ULONG StartValue; ULONG StartValue;
NTSTATUS Status; NTSTATUS Status;
@ -518,16 +514,16 @@ ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List)
return FALSE; return FALSE;
} }
if (!InfFindFirstLine(InfFile, L"Display", Entry->UserData, &Context)) if (!SetupFindFirstLineW(InfFile, L"Display", Entry->UserData, &Context))
{ {
DPRINT("InfFindFirstLine() failed\n"); DPRINT("SetupFindFirstLineW() failed\n");
return FALSE; return FALSE;
} }
/* Enable the right driver */ /* Enable the right driver */
if (!InfGetDataField(Context, 3, &ServiceName)) if (!INF_GetDataField(&Context, 3, &ServiceName))
{ {
DPRINT("InfGetDataField() failed\n"); DPRINT("INF_GetDataField() failed\n");
return FALSE; return FALSE;
} }
@ -551,9 +547,9 @@ ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List)
/* Set the resolution */ /* Set the resolution */
swprintf(RegPath, L"\\Registry\\Machine\\System\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\%s\\Device0", ServiceName); swprintf(RegPath, L"\\Registry\\Machine\\System\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\%s\\Device0", ServiceName);
if (!InfGetDataField(Context, 4, &Buffer)) if (!INF_GetDataField(&Context, 4, &Buffer))
{ {
DPRINT("InfGetDataField() failed\n"); DPRINT("INF_GetDataField() failed\n");
return FALSE; return FALSE;
} }
Width = wcstoul(Buffer, NULL, 10); Width = wcstoul(Buffer, NULL, 10);
@ -570,9 +566,9 @@ ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List)
} }
if (!InfGetDataField(Context, 5, &Buffer)) if (!INF_GetDataField(&Context, 5, &Buffer))
{ {
DPRINT("InfGetDataField() failed\n"); DPRINT("INF_GetDataField() failed\n");
return FALSE; return FALSE;
} }
Hight = wcstoul(Buffer, 0, 0); Hight = wcstoul(Buffer, 0, 0);
@ -588,9 +584,9 @@ ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List)
return FALSE; return FALSE;
} }
if (!InfGetDataField(Context, 6, &Buffer)) if (!INF_GetDataField(&Context, 6, &Buffer))
{ {
DPRINT("InfGetDataField() failed\n"); DPRINT("INF_GetDataField() failed\n");
return FALSE; return FALSE;
} }
Bpp = wcstoul(Buffer, 0, 0); Bpp = wcstoul(Buffer, 0, 0);
@ -606,8 +602,6 @@ ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List)
return FALSE; return FALSE;
} }
InfFreeContext(Context);
DPRINT("ProcessDisplayRegistry() done\n"); DPRINT("ProcessDisplayRegistry() done\n");
return TRUE; return TRUE;
@ -619,7 +613,7 @@ CreateKeyboardDriverList(HINF InfFile)
{ {
CHAR Buffer[128]; CHAR Buffer[128];
PGENERIC_LIST List; PGENERIC_LIST List;
PINFCONTEXT Context; INFCONTEXT Context;
PWCHAR KeyName; PWCHAR KeyName;
PWCHAR KeyValue; PWCHAR KeyValue;
PWCHAR UserData; PWCHAR UserData;
@ -628,7 +622,7 @@ CreateKeyboardDriverList(HINF InfFile)
if (List == NULL) if (List == NULL)
return NULL; return NULL;
if (!InfFindFirstLine (InfFile, L"Keyboard", NULL, &Context)) if (!SetupFindFirstLineW (InfFile, L"Keyboard", NULL, &Context))
{ {
DestroyGenericList(List, FALSE); DestroyGenericList(List, FALSE);
return NULL; return NULL;
@ -636,10 +630,10 @@ CreateKeyboardDriverList(HINF InfFile)
do do
{ {
if (!InfGetData (Context, &KeyName, &KeyValue)) if (!INF_GetData (&Context, &KeyName, &KeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetData() failed\n"); DPRINT("INF_GetData() failed\n");
break; break;
} }
@ -656,8 +650,7 @@ CreateKeyboardDriverList(HINF InfFile)
sprintf(Buffer, "%S", KeyValue); sprintf(Buffer, "%S", KeyValue);
AppendGenericListEntry(List, Buffer, UserData, FALSE); AppendGenericListEntry(List, Buffer, UserData, FALSE);
} }
while (InfFindNextLine(Context, Context)); while (SetupFindNextLine(&Context, &Context));
InfFreeContext(Context);
return List; return List;
} }
@ -668,42 +661,37 @@ CreateKeyboardLayoutList(HINF InfFile)
{ {
CHAR Buffer[128]; CHAR Buffer[128];
PGENERIC_LIST List; PGENERIC_LIST List;
PINFCONTEXT Context; INFCONTEXT Context;
PWCHAR KeyName; PWCHAR KeyName;
PWCHAR KeyValue; PWCHAR KeyValue;
PWCHAR UserData; PWCHAR UserData;
WCHAR DefaultLayout[20]; WCHAR DefaultLayout[20];
/* Get default layout id */ /* Get default layout id */
if (!InfFindFirstLine (InfFile, L"NLS", L"DefaultLayout", &Context)) if (!SetupFindFirstLineW (InfFile, L"NLS", L"DefaultLayout", &Context))
return NULL; return NULL;
if (!InfGetData (Context, NULL, &KeyValue)) if (!INF_GetData (&Context, NULL, &KeyValue))
{ return NULL;
InfFreeContext(Context);
return NULL;
}
wcscpy(DefaultLayout, KeyValue); wcscpy(DefaultLayout, KeyValue);
InfFreeContext(Context);
List = CreateGenericList(); List = CreateGenericList();
if (List == NULL) if (List == NULL)
return NULL; return NULL;
if (!InfFindFirstLine (InfFile, L"KeyboardLayout", NULL, &Context)) if (!SetupFindFirstLineW (InfFile, L"KeyboardLayout", NULL, &Context))
{ {
DestroyGenericList(List, FALSE); DestroyGenericList(List, FALSE);
InfFreeContext(Context);
return NULL; return NULL;
} }
do do
{ {
if (!InfGetData (Context, &KeyName, &KeyValue)) if (!INF_GetData (&Context, &KeyName, &KeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetData() failed\n"); DPRINT("INF_GetData() failed\n");
break; break;
} }
@ -723,8 +711,7 @@ CreateKeyboardLayoutList(HINF InfFile)
UserData, UserData,
_wcsicmp(KeyName, DefaultLayout) ? FALSE : TRUE); _wcsicmp(KeyName, DefaultLayout) ? FALSE : TRUE);
} }
while (InfFindNextLine(Context, Context)); while (SetupFindNextLine(&Context, &Context));
InfFreeContext(Context);
return List; return List;
} }

View file

@ -25,7 +25,7 @@
* Casper S. Hornstrup (chorns@users.sourceforge.net) * Casper S. Hornstrup (chorns@users.sourceforge.net)
*/ */
#include <usetup.h> #include "usetup.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -411,12 +411,10 @@ VOID
CheckUnattendedSetup(VOID) CheckUnattendedSetup(VOID)
{ {
WCHAR UnattendInfPath[MAX_PATH]; WCHAR UnattendInfPath[MAX_PATH];
UNICODE_STRING FileName; INFCONTEXT Context;
PINFCONTEXT Context;
HINF UnattendInf; HINF UnattendInf;
ULONG ErrorLine; UINT ErrorLine;
NTSTATUS Status; INT IntValue;
LONG IntValue;
PWCHAR Value; PWCHAR Value;
if (DoesFileExist(SourcePath.Buffer, L"unattend.inf") == FALSE) if (DoesFileExist(SourcePath.Buffer, L"unattend.inf") == FALSE)
@ -429,34 +427,30 @@ CheckUnattendedSetup(VOID)
wcscpy(UnattendInfPath, SourcePath.Buffer); wcscpy(UnattendInfPath, SourcePath.Buffer);
wcscat(UnattendInfPath, L"\\unattend.inf"); wcscat(UnattendInfPath, L"\\unattend.inf");
RtlInitUnicodeString(&FileName,
UnattendInfPath);
/* Load 'unattend.inf' from install media. */ /* Load 'unattend.inf' from install media. */
Status = InfOpenFile(&UnattendInf, UnattendInf = SetupOpenInfFileW(UnattendInfPath,
&FileName, NULL,
INF_STYLE_WIN4,
&ErrorLine); &ErrorLine);
if (!NT_SUCCESS(Status)) if (UnattendInf == INVALID_HANDLE_VALUE)
{ {
DPRINT("InfOpenFile() failed with status 0x%x\n", Status); DPRINT("SetupOpenInfFileW() failed\n");
return; return;
} }
/* Open 'Unattend' section */ /* Open 'Unattend' section */
if (!InfFindFirstLine(UnattendInf, L"Unattend", L"Signature", &Context)) if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"Signature", &Context))
{ {
DPRINT("InfFindFirstLine() failed for section 'Unattend'\n"); DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n");
InfFreeContext(Context); SetupCloseInfFile(&UnattendInf);
InfCloseFile(UnattendInf);
return; return;
} }
/* Get pointer 'Signature' key */ /* Get pointer 'Signature' key */
if (!InfGetData(Context, NULL, &Value)) if (!INF_GetData(&Context, NULL, &Value))
{ {
DPRINT("InfGetData() failed for key 'Signature'\n"); DPRINT("INF_GetData() failed for key 'Signature'\n");
InfFreeContext(Context); SetupCloseInfFile(&UnattendInf);
InfCloseFile(UnattendInf);
return; return;
} }
@ -464,88 +458,75 @@ CheckUnattendedSetup(VOID)
if (_wcsicmp(Value, L"$ReactOS$") != 0) if (_wcsicmp(Value, L"$ReactOS$") != 0)
{ {
DPRINT("Signature not $ReactOS$\n"); DPRINT("Signature not $ReactOS$\n");
InfFreeContext(Context); SetupCloseInfFile(&UnattendInf);
InfCloseFile(UnattendInf);
return; return;
} }
/* Search for 'DestinationDiskNumber' in the 'Unattend' section */ /* Search for 'DestinationDiskNumber' in the 'Unattend' section */
if (!InfFindFirstLine(UnattendInf, L"Unattend", L"DestinationDiskNumber", &Context)) if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"DestinationDiskNumber", &Context))
{ {
DPRINT("InfFindFirstLine() failed for key 'DestinationDiskNumber'\n"); DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n");
InfFreeContext(Context); SetupCloseInfFile(&UnattendInf);
InfCloseFile(UnattendInf);
return; return;
} }
if (!InfGetIntField(Context, 0, &IntValue)) if (!SetupGetIntField(&Context, 0, &IntValue))
{ {
DPRINT("InfGetIntField() failed for key 'DestinationDiskNumber'\n"); DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n");
InfFreeContext(Context); SetupCloseInfFile(&UnattendInf);
InfCloseFile(UnattendInf);
return; return;
} }
UnattendDestinationDiskNumber = IntValue; UnattendDestinationDiskNumber = (LONG)IntValue;
InfFreeContext(Context);
/* Search for 'DestinationPartitionNumber' in the 'Unattend' section */ /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
if (!InfFindFirstLine(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context)) if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context))
{ {
DPRINT("InfFindFirstLine() failed for key 'DestinationPartitionNumber'\n"); DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
InfFreeContext(Context); SetupCloseInfFile(UnattendInf);
InfCloseFile(UnattendInf);
return; return;
} }
if (!InfGetIntField(Context, 0, &IntValue)) if (!SetupGetIntField(&Context, 0, &IntValue))
{ {
DPRINT("InfGetIntField() failed for key 'DestinationPartitionNumber'\n"); DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n");
InfFreeContext(Context); SetupCloseInfFile(UnattendInf);
InfCloseFile(UnattendInf);
return; return;
} }
UnattendDestinationPartitionNumber = IntValue; UnattendDestinationPartitionNumber = IntValue;
InfFreeContext(Context);
/* Search for 'DestinationPartitionNumber' in the 'Unattend' section */ /* Search for 'DestinationPartitionNumber' in the 'Unattend' section */
if (!InfFindFirstLine(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context)) if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context))
{ {
DPRINT("InfFindFirstLine() failed for key 'DestinationPartitionNumber'\n"); DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
InfCloseFile(UnattendInf); SetupCloseInfFile(UnattendInf);
return; return;
} }
/* Get pointer 'InstallationDirectory' key */ /* Get pointer 'InstallationDirectory' key */
if (!InfGetData(Context, NULL, &Value)) if (!INF_GetData(&Context, NULL, &Value))
{ {
DPRINT("InfGetData() failed for key 'InstallationDirectory'\n"); DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n");
InfFreeContext(Context); SetupCloseInfFile(UnattendInf);
InfCloseFile(UnattendInf);
return; return;
} }
wcscpy(UnattendInstallationDirectory, Value); wcscpy(UnattendInstallationDirectory, Value);
InfFreeContext(Context);
IsUnattendedSetup = TRUE; IsUnattendedSetup = TRUE;
/* Search for 'MBRInstallType' in the 'Unattend' section */ /* Search for 'MBRInstallType' in the 'Unattend' section */
if (!InfFindFirstLine(UnattendInf, L"Unattend", L"MBRInstallType", &Context)) if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"MBRInstallType", &Context))
{ {
DPRINT("InfFindFirstLine() failed for key 'MBRInstallType'\n"); DPRINT("SetupFindFirstLine() failed for key 'MBRInstallType'\n");
InfFreeContext(Context); SetupCloseInfFile(UnattendInf);
InfCloseFile(UnattendInf);
return; return;
} }
if (!InfGetIntField(Context, 0, &IntValue)) if (!SetupGetIntField(&Context, 0, &IntValue))
{ {
DPRINT("InfGetIntField() failed for key 'MBRInstallType'\n"); DPRINT("SetupGetIntField() failed for key 'MBRInstallType'\n");
InfFreeContext(Context); SetupCloseInfFile(UnattendInf);
InfCloseFile(UnattendInf);
return; return;
} }
UnattendMBRInstallType = IntValue; UnattendMBRInstallType = IntValue;
InfFreeContext(Context);
InfCloseFile(UnattendInf); SetupCloseInfFile(UnattendInf);
DPRINT("Running unattended setup\n"); DPRINT("Running unattended setup\n");
} }
@ -562,10 +543,9 @@ SetupStartPage(PINPUT_RECORD Ir)
SYSTEM_DEVICE_INFORMATION Sdi; SYSTEM_DEVICE_INFORMATION Sdi;
NTSTATUS Status; NTSTATUS Status;
WCHAR FileNameBuffer[MAX_PATH]; WCHAR FileNameBuffer[MAX_PATH];
UNICODE_STRING FileName; INFCONTEXT Context;
PINFCONTEXT Context;
PWCHAR Value; PWCHAR Value;
ULONG ErrorLine; UINT ErrorLine;
ULONG ReturnSize; ULONG ReturnSize;
CONSOLE_SetStatusText(" Please wait..."); CONSOLE_SetStatusText(" Please wait...");
@ -636,13 +616,12 @@ SetupStartPage(PINPUT_RECORD Ir)
/* Load txtsetup.sif from install media. */ /* Load txtsetup.sif from install media. */
wcscpy(FileNameBuffer, SourceRootPath.Buffer); wcscpy(FileNameBuffer, SourceRootPath.Buffer);
wcscat(FileNameBuffer, L"\\reactos\\txtsetup.sif"); wcscat(FileNameBuffer, L"\\reactos\\txtsetup.sif");
RtlInitUnicodeString(&FileName,
FileNameBuffer);
Status = InfOpenFile(&SetupInf, SetupInf = SetupOpenInfFileW(FileNameBuffer,
&FileName, NULL,
INF_STYLE_WIN4,
&ErrorLine); &ErrorLine);
if (!NT_SUCCESS(Status)) if (SetupInf == INVALID_HANDLE_VALUE)
{ {
PopupError("Setup failed to load the file TXTSETUP.SIF.\n", PopupError("Setup failed to load the file TXTSETUP.SIF.\n",
"ENTER = Reboot computer"); "ENTER = Reboot computer");
@ -659,7 +638,7 @@ SetupStartPage(PINPUT_RECORD Ir)
} }
/* Open 'Version' section */ /* Open 'Version' section */
if (!InfFindFirstLine (SetupInf, L"Version", L"Signature", &Context)) if (!SetupFindFirstLineW (SetupInf, L"Version", L"Signature", &Context))
{ {
PopupError("Setup found a corrupt TXTSETUP.SIF.\n", PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
"ENTER = Reboot computer"); "ENTER = Reboot computer");
@ -677,9 +656,8 @@ SetupStartPage(PINPUT_RECORD Ir)
/* Get pointer 'Signature' key */ /* Get pointer 'Signature' key */
if (!InfGetData (Context, NULL, &Value)) if (!INF_GetData (&Context, NULL, &Value))
{ {
InfFreeContext(Context);
PopupError("Setup found a corrupt TXTSETUP.SIF.\n", PopupError("Setup found a corrupt TXTSETUP.SIF.\n",
"ENTER = Reboot computer"); "ENTER = Reboot computer");
@ -697,7 +675,6 @@ SetupStartPage(PINPUT_RECORD Ir)
/* Check 'Signature' string */ /* Check 'Signature' string */
if (_wcsicmp(Value, L"$ReactOS$") != 0) if (_wcsicmp(Value, L"$ReactOS$") != 0)
{ {
InfFreeContext(Context);
PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n", PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n",
"ENTER = Reboot computer"); "ENTER = Reboot computer");
@ -711,7 +688,6 @@ SetupStartPage(PINPUT_RECORD Ir)
} }
} }
} }
InfFreeContext(Context);
CheckUnattendedSetup(); CheckUnattendedSetup();
@ -2605,7 +2581,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
WCHAR InstallDir[51]; WCHAR InstallDir[51];
PWCHAR DefaultPath; PWCHAR DefaultPath;
PINFCONTEXT Context; INFCONTEXT Context;
ULONG Length; ULONG Length;
if (PartitionList == NULL || if (PartitionList == NULL ||
@ -2620,7 +2596,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
PartEntry = PartitionList->CurrentPartition; PartEntry = PartitionList->CurrentPartition;
/* Search for 'DefaultPath' in the 'SetupData' section */ /* Search for 'DefaultPath' in the 'SetupData' section */
if (!InfFindFirstLine (SetupInf, L"SetupData", L"DefaultPath", &Context)) if (!SetupFindFirstLineW (SetupInf, L"SetupData", L"DefaultPath", &Context))
{ {
PopupError("Setup failed to find the 'SetupData' section\n" PopupError("Setup failed to find the 'SetupData' section\n"
"in TXTSETUP.SIF.\n", "in TXTSETUP.SIF.\n",
@ -2638,7 +2614,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
} }
/* Read the 'DefaultPath' data */ /* Read the 'DefaultPath' data */
if (InfGetData (Context, NULL, &DefaultPath)) if (INF_GetData (&Context, NULL, &DefaultPath))
{ {
wcscpy(InstallDir, DefaultPath); wcscpy(InstallDir, DefaultPath);
} }
@ -2646,7 +2622,6 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
{ {
wcscpy(InstallDir, L"\\ReactOS"); wcscpy(InstallDir, L"\\ReactOS");
} }
InfFreeContext(Context);
Length = wcslen(InstallDir); Length = wcslen(InstallDir);
CONSOLE_SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a"); CONSOLE_SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a");
@ -2711,15 +2686,15 @@ AddSectionToCopyQueue(HINF InfFile,
PWCHAR SourceCabinet, PWCHAR SourceCabinet,
PINPUT_RECORD Ir) PINPUT_RECORD Ir)
{ {
PINFCONTEXT FilesContext; INFCONTEXT FilesContext;
PINFCONTEXT DirContext; INFCONTEXT DirContext;
PWCHAR FileKeyName; PWCHAR FileKeyName;
PWCHAR FileKeyValue; PWCHAR FileKeyValue;
PWCHAR DirKeyValue; PWCHAR DirKeyValue;
PWCHAR TargetFileName; PWCHAR TargetFileName;
/* Search for the SectionName section */ /* Search for the SectionName section */
if (!InfFindFirstLine (InfFile, SectionName, NULL, &FilesContext)) if (!SetupFindFirstLineW (InfFile, SectionName, NULL, &FilesContext))
{ {
char Buffer[128]; char Buffer[128];
sprintf(Buffer, "Setup failed to find the '%S' section\nin TXTSETUP.SIF.\n", SectionName); sprintf(Buffer, "Setup failed to find the '%S' section\nin TXTSETUP.SIF.\n", SectionName);
@ -2743,32 +2718,31 @@ AddSectionToCopyQueue(HINF InfFile,
do do
{ {
/* Get source file name and target directory id */ /* Get source file name and target directory id */
if (!InfGetData (FilesContext, &FileKeyName, &FileKeyValue)) if (!INF_GetData (&FilesContext, &FileKeyName, &FileKeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT1("InfGetData() failed\n"); DPRINT1("INF_GetData() failed\n");
break; break;
} }
/* Get optional target file name */ /* Get optional target file name */
if (!InfGetDataField (FilesContext, 2, &TargetFileName)) if (!INF_GetDataField (&FilesContext, 2, &TargetFileName))
TargetFileName = NULL; TargetFileName = NULL;
DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue); DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue);
/* Lookup target directory */ /* Lookup target directory */
if (!InfFindFirstLine (InfFile, L"Directories", FileKeyValue, &DirContext)) if (!SetupFindFirstLineW (InfFile, L"Directories", FileKeyValue, &DirContext))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT1("InfFindFirstLine() failed\n"); DPRINT1("SetupFindFirstLine() failed\n");
break; break;
} }
if (!InfGetData (DirContext, NULL, &DirKeyValue)) if (!INF_GetData (&DirContext, NULL, &DirKeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
InfFreeContext(DirContext); DPRINT1("INF_GetData() failed\n");
DPRINT1("InfGetData() failed\n");
break; break;
} }
@ -2783,11 +2757,8 @@ AddSectionToCopyQueue(HINF InfFile,
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT1("SetupQueueCopy() failed\n"); DPRINT1("SetupQueueCopy() failed\n");
} }
InfFreeContext(DirContext);
} }
while (InfFindNextLine(FilesContext, FilesContext)); while (SetupFindNextLine(&FilesContext, &FilesContext));
InfFreeContext(FilesContext);
return TRUE; return TRUE;
} }
@ -2798,7 +2769,7 @@ PrepareCopyPageInfFile(HINF InfFile,
PINPUT_RECORD Ir) PINPUT_RECORD Ir)
{ {
WCHAR PathBuffer[MAX_PATH]; WCHAR PathBuffer[MAX_PATH];
PINFCONTEXT DirContext; INFCONTEXT DirContext;
PWCHAR AdditionalSectionName = NULL; PWCHAR AdditionalSectionName = NULL;
PWCHAR KeyValue; PWCHAR KeyValue;
ULONG Length; ULONG Length;
@ -2858,7 +2829,7 @@ PrepareCopyPageInfFile(HINF InfFile,
/* Search for the 'Directories' section */ /* Search for the 'Directories' section */
if (!InfFindFirstLine(InfFile, L"Directories", NULL, &DirContext)) if (!SetupFindFirstLineW(InfFile, L"Directories", NULL, &DirContext))
{ {
if (SourceCabinet) if (SourceCabinet)
{ {
@ -2885,7 +2856,7 @@ PrepareCopyPageInfFile(HINF InfFile,
/* Enumerate the directory values and create the subdirectories */ /* Enumerate the directory values and create the subdirectories */
do do
{ {
if (!InfGetData (DirContext, NULL, &KeyValue)) if (!INF_GetData (&DirContext, NULL, &KeyValue))
{ {
DPRINT1("break\n"); DPRINT1("break\n");
break; break;
@ -2928,9 +2899,7 @@ PrepareCopyPageInfFile(HINF InfFile,
} }
} }
} }
while (InfFindNextLine (DirContext, DirContext)); while (SetupFindNextLine (&DirContext, &DirContext));
InfFreeContext(DirContext);
return(TRUE); return(TRUE);
} }
@ -2941,11 +2910,10 @@ PrepareCopyPage(PINPUT_RECORD Ir)
{ {
HINF InfHandle; HINF InfHandle;
WCHAR PathBuffer[MAX_PATH]; WCHAR PathBuffer[MAX_PATH];
PINFCONTEXT CabinetsContext; INFCONTEXT CabinetsContext;
ULONG InfFileSize; ULONG InfFileSize;
PWCHAR KeyValue; PWCHAR KeyValue;
NTSTATUS Status; UINT ErrorLine;
ULONG ErrorLine;
PVOID InfFileData; PVOID InfFileData;
CONSOLE_SetTextXY(6, 8, "Setup prepares your computer for copying the ReactOS files. "); CONSOLE_SetTextXY(6, 8, "Setup prepares your computer for copying the ReactOS files. ");
@ -2976,7 +2944,7 @@ PrepareCopyPage(PINPUT_RECORD Ir)
} }
/* Search for the 'Cabinets' section */ /* Search for the 'Cabinets' section */
if (!InfFindFirstLine (SetupInf, L"Cabinets", NULL, &CabinetsContext)) if (!SetupFindFirstLineW (SetupInf, L"Cabinets", NULL, &CabinetsContext))
{ {
return FILE_COPY_PAGE; return FILE_COPY_PAGE;
} }
@ -2987,7 +2955,7 @@ PrepareCopyPage(PINPUT_RECORD Ir)
*/ */
do do
{ {
if (!InfGetData (CabinetsContext, NULL, &KeyValue)) if (!INF_GetData (&CabinetsContext, NULL, &KeyValue))
break; break;
wcscpy(PathBuffer, SourcePath.Buffer); wcscpy(PathBuffer, SourcePath.Buffer);
@ -3037,11 +3005,12 @@ PrepareCopyPage(PINPUT_RECORD Ir)
} }
} }
Status = InfOpenBufferedFile(&InfHandle, InfHandle = INF_OpenBufferedFileA(InfFileData,
InfFileData,
InfFileSize, InfFileSize,
NULL,
INF_STYLE_WIN4,
&ErrorLine); &ErrorLine);
if (!NT_SUCCESS(Status)) if (InfHandle == INVALID_HANDLE_VALUE)
{ {
PopupError("Cabinet has no valid inf file.\n", PopupError("Cabinet has no valid inf file.\n",
"ENTER = Reboot computer"); "ENTER = Reboot computer");
@ -3064,9 +3033,7 @@ PrepareCopyPage(PINPUT_RECORD Ir)
return QUIT_PAGE; return QUIT_PAGE;
} }
} }
while (InfFindNextLine (CabinetsContext, CabinetsContext)); while (SetupFindNextLine (&CabinetsContext, &CabinetsContext));
InfFreeContext(CabinetsContext);
return FILE_COPY_PAGE; return FILE_COPY_PAGE;
} }
@ -3144,7 +3111,7 @@ FileCopyPage(PINPUT_RECORD Ir)
static PAGE_NUMBER static PAGE_NUMBER
RegistryPage(PINPUT_RECORD Ir) RegistryPage(PINPUT_RECORD Ir)
{ {
PINFCONTEXT InfContext; INFCONTEXT InfContext;
PWSTR Action; PWSTR Action;
PWSTR File; PWSTR File;
PWSTR Section; PWSTR Section;
@ -3194,9 +3161,9 @@ RegistryPage(PINPUT_RECORD Ir)
/* Update registry */ /* Update registry */
CONSOLE_SetStatusText(" Updating registry hives..."); CONSOLE_SetStatusText(" Updating registry hives...");
if (!InfFindFirstLine(SetupInf, L"HiveInfs.Install", NULL, &InfContext)) if (!SetupFindFirstLineW(SetupInf, L"HiveInfs.Install", NULL, &InfContext))
{ {
DPRINT1("InfFindFirstLine() failed\n"); DPRINT1("SetupFindFirstLine() failed\n");
PopupError("Setup failed to find the registry data files.", PopupError("Setup failed to find the registry data files.",
"ENTER = Reboot computer"); "ENTER = Reboot computer");
@ -3213,9 +3180,9 @@ RegistryPage(PINPUT_RECORD Ir)
do do
{ {
InfGetDataField (InfContext, 0, &Action); INF_GetDataField (&InfContext, 0, &Action);
InfGetDataField (InfContext, 1, &File); INF_GetDataField (&InfContext, 1, &File);
InfGetDataField (InfContext, 2, &Section); INF_GetDataField (&InfContext, 2, &Section);
DPRINT("Action: %S File: %S Section %S\n", Action, File, Section); DPRINT("Action: %S File: %S Section %S\n", Action, File, Section);
@ -3252,9 +3219,7 @@ RegistryPage(PINPUT_RECORD Ir)
} }
} }
} }
while (InfFindNextLine (InfContext, InfContext)); while (SetupFindNextLine (&InfContext, &InfContext));
InfFreeContext(InfContext);
/* Update display registry settings */ /* Update display registry settings */
CONSOLE_SetStatusText(" Updating display registry settings..."); CONSOLE_SetStatusText(" Updating display registry settings...");
@ -3714,7 +3679,7 @@ NtProcessStartup(PPEB Peb)
RtlNormalizeProcessParams(Peb->ProcessParameters); RtlNormalizeProcessParams(Peb->ProcessParameters);
ProcessHeap = Peb->ProcessHeap; ProcessHeap = Peb->ProcessHeap;
InfSetHeap(ProcessHeap); INF_SetHeap(ProcessHeap);
SignalInitEvent(); SignalInitEvent();

View file

@ -54,11 +54,10 @@
/* ReactOS Version */ /* ReactOS Version */
#include <reactos/buildno.h> #include <reactos/buildno.h>
#include <infros.h>
/* Internal Headers */ /* Internal Headers */
#include "console.h" #include "console.h"
#include "partlist.h" #include "partlist.h"
#include "inffile.h"
#include "inicache.h" #include "inicache.h"
#include "filequeue.h" #include "filequeue.h"
#include "progress.h" #include "progress.h"

View file

@ -1,4 +1,4 @@
<module name="usetup" type="nativecui" installbase="system32" installname="usetup.exe" allowwarnings="true"> <module name="usetup" type="nativecui" installbase="system32" installname="usetup.exe" allowwarnings="false">
<bootstrap base="reactos/system32" nameoncd="smss.exe" /> <bootstrap base="reactos/system32" nameoncd="smss.exe" />
<include base="usetup">.</include> <include base="usetup">.</include>
<include base="zlib">.</include> <include base="zlib">.</include>
@ -13,7 +13,7 @@
<library>inflib</library> <library>inflib</library>
<library>vfatlib</library> <library>vfatlib</library>
<library>ntdll</library> <library>ntdll</library>
<pch>usetup.h</pch> <!--pch>usetup.h</pch-->
<compilationunit name="unit.c"> <compilationunit name="unit.c">
<file>bootsup.c</file> <file>bootsup.c</file>
<file>cabinet.c</file> <file>cabinet.c</file>
@ -24,6 +24,7 @@
<file>format.c</file> <file>format.c</file>
<file>fslist.c</file> <file>fslist.c</file>
<file>genlist.c</file> <file>genlist.c</file>
<file>inffile.c</file>
<file>inicache.c</file> <file>inicache.c</file>
<file>keytrans.c</file> <file>keytrans.c</file>
<file>partlist.c</file> <file>partlist.c</file>