Use inflib

svn path=/trunk/; revision=19517
This commit is contained in:
Gé van Geldorp 2005-11-24 08:12:20 +00:00
parent 1c781d1933
commit 5976ea377e
7 changed files with 158 additions and 1875 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,136 +0,0 @@
/*
* ReactOS kernel
* Copyright (C) 2002, 2003 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.
*/
/* $Id$
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup
* FILE: subsys/system/usetup/infcache.h
* PURPOSE: INF file parser that caches contents of INF file in memory
* PROGRAMMER: Royce Mitchell III
* Eric Kohl
*/
#ifndef __INFCACHE_H__
#define __INFCACHE_H__
#define STATUS_BAD_SECTION_NAME_LINE (0xC0700001)
#define STATUS_SECTION_NAME_TOO_LONG (0xC0700002)
#define STATUS_WRONG_INF_STYLE (0xC0700003)
#define STATUS_NOT_ENOUGH_MEMORY (0xC0700004)
#define MAX_INF_STRING_LENGTH 512
typedef PVOID HINF, *PHINF;
typedef struct _INFCONTEXT
{
PVOID Inf;
// PVOID CurrentInf;
PVOID Section;
PVOID Line;
} INFCONTEXT, *PINFCONTEXT;
/* FUNCTIONS ****************************************************************/
NTSTATUS
InfOpenBufferedFile(PHINF InfHandle,
PVOID Buffer,
ULONG BufferSize,
PULONG ErrorLine);
NTSTATUS
InfOpenFile (PHINF InfHandle,
PUNICODE_STRING FileName,
PULONG ErrorLine);
VOID
InfCloseFile (HINF InfHandle);
BOOLEAN
InfFindFirstLine (HINF InfHandle,
PCWSTR Section,
PCWSTR Key,
PINFCONTEXT Context);
BOOLEAN
InfFindNextLine (PINFCONTEXT ContextIn,
PINFCONTEXT ContextOut);
BOOLEAN
InfFindFirstMatchLine (PINFCONTEXT ContextIn,
PCWSTR Key,
PINFCONTEXT ContextOut);
BOOLEAN
InfFindNextMatchLine (PINFCONTEXT ContextIn,
PCWSTR Key,
PINFCONTEXT ContextOut);
LONG
InfGetLineCount (HINF InfHandle,
PCWSTR Section);
LONG
InfGetFieldCount (PINFCONTEXT Context);
BOOLEAN
InfGetBinaryField (PINFCONTEXT Context,
ULONG FieldIndex,
PUCHAR ReturnBuffer,
ULONG ReturnBufferSize,
PULONG RequiredSize);
BOOLEAN
InfGetIntField (PINFCONTEXT Context,
ULONG FieldIndex,
PLONG IntegerValue);
BOOLEAN
InfGetMultiSzField (PINFCONTEXT Context,
ULONG FieldIndex,
PWSTR ReturnBuffer,
ULONG ReturnBufferSize,
PULONG RequiredSize);
BOOLEAN
InfGetStringField (PINFCONTEXT Context,
ULONG FieldIndex,
PWSTR ReturnBuffer,
ULONG ReturnBufferSize,
PULONG RequiredSize);
BOOLEAN
InfGetData (PINFCONTEXT Context,
PWCHAR *Key,
PWCHAR *Data);
BOOLEAN
InfGetDataField (PINFCONTEXT Context,
ULONG FieldIndex,
PWCHAR *Data);
#endif /* __INFCACHE_H__ */
/* EOF */

View file

@ -484,86 +484,90 @@ registry_callback (HINF hInf, PCWSTR Section, BOOLEAN Delete)
ULONG Flags; ULONG Flags;
ULONG Length; ULONG Length;
INFCONTEXT Context; PINFCONTEXT Context;
HANDLE KeyHandle; HANDLE KeyHandle;
BOOLEAN Ok; BOOLEAN Ok;
Ok = InfFindFirstLine (hInf, Section, NULL, &Context); Ok = InfFindFirstLine (hInf, Section, NULL, &Context);
for (;Ok; Ok = InfFindNextLine (&Context, &Context)) if (Ok)
{ {
/* get root */ for (;Ok; Ok = InfFindNextLine (Context, Context))
if (!InfGetStringField (&Context, 1, Buffer, MAX_INF_STRING_LENGTH, NULL)) {
continue; /* get root */
if (!GetRootKey (Buffer)) if (!InfGetStringField (Context, 1, Buffer, MAX_INF_STRING_LENGTH, NULL))
continue; continue;
if (!GetRootKey (Buffer))
continue;
/* get key */ /* get key */
Length = wcslen (Buffer); Length = wcslen (Buffer);
if (!InfGetStringField (&Context, 2, Buffer + Length, MAX_INF_STRING_LENGTH - Length, NULL)) if (!InfGetStringField (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 (!InfGetIntField (Context, 4, (PLONG)&Flags))
Flags = 0; Flags = 0;
DPRINT("Flags: %lx\n", Flags); DPRINT("Flags: %lx\n", Flags);
RtlInitUnicodeString (&Name, RtlInitUnicodeString (&Name,
Buffer); Buffer);
InitializeObjectAttributes (&ObjectAttributes, InitializeObjectAttributes (&ObjectAttributes,
&Name, &Name,
OBJ_CASE_INSENSITIVE, OBJ_CASE_INSENSITIVE,
NULL, NULL,
NULL); NULL);
if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY)) if (Delete || (Flags & FLG_ADDREG_OVERWRITEONLY))
{ {
Status = NtOpenKey (&KeyHandle, Status = NtOpenKey (&KeyHandle,
KEY_ALL_ACCESS, KEY_ALL_ACCESS,
&ObjectAttributes); &ObjectAttributes);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("NtOpenKey(%wZ) failed (Status %lx)\n", &Name, Status); DPRINT("NtOpenKey(%wZ) failed (Status %lx)\n", &Name, Status);
continue; /* ignore if it doesn't exist */ continue; /* ignore if it doesn't exist */
} }
} }
else else
{ {
Status = CreateNestedKey (&KeyHandle, Status = CreateNestedKey (&KeyHandle,
KEY_ALL_ACCESS, KEY_ALL_ACCESS,
&ObjectAttributes); &ObjectAttributes);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("CreateNestedKey(%wZ) failed (Status %lx)\n", &Name, Status); DPRINT("CreateNestedKey(%wZ) failed (Status %lx)\n", &Name, Status);
continue; continue;
} }
} }
/* get value name */ /* get value name */
if (InfGetStringField (&Context, 3, Buffer, MAX_INF_STRING_LENGTH, NULL)) if (InfGetStringField (Context, 3, Buffer, MAX_INF_STRING_LENGTH, NULL))
{ {
RtlInitUnicodeString (&Value, RtlInitUnicodeString (&Value,
Buffer); Buffer);
ValuePtr = &Value; ValuePtr = &Value;
} }
else else
{ {
ValuePtr = NULL; ValuePtr = NULL;
} }
/* 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;
} }
NtClose (KeyHandle); NtClose (KeyHandle);
}
InfFreeContext(Context);
} }
return TRUE; return TRUE;

View file

@ -121,7 +121,7 @@ CreateComputerTypeList(HINF InfFile)
{ {
CHAR Buffer[128]; CHAR Buffer[128];
PGENERIC_LIST List; PGENERIC_LIST List;
INFCONTEXT Context; PINFCONTEXT Context;
PWCHAR KeyName; PWCHAR KeyName;
PWCHAR KeyValue; PWCHAR KeyValue;
PWCHAR UserData; PWCHAR UserData;
@ -145,7 +145,7 @@ CreateComputerTypeList(HINF InfFile)
do do
{ {
if (!InfGetDataField(&Context, 1, &KeyValue)) if (!InfGetDataField(Context, 1, &KeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetDataField() failed\n"); DPRINT("InfGetDataField() failed\n");
@ -155,7 +155,7 @@ CreateComputerTypeList(HINF InfFile)
DPRINT("KeyValue: %S\n", KeyValue); DPRINT("KeyValue: %S\n", KeyValue);
if (wcsstr(ComputerIdentifier, KeyValue)) if (wcsstr(ComputerIdentifier, KeyValue))
{ {
if (!InfGetDataField(&Context, 0, &KeyName)) if (!InfGetDataField(Context, 0, &KeyName))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetDataField() failed\n"); DPRINT("InfGetDataField() failed\n");
@ -166,7 +166,8 @@ CreateComputerTypeList(HINF InfFile)
wcscpy(ComputerKey, KeyName); wcscpy(ComputerKey, KeyName);
} }
} }
while (InfFindNextLine(&Context, &Context)); while (InfFindNextLine(Context, Context));
InfFreeContext(Context);
List = CreateGenericList(); List = CreateGenericList();
if (List == NULL) if (List == NULL)
@ -180,7 +181,7 @@ CreateComputerTypeList(HINF InfFile)
do do
{ {
if (!InfGetData (&Context, &KeyName, &KeyValue)) if (!InfGetData (Context, &KeyName, &KeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetData() failed\n"); DPRINT("InfGetData() failed\n");
@ -201,7 +202,8 @@ 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 (InfFindNextLine(Context, Context));
InfFreeContext(Context);
return List; return List;
} }
@ -371,7 +373,7 @@ CreateDisplayDriverList(HINF InfFile)
{ {
CHAR Buffer[128]; CHAR Buffer[128];
PGENERIC_LIST List; PGENERIC_LIST List;
INFCONTEXT Context; PINFCONTEXT Context;
PWCHAR KeyName; PWCHAR KeyName;
PWCHAR KeyValue; PWCHAR KeyValue;
PWCHAR UserData; PWCHAR UserData;
@ -395,7 +397,7 @@ CreateDisplayDriverList(HINF InfFile)
do do
{ {
if (!InfGetDataField(&Context, 1, &KeyValue)) if (!InfGetDataField(Context, 1, &KeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetDataField() failed\n"); DPRINT("InfGetDataField() failed\n");
@ -405,7 +407,7 @@ CreateDisplayDriverList(HINF InfFile)
DPRINT("KeyValue: %S\n", KeyValue); DPRINT("KeyValue: %S\n", KeyValue);
if (wcsstr(DisplayIdentifier, KeyValue)) if (wcsstr(DisplayIdentifier, KeyValue))
{ {
if (!InfGetDataField(&Context, 0, &KeyName)) if (!InfGetDataField(Context, 0, &KeyName))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetDataField() failed\n"); DPRINT("InfGetDataField() failed\n");
@ -416,7 +418,8 @@ CreateDisplayDriverList(HINF InfFile)
wcscpy(DisplayKey, KeyName); wcscpy(DisplayKey, KeyName);
} }
} }
while (InfFindNextLine(&Context, &Context)); while (InfFindNextLine(Context, Context));
InfFreeContext(Context);
List = CreateGenericList(); List = CreateGenericList();
@ -431,13 +434,13 @@ CreateDisplayDriverList(HINF InfFile)
do do
{ {
if (!InfGetDataField(&Context, 0, &KeyName)) if (!InfGetDataField(Context, 0, &KeyName))
{ {
DPRINT1("InfGetDataField() failed\n"); DPRINT1("InfGetDataField() failed\n");
break; break;
} }
if (!InfGetDataField(&Context, 1, &KeyValue)) if (!InfGetDataField(Context, 1, &KeyValue))
{ {
DPRINT1("InfGetDataField() failed\n"); DPRINT1("InfGetDataField() failed\n");
break; break;
@ -461,7 +464,8 @@ CreateDisplayDriverList(HINF InfFile)
UserData, UserData,
_wcsicmp(KeyName, DisplayKey) ? FALSE : TRUE); _wcsicmp(KeyName, DisplayKey) ? FALSE : TRUE);
} }
while (InfFindNextLine(&Context, &Context)); while (InfFindNextLine(Context, Context));
InfFreeContext(Context);
#if 0 #if 0
AppendGenericListEntry(List, "Other display driver", NULL, TRUE); AppendGenericListEntry(List, "Other display driver", NULL, TRUE);
@ -497,7 +501,7 @@ BOOLEAN
ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List) ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List)
{ {
PGENERIC_LIST_ENTRY Entry; PGENERIC_LIST_ENTRY Entry;
INFCONTEXT Context; PINFCONTEXT Context;
PWCHAR ServiceName; PWCHAR ServiceName;
ULONG StartValue; ULONG StartValue;
NTSTATUS Status; NTSTATUS Status;
@ -517,7 +521,7 @@ ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List)
return FALSE; return FALSE;
} }
if (!InfGetDataField(&Context, 3, &ServiceName)) if (!InfGetDataField(Context, 3, &ServiceName))
{ {
DPRINT("InfGetDataField() failed\n"); DPRINT("InfGetDataField() failed\n");
return FALSE; return FALSE;
@ -532,6 +536,7 @@ ProcessDisplayRegistry(HINF InfFile, PGENERIC_LIST List)
REG_DWORD, REG_DWORD,
&StartValue, &StartValue,
sizeof(ULONG)); sizeof(ULONG));
InfFreeContext(Context);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("RtlWriteRegistryValue() failed (Status %lx)\n", Status); DPRINT("RtlWriteRegistryValue() failed (Status %lx)\n", Status);
@ -549,7 +554,7 @@ CreateKeyboardDriverList(HINF InfFile)
{ {
CHAR Buffer[128]; CHAR Buffer[128];
PGENERIC_LIST List; PGENERIC_LIST List;
INFCONTEXT Context; PINFCONTEXT Context;
PWCHAR KeyName; PWCHAR KeyName;
PWCHAR KeyValue; PWCHAR KeyValue;
PWCHAR UserData; PWCHAR UserData;
@ -566,7 +571,7 @@ CreateKeyboardDriverList(HINF InfFile)
do do
{ {
if (!InfGetData (&Context, &KeyName, &KeyValue)) if (!InfGetData (Context, &KeyName, &KeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetData() failed\n"); DPRINT("InfGetData() failed\n");
@ -586,7 +591,8 @@ 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 (InfFindNextLine(Context, Context));
InfFreeContext(Context);
return List; return List;
} }
@ -597,7 +603,7 @@ CreateKeyboardLayoutList(HINF InfFile)
{ {
CHAR Buffer[128]; CHAR Buffer[128];
PGENERIC_LIST List; PGENERIC_LIST List;
INFCONTEXT Context; PINFCONTEXT Context;
PWCHAR KeyName; PWCHAR KeyName;
PWCHAR KeyValue; PWCHAR KeyValue;
PWCHAR UserData; PWCHAR UserData;
@ -607,10 +613,14 @@ CreateKeyboardLayoutList(HINF InfFile)
if (!InfFindFirstLine (InfFile, L"NLS", L"DefaultLayout", &Context)) if (!InfFindFirstLine (InfFile, L"NLS", L"DefaultLayout", &Context))
return NULL; return NULL;
if (!InfGetData (&Context, NULL, &KeyValue)) if (!InfGetData (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)
@ -619,12 +629,13 @@ CreateKeyboardLayoutList(HINF InfFile)
if (!InfFindFirstLine (InfFile, L"KeyboardLayout", NULL, &Context)) if (!InfFindFirstLine (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 (!InfGetData (Context, &KeyName, &KeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT("InfGetData() failed\n"); DPRINT("InfGetData() failed\n");
@ -647,7 +658,8 @@ CreateKeyboardLayoutList(HINF InfFile)
UserData, UserData,
_wcsicmp(KeyName, DefaultLayout) ? FALSE : TRUE); _wcsicmp(KeyName, DefaultLayout) ? FALSE : TRUE);
} }
while (InfFindNextLine(&Context, &Context)); while (InfFindNextLine(Context, Context));
InfFreeContext(Context);
return List; return List;
} }

View file

@ -395,7 +395,7 @@ CheckUnattendedSetup(VOID)
{ {
WCHAR UnattendInfPath[MAX_PATH]; WCHAR UnattendInfPath[MAX_PATH];
UNICODE_STRING FileName; UNICODE_STRING FileName;
INFCONTEXT Context; PINFCONTEXT Context;
HINF UnattendInf; HINF UnattendInf;
ULONG ErrorLine; ULONG ErrorLine;
NTSTATUS Status; NTSTATUS Status;
@ -429,14 +429,16 @@ CheckUnattendedSetup(VOID)
if (!InfFindFirstLine(UnattendInf, L"Unattend", L"Signature", &Context)) if (!InfFindFirstLine(UnattendInf, L"Unattend", L"Signature", &Context))
{ {
DPRINT("InfFindFirstLine() failed for section 'Unattend'\n"); DPRINT("InfFindFirstLine() failed for section 'Unattend'\n");
InfFreeContext(Context);
InfCloseFile(UnattendInf); InfCloseFile(UnattendInf);
return; return;
} }
/* Get pointer 'Signature' key */ /* Get pointer 'Signature' key */
if (!InfGetData(&Context, NULL, &Value)) if (!InfGetData(Context, NULL, &Value))
{ {
DPRINT("InfGetData() failed for key 'Signature'\n"); DPRINT("InfGetData() failed for key 'Signature'\n");
InfFreeContext(Context);
InfCloseFile(UnattendInf); InfCloseFile(UnattendInf);
return; return;
} }
@ -445,6 +447,7 @@ 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);
InfCloseFile(UnattendInf); InfCloseFile(UnattendInf);
return; return;
} }
@ -453,31 +456,37 @@ CheckUnattendedSetup(VOID)
if (!InfFindFirstLine(UnattendInf, L"Unattend", L"DestinationDiskNumber", &Context)) if (!InfFindFirstLine(UnattendInf, L"Unattend", L"DestinationDiskNumber", &Context))
{ {
DPRINT("InfFindFirstLine() failed for key 'DestinationDiskNumber'\n"); DPRINT("InfFindFirstLine() failed for key 'DestinationDiskNumber'\n");
InfFreeContext(Context);
InfCloseFile(UnattendInf); InfCloseFile(UnattendInf);
return; return;
} }
if (!InfGetIntField(&Context, 0, &IntValue)) if (!InfGetIntField(Context, 0, &IntValue))
{ {
DPRINT("InfGetIntField() failed for key 'DestinationDiskNumber'\n"); DPRINT("InfGetIntField() failed for key 'DestinationDiskNumber'\n");
InfFreeContext(Context);
InfCloseFile(UnattendInf); InfCloseFile(UnattendInf);
return; return;
} }
UnattendDestinationDiskNumber = IntValue; UnattendDestinationDiskNumber = 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 (!InfFindFirstLine(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context))
{ {
DPRINT("InfFindFirstLine() failed for key 'DestinationPartitionNumber'\n"); DPRINT("InfFindFirstLine() failed for key 'DestinationPartitionNumber'\n");
InfFreeContext(Context);
InfCloseFile(UnattendInf); InfCloseFile(UnattendInf);
return; return;
} }
if (!InfGetIntField(&Context, 0, &IntValue)) if (!InfGetIntField(Context, 0, &IntValue))
{ {
DPRINT("InfGetIntField() failed for key 'DestinationPartitionNumber'\n"); DPRINT("InfGetIntField() failed for key 'DestinationPartitionNumber'\n");
InfFreeContext(Context);
InfCloseFile(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 (!InfFindFirstLine(UnattendInf, L"Unattend", L"DestinationPartitionNumber", &Context))
@ -488,14 +497,16 @@ CheckUnattendedSetup(VOID)
} }
/* Get pointer 'InstallationDirectory' key */ /* Get pointer 'InstallationDirectory' key */
if (!InfGetData(&Context, NULL, &Value)) if (!InfGetData(Context, NULL, &Value))
{ {
DPRINT("InfGetData() failed for key 'InstallationDirectory'\n"); DPRINT("InfGetData() failed for key 'InstallationDirectory'\n");
InfFreeContext(Context);
InfCloseFile(UnattendInf); InfCloseFile(UnattendInf);
return; return;
} }
wcscpy(UnattendInstallationDirectory, Value); wcscpy(UnattendInstallationDirectory, Value);
InfFreeContext(Context);
InfCloseFile(UnattendInf); InfCloseFile(UnattendInf);
IsUnattendedSetup = TRUE; IsUnattendedSetup = TRUE;
@ -516,7 +527,7 @@ SetupStartPage(PINPUT_RECORD Ir)
NTSTATUS Status; NTSTATUS Status;
WCHAR FileNameBuffer[MAX_PATH]; WCHAR FileNameBuffer[MAX_PATH];
UNICODE_STRING FileName; UNICODE_STRING FileName;
INFCONTEXT Context; PINFCONTEXT Context;
PWCHAR Value; PWCHAR Value;
ULONG ErrorLine; ULONG ErrorLine;
ULONG ReturnSize; ULONG ReturnSize;
@ -630,8 +641,9 @@ SetupStartPage(PINPUT_RECORD Ir)
/* Get pointer 'Signature' key */ /* Get pointer 'Signature' key */
if (!InfGetData (&Context, NULL, &Value)) if (!InfGetData (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");
@ -649,6 +661,7 @@ 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");
@ -662,6 +675,7 @@ SetupStartPage(PINPUT_RECORD Ir)
} }
} }
} }
InfFreeContext(Context);
CheckUnattendedSetup(); CheckUnattendedSetup();
@ -2565,7 +2579,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
WCHAR InstallDir[51]; WCHAR InstallDir[51];
PWCHAR DefaultPath; PWCHAR DefaultPath;
INFCONTEXT Context; PINFCONTEXT Context;
ULONG Length; ULONG Length;
if (PartitionList == NULL || if (PartitionList == NULL ||
@ -2598,7 +2612,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
} }
/* Read the 'DefaultPath' data */ /* Read the 'DefaultPath' data */
if (InfGetData (&Context, NULL, &DefaultPath)) if (InfGetData (Context, NULL, &DefaultPath))
{ {
wcscpy(InstallDir, DefaultPath); wcscpy(InstallDir, DefaultPath);
} }
@ -2606,6 +2620,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
{ {
wcscpy(InstallDir, L"\\ReactOS"); wcscpy(InstallDir, L"\\ReactOS");
} }
InfFreeContext(Context);
Length = wcslen(InstallDir); Length = wcslen(InstallDir);
SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a"); SetTextXY(6, 8, "Setup installs ReactOS files onto the selected partition. Choose a");
@ -2670,8 +2685,8 @@ AddSectionToCopyQueue(HINF InfFile,
PWCHAR SourceCabinet, PWCHAR SourceCabinet,
PINPUT_RECORD Ir) PINPUT_RECORD Ir)
{ {
INFCONTEXT FilesContext; PINFCONTEXT FilesContext;
INFCONTEXT DirContext; PINFCONTEXT DirContext;
PWCHAR FileKeyName; PWCHAR FileKeyName;
PWCHAR FileKeyValue; PWCHAR FileKeyValue;
PWCHAR DirKeyValue; PWCHAR DirKeyValue;
@ -2702,7 +2717,7 @@ 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 (!InfGetData (FilesContext, &FileKeyName, &FileKeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT1("InfGetData() failed\n"); DPRINT1("InfGetData() failed\n");
@ -2710,7 +2725,7 @@ AddSectionToCopyQueue(HINF InfFile,
} }
/* Get optional target file name */ /* Get optional target file name */
if (!InfGetDataField (&FilesContext, 2, &TargetFileName)) if (!InfGetDataField (FilesContext, 2, &TargetFileName))
TargetFileName = NULL; TargetFileName = NULL;
DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue); DPRINT ("FileKeyName: '%S' FileKeyValue: '%S'\n", FileKeyName, FileKeyValue);
@ -2723,9 +2738,10 @@ AddSectionToCopyQueue(HINF InfFile,
break; break;
} }
if (!InfGetData (&DirContext, NULL, &DirKeyValue)) if (!InfGetData (DirContext, NULL, &DirKeyValue))
{ {
/* FIXME: Handle error! */ /* FIXME: Handle error! */
InfFreeContext(DirContext);
DPRINT1("InfGetData() failed\n"); DPRINT1("InfGetData() failed\n");
break; break;
} }
@ -2741,8 +2757,11 @@ AddSectionToCopyQueue(HINF InfFile,
/* FIXME: Handle error! */ /* FIXME: Handle error! */
DPRINT1("SetupQueueCopy() failed\n"); DPRINT1("SetupQueueCopy() failed\n");
} }
InfFreeContext(DirContext);
} }
while (InfFindNextLine(&FilesContext, &FilesContext)); while (InfFindNextLine(FilesContext, FilesContext));
InfFreeContext(FilesContext);
return TRUE; return TRUE;
} }
@ -2753,7 +2772,7 @@ PrepareCopyPageInfFile(HINF InfFile,
PINPUT_RECORD Ir) PINPUT_RECORD Ir)
{ {
WCHAR PathBuffer[MAX_PATH]; WCHAR PathBuffer[MAX_PATH];
INFCONTEXT DirContext; PINFCONTEXT DirContext;
PWCHAR AdditionalSectionName; PWCHAR AdditionalSectionName;
PWCHAR KeyValue; PWCHAR KeyValue;
ULONG Length; ULONG Length;
@ -2840,7 +2859,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 (!InfGetData (DirContext, NULL, &KeyValue))
{ {
DPRINT1("break\n"); DPRINT1("break\n");
break; break;
@ -2883,7 +2902,9 @@ PrepareCopyPageInfFile(HINF InfFile,
} }
} }
} }
while (InfFindNextLine (&DirContext, &DirContext)); while (InfFindNextLine (DirContext, DirContext));
InfFreeContext(DirContext);
return(TRUE); return(TRUE);
} }
@ -2894,7 +2915,7 @@ PrepareCopyPage(PINPUT_RECORD Ir)
{ {
HINF InfHandle; HINF InfHandle;
WCHAR PathBuffer[MAX_PATH]; WCHAR PathBuffer[MAX_PATH];
INFCONTEXT CabinetsContext; PINFCONTEXT CabinetsContext;
ULONG InfFileSize; ULONG InfFileSize;
PWCHAR KeyValue; PWCHAR KeyValue;
NTSTATUS Status; NTSTATUS Status;
@ -2940,7 +2961,7 @@ PrepareCopyPage(PINPUT_RECORD Ir)
*/ */
do do
{ {
if (!InfGetData (&CabinetsContext, NULL, &KeyValue)) if (!InfGetData (CabinetsContext, NULL, &KeyValue))
break; break;
wcscpy(PathBuffer, SourcePath.Buffer); wcscpy(PathBuffer, SourcePath.Buffer);
@ -3017,7 +3038,9 @@ PrepareCopyPage(PINPUT_RECORD Ir)
return QUIT_PAGE; return QUIT_PAGE;
} }
} }
while (InfFindNextLine (&CabinetsContext, &CabinetsContext)); while (InfFindNextLine (CabinetsContext, CabinetsContext));
InfFreeContext(CabinetsContext);
return FILE_COPY_PAGE; return FILE_COPY_PAGE;
} }
@ -3095,7 +3118,7 @@ FileCopyPage(PINPUT_RECORD Ir)
static PAGE_NUMBER static PAGE_NUMBER
RegistryPage(PINPUT_RECORD Ir) RegistryPage(PINPUT_RECORD Ir)
{ {
INFCONTEXT InfContext; PINFCONTEXT InfContext;
PWSTR Action; PWSTR Action;
PWSTR File; PWSTR File;
PWSTR Section; PWSTR Section;
@ -3164,9 +3187,9 @@ RegistryPage(PINPUT_RECORD Ir)
do do
{ {
InfGetDataField (&InfContext, 0, &Action); InfGetDataField (InfContext, 0, &Action);
InfGetDataField (&InfContext, 1, &File); InfGetDataField (InfContext, 1, &File);
InfGetDataField (&InfContext, 2, &Section); InfGetDataField (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);
@ -3203,7 +3226,9 @@ RegistryPage(PINPUT_RECORD Ir)
} }
} }
} }
while (InfFindNextLine (&InfContext, &InfContext)); while (InfFindNextLine (InfContext, InfContext));
InfFreeContext(InfContext);
/* Update display registry settings */ /* Update display registry settings */
SetStatusText(" Updating display registry settings..."); SetStatusText(" Updating display registry settings...");
@ -3647,6 +3672,7 @@ NtProcessStartup(PPEB Peb)
RtlNormalizeProcessParams(Peb->ProcessParameters); RtlNormalizeProcessParams(Peb->ProcessParameters);
ProcessHeap = Peb->ProcessHeap; ProcessHeap = Peb->ProcessHeap;
InfSetHeap(ProcessHeap);
SignalInitEvent(); SignalInitEvent();

View file

@ -54,11 +54,12 @@
/* 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 "inicache.h" #include "inicache.h"
#include "infcache.h"
#include "filequeue.h" #include "filequeue.h"
#include "progress.h" #include "progress.h"
#include "bootsup.h" #include "bootsup.h"

View file

@ -2,12 +2,14 @@
<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>
<include base="inflib">.</include>
<define name="__USE_W32API" /> <define name="__USE_W32API" />
<define name="_DISABLE_TIDENTS" /> <define name="_DISABLE_TIDENTS" />
<define name="_WIN32_WINNT">0x0502</define> <define name="_WIN32_WINNT">0x0502</define>
<define name="__NO_CTYPE_INLINES" /> <define name="__NO_CTYPE_INLINES" />
<linkerflag>-lgcc</linkerflag> <linkerflag>-lgcc</linkerflag>
<library>zlib</library> <library>zlib</library>
<library>inflib</library>
<library>vfatlib</library> <library>vfatlib</library>
<library>ntdll</library> <library>ntdll</library>
<pch>usetup.h</pch> <pch>usetup.h</pch>
@ -20,7 +22,6 @@
<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>infcache.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>