mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
- Added .inf-file parser
- SetupLdr loads and uses txtsetup.sif - Removed .hiv (text-hive) parser svn path=/trunk/; revision=4758
This commit is contained in:
parent
c028a8b5e0
commit
939d5316af
12 changed files with 1706 additions and 645 deletions
|
@ -1,3 +1,9 @@
|
|||
Changes in v1.8.12 (5/25/2003) (ekohl)
|
||||
|
||||
- Added .inf-file parser
|
||||
- SetupLdr loads and uses txtsetup.sif
|
||||
- Removed .hiv (text-hive) parser
|
||||
|
||||
Changes in v1.8.11 (4/30/2003) (ekohl)
|
||||
|
||||
- Added DiskGetExtendedDriveParameters()
|
||||
|
|
|
@ -233,9 +233,7 @@ UI_OBJS = tui.o \
|
|||
ui.o \
|
||||
gui.o
|
||||
|
||||
REACTOS_OBJS= reactos.o \
|
||||
arcname.o \
|
||||
reghive.o \
|
||||
REACTOS_OBJS= arcname.o \
|
||||
binhive.o \
|
||||
registry.o
|
||||
|
||||
|
@ -255,6 +253,8 @@ INIFILE_OBJS= inifile.o \
|
|||
ini_init.o \
|
||||
parse.o
|
||||
|
||||
INFFILE_OBJS= inffile.o
|
||||
|
||||
VIDEO_OBJS = video.o \
|
||||
vidmode.o \
|
||||
fade.o \
|
||||
|
@ -269,17 +269,19 @@ MATH_OBJS = libgcc2.o
|
|||
|
||||
BASE_OBJS = freeldr.o \
|
||||
debug.o \
|
||||
drivemap.o \
|
||||
multiboot.o \
|
||||
version.o
|
||||
|
||||
FREELDR_OBJS= bootmgr.o \
|
||||
drivemap.o \
|
||||
miscboot.o \
|
||||
options.o \
|
||||
linuxboot.o \
|
||||
oslist.o \
|
||||
custom.o
|
||||
|
||||
ROSLDR_OBJS = reactos.o
|
||||
|
||||
SETUPLDR_OBJS= setupldr.o
|
||||
|
||||
COMMON_OBJS = $(ARCH_OBJS) \
|
||||
|
@ -291,23 +293,33 @@ COMMON_OBJS = $(ARCH_OBJS) \
|
|||
$(DISK_OBJS) \
|
||||
$(MM_OBJS) \
|
||||
$(CACHE_OBJS) \
|
||||
$(INIFILE_OBJS) \
|
||||
$(VIDEO_OBJS) \
|
||||
$(MATH_OBJS) \
|
||||
$(BASE_OBJS)
|
||||
|
||||
SPECIAL_OBJS = $(INIFILE_OBJS) \
|
||||
$(INFFILE_OBJS) \
|
||||
$(FREELDR_OBJS) \
|
||||
$(ROSLDR_OBJS) \
|
||||
$(SETUPLDR_OBJS)
|
||||
|
||||
|
||||
F_OBJS = $(COMMON_OBJS) \
|
||||
$(INIFILE_OBJS) \
|
||||
$(ROSLDR_OBJS) \
|
||||
$(FREELDR_OBJS)
|
||||
|
||||
S_OBJS = $(COMMON_OBJS) \
|
||||
$(INIFILE_OBJS) \
|
||||
$(INFFILE_OBJS) \
|
||||
$(SETUPLDR_OBJS)
|
||||
|
||||
|
||||
#############################################
|
||||
# ALL THE OBJECTS
|
||||
#
|
||||
ALL_OBJS = $(COMMON_OBJS) \
|
||||
$(FREELDR_OBJS) \
|
||||
$(SETUPLDR_OBJS)
|
||||
$(SPECIAL_OBJS)
|
||||
|
||||
|
||||
#############################################
|
||||
|
@ -324,6 +336,7 @@ VPATH = $(SRCDIR)/ \
|
|||
$(SRCDIR)/mm \
|
||||
$(SRCDIR)/cache \
|
||||
$(SRCDIR)/inifile \
|
||||
$(SRCDIR)/inffile \
|
||||
$(SRCDIR)/video \
|
||||
$(SRCDIR)/math \
|
||||
$(SRCDIR)/include
|
||||
|
@ -347,7 +360,6 @@ freeldr.sys : $(ALL_OBJS)
|
|||
|
||||
setupldr.sys : $(ALL_OBJS)
|
||||
@echo ===================================================== LINKING $@
|
||||
# @$(LD) -N -Ttext=0x8000 --oformat=binary -s -o setupldr.sys $(S_OBJS)
|
||||
@$(LD) $(LFLAGS) -Map setupldr.map -o setupldr.exe $(S_OBJS)
|
||||
@$(NM) --numeric-sort setupldr.exe > setupldr.sym
|
||||
@$(OBJCOPY) -O binary setupldr.exe setupldr.sys
|
||||
|
|
130
freeldr/freeldr/include/inffile.h
Normal file
130
freeldr/freeldr/include/inffile.h
Normal file
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* 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: inffile.h,v 1.1 2003/05/25 21:17:30 ekohl Exp $
|
||||
* 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 PU32 HINF, *PHINF;
|
||||
|
||||
typedef struct _INFCONTEXT
|
||||
{
|
||||
PVOID Inf;
|
||||
// PVOID CurrentInf;
|
||||
PVOID Section;
|
||||
PVOID Line;
|
||||
} INFCONTEXT, *PINFCONTEXT;
|
||||
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
BOOLEAN
|
||||
InfOpenFile (PHINF InfHandle,
|
||||
PCHAR FileName,
|
||||
PU32 ErrorLine);
|
||||
|
||||
VOID
|
||||
InfCloseFile (HINF InfHandle);
|
||||
|
||||
|
||||
BOOLEAN
|
||||
InfFindFirstLine (HINF InfHandle,
|
||||
PCHAR Section,
|
||||
PCHAR Key,
|
||||
PINFCONTEXT Context);
|
||||
|
||||
BOOLEAN
|
||||
InfFindNextLine (PINFCONTEXT ContextIn,
|
||||
PINFCONTEXT ContextOut);
|
||||
|
||||
BOOLEAN
|
||||
InfFindFirstMatchLine (PINFCONTEXT ContextIn,
|
||||
PCHAR Key,
|
||||
PINFCONTEXT ContextOut);
|
||||
|
||||
BOOLEAN
|
||||
InfFindNextMatchLine (PINFCONTEXT ContextIn,
|
||||
PCHAR Key,
|
||||
PINFCONTEXT ContextOut);
|
||||
|
||||
|
||||
S32
|
||||
InfGetLineCount (HINF InfHandle,
|
||||
PCHAR Section);
|
||||
|
||||
S32
|
||||
InfGetFieldCount (PINFCONTEXT Context);
|
||||
|
||||
|
||||
BOOLEAN
|
||||
InfGetBinaryField (PINFCONTEXT Context,
|
||||
U32 FieldIndex,
|
||||
PU8 ReturnBuffer,
|
||||
U32 ReturnBufferSize,
|
||||
PU32 RequiredSize);
|
||||
|
||||
BOOLEAN
|
||||
InfGetIntField (PINFCONTEXT Context,
|
||||
U32 FieldIndex,
|
||||
S32 *IntegerValue);
|
||||
|
||||
BOOLEAN
|
||||
InfGetMultiSzField (PINFCONTEXT Context,
|
||||
U32 FieldIndex,
|
||||
PCHAR ReturnBuffer,
|
||||
U32 ReturnBufferSize,
|
||||
PU32 RequiredSize);
|
||||
|
||||
BOOLEAN
|
||||
InfGetStringField (PINFCONTEXT Context,
|
||||
U32 FieldIndex,
|
||||
PCHAR ReturnBuffer,
|
||||
U32 ReturnBufferSize,
|
||||
PU32 RequiredSize);
|
||||
|
||||
|
||||
|
||||
BOOLEAN
|
||||
InfGetData (PINFCONTEXT Context,
|
||||
PCHAR *Key,
|
||||
PCHAR *Data);
|
||||
|
||||
BOOLEAN
|
||||
InfGetDataField (PINFCONTEXT Context,
|
||||
U32 FieldIndex,
|
||||
PCHAR *Data);
|
||||
|
||||
#endif /* __INFCACHE_H__ */
|
||||
|
||||
/* EOF */
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
/* just some stuff */
|
||||
#define VERSION "FreeLoader v1.8.11"
|
||||
#define VERSION "FreeLoader v1.8.12"
|
||||
#define COPYRIGHT "Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>"
|
||||
#define AUTHOR_EMAIL "<brianp@sginet.com>"
|
||||
#define BY_AUTHOR "by Brian Palmer"
|
||||
|
@ -36,7 +36,7 @@
|
|||
//
|
||||
#define FREELOADER_MAJOR_VERSION 1
|
||||
#define FREELOADER_MINOR_VERSION 8
|
||||
#define FREELOADER_PATCH_VERSION 11
|
||||
#define FREELOADER_PATCH_VERSION 12
|
||||
|
||||
|
||||
PUCHAR GetFreeLoaderVersionString(VOID);
|
||||
|
|
1494
freeldr/freeldr/inffile/inffile.c
Normal file
1494
freeldr/freeldr/inffile/inffile.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -30,6 +30,9 @@ BOOL IniOpenSection(PUCHAR SectionName, U32* SectionId)
|
|||
|
||||
DbgPrint((DPRINT_INIFILE, "IniOpenSection() SectionName = %s\n", SectionName));
|
||||
|
||||
if (!IniFileSectionListHead)
|
||||
return FALSE;
|
||||
|
||||
// Loop through each section and find the one they want
|
||||
Section = (PINI_SECTION)RtlListGetHead((PLIST_ITEM)IniFileSectionListHead);
|
||||
while (Section != NULL)
|
||||
|
|
|
@ -207,6 +207,7 @@ PVOID MultiBootLoadModule(FILE *ModuleImage, char *ModuleName, U32* ModuleSize)
|
|||
return((PVOID)pModule->mod_start);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int GetBootPartition(char *OperatingSystemName)
|
||||
{
|
||||
int BootPartitionNumber = -1;
|
||||
|
@ -223,7 +224,7 @@ int GetBootPartition(char *OperatingSystemName)
|
|||
|
||||
return BootPartitionNumber;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
PVOID MultiBootCreateModule(char *ModuleName)
|
||||
{
|
||||
|
|
|
@ -662,21 +662,8 @@ LoadAndBootReactOS(PUCHAR OperatingSystemName)
|
|||
FilePointer = FsOpenFile(szFileName);
|
||||
if (FilePointer == NULL)
|
||||
{
|
||||
strcpy(szFileName, szBootPath);
|
||||
strcat(szFileName, "SYSTEM32\\CONFIG\\SYSTEM.HIV");
|
||||
|
||||
DbgPrint((DPRINT_REACTOS, "SystemHive: '%s'", szFileName));
|
||||
|
||||
FilePointer = FsOpenFile(szFileName);
|
||||
if (FilePointer == NULL)
|
||||
{
|
||||
UiMessageBox("Could not find the System hive!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
TextHive = TRUE;
|
||||
}
|
||||
UiMessageBox("Could not find the System hive!");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -702,14 +689,7 @@ LoadAndBootReactOS(PUCHAR OperatingSystemName)
|
|||
/*
|
||||
* Import the loaded system hive
|
||||
*/
|
||||
if (TextHive)
|
||||
{
|
||||
RegImportTextHive(Base, Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
RegImportBinaryHive(Base, Size);
|
||||
}
|
||||
RegImportBinaryHive(Base, Size);
|
||||
|
||||
/*
|
||||
* Initialize the 'CurrentControlSet' link
|
||||
|
|
|
@ -1,591 +0,0 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
*
|
||||
* Copyright (C) 2001 Rex Jolliff
|
||||
* Copyright (C) 2001 Eric Kohl
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <freeldr.h>
|
||||
#include <rtl.h>
|
||||
#include <mm.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "registry.h"
|
||||
|
||||
|
||||
#define REGISTRY_FILE_MAGIC "REGEDIT4"
|
||||
|
||||
static PCHAR
|
||||
checkAndSkipMagic (PCHAR regChunk)
|
||||
{
|
||||
if (strncmp (regChunk,
|
||||
REGISTRY_FILE_MAGIC,
|
||||
strlen (REGISTRY_FILE_MAGIC)) != 0)
|
||||
{
|
||||
DbgPrint((DPRINT_REGISTRY, "Incorrect magic number in registry chunk. Expected: '%s' Got: '%.*s'\n",
|
||||
REGISTRY_FILE_MAGIC, strlen(REGISTRY_FILE_MAGIC), regChunk));
|
||||
|
||||
return 0;
|
||||
}
|
||||
regChunk += strlen (REGISTRY_FILE_MAGIC);
|
||||
|
||||
DbgPrint((DPRINT_REGISTRY, "Found registry chunk magic value\n"));
|
||||
|
||||
return regChunk;
|
||||
}
|
||||
|
||||
static PCHAR
|
||||
skipWhitespaceInChunk (PCHAR regChunk)
|
||||
{
|
||||
while (*regChunk && isspace (*regChunk))
|
||||
regChunk++;
|
||||
|
||||
return *regChunk ? regChunk : 0;
|
||||
}
|
||||
|
||||
static int
|
||||
computeKeyNameSize (PCHAR regChunk)
|
||||
{
|
||||
int copyCount = 0;
|
||||
|
||||
while (*regChunk != 0 && *regChunk != ']')
|
||||
{
|
||||
copyCount++;
|
||||
regChunk++;
|
||||
}
|
||||
|
||||
return copyCount;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
allocateKeyName(PCHAR *newKeyName, int newKeySize)
|
||||
{
|
||||
if (*newKeyName != NULL)
|
||||
MmFreeMemory(*newKeyName);
|
||||
|
||||
*newKeyName = MmAllocateMemory(newKeySize + 1);
|
||||
if (*newKeyName == NULL)
|
||||
return(FALSE);
|
||||
|
||||
memset(*newKeyName, 0, newKeySize + 1);
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static PCHAR
|
||||
skipToNextKeyInChunk (PCHAR regChunk)
|
||||
{
|
||||
while (*regChunk != 0 && *regChunk != '[')
|
||||
{
|
||||
while (*regChunk != 0 && *regChunk != '\n')
|
||||
{
|
||||
regChunk++;
|
||||
}
|
||||
regChunk++;
|
||||
}
|
||||
|
||||
return *regChunk ? regChunk : 0;
|
||||
}
|
||||
|
||||
static PCHAR
|
||||
getKeyNameFromChunk (PCHAR regChunk, PCHAR newKeyName)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
while (*regChunk != 0 && *regChunk != ']')
|
||||
{
|
||||
newKeyName[index++] = *regChunk++;
|
||||
}
|
||||
newKeyName[index] = '\0';
|
||||
|
||||
return *regChunk ? regChunk : 0;
|
||||
}
|
||||
|
||||
static HKEY
|
||||
createNewKey (PCHAR newKeyName)
|
||||
{
|
||||
HKEY handleToReturn = NULL;
|
||||
|
||||
DbgPrint((DPRINT_REGISTRY, "Adding new key '%s'\n", newKeyName));
|
||||
|
||||
RegCreateKey(NULL,
|
||||
newKeyName,
|
||||
&handleToReturn);
|
||||
|
||||
DbgPrint((DPRINT_REGISTRY, "Returned handle: 0x%x\n", handleToReturn));
|
||||
|
||||
return handleToReturn;
|
||||
}
|
||||
|
||||
static PCHAR
|
||||
skipToNextKeyValueInChunk (PCHAR regChunk)
|
||||
{
|
||||
while (*regChunk != 0 && *regChunk != '\n')
|
||||
regChunk++;
|
||||
regChunk = skipWhitespaceInChunk (regChunk);
|
||||
|
||||
return regChunk;
|
||||
}
|
||||
|
||||
static int
|
||||
computeKeyValueNameSize (PCHAR regChunk)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
if (*regChunk != '\"')
|
||||
return 0;
|
||||
regChunk++;
|
||||
while (*regChunk != 0 && *regChunk != '\"')
|
||||
{
|
||||
size++;
|
||||
regChunk++;
|
||||
}
|
||||
|
||||
return regChunk ? size : 0;
|
||||
}
|
||||
|
||||
static PCHAR
|
||||
getKeyValueNameFromChunk (PCHAR regChunk, PCHAR newKeyName)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
regChunk++;
|
||||
while (*regChunk != 0 && *regChunk != '\"')
|
||||
{
|
||||
newKeyName[index++] = *regChunk++;
|
||||
}
|
||||
newKeyName[index] = '\0';
|
||||
regChunk++;
|
||||
|
||||
return *regChunk ? regChunk : 0;
|
||||
}
|
||||
|
||||
static PCHAR
|
||||
getKeyValueTypeFromChunk (PCHAR regChunk, PCHAR dataFormat, int *keyValueType)
|
||||
{
|
||||
if (*regChunk == '\"')
|
||||
{
|
||||
strcpy (dataFormat, "string");
|
||||
*keyValueType = REG_SZ;
|
||||
}
|
||||
else if (strncmp (regChunk, "hex", 3) == 0)
|
||||
{
|
||||
strcpy (dataFormat, "hex");
|
||||
regChunk += 3;
|
||||
if (*regChunk == '(')
|
||||
{
|
||||
regChunk++;
|
||||
*keyValueType = atoi (regChunk);
|
||||
while (*regChunk != 0 && *regChunk != ')')
|
||||
regChunk++;
|
||||
regChunk++;
|
||||
}
|
||||
else
|
||||
*keyValueType = REG_BINARY;
|
||||
if (*regChunk == ':')
|
||||
regChunk++;
|
||||
}
|
||||
else if (strncmp (regChunk, "dword", 5) == 0)
|
||||
{
|
||||
strcpy (dataFormat, "dword");
|
||||
*keyValueType = REG_DWORD;
|
||||
regChunk += 5;
|
||||
if (*regChunk == ':')
|
||||
regChunk++;
|
||||
}
|
||||
else if (strncmp (regChunk, "multi", 5) == 0)
|
||||
{
|
||||
strcpy (dataFormat, "multi");
|
||||
*keyValueType = REG_MULTI_SZ;
|
||||
regChunk += 5;
|
||||
if (*regChunk == ':')
|
||||
regChunk++;
|
||||
}
|
||||
else if (strncmp (regChunk, "expand", 6) == 0)
|
||||
{
|
||||
strcpy (dataFormat, "expand");
|
||||
*keyValueType = REG_EXPAND_SZ;
|
||||
regChunk += 6;
|
||||
if (*regChunk == ':')
|
||||
regChunk++;
|
||||
}
|
||||
else
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
return *regChunk ? regChunk : 0;
|
||||
}
|
||||
|
||||
static int
|
||||
computeKeyValueDataSize (PCHAR regChunk, PCHAR dataFormat)
|
||||
{
|
||||
int dataSize = 0;
|
||||
|
||||
if (strcmp (dataFormat, "string") == 0)
|
||||
{
|
||||
regChunk++;
|
||||
while (*regChunk != 0 && *regChunk != '\"')
|
||||
{
|
||||
dataSize++;
|
||||
regChunk++;
|
||||
}
|
||||
dataSize++;
|
||||
}
|
||||
else if (strcmp (dataFormat, "hex") == 0)
|
||||
{
|
||||
while (*regChunk != 0 && isxdigit(*regChunk))
|
||||
{
|
||||
regChunk++;
|
||||
regChunk++;
|
||||
dataSize++;
|
||||
if (*regChunk == ',')
|
||||
{
|
||||
regChunk++;
|
||||
if (*regChunk == '\\')
|
||||
{
|
||||
regChunk++;
|
||||
regChunk = skipWhitespaceInChunk (regChunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (strcmp (dataFormat, "dword") == 0)
|
||||
{
|
||||
dataSize = sizeof(U32);
|
||||
while (*regChunk != 0 && isxdigit(*regChunk))
|
||||
{
|
||||
regChunk++;
|
||||
}
|
||||
}
|
||||
else if (strcmp (dataFormat, "multi") == 0)
|
||||
{
|
||||
while (*regChunk == '\"')
|
||||
{
|
||||
regChunk++;
|
||||
while (*regChunk != 0 && *regChunk != '\"')
|
||||
{
|
||||
dataSize++;
|
||||
regChunk++;
|
||||
}
|
||||
regChunk++;
|
||||
dataSize++;
|
||||
if (*regChunk == ',')
|
||||
{
|
||||
regChunk++;
|
||||
regChunk = skipWhitespaceInChunk (regChunk);
|
||||
if (*regChunk == '\\')
|
||||
{
|
||||
regChunk++;
|
||||
regChunk = skipWhitespaceInChunk (regChunk);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
dataSize++;
|
||||
}
|
||||
else if (strcmp (dataFormat, "expand") == 0)
|
||||
{
|
||||
regChunk++;
|
||||
while (*regChunk != 0 && *regChunk != '\"')
|
||||
{
|
||||
dataSize++;
|
||||
regChunk++;
|
||||
}
|
||||
dataSize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
return dataSize;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
allocateDataBuffer (PVOID * data, int * dataBufferSize, int dataSize)
|
||||
{
|
||||
if (*dataBufferSize < dataSize)
|
||||
{
|
||||
if (*dataBufferSize > 0)
|
||||
MmFreeMemory(*data);
|
||||
*data = MmAllocateMemory(dataSize);
|
||||
*dataBufferSize = dataSize;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static PCHAR
|
||||
getKeyValueDataFromChunk (PCHAR regChunk, PCHAR dataFormat, PCHAR data)
|
||||
{
|
||||
char dataValue;
|
||||
U32 ulValue;
|
||||
PCHAR ptr;
|
||||
|
||||
if (strcmp (dataFormat, "string") == 0)
|
||||
{
|
||||
/* convert quoted string to zero-terminated Unicode string */
|
||||
ptr = (PCHAR)data;
|
||||
regChunk++;
|
||||
while (*regChunk != 0 && *regChunk != '\"')
|
||||
{
|
||||
*ptr++ = (CHAR)*regChunk++;
|
||||
}
|
||||
*ptr = 0;
|
||||
regChunk++;
|
||||
}
|
||||
else if (strcmp (dataFormat, "hex") == 0)
|
||||
{
|
||||
while (*regChunk != 0 && isxdigit (*regChunk))
|
||||
{
|
||||
dataValue = (isdigit (*regChunk) ? *regChunk - '0' :
|
||||
tolower(*regChunk) - 'a') << 4;
|
||||
regChunk++;
|
||||
dataValue += (isdigit (*regChunk) ? *regChunk - '0' :
|
||||
tolower(*regChunk) - 'a');
|
||||
regChunk++;
|
||||
*data++ = dataValue;
|
||||
if (*regChunk == ',')
|
||||
{
|
||||
regChunk++;
|
||||
if (*regChunk == '\\')
|
||||
{
|
||||
regChunk++;
|
||||
regChunk = skipWhitespaceInChunk (regChunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (strcmp (dataFormat, "dword") == 0)
|
||||
{
|
||||
ulValue = 0;
|
||||
while (*regChunk != 0 && isxdigit(*regChunk))
|
||||
{
|
||||
dataValue = (isdigit (*regChunk) ? *regChunk - '0' :
|
||||
tolower(*regChunk) - 'a');
|
||||
ulValue = (ulValue << 4) + dataValue;
|
||||
regChunk++;
|
||||
}
|
||||
memcpy(data, &ulValue, sizeof(U32));
|
||||
}
|
||||
else if (strcmp (dataFormat, "multi") == 0)
|
||||
{
|
||||
ptr = (PCHAR)data;
|
||||
while (*regChunk == '\"')
|
||||
{
|
||||
regChunk++;
|
||||
while (*regChunk != 0 && *regChunk != '\"')
|
||||
{
|
||||
*ptr++ = (CHAR)*regChunk++;
|
||||
}
|
||||
regChunk++;
|
||||
*ptr++ = 0;
|
||||
if (*regChunk == ',')
|
||||
{
|
||||
regChunk++;
|
||||
regChunk = skipWhitespaceInChunk (regChunk);
|
||||
if (*regChunk == '\\')
|
||||
{
|
||||
regChunk++;
|
||||
regChunk = skipWhitespaceInChunk (regChunk);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
*ptr = 0;
|
||||
}
|
||||
else if (strcmp (dataFormat, "expand") == 0)
|
||||
{
|
||||
/* convert quoted string to zero-terminated Unicode string */
|
||||
ptr = (PCHAR)data;
|
||||
regChunk++;
|
||||
while (*regChunk != 0 && *regChunk != '\"')
|
||||
{
|
||||
*ptr++ = (CHAR)*regChunk++;
|
||||
}
|
||||
*ptr = 0;
|
||||
regChunk++;
|
||||
}
|
||||
else
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
return *regChunk ? regChunk : 0;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
setKeyValue (HKEY currentKey,
|
||||
PCHAR newValueName,
|
||||
U32 keyValueType,
|
||||
PVOID data,
|
||||
U32 dataSize)
|
||||
{
|
||||
S32 status;
|
||||
|
||||
DbgPrint((DPRINT_REGISTRY, "Adding value (%s) to current key, with data type %d and size %d\n",
|
||||
newValueName, (int)keyValueType, (int)dataSize));
|
||||
|
||||
status = RegSetValue(currentKey,
|
||||
newValueName,
|
||||
keyValueType,
|
||||
data,
|
||||
dataSize);
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_REGISTRY, "Could not set key value. status: %d\n", status));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
RegImportTextHive(PCHAR ChunkBase,
|
||||
U32 ChunkSize)
|
||||
{
|
||||
HKEY currentKey = INVALID_HANDLE_VALUE;
|
||||
char *newKeyName = NULL;
|
||||
int newKeySize;
|
||||
char dataFormat [10];
|
||||
int keyValueType;
|
||||
int dataSize = 0;
|
||||
int dataBufferSize = 0;
|
||||
PVOID data = 0;
|
||||
PCHAR regChunk;
|
||||
|
||||
DbgPrint((DPRINT_REGISTRY, "ChunkBase %p ChunkSize %lx\n", ChunkBase, ChunkSize));
|
||||
|
||||
regChunk = checkAndSkipMagic (ChunkBase);
|
||||
if (regChunk == 0)
|
||||
return FALSE;
|
||||
|
||||
while (regChunk != 0 && *regChunk != 0 && (((U32)regChunk-(U32)ChunkBase) < ChunkSize))
|
||||
{
|
||||
regChunk = skipWhitespaceInChunk (regChunk);
|
||||
if (regChunk == 0)
|
||||
continue;
|
||||
|
||||
if (*regChunk == '[')
|
||||
{
|
||||
if (currentKey != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DbgPrint((DPRINT_REGISTRY, "Closing current key: 0x%lx\n", currentKey));
|
||||
currentKey = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
regChunk++;
|
||||
|
||||
newKeySize = computeKeyNameSize (regChunk);
|
||||
if (!allocateKeyName (&newKeyName, newKeySize))
|
||||
{
|
||||
regChunk = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
regChunk = getKeyNameFromChunk (regChunk, newKeyName);
|
||||
if (regChunk == 0)
|
||||
continue;
|
||||
|
||||
currentKey = createNewKey (newKeyName);
|
||||
if (currentKey == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
regChunk = skipToNextKeyInChunk (regChunk);
|
||||
continue;
|
||||
}
|
||||
|
||||
regChunk++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentKey == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
regChunk = skipToNextKeyInChunk (regChunk);
|
||||
continue;
|
||||
}
|
||||
|
||||
newKeySize = computeKeyValueNameSize (regChunk);
|
||||
if (!allocateKeyName (&newKeyName, newKeySize))
|
||||
{
|
||||
regChunk = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
regChunk = getKeyValueNameFromChunk (regChunk, newKeyName);
|
||||
if (regChunk == 0)
|
||||
continue;
|
||||
|
||||
if (*regChunk != '=')
|
||||
{
|
||||
regChunk = skipToNextKeyValueInChunk (regChunk);
|
||||
continue;
|
||||
}
|
||||
regChunk++;
|
||||
|
||||
regChunk = getKeyValueTypeFromChunk (regChunk, dataFormat, &keyValueType);
|
||||
if (regChunk == 0)
|
||||
continue;
|
||||
|
||||
dataSize = computeKeyValueDataSize (regChunk, dataFormat);
|
||||
if (!allocateDataBuffer (&data, &dataBufferSize, dataSize))
|
||||
{
|
||||
regChunk = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
regChunk = getKeyValueDataFromChunk (regChunk, dataFormat, data);
|
||||
if (regChunk == 0)
|
||||
continue;
|
||||
|
||||
if (!setKeyValue (currentKey, newKeyName, keyValueType, data, dataSize))
|
||||
{
|
||||
regChunk = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentKey != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DbgPrint((DPRINT_REGISTRY, "Closing current key: 0x%lx\n", currentKey));
|
||||
}
|
||||
|
||||
if (newKeyName != NULL)
|
||||
{
|
||||
MmFreeMemory(newKeyName);
|
||||
}
|
||||
|
||||
if (data != NULL)
|
||||
{
|
||||
MmFreeMemory(data);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
BOOL
|
||||
RegExportHive(PCHAR ChunkBase, U32* ChunkSize)
|
||||
{
|
||||
return(TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* EOF */
|
|
@ -288,10 +288,6 @@ U32
|
|||
RegGetValueCount (HKEY Key);
|
||||
|
||||
|
||||
BOOL
|
||||
RegImportTextHive (PCHAR ChunkBase,
|
||||
U32 ChunkSize);
|
||||
|
||||
BOOL
|
||||
RegImportBinaryHive (PCHAR ChunkBase,
|
||||
U32 ChunkSize);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <multiboot.h>
|
||||
#include <mm.h>
|
||||
#include <ui.h>
|
||||
#include <inffile.h>
|
||||
|
||||
#include "registry.h"
|
||||
|
||||
|
@ -238,6 +239,10 @@ VOID RunLoader(VOID)
|
|||
char *SourcePath;
|
||||
char *LoadOptions;
|
||||
|
||||
HINF InfHandle;
|
||||
U32 ErrorLine;
|
||||
INFCONTEXT InfContext;
|
||||
|
||||
/* Setup multiboot information structure */
|
||||
mb_info.flags = MB_INFO_FLAG_MEM_SIZE | MB_INFO_FLAG_BOOT_DEVICE | MB_INFO_FLAG_COMMAND_LINE | MB_INFO_FLAG_MODULES;
|
||||
mb_info.mem_lower = GetConventionalMemorySize();
|
||||
|
@ -298,9 +303,46 @@ VOID RunLoader(VOID)
|
|||
((char *)(&mb_info.boot_device))[1] = (char)BootPartition;
|
||||
|
||||
|
||||
/* Set load options */
|
||||
// LoadOptions = "/DEBUGPORT=COM1";
|
||||
LoadOptions = "/DEBUGPORT=SCREEN";
|
||||
/* Open boot drive */
|
||||
if (!FsOpenVolume(BootDrive, BootPartition))
|
||||
{
|
||||
#ifdef USE_UI
|
||||
UiMessageBox("Failed to open boot drive.");
|
||||
#else
|
||||
printf("Failed to open boot drive.");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/* Open 'txtsetup.sif' */
|
||||
if (!InfOpenFile (&InfHandle,
|
||||
(BootDrive < 0x80) ? "\\txtsetup.sif" : "\\reactos\\txtsetup.sif",
|
||||
&ErrorLine))
|
||||
{
|
||||
printf("Failed to open 'txtsetup.sif'\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get load options */
|
||||
if (!InfFindFirstLine (InfHandle,
|
||||
"SetupData",
|
||||
"OsLoadOptions",
|
||||
&InfContext))
|
||||
{
|
||||
printf("Failed to find 'SetupData/OsLoadOptions'\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!InfGetDataField (&InfContext,
|
||||
1,
|
||||
&LoadOptions))
|
||||
{
|
||||
printf("Failed to get load options\n");
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
printf("LoadOptions: '%s'\n", LoadOptions);
|
||||
#endif
|
||||
|
||||
if (BootDrive < 0x80)
|
||||
{
|
||||
|
@ -321,18 +363,6 @@ VOID RunLoader(VOID)
|
|||
SourcePath,
|
||||
LoadOptions);
|
||||
|
||||
|
||||
/* Open boot drive */
|
||||
if (!FsOpenVolume(BootDrive, BootPartition))
|
||||
{
|
||||
#ifdef USE_UI
|
||||
UiMessageBox("Failed to open boot drive.");
|
||||
#else
|
||||
printf("Failed to open boot drive.");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/* Load ntoskrnl.exe */
|
||||
if (!LoadKernel(SourcePath, "ntoskrnl.exe"))
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue