From cc2684d474c5bfd3157bf69f3e415f43d63ba1da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Thu, 31 Aug 2006 09:13:03 +0000 Subject: [PATCH] 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 --- reactos/base/setup/usetup/bootsup.c | 2 +- reactos/base/setup/usetup/cabinet.c | 2 +- reactos/base/setup/usetup/console.c | 600 +++++++++++++----------- reactos/base/setup/usetup/console.h | 94 +++- reactos/base/setup/usetup/drivesup.c | 2 +- reactos/base/setup/usetup/filequeue.c | 2 +- reactos/base/setup/usetup/filesup.c | 2 +- reactos/base/setup/usetup/format.c | 2 +- reactos/base/setup/usetup/fslist.c | 2 +- reactos/base/setup/usetup/genlist.c | 2 +- reactos/base/setup/usetup/inffile.c | 197 ++++++++ reactos/base/setup/usetup/inffile.h | 135 ++++++ reactos/base/setup/usetup/inicache.c | 2 +- reactos/base/setup/usetup/keytrans.c | 2 +- reactos/base/setup/usetup/partlist.c | 22 +- reactos/base/setup/usetup/progress.c | 2 +- reactos/base/setup/usetup/registry.c | 54 +-- reactos/base/setup/usetup/settings.c | 111 ++--- reactos/base/setup/usetup/usetup.c | 205 ++++---- reactos/base/setup/usetup/usetup.h | 3 +- reactos/base/setup/usetup/usetup.rbuild | 5 +- 21 files changed, 906 insertions(+), 542 deletions(-) create mode 100644 reactos/base/setup/usetup/inffile.c create mode 100644 reactos/base/setup/usetup/inffile.h diff --git a/reactos/base/setup/usetup/bootsup.c b/reactos/base/setup/usetup/bootsup.c index 50934213253..3ee55733f9f 100644 --- a/reactos/base/setup/usetup/bootsup.c +++ b/reactos/base/setup/usetup/bootsup.c @@ -24,7 +24,7 @@ * PROGRAMMER: Eric Kohl */ -#include +#include "usetup.h" #define NDEBUG #include diff --git a/reactos/base/setup/usetup/cabinet.c b/reactos/base/setup/usetup/cabinet.c index 4ba83bcd8fc..e72a2536248 100644 --- a/reactos/base/setup/usetup/cabinet.c +++ b/reactos/base/setup/usetup/cabinet.c @@ -8,7 +8,7 @@ * CSH 15/08-2003 Created */ -#include +#include "usetup.h" #include #define NDEBUG diff --git a/reactos/base/setup/usetup/console.c b/reactos/base/setup/usetup/console.c index 30fb93cd136..c9d4cb7430f 100644 --- a/reactos/base/setup/usetup/console.c +++ b/reactos/base/setup/usetup/console.c @@ -26,15 +26,15 @@ /* INCLUDES ******************************************************************/ -#include +#include "usetup.h" #define NDEBUG #include /* GLOBALS ******************************************************************/ -static HANDLE StdInput = INVALID_HANDLE_VALUE; -static HANDLE StdOutput = INVALID_HANDLE_VALUE; +HANDLE StdInput = INVALID_HANDLE_VALUE; +HANDLE StdOutput = INVALID_HANDLE_VALUE; static SHORT xScreen = 0; static SHORT yScreen = 0; @@ -436,138 +436,133 @@ ConSetConsoleTextAttribute( return NT_SUCCESS(Status); } - - - VOID -CONSOLE_ConInKey(PINPUT_RECORD Buffer) +CONSOLE_ConInKey( + OUT PINPUT_RECORD Buffer) { ULONG Read; - while (TRUE) - { - ReadConsoleInput(StdInput, Buffer, 1, &Read); + while (TRUE) + { + ReadConsoleInput(StdInput, Buffer, 1, &Read); - if ((Buffer->EventType == KEY_EVENT) && - (Buffer->Event.KeyEvent.bKeyDown == TRUE)) - break; - } + if ((Buffer->EventType == KEY_EVENT) + && (Buffer->Event.KeyEvent.bKeyDown == TRUE)) + break; + } } - VOID -CONSOLE_ConOutChar(CHAR c) +CONSOLE_ConOutChar( + IN CHAR c) { - ULONG Written; + ULONG Written; - WriteConsole(StdOutput, - &c, - 1, - &Written, - NULL); + WriteConsole( + StdOutput, + &c, + 1, + &Written, + NULL); } - VOID -CONSOLE_ConOutPuts(LPSTR szText) +CONSOLE_ConOutPuts( + IN LPCSTR szText) { - ULONG Written; + ULONG Written; - WriteConsole(StdOutput, - szText, - strlen(szText), - &Written, - NULL); - WriteConsole(StdOutput, - "\n", - 1, - &Written, - NULL); + WriteConsole( + StdOutput, + szText, + strlen(szText), + &Written, + NULL); + WriteConsole( + StdOutput, + "\n", + 1, + &Written, + NULL); } - VOID -CONSOLE_ConOutPrintf(LPSTR szFormat, ...) +CONSOLE_ConOutPrintf( + IN LPCSTR szFormat, ...) { - CHAR szOut[256]; - DWORD dwWritten; - va_list arg_ptr; + CHAR szOut[256]; + DWORD dwWritten; + va_list arg_ptr; - va_start(arg_ptr, szFormat); - vsprintf(szOut, szFormat, arg_ptr); - va_end(arg_ptr); + va_start(arg_ptr, szFormat); + vsprintf(szOut, szFormat, arg_ptr); + va_end(arg_ptr); - WriteConsole(StdOutput, - szOut, - strlen(szOut), - &dwWritten, - NULL); + WriteConsole( + StdOutput, + szOut, + strlen(szOut), + &dwWritten, + NULL); } - - - - SHORT 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 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 -CONSOLE_GetScreenSize(SHORT *maxx, - SHORT *maxy) +CONSOLE_GetScreenSize( + 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 -CONSOLE_SetCursorType(BOOL bInsert, - BOOL bVisible) +CONSOLE_SetCursorType( + IN BOOL bInsert, + IN BOOL bVisible) { - CONSOLE_CURSOR_INFO cci; + CONSOLE_CURSOR_INFO cci; - cci.dwSize = bInsert ? 10 : 99; - cci.bVisible = bVisible; + cci.dwSize = bInsert ? 10 : 99; + cci.bVisible = bVisible; - SetConsoleCursorInfo(StdOutput, &cci); + SetConsoleCursorInfo(StdOutput, &cci); } - VOID -CONSOLE_SetCursorXY(SHORT x, - SHORT y) +CONSOLE_SetCursorXY( + IN SHORT x, + IN SHORT y) { - COORD coPos; + COORD coPos; - coPos.X = x; - coPos.Y = y; - SetConsoleCursorPosition(StdOutput, coPos); + coPos.X = x; + coPos.Y = y; + SetConsoleCursorPosition(StdOutput, coPos); } VOID @@ -594,284 +589,321 @@ CONSOLE_ClearScreen(VOID) &Written); } - VOID -CONSOLE_SetStatusText(char* fmt, ...) +CONSOLE_SetStatusText( + IN LPCSTR fmt, ...) { - char Buffer[128]; - va_list ap; - COORD coPos; - ULONG Written; + CHAR Buffer[128]; + va_list ap; + COORD coPos; + ULONG Written; - va_start(ap, fmt); - vsprintf(Buffer, fmt, ap); - va_end(ap); + va_start(ap, fmt); + vsprintf(Buffer, fmt, ap); + va_end(ap); - coPos.X = 0; - coPos.Y = yScreen - 1; + coPos.X = 0; + coPos.Y = yScreen - 1; - FillConsoleOutputAttribute(StdOutput, - BACKGROUND_WHITE, - xScreen, - coPos, - &Written); + FillConsoleOutputAttribute( + StdOutput, + BACKGROUND_WHITE, + xScreen, + coPos, + &Written); - FillConsoleOutputCharacterA(StdOutput, - ' ', - xScreen, - coPos, - &Written); + FillConsoleOutputCharacterA( + StdOutput, + ' ', + xScreen, + coPos, + &Written); - WriteConsoleOutputCharacterA(StdOutput, - Buffer, - strlen(Buffer), - coPos, - &Written); + WriteConsoleOutputCharacterA( + StdOutput, + Buffer, + strlen(Buffer), + coPos, + &Written); } - 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; - ULONG Written; + COORD coPos; + ULONG Written; - for (coPos.Y = y; coPos.Y < y + row; coPos.Y++) - { - coPos.X = x; + for (coPos.Y = y; coPos.Y < y + row; coPos.Y++) + { + coPos.X = x; - FillConsoleOutputAttribute(StdOutput, - FOREGROUND_BLUE | BACKGROUND_WHITE, - col, - coPos, - &Written); - } + FillConsoleOutputAttribute( + StdOutput, + FOREGROUND_BLUE | BACKGROUND_WHITE, + col, + coPos, + &Written); + } } - 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; - ULONG Written; + COORD coPos; + ULONG Written; - for (coPos.Y = y; coPos.Y < y + row; coPos.Y++) - { - coPos.X = x; + for (coPos.Y = y; coPos.Y < y + row; coPos.Y++) + { + coPos.X = x; - FillConsoleOutputAttribute(StdOutput, - FOREGROUND_BLUE | BACKGROUND_WHITE, - col, - coPos, - &Written); - } + FillConsoleOutputAttribute( + StdOutput, + FOREGROUND_BLUE | BACKGROUND_WHITE, + col, + coPos, + &Written); + } } - VOID -CONSOLE_SetTextXY(SHORT x, SHORT y, PCHAR Text) +CONSOLE_SetTextXY( + IN SHORT x, + IN SHORT y, + IN LPCSTR Text) { - COORD coPos; - ULONG Written; + COORD coPos; + ULONG Written; - coPos.X = x; - coPos.Y = y; + coPos.X = x; + coPos.Y = y; - WriteConsoleOutputCharacterA(StdOutput, - Text, - strlen(Text), - coPos, - &Written); + WriteConsoleOutputCharacterA( + StdOutput, + Text, + strlen(Text), + coPos, + &Written); } - 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; - ULONG Length; - ULONG Written; + COORD coPos; + ULONG Length; + ULONG Written; - coPos.X = x; - coPos.Y = y; + coPos.X = x; + coPos.Y = y; - Length = wcslen(Text); - if (Length > (ULONG)len - 1) - { - Length = len - 1; - } + Length = wcslen(Text); + if (Length > (ULONG)len - 1) + Length = len - 1; - FillConsoleOutputAttribute(StdOutput, - BACKGROUND_WHITE, - len, - coPos, - &Written); + FillConsoleOutputAttribute( + StdOutput, + BACKGROUND_WHITE, + len, + coPos, + &Written); - WriteConsoleOutputCharacterW(StdOutput, - Text, - Length, - coPos, - &Written); + WriteConsoleOutputCharacterW( + StdOutput, + Text, + Length, + coPos, + &Written); - coPos.X += Length; - FillConsoleOutputCharacterA(StdOutput, - '_', - 1, - coPos, - &Written); + coPos.X += Length; + FillConsoleOutputCharacterA( + StdOutput, + '_', + 1, + coPos, + &Written); - if ((ULONG)len > Length + 1) - { - coPos.X++; - FillConsoleOutputCharacterA(StdOutput, - ' ', - len - Length - 1, - coPos, - &Written); - } + if ((ULONG)len > Length + 1) + { + coPos.X++; + FillConsoleOutputCharacterA( + StdOutput, + ' ', + len - Length - 1, + coPos, + &Written); + } } - VOID -CONSOLE_SetUnderlinedTextXY(SHORT x, SHORT y, PCHAR Text) +CONSOLE_SetUnderlinedTextXY( + IN SHORT x, + IN SHORT y, + IN LPCSTR Text) { - COORD coPos; - ULONG Length; - ULONG Written; + COORD coPos; + ULONG Length; + ULONG Written; - coPos.X = x; - coPos.Y = y; + coPos.X = x; + coPos.Y = y; - Length = strlen(Text); + Length = strlen(Text); - WriteConsoleOutputCharacterA(StdOutput, - Text, - Length, - coPos, - &Written); + WriteConsoleOutputCharacterA( + StdOutput, + Text, + Length, + coPos, + &Written); - coPos.Y++; - FillConsoleOutputCharacterA(StdOutput, - 0xCD, - Length, - coPos, - &Written); + coPos.Y++; + FillConsoleOutputCharacterA( + StdOutput, + 0xCD, + Length, + coPos, + &Written); } - VOID -CONSOLE_SetInvertedTextXY(SHORT x, SHORT y, PCHAR Text) +CONSOLE_SetInvertedTextXY( + IN SHORT x, + IN SHORT y, + IN LPCSTR Text) { - COORD coPos; - ULONG Length; - ULONG Written; + COORD coPos; + ULONG Length; + ULONG Written; - coPos.X = x; - coPos.Y = y; + coPos.X = x; + coPos.Y = y; - Length = strlen(Text); + Length = strlen(Text); - FillConsoleOutputAttribute(StdOutput, - FOREGROUND_BLUE | BACKGROUND_WHITE, - Length, - coPos, - &Written); + FillConsoleOutputAttribute( + StdOutput, + FOREGROUND_BLUE | BACKGROUND_WHITE, + Length, + coPos, + &Written); - WriteConsoleOutputCharacterA(StdOutput, - Text, - Length, - coPos, - &Written); + WriteConsoleOutputCharacterA( + StdOutput, + Text, + Length, + coPos, + &Written); } - VOID -CONSOLE_SetHighlightedTextXY(SHORT x, SHORT y, PCHAR Text) +CONSOLE_SetHighlightedTextXY( + IN SHORT x, + IN SHORT y, + IN LPCSTR Text) { - COORD coPos; - ULONG Length; - ULONG Written; + COORD coPos; + ULONG Length; + ULONG Written; - coPos.X = x; - coPos.Y = y; + coPos.X = x; + coPos.Y = y; - Length = strlen(Text); + Length = strlen(Text); - FillConsoleOutputAttribute(StdOutput, - FOREGROUND_WHITE | FOREGROUND_INTENSITY | BACKGROUND_BLUE, - Length, - coPos, - &Written); + FillConsoleOutputAttribute( + StdOutput, + FOREGROUND_WHITE | FOREGROUND_INTENSITY | BACKGROUND_BLUE, + Length, + coPos, + &Written); - WriteConsoleOutputCharacterA(StdOutput, - Text, - Length, - coPos, - &Written); + WriteConsoleOutputCharacterA( + StdOutput, + Text, + Length, + coPos, + &Written); } - VOID -CONSOLE_PrintTextXY(SHORT x, SHORT y, char* fmt, ...) +CONSOLE_PrintTextXY( + IN SHORT x, + IN SHORT y, + IN LPCSTR fmt, ...) { - char buffer[512]; - va_list ap; - COORD coPos; - ULONG Written; + CHAR buffer[512]; + va_list ap; + COORD coPos; + ULONG Written; - va_start(ap, fmt); - vsprintf(buffer, fmt, ap); - va_end(ap); + va_start(ap, fmt); + vsprintf(buffer, fmt, ap); + va_end(ap); - coPos.X = x; - coPos.Y = y; + coPos.X = x; + coPos.Y = y; - WriteConsoleOutputCharacterA(StdOutput, - buffer, - strlen(buffer), - coPos, - &Written); + WriteConsoleOutputCharacterA( + StdOutput, + buffer, + strlen(buffer), + coPos, + &Written); } - 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]; - va_list ap; - COORD coPos; - ULONG Length; - ULONG Written; + CHAR buffer[512]; + va_list ap; + COORD coPos; + ULONG Length; + ULONG Written; - va_start(ap, fmt); - vsprintf(buffer, fmt, ap); - va_end(ap); + va_start(ap, fmt); + vsprintf(buffer, fmt, ap); + va_end(ap); - coPos.X = x; - coPos.Y = y; + coPos.X = x; + coPos.Y = y; - Length = strlen(buffer); - if (Length > (ULONG)len - 1) - { - Length = len - 1; - } + Length = strlen(buffer); + if (Length > (ULONG)len - 1) + Length = len - 1; - WriteConsoleOutputCharacterA(StdOutput, - buffer, - Length, - coPos, - &Written); + WriteConsoleOutputCharacterA( + StdOutput, + buffer, + Length, + coPos, + &Written); - coPos.X += Length; + coPos.X += Length; - if ((ULONG)len > Length) - { - FillConsoleOutputCharacterA(StdOutput, - ' ', - len - Length, - coPos, - &Written); - } + if ((ULONG)len > Length) + { + FillConsoleOutputCharacterA( + StdOutput, + ' ', + len - Length, + coPos, + &Written); + } } /* EOF */ diff --git a/reactos/base/setup/usetup/console.h b/reactos/base/setup/usetup/console.h index 477b5a8a140..121e772ff0a 100644 --- a/reactos/base/setup/usetup/console.h +++ b/reactos/base/setup/usetup/console.h @@ -48,6 +48,8 @@ #define FOREGROUND_YELLOW (FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN) #define BACKGROUND_WHITE (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE) +extern HANDLE StdInput, StdOutput; + BOOL WINAPI ConAllocConsole( IN DWORD dwProcessId); @@ -123,18 +125,24 @@ ConWriteConsoleOutputCharacterA( OUT LPDWORD lpNumberOfCharsWritten); +VOID +CONSOLE_ClearScreen(VOID); VOID -CONSOLE_ConInKey(PINPUT_RECORD Buffer); +CONSOLE_ConInKey( + OUT PINPUT_RECORD Buffer); VOID -CONSOLE_ConOutChar(CHAR c); +CONSOLE_ConOutChar( + IN CHAR c); VOID -CONSOLE_ConOutPuts(LPSTR szText); +CONSOLE_ConOutPrintf( + IN LPCSTR szFormat, ...); VOID -CONSOLE_ConOutPrintf(LPSTR szFormat, ...); +CONSOLE_ConOutPuts( + IN LPCSTR szText); SHORT CONSOLE_GetCursorX(VOID); @@ -143,49 +151,93 @@ SHORT CONSOLE_GetCursorY(VOID); VOID -CONSOLE_GetScreenSize(SHORT *maxx, - SHORT *maxy); +CONSOLE_GetScreenSize( + OUT SHORT *maxx, + OUT SHORT *maxy); VOID -CONSOLE_SetCursorType(BOOL bInsert, - BOOL bVisible); +CONSOLE_InvertTextXY( + IN SHORT x, + IN SHORT y, + IN SHORT col, + IN SHORT row); VOID -CONSOLE_SetCursorXY(SHORT x, - SHORT y); +CONSOLE_NormalTextXY( + IN SHORT x, + IN SHORT y, + IN SHORT col, + IN SHORT row); VOID -CONSOLE_ClearScreen(VOID); +CONSOLE_PrintTextXY( + IN SHORT x, + IN SHORT y, + IN LPCSTR fmt, ...); VOID -CONSOLE_SetStatusText(char* fmt, ...); +CONSOLE_PrintTextXYN( + IN SHORT x, + IN SHORT y, + IN SHORT len, + IN LPCSTR fmt, ...); VOID -CONSOLE_InvertTextXY(SHORT x, SHORT y, SHORT col, SHORT row); +CONSOLE_SetCursorType( + IN BOOL bInsert, + IN BOOL bVisible); VOID -CONSOLE_NormalTextXY(SHORT x, SHORT y, SHORT col, SHORT row); +CONSOLE_SetCursorXY( + IN SHORT x, + IN SHORT y); VOID -CONSOLE_SetTextXY(SHORT x, SHORT y, PCHAR Text); +CONSOLE_SetCursorXY( + IN SHORT x, + IN SHORT y); VOID -CONSOLE_SetInputTextXY(SHORT x, SHORT y, SHORT len, PWCHAR Text); +CONSOLE_SetHighlightedTextXY( + IN SHORT x, + IN SHORT y, + IN LPCSTR Text); VOID -CONSOLE_SetUnderlinedTextXY(SHORT x, SHORT y, PCHAR Text); +CONSOLE_SetInputTextXY( + IN SHORT x, + IN SHORT y, + IN SHORT len, + IN LPCWSTR Text); VOID -CONSOLE_SetInvertedTextXY(SHORT x, SHORT y, PCHAR Text); +CONSOLE_SetInputTextXY( + IN SHORT x, + IN SHORT y, + IN SHORT len, + IN LPCWSTR Text); VOID -CONSOLE_SetHighlightedTextXY(SHORT x, SHORT y, PCHAR Text); +CONSOLE_SetInvertedTextXY( + IN SHORT x, + IN SHORT y, + IN LPCSTR Text); VOID -CONSOLE_PrintTextXY(SHORT x, SHORT y, char* fmt, ...); +CONSOLE_SetStatusText( + IN LPCSTR fmt, ...); 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__*/ diff --git a/reactos/base/setup/usetup/drivesup.c b/reactos/base/setup/usetup/drivesup.c index 36988512d43..53fefc23735 100644 --- a/reactos/base/setup/usetup/drivesup.c +++ b/reactos/base/setup/usetup/drivesup.c @@ -26,7 +26,7 @@ /* INCLUDES *****************************************************************/ -#include +#include "usetup.h" #define NDEBUG #include diff --git a/reactos/base/setup/usetup/filequeue.c b/reactos/base/setup/usetup/filequeue.c index a9477b54cb5..be5452d9acc 100644 --- a/reactos/base/setup/usetup/filequeue.c +++ b/reactos/base/setup/usetup/filequeue.c @@ -27,7 +27,7 @@ /* INCLUDES *****************************************************************/ -#include +#include "usetup.h" #define NDEBUG #include diff --git a/reactos/base/setup/usetup/filesup.c b/reactos/base/setup/usetup/filesup.c index 73a1319ae59..88e144fae75 100644 --- a/reactos/base/setup/usetup/filesup.c +++ b/reactos/base/setup/usetup/filesup.c @@ -27,7 +27,7 @@ /* INCLUDES *****************************************************************/ -#include +#include "usetup.h" #define NDEBUG #include diff --git a/reactos/base/setup/usetup/format.c b/reactos/base/setup/usetup/format.c index f908722c89c..690c3703271 100644 --- a/reactos/base/setup/usetup/format.c +++ b/reactos/base/setup/usetup/format.c @@ -26,7 +26,7 @@ /* INCLUDES *****************************************************************/ -#include +#include "usetup.h" #define NDEBUG #include diff --git a/reactos/base/setup/usetup/fslist.c b/reactos/base/setup/usetup/fslist.c index 5c85cd64ca5..684acee2a7d 100644 --- a/reactos/base/setup/usetup/fslist.c +++ b/reactos/base/setup/usetup/fslist.c @@ -25,7 +25,7 @@ * Casper S. Hornstrup (chorns@users.sourceforge.net) */ -#include +#include "usetup.h" #define NDEBUG #include diff --git a/reactos/base/setup/usetup/genlist.c b/reactos/base/setup/usetup/genlist.c index f00c84dd252..a1db0c20503 100644 --- a/reactos/base/setup/usetup/genlist.c +++ b/reactos/base/setup/usetup/genlist.c @@ -26,7 +26,7 @@ /* INCLUDES *****************************************************************/ -#include +#include "usetup.h" #define NDEBUG #include diff --git a/reactos/base/setup/usetup/inffile.c b/reactos/base/setup/usetup/inffile.c new file mode 100644 index 00000000000..9a898808943 --- /dev/null +++ b/reactos/base/setup/usetup/inffile.c @@ -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 + +#define NDEBUG +#include + +/* 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 */ diff --git a/reactos/base/setup/usetup/inffile.h b/reactos/base/setup/usetup/inffile.h new file mode 100644 index 00000000000..ae2f8abd203 --- /dev/null +++ b/reactos/base/setup/usetup/inffile.h @@ -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 + +#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 */ diff --git a/reactos/base/setup/usetup/inicache.c b/reactos/base/setup/usetup/inicache.c index 255a585b672..2eb6bc1b462 100644 --- a/reactos/base/setup/usetup/inicache.c +++ b/reactos/base/setup/usetup/inicache.c @@ -27,7 +27,7 @@ /* INCLUDES *****************************************************************/ -#include +#include "usetup.h" #define NDEBUG #include diff --git a/reactos/base/setup/usetup/keytrans.c b/reactos/base/setup/usetup/keytrans.c index e8c81e29d6c..1748b232973 100644 --- a/reactos/base/setup/usetup/keytrans.c +++ b/reactos/base/setup/usetup/keytrans.c @@ -25,7 +25,7 @@ * * NB: Hardcoded to US keyboard */ -#include +#include "usetup.h" #define NDEBUG #include diff --git a/reactos/base/setup/usetup/partlist.c b/reactos/base/setup/usetup/partlist.c index ca43bccc6a1..8a14cb97b3a 100644 --- a/reactos/base/setup/usetup/partlist.c +++ b/reactos/base/setup/usetup/partlist.c @@ -25,7 +25,7 @@ * Casper S. Hornstrup (chorns@users.sourceforge.net) */ -#include +#include "usetup.h" #define NDEBUG #include @@ -1237,7 +1237,7 @@ PrintDiskData (PPARTLIST List, ULONG Written; USHORT Width; USHORT Height; - ULONGLONG DiskSize; + ULARGE_INTEGER DiskSize; PCHAR Unit; Width = List->Right - List->Left - 1; @@ -1250,35 +1250,35 @@ PrintDiskData (PPARTLIST List, #if 0 if (DiskEntry->DiskSize >= 0x280000000ULL) /* 10 GB */ { - DiskSize = (DiskEntry->DiskSize + (1 << 29)) >> 30; + DiskSize.QuadPart = (DiskEntry->DiskSize + (1 << 29)) >> 30; Unit = "GB"; } else #endif { - DiskSize = (DiskEntry->DiskSize + (1 << 19)) >> 20; - if (DiskSize == 0) - DiskSize = 1; + DiskSize.QuadPart = (DiskEntry->DiskSize + (1 << 19)) >> 20; + if (DiskSize.QuadPart == 0) + DiskSize.QuadPart = 1; Unit = "MB"; } if (DiskEntry->DriverName.Length > 0) { sprintf (LineBuffer, - "%6I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ", - DiskSize, + "%6lu %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %S", + DiskSize.u.LowPart, Unit, DiskEntry->DiskNumber, DiskEntry->Port, DiskEntry->Bus, DiskEntry->Id, - &DiskEntry->DriverName); + DiskEntry->DriverName.Buffer); } else { sprintf (LineBuffer, - "%6I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu)", - DiskSize, + "%6lu %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu)", + DiskSize.u.LowPart, Unit, DiskEntry->DiskNumber, DiskEntry->Port, diff --git a/reactos/base/setup/usetup/progress.c b/reactos/base/setup/usetup/progress.c index 34308bb72d1..9f70a4dc7d6 100644 --- a/reactos/base/setup/usetup/progress.c +++ b/reactos/base/setup/usetup/progress.c @@ -1,7 +1,7 @@ /* INCLUDES *****************************************************************/ -#include +#include "usetup.h" #define NDEBUG #include diff --git a/reactos/base/setup/usetup/registry.c b/reactos/base/setup/usetup/registry.c index bc57607a38f..e4a5d2cdf9a 100644 --- a/reactos/base/setup/usetup/registry.c +++ b/reactos/base/setup/usetup/registry.c @@ -26,7 +26,7 @@ /* INCLUDES *****************************************************************/ -#include +#include "usetup.h" #define NDEBUG #include @@ -257,13 +257,13 @@ do_reg_operation(HANDLE KeyHandle, } if (!(Flags & FLG_ADDREG_BINVALUETYPE) || - (Type == REG_DWORD && InfGetFieldCount (Context) == 5)) + (Type == REG_DWORD && SetupGetFieldCount (Context) == 5)) { PWCHAR Str = NULL; if (Type == REG_MULTI_SZ) { - if (!InfGetMultiSzField (Context, 5, NULL, 0, &Size)) + if (!SetupGetMultiSzFieldW (Context, 5, NULL, 0, &Size)) Size = 0; if (Size) @@ -272,7 +272,7 @@ do_reg_operation(HANDLE KeyHandle, if (Str == NULL) return FALSE; - InfGetMultiSzField (Context, 5, Str, Size, NULL); + SetupGetMultiSzFieldW (Context, 5, Str, Size, NULL); } if (Flags & FLG_ADDREG_APPEND) @@ -289,7 +289,7 @@ do_reg_operation(HANDLE KeyHandle, } else { - if (!InfGetStringField (Context, 5, NULL, 0, &Size)) + if (!SetupGetStringFieldW (Context, 5, NULL, 0, &Size)) Size = 0; if (Size) @@ -298,7 +298,7 @@ do_reg_operation(HANDLE KeyHandle, if (Str == NULL) 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; - if (!InfGetBinaryField (Context, 5, NULL, 0, &Size)) + if (!SetupGetBinaryField (Context, 5, NULL, 0, &Size)) Size = 0; if (Size) @@ -354,7 +354,7 @@ do_reg_operation(HANDLE KeyHandle, return FALSE; DPRINT("setting binary data %wZ len %lu\n", ValueName, Size); - InfGetBinaryField (Context, 5, Data, Size, NULL); + SetupGetBinaryField (Context, 5, Data, Size, NULL); } NtSetValueKey (KeyHandle, @@ -481,35 +481,35 @@ registry_callback (HINF hInf, PCWSTR Section, BOOLEAN Delete) UNICODE_STRING Value; PUNICODE_STRING ValuePtr; NTSTATUS Status; - ULONG Flags; + UINT Flags; ULONG Length; - PINFCONTEXT Context; + INFCONTEXT Context; HANDLE KeyHandle; BOOLEAN Ok; - Ok = InfFindFirstLine (hInf, Section, NULL, &Context); + Ok = SetupFindFirstLineW (hInf, Section, NULL, &Context); if (Ok) { - for (;Ok; Ok = InfFindNextLine (Context, Context)) + for (;Ok; Ok = SetupFindNextLine (&Context, &Context)) { /* get root */ - if (!InfGetStringField (Context, 1, Buffer, MAX_INF_STRING_LENGTH, NULL)) + if (!SetupGetStringFieldW (&Context, 1, Buffer, MAX_INF_STRING_LENGTH, NULL)) continue; if (!GetRootKey (Buffer)) continue; /* get key */ 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; DPRINT("KeyName: <%S>\n", Buffer); /* get flags */ - if (!InfGetIntField (Context, 4, (PLONG)&Flags)) + if (!SetupGetIntField (&Context, 4, (PINT)&Flags)) Flags = 0; DPRINT("Flags: %lx\n", Flags); @@ -547,7 +547,7 @@ registry_callback (HINF hInf, PCWSTR Section, BOOLEAN Delete) } /* 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, Buffer); @@ -559,7 +559,7 @@ registry_callback (HINF hInf, PCWSTR Section, BOOLEAN Delete) } /* and now do it */ - if (!do_reg_operation (KeyHandle, ValuePtr, Context, Flags)) + if (!do_reg_operation (KeyHandle, ValuePtr, &Context, Flags)) { NtClose (KeyHandle); return FALSE; @@ -567,7 +567,6 @@ registry_callback (HINF hInf, PCWSTR Section, BOOLEAN Delete) NtClose (KeyHandle); } - InfFreeContext(Context); } return TRUE; @@ -580,25 +579,22 @@ ImportRegistryFile(PWSTR Filename, BOOLEAN Delete) { WCHAR FileNameBuffer[MAX_PATH]; - UNICODE_STRING FileName; HINF hInf; - NTSTATUS Status; - ULONG ErrorLine; + UINT ErrorLine; /* Load inf file from install media. */ wcscpy(FileNameBuffer, SourceRootPath.Buffer); wcscat(FileNameBuffer, L"\\reactos\\"); wcscat(FileNameBuffer, Filename); - RtlInitUnicodeString(&FileName, - FileNameBuffer); - - Status = InfOpenFile(&hInf, - &FileName, + hInf = SetupOpenInfFileW( + FileNameBuffer, + NULL, + INF_STYLE_WIN4, &ErrorLine); - if (!NT_SUCCESS(Status)) + if (hInf == INVALID_HANDLE_VALUE) { - DPRINT1("InfOpenFile() failed (Status %lx)\n", Status); + DPRINT1("SetupOpenInfFile() failed\n"); return FALSE; } @@ -607,7 +603,7 @@ ImportRegistryFile(PWSTR Filename, DPRINT1("registry_callback() failed\n"); } - InfCloseFile (hInf); + SetupCloseInfFile (hInf); return TRUE; } diff --git a/reactos/base/setup/usetup/settings.c b/reactos/base/setup/usetup/settings.c index c28882f29b3..51bb2e79ecb 100644 --- a/reactos/base/setup/usetup/settings.c +++ b/reactos/base/setup/usetup/settings.c @@ -25,7 +25,7 @@ /* INCLUDES *****************************************************************/ -#include +#include "usetup.h" #define NDEBUG #include @@ -121,7 +121,7 @@ CreateComputerTypeList(HINF InfFile) { CHAR Buffer[128]; PGENERIC_LIST List; - PINFCONTEXT Context; + INFCONTEXT Context; PWCHAR KeyName; PWCHAR KeyValue; PWCHAR UserData; @@ -137,7 +137,7 @@ CreateComputerTypeList(HINF InfFile) DPRINT("Computer identifier: '%S'\n", ComputerIdentifier); /* Search for matching device identifier */ - if (!InfFindFirstLine(InfFile, L"Map.Computer", NULL, &Context)) + if (!SetupFindFirstLineW(InfFile, L"Map.Computer", NULL, &Context)) { /* FIXME: error message */ return NULL; @@ -145,20 +145,20 @@ CreateComputerTypeList(HINF InfFile) do { - if (!InfGetDataField(Context, 1, &KeyValue)) + if (!INF_GetDataField(&Context, 1, &KeyValue)) { /* FIXME: Handle error! */ - DPRINT("InfGetDataField() failed\n"); + DPRINT("INF_GetDataField() failed\n"); return NULL; } DPRINT("KeyValue: %S\n", KeyValue); if (wcsstr(ComputerIdentifier, KeyValue)) { - if (!InfGetDataField(Context, 0, &KeyName)) + if (!INF_GetDataField(&Context, 0, &KeyName)) { /* FIXME: Handle error! */ - DPRINT("InfGetDataField() failed\n"); + DPRINT("INF_GetDataField() failed\n"); return NULL; } @@ -166,14 +166,13 @@ CreateComputerTypeList(HINF InfFile) wcscpy(ComputerKey, KeyName); } } - while (InfFindNextLine(Context, Context)); - InfFreeContext(Context); + while (SetupFindNextLine(&Context, &Context)); List = CreateGenericList(); if (List == NULL) return NULL; - if (!InfFindFirstLine (InfFile, L"Computer", NULL, &Context)) + if (!SetupFindFirstLineW (InfFile, L"Computer", NULL, &Context)) { DestroyGenericList(List, FALSE); return NULL; @@ -181,10 +180,10 @@ CreateComputerTypeList(HINF InfFile) do { - if (!InfGetData (Context, &KeyName, &KeyValue)) + if (!INF_GetData (&Context, &KeyName, &KeyValue)) { /* FIXME: Handle error! */ - DPRINT("InfGetData() failed\n"); + DPRINT("INF_GetData() failed\n"); break; } @@ -202,8 +201,7 @@ CreateComputerTypeList(HINF InfFile) AppendGenericListEntry(List, Buffer, UserData, _wcsicmp(KeyName, ComputerKey) ? FALSE : TRUE); } - while (InfFindNextLine(Context, Context)); - InfFreeContext(Context); + while (SetupFindNextLine(&Context, &Context)); return List; } @@ -373,7 +371,7 @@ CreateDisplayDriverList(HINF InfFile) { CHAR Buffer[128]; PGENERIC_LIST List; - PINFCONTEXT Context; + INFCONTEXT Context; PWCHAR KeyName; PWCHAR KeyValue; PWCHAR UserData; @@ -389,7 +387,7 @@ CreateDisplayDriverList(HINF InfFile) DPRINT("Display identifier: '%S'\n", DisplayIdentifier); /* Search for matching device identifier */ - if (!InfFindFirstLine(InfFile, L"Map.Display", NULL, &Context)) + if (!SetupFindFirstLineW(InfFile, L"Map.Display", NULL, &Context)) { /* FIXME: error message */ return NULL; @@ -397,20 +395,20 @@ CreateDisplayDriverList(HINF InfFile) do { - if (!InfGetDataField(Context, 1, &KeyValue)) + if (!INF_GetDataField(&Context, 1, &KeyValue)) { /* FIXME: Handle error! */ - DPRINT("InfGetDataField() failed\n"); + DPRINT("INF_GetDataField() failed\n"); return NULL; } DPRINT("KeyValue: %S\n", KeyValue); if (wcsstr(DisplayIdentifier, KeyValue)) { - if (!InfGetDataField(Context, 0, &KeyName)) + if (!INF_GetDataField(&Context, 0, &KeyName)) { /* FIXME: Handle error! */ - DPRINT("InfGetDataField() failed\n"); + DPRINT("INF_GetDataField() failed\n"); return NULL; } @@ -418,15 +416,14 @@ CreateDisplayDriverList(HINF InfFile) wcscpy(DisplayKey, KeyName); } } - while (InfFindNextLine(Context, Context)); - InfFreeContext(Context); + while (SetupFindNextLine(&Context, &Context)); List = CreateGenericList(); if (List == NULL) return NULL; - if (!InfFindFirstLine (InfFile, L"Display", NULL, &Context)) + if (!SetupFindFirstLineW (InfFile, L"Display", NULL, &Context)) { DestroyGenericList(List, FALSE); return NULL; @@ -434,15 +431,15 @@ CreateDisplayDriverList(HINF InfFile) do { - if (!InfGetDataField(Context, 0, &KeyName)) + if (!INF_GetDataField(&Context, 0, &KeyName)) { - DPRINT1("InfGetDataField() failed\n"); + DPRINT1("INF_GetDataField() failed\n"); break; } - if (!InfGetDataField(Context, 1, &KeyValue)) + if (!INF_GetDataField(&Context, 1, &KeyValue)) { - DPRINT1("InfGetDataField() failed\n"); + DPRINT1("INF_GetDataField() failed\n"); break; } @@ -464,8 +461,7 @@ CreateDisplayDriverList(HINF InfFile) UserData, _wcsicmp(KeyName, DisplayKey) ? FALSE : TRUE); } - while (InfFindNextLine(Context, Context)); - InfFreeContext(Context); + while (SetupFindNextLine(&Context, &Context)); #if 0 AppendGenericListEntry(List, "Other display driver", NULL, TRUE); @@ -501,7 +497,7 @@ BOOLEAN ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List) { PGENERIC_LIST_ENTRY Entry; - PINFCONTEXT Context; + INFCONTEXT Context; PWCHAR ServiceName; ULONG StartValue; NTSTATUS Status; @@ -518,16 +514,16 @@ ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List) 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; } /* 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; } @@ -551,9 +547,9 @@ ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List) /* Set the resolution */ 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; } 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; } Hight = wcstoul(Buffer, 0, 0); @@ -588,9 +584,9 @@ ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List) return FALSE; } - if (!InfGetDataField(Context, 6, &Buffer)) + if (!INF_GetDataField(&Context, 6, &Buffer)) { - DPRINT("InfGetDataField() failed\n"); + DPRINT("INF_GetDataField() failed\n"); return FALSE; } Bpp = wcstoul(Buffer, 0, 0); @@ -606,8 +602,6 @@ ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List) return FALSE; } - InfFreeContext(Context); - DPRINT("ProcessDisplayRegistry() done\n"); return TRUE; @@ -619,7 +613,7 @@ CreateKeyboardDriverList(HINF InfFile) { CHAR Buffer[128]; PGENERIC_LIST List; - PINFCONTEXT Context; + INFCONTEXT Context; PWCHAR KeyName; PWCHAR KeyValue; PWCHAR UserData; @@ -628,7 +622,7 @@ CreateKeyboardDriverList(HINF InfFile) if (List == NULL) return NULL; - if (!InfFindFirstLine (InfFile, L"Keyboard", NULL, &Context)) + if (!SetupFindFirstLineW (InfFile, L"Keyboard", NULL, &Context)) { DestroyGenericList(List, FALSE); return NULL; @@ -636,10 +630,10 @@ CreateKeyboardDriverList(HINF InfFile) do { - if (!InfGetData (Context, &KeyName, &KeyValue)) + if (!INF_GetData (&Context, &KeyName, &KeyValue)) { /* FIXME: Handle error! */ - DPRINT("InfGetData() failed\n"); + DPRINT("INF_GetData() failed\n"); break; } @@ -656,8 +650,7 @@ CreateKeyboardDriverList(HINF InfFile) sprintf(Buffer, "%S", KeyValue); AppendGenericListEntry(List, Buffer, UserData, FALSE); } - while (InfFindNextLine(Context, Context)); - InfFreeContext(Context); + while (SetupFindNextLine(&Context, &Context)); return List; } @@ -668,42 +661,37 @@ CreateKeyboardLayoutList(HINF InfFile) { CHAR Buffer[128]; PGENERIC_LIST List; - PINFCONTEXT Context; + INFCONTEXT Context; PWCHAR KeyName; PWCHAR KeyValue; PWCHAR UserData; WCHAR DefaultLayout[20]; /* Get default layout id */ - if (!InfFindFirstLine (InfFile, L"NLS", L"DefaultLayout", &Context)) + if (!SetupFindFirstLineW (InfFile, L"NLS", L"DefaultLayout", &Context)) return NULL; - if (!InfGetData (Context, NULL, &KeyValue)) - { - InfFreeContext(Context); - return NULL; - } + if (!INF_GetData (&Context, NULL, &KeyValue)) + return NULL; wcscpy(DefaultLayout, KeyValue); - InfFreeContext(Context); List = CreateGenericList(); if (List == NULL) return NULL; - if (!InfFindFirstLine (InfFile, L"KeyboardLayout", NULL, &Context)) + if (!SetupFindFirstLineW (InfFile, L"KeyboardLayout", NULL, &Context)) { DestroyGenericList(List, FALSE); - InfFreeContext(Context); return NULL; } do { - if (!InfGetData (Context, &KeyName, &KeyValue)) + if (!INF_GetData (&Context, &KeyName, &KeyValue)) { /* FIXME: Handle error! */ - DPRINT("InfGetData() failed\n"); + DPRINT("INF_GetData() failed\n"); break; } @@ -723,8 +711,7 @@ CreateKeyboardLayoutList(HINF InfFile) UserData, _wcsicmp(KeyName, DefaultLayout) ? FALSE : TRUE); } - while (InfFindNextLine(Context, Context)); - InfFreeContext(Context); + while (SetupFindNextLine(&Context, &Context)); return List; } diff --git a/reactos/base/setup/usetup/usetup.c b/reactos/base/setup/usetup/usetup.c index f7ee27525a1..a986d2e8004 100644 --- a/reactos/base/setup/usetup/usetup.c +++ b/reactos/base/setup/usetup/usetup.c @@ -25,7 +25,7 @@ * Casper S. Hornstrup (chorns@users.sourceforge.net) */ -#include +#include "usetup.h" #define NDEBUG #include @@ -411,12 +411,10 @@ VOID CheckUnattendedSetup(VOID) { WCHAR UnattendInfPath[MAX_PATH]; - UNICODE_STRING FileName; - PINFCONTEXT Context; + INFCONTEXT Context; HINF UnattendInf; - ULONG ErrorLine; - NTSTATUS Status; - LONG IntValue; + UINT ErrorLine; + INT IntValue; PWCHAR Value; if (DoesFileExist(SourcePath.Buffer, L"unattend.inf") == FALSE) @@ -429,34 +427,30 @@ CheckUnattendedSetup(VOID) wcscpy(UnattendInfPath, SourcePath.Buffer); wcscat(UnattendInfPath, L"\\unattend.inf"); - RtlInitUnicodeString(&FileName, - UnattendInfPath); - /* Load 'unattend.inf' from install media. */ - Status = InfOpenFile(&UnattendInf, - &FileName, + UnattendInf = SetupOpenInfFileW(UnattendInfPath, + NULL, + INF_STYLE_WIN4, &ErrorLine); - if (!NT_SUCCESS(Status)) + if (UnattendInf == INVALID_HANDLE_VALUE) { - DPRINT("InfOpenFile() failed with status 0x%x\n", Status); + DPRINT("SetupOpenInfFileW() failed\n"); return; } /* 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"); - InfFreeContext(Context); - InfCloseFile(UnattendInf); + DPRINT("SetupFindFirstLineW() failed for section 'Unattend'\n"); + SetupCloseInfFile(&UnattendInf); return; } /* Get pointer 'Signature' key */ - if (!InfGetData(Context, NULL, &Value)) + if (!INF_GetData(&Context, NULL, &Value)) { - DPRINT("InfGetData() failed for key 'Signature'\n"); - InfFreeContext(Context); - InfCloseFile(UnattendInf); + DPRINT("INF_GetData() failed for key 'Signature'\n"); + SetupCloseInfFile(&UnattendInf); return; } @@ -464,88 +458,75 @@ CheckUnattendedSetup(VOID) if (_wcsicmp(Value, L"$ReactOS$") != 0) { DPRINT("Signature not $ReactOS$\n"); - InfFreeContext(Context); - InfCloseFile(UnattendInf); + SetupCloseInfFile(&UnattendInf); return; } /* 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"); - InfFreeContext(Context); - InfCloseFile(UnattendInf); + DPRINT("SetupFindFirstLine() failed for key 'DestinationDiskNumber'\n"); + SetupCloseInfFile(&UnattendInf); return; } - if (!InfGetIntField(Context, 0, &IntValue)) + if (!SetupGetIntField(&Context, 0, &IntValue)) { - DPRINT("InfGetIntField() failed for key 'DestinationDiskNumber'\n"); - InfFreeContext(Context); - InfCloseFile(UnattendInf); + DPRINT("SetupGetIntField() failed for key 'DestinationDiskNumber'\n"); + SetupCloseInfFile(&UnattendInf); return; } - UnattendDestinationDiskNumber = IntValue; - InfFreeContext(Context); + UnattendDestinationDiskNumber = (LONG)IntValue; /* 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"); - InfFreeContext(Context); - InfCloseFile(UnattendInf); + DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n"); + SetupCloseInfFile(UnattendInf); return; } - if (!InfGetIntField(Context, 0, &IntValue)) + if (!SetupGetIntField(&Context, 0, &IntValue)) { - DPRINT("InfGetIntField() failed for key 'DestinationPartitionNumber'\n"); - InfFreeContext(Context); - InfCloseFile(UnattendInf); + DPRINT("SetupGetIntField() failed for key 'DestinationPartitionNumber'\n"); + SetupCloseInfFile(UnattendInf); return; } UnattendDestinationPartitionNumber = IntValue; - InfFreeContext(Context); /* 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"); - InfCloseFile(UnattendInf); + DPRINT("SetupFindFirstLine() failed for key 'DestinationPartitionNumber'\n"); + SetupCloseInfFile(UnattendInf); return; } /* Get pointer 'InstallationDirectory' key */ - if (!InfGetData(Context, NULL, &Value)) + if (!INF_GetData(&Context, NULL, &Value)) { - DPRINT("InfGetData() failed for key 'InstallationDirectory'\n"); - InfFreeContext(Context); - InfCloseFile(UnattendInf); + DPRINT("INF_GetData() failed for key 'InstallationDirectory'\n"); + SetupCloseInfFile(UnattendInf); return; } wcscpy(UnattendInstallationDirectory, Value); - InfFreeContext(Context); - IsUnattendedSetup = TRUE; /* 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"); - InfFreeContext(Context); - InfCloseFile(UnattendInf); + DPRINT("SetupFindFirstLine() failed for key 'MBRInstallType'\n"); + SetupCloseInfFile(UnattendInf); return; } - if (!InfGetIntField(Context, 0, &IntValue)) + if (!SetupGetIntField(&Context, 0, &IntValue)) { - DPRINT("InfGetIntField() failed for key 'MBRInstallType'\n"); - InfFreeContext(Context); - InfCloseFile(UnattendInf); + DPRINT("SetupGetIntField() failed for key 'MBRInstallType'\n"); + SetupCloseInfFile(UnattendInf); return; } UnattendMBRInstallType = IntValue; - InfFreeContext(Context); - InfCloseFile(UnattendInf); + SetupCloseInfFile(UnattendInf); DPRINT("Running unattended setup\n"); } @@ -562,10 +543,9 @@ SetupStartPage(PINPUT_RECORD Ir) SYSTEM_DEVICE_INFORMATION Sdi; NTSTATUS Status; WCHAR FileNameBuffer[MAX_PATH]; - UNICODE_STRING FileName; - PINFCONTEXT Context; + INFCONTEXT Context; PWCHAR Value; - ULONG ErrorLine; + UINT ErrorLine; ULONG ReturnSize; CONSOLE_SetStatusText(" Please wait..."); @@ -636,13 +616,12 @@ SetupStartPage(PINPUT_RECORD Ir) /* Load txtsetup.sif from install media. */ wcscpy(FileNameBuffer, SourceRootPath.Buffer); wcscat(FileNameBuffer, L"\\reactos\\txtsetup.sif"); - RtlInitUnicodeString(&FileName, - FileNameBuffer); - Status = InfOpenFile(&SetupInf, - &FileName, + SetupInf = SetupOpenInfFileW(FileNameBuffer, + NULL, + INF_STYLE_WIN4, &ErrorLine); - if (!NT_SUCCESS(Status)) + if (SetupInf == INVALID_HANDLE_VALUE) { PopupError("Setup failed to load the file TXTSETUP.SIF.\n", "ENTER = Reboot computer"); @@ -659,7 +638,7 @@ SetupStartPage(PINPUT_RECORD Ir) } /* 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", "ENTER = Reboot computer"); @@ -677,9 +656,8 @@ SetupStartPage(PINPUT_RECORD Ir) /* 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", "ENTER = Reboot computer"); @@ -697,7 +675,6 @@ SetupStartPage(PINPUT_RECORD Ir) /* Check 'Signature' string */ if (_wcsicmp(Value, L"$ReactOS$") != 0) { - InfFreeContext(Context); PopupError("Setup found an invalid signature in TXTSETUP.SIF.\n", "ENTER = Reboot computer"); @@ -711,7 +688,6 @@ SetupStartPage(PINPUT_RECORD Ir) } } } - InfFreeContext(Context); CheckUnattendedSetup(); @@ -2605,7 +2581,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir) PPARTENTRY PartEntry; WCHAR InstallDir[51]; PWCHAR DefaultPath; - PINFCONTEXT Context; + INFCONTEXT Context; ULONG Length; if (PartitionList == NULL || @@ -2620,7 +2596,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir) PartEntry = PartitionList->CurrentPartition; /* 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" "in TXTSETUP.SIF.\n", @@ -2638,7 +2614,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir) } /* Read the 'DefaultPath' data */ - if (InfGetData (Context, NULL, &DefaultPath)) + if (INF_GetData (&Context, NULL, &DefaultPath)) { wcscpy(InstallDir, DefaultPath); } @@ -2646,7 +2622,6 @@ InstallDirectoryPage(PINPUT_RECORD Ir) { wcscpy(InstallDir, L"\\ReactOS"); } - InfFreeContext(Context); Length = wcslen(InstallDir); CONSOLE_SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a"); @@ -2711,15 +2686,15 @@ AddSectionToCopyQueue(HINF InfFile, PWCHAR SourceCabinet, PINPUT_RECORD Ir) { - PINFCONTEXT FilesContext; - PINFCONTEXT DirContext; + INFCONTEXT FilesContext; + INFCONTEXT DirContext; PWCHAR FileKeyName; PWCHAR FileKeyValue; PWCHAR DirKeyValue; PWCHAR TargetFileName; /* Search for the SectionName section */ - if (!InfFindFirstLine (InfFile, SectionName, NULL, &FilesContext)) + if (!SetupFindFirstLineW (InfFile, SectionName, NULL, &FilesContext)) { char Buffer[128]; sprintf(Buffer, "Setup failed to find the '%S' section\nin TXTSETUP.SIF.\n", SectionName); @@ -2743,32 +2718,31 @@ AddSectionToCopyQueue(HINF InfFile, do { /* Get source file name and target directory id */ - if (!InfGetData (FilesContext, &FileKeyName, &FileKeyValue)) + if (!INF_GetData (&FilesContext, &FileKeyName, &FileKeyValue)) { /* FIXME: Handle error! */ - DPRINT1("InfGetData() failed\n"); + DPRINT1("INF_GetData() failed\n"); break; } /* Get optional target file name */ - if (!InfGetDataField (FilesContext, 2, &TargetFileName)) + if (!INF_GetDataField (&FilesContext, 2, &TargetFileName)) TargetFileName = NULL; DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue); /* Lookup target directory */ - if (!InfFindFirstLine (InfFile, L"Directories", FileKeyValue, &DirContext)) + if (!SetupFindFirstLineW (InfFile, L"Directories", FileKeyValue, &DirContext)) { /* FIXME: Handle error! */ - DPRINT1("InfFindFirstLine() failed\n"); + DPRINT1("SetupFindFirstLine() failed\n"); break; } - if (!InfGetData (DirContext, NULL, &DirKeyValue)) + if (!INF_GetData (&DirContext, NULL, &DirKeyValue)) { /* FIXME: Handle error! */ - InfFreeContext(DirContext); - DPRINT1("InfGetData() failed\n"); + DPRINT1("INF_GetData() failed\n"); break; } @@ -2783,11 +2757,8 @@ AddSectionToCopyQueue(HINF InfFile, /* FIXME: Handle error! */ DPRINT1("SetupQueueCopy() failed\n"); } - InfFreeContext(DirContext); } - while (InfFindNextLine(FilesContext, FilesContext)); - - InfFreeContext(FilesContext); + while (SetupFindNextLine(&FilesContext, &FilesContext)); return TRUE; } @@ -2798,7 +2769,7 @@ PrepareCopyPageInfFile(HINF InfFile, PINPUT_RECORD Ir) { WCHAR PathBuffer[MAX_PATH]; - PINFCONTEXT DirContext; + INFCONTEXT DirContext; PWCHAR AdditionalSectionName = NULL; PWCHAR KeyValue; ULONG Length; @@ -2858,7 +2829,7 @@ PrepareCopyPageInfFile(HINF InfFile, /* Search for the 'Directories' section */ - if (!InfFindFirstLine(InfFile, L"Directories", NULL, &DirContext)) + if (!SetupFindFirstLineW(InfFile, L"Directories", NULL, &DirContext)) { if (SourceCabinet) { @@ -2885,7 +2856,7 @@ PrepareCopyPageInfFile(HINF InfFile, /* Enumerate the directory values and create the subdirectories */ do { - if (!InfGetData (DirContext, NULL, &KeyValue)) + if (!INF_GetData (&DirContext, NULL, &KeyValue)) { DPRINT1("break\n"); break; @@ -2928,9 +2899,7 @@ PrepareCopyPageInfFile(HINF InfFile, } } } - while (InfFindNextLine (DirContext, DirContext)); - - InfFreeContext(DirContext); + while (SetupFindNextLine (&DirContext, &DirContext)); return(TRUE); } @@ -2941,11 +2910,10 @@ PrepareCopyPage(PINPUT_RECORD Ir) { HINF InfHandle; WCHAR PathBuffer[MAX_PATH]; - PINFCONTEXT CabinetsContext; + INFCONTEXT CabinetsContext; ULONG InfFileSize; PWCHAR KeyValue; - NTSTATUS Status; - ULONG ErrorLine; + UINT ErrorLine; PVOID InfFileData; 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 */ - if (!InfFindFirstLine (SetupInf, L"Cabinets", NULL, &CabinetsContext)) + if (!SetupFindFirstLineW (SetupInf, L"Cabinets", NULL, &CabinetsContext)) { return FILE_COPY_PAGE; } @@ -2987,7 +2955,7 @@ PrepareCopyPage(PINPUT_RECORD Ir) */ do { - if (!InfGetData (CabinetsContext, NULL, &KeyValue)) + if (!INF_GetData (&CabinetsContext, NULL, &KeyValue)) break; wcscpy(PathBuffer, SourcePath.Buffer); @@ -3037,11 +3005,12 @@ PrepareCopyPage(PINPUT_RECORD Ir) } } - Status = InfOpenBufferedFile(&InfHandle, - InfFileData, + InfHandle = INF_OpenBufferedFileA(InfFileData, InfFileSize, + NULL, + INF_STYLE_WIN4, &ErrorLine); - if (!NT_SUCCESS(Status)) + if (InfHandle == INVALID_HANDLE_VALUE) { PopupError("Cabinet has no valid inf file.\n", "ENTER = Reboot computer"); @@ -3064,9 +3033,7 @@ PrepareCopyPage(PINPUT_RECORD Ir) return QUIT_PAGE; } } - while (InfFindNextLine (CabinetsContext, CabinetsContext)); - - InfFreeContext(CabinetsContext); + while (SetupFindNextLine (&CabinetsContext, &CabinetsContext)); return FILE_COPY_PAGE; } @@ -3144,7 +3111,7 @@ FileCopyPage(PINPUT_RECORD Ir) static PAGE_NUMBER RegistryPage(PINPUT_RECORD Ir) { - PINFCONTEXT InfContext; + INFCONTEXT InfContext; PWSTR Action; PWSTR File; PWSTR Section; @@ -3194,9 +3161,9 @@ RegistryPage(PINPUT_RECORD Ir) /* Update registry */ 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.", "ENTER = Reboot computer"); @@ -3213,9 +3180,9 @@ RegistryPage(PINPUT_RECORD Ir) do { - InfGetDataField (InfContext, 0, &Action); - InfGetDataField (InfContext, 1, &File); - InfGetDataField (InfContext, 2, &Section); + INF_GetDataField (&InfContext, 0, &Action); + INF_GetDataField (&InfContext, 1, &File); + INF_GetDataField (&InfContext, 2, &Section); DPRINT("Action: %S File: %S Section %S\n", Action, File, Section); @@ -3252,9 +3219,7 @@ RegistryPage(PINPUT_RECORD Ir) } } } - while (InfFindNextLine (InfContext, InfContext)); - - InfFreeContext(InfContext); + while (SetupFindNextLine (&InfContext, &InfContext)); /* Update display registry settings */ CONSOLE_SetStatusText(" Updating display registry settings..."); @@ -3714,7 +3679,7 @@ NtProcessStartup(PPEB Peb) RtlNormalizeProcessParams(Peb->ProcessParameters); ProcessHeap = Peb->ProcessHeap; - InfSetHeap(ProcessHeap); + INF_SetHeap(ProcessHeap); SignalInitEvent(); diff --git a/reactos/base/setup/usetup/usetup.h b/reactos/base/setup/usetup/usetup.h index 006f43eb99f..78380ae42b2 100644 --- a/reactos/base/setup/usetup/usetup.h +++ b/reactos/base/setup/usetup/usetup.h @@ -54,11 +54,10 @@ /* ReactOS Version */ #include -#include - /* Internal Headers */ #include "console.h" #include "partlist.h" +#include "inffile.h" #include "inicache.h" #include "filequeue.h" #include "progress.h" diff --git a/reactos/base/setup/usetup/usetup.rbuild b/reactos/base/setup/usetup/usetup.rbuild index 0e7c024611c..1e6a405ef7c 100644 --- a/reactos/base/setup/usetup/usetup.rbuild +++ b/reactos/base/setup/usetup/usetup.rbuild @@ -1,4 +1,4 @@ - + . . @@ -13,7 +13,7 @@ inflib vfatlib ntdll - usetup.h + bootsup.c cabinet.c @@ -24,6 +24,7 @@ format.c fslist.c genlist.c + inffile.c inicache.c keytrans.c partlist.c