mirror of
https://github.com/reactos/reactos.git
synced 2024-10-06 09:24:11 +00:00
Add multi and expand registry key type support.
svn path=/trunk/; revision=3049
This commit is contained in:
parent
30a776c6e9
commit
669a991546
|
@ -20,20 +20,9 @@
|
||||||
|
|
||||||
#include <freeldr.h>
|
#include <freeldr.h>
|
||||||
#include <rtl.h>
|
#include <rtl.h>
|
||||||
|
#include <debug.h>
|
||||||
//#define NDEBUG
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
DetectHardware(VOID)
|
DetectHardware(VOID)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
printf("DetectHardware() called\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
printf("DetectHardware() done\n");
|
|
||||||
#endif
|
|
||||||
//for(;;);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ LoadBootDrivers(PCHAR szSystemRoot, int nPos)
|
||||||
{
|
{
|
||||||
LONG rc = 0;
|
LONG rc = 0;
|
||||||
HKEY hGroupKey, hServiceKey, hDriverKey;
|
HKEY hGroupKey, hServiceKey, hDriverKey;
|
||||||
char ValueBuffer[256];
|
char ValueBuffer[512];
|
||||||
char ServiceName[256];
|
char ServiceName[256];
|
||||||
ULONG BufferSize;
|
ULONG BufferSize;
|
||||||
ULONG Index;
|
ULONG Index;
|
||||||
|
@ -175,7 +175,7 @@ LoadBootDrivers(PCHAR szSystemRoot, int nPos)
|
||||||
rc = RegOpenKey(NULL,
|
rc = RegOpenKey(NULL,
|
||||||
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder",
|
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder",
|
||||||
&hGroupKey);
|
&hGroupKey);
|
||||||
// printf("RegOpenKey(): rc %d\n", (int)rc);
|
DbgPrint((DPRINT_REACTOS, "RegOpenKey(): rc %d\n", (int)rc));
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -183,51 +183,50 @@ LoadBootDrivers(PCHAR szSystemRoot, int nPos)
|
||||||
rc = RegOpenKey(NULL,
|
rc = RegOpenKey(NULL,
|
||||||
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
|
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
|
||||||
&hServiceKey);
|
&hServiceKey);
|
||||||
// printf("RegOpenKey(): rc %d\n", (int)rc);
|
DbgPrint((DPRINT_REACTOS, "RegOpenKey(): rc %d\n", (int)rc));
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// printf("hKey: %x\n", (int)hKey);
|
DbgPrint((DPRINT_REACTOS, "hServiceKey: %x\n", (int)hServiceKey));
|
||||||
|
|
||||||
BufferSize = 256;
|
BufferSize = sizeof(ValueBuffer);
|
||||||
rc = RegQueryValue(hGroupKey, "List", NULL, (PUCHAR)ValueBuffer, &BufferSize);
|
rc = RegQueryValue(hGroupKey, "List", NULL, (PUCHAR)&ValueBuffer, &BufferSize);
|
||||||
// printf("RegQueryValue(): rc %d\n", (int)rc);
|
DbgPrint((DPRINT_REACTOS, "RegQueryValue(): rc %d\n", (int)rc));
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
DbgPrint((DPRINT_REACTOS, "BufferSize: %d \n", (int)BufferSize));
|
||||||
|
|
||||||
// printf("BufferSize: %d \n", (int)BufferSize);
|
DbgPrint((DPRINT_REACTOS, "ValueBuffer: '%s' \n", ValueBuffer));
|
||||||
|
|
||||||
// printf("ValueBuffer: '%s' \n", ValueBuffer);
|
|
||||||
|
|
||||||
GroupName = ValueBuffer;
|
GroupName = ValueBuffer;
|
||||||
while (*GroupName)
|
while (*GroupName)
|
||||||
{
|
{
|
||||||
// printf("Driver group: '%s'\n", GroupName);
|
DbgPrint((DPRINT_REACTOS, "Driver group: '%s'\n", GroupName));
|
||||||
|
|
||||||
/* enumerate all drivers */
|
/* enumerate all drivers */
|
||||||
Index = 0;
|
Index = 0;
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
ValueSize = 256;
|
ValueSize = sizeof(ValueBuffer);
|
||||||
rc = RegEnumKey(hServiceKey, Index, ServiceName, &ValueSize);
|
rc = RegEnumKey(hServiceKey, Index, ServiceName, &ValueSize);
|
||||||
// printf("RegEnumKey(): rc %d\n", (int)rc);
|
DbgPrint((DPRINT_REACTOS, "RegEnumKey(): rc %d\n", (int)rc));
|
||||||
if (rc == ERROR_NO_MORE_ITEMS)
|
if (rc == ERROR_NO_MORE_ITEMS)
|
||||||
break;
|
break;
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
return;
|
return;
|
||||||
// printf("Service %d: '%s'\n", (int)Index, ServiceName);
|
DbgPrint((DPRINT_REACTOS, "Service %d: '%s'\n", (int)Index, ServiceName));
|
||||||
|
|
||||||
/* open driver Key */
|
/* open driver Key */
|
||||||
rc = RegOpenKey(hServiceKey, ServiceName, &hDriverKey);
|
rc = RegOpenKey(hServiceKey, ServiceName, &hDriverKey);
|
||||||
|
|
||||||
ValueSize = sizeof(ULONG);
|
ValueSize = sizeof(ULONG);
|
||||||
rc = RegQueryValue(hDriverKey, "Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
|
rc = RegQueryValue(hDriverKey, "Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
|
||||||
// printf(" Start: %x \n", (int)StartValue);
|
DbgPrint((DPRINT_REACTOS, " Start: %x \n", (int)StartValue));
|
||||||
|
|
||||||
DriverGroupSize = 256;
|
DriverGroupSize = 256;
|
||||||
rc = RegQueryValue(hDriverKey, "Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
|
rc = RegQueryValue(hDriverKey, "Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
|
||||||
// printf(" Group: %s \n", DriverGroup);
|
DbgPrint((DPRINT_REACTOS, " Group: '%s' \n", DriverGroup));
|
||||||
|
|
||||||
if ((StartValue == 0) && (stricmp(DriverGroup, GroupName) == 0))
|
if ((StartValue == 0) && (stricmp(DriverGroup, GroupName) == 0))
|
||||||
{
|
{
|
||||||
|
@ -239,7 +238,7 @@ LoadBootDrivers(PCHAR szSystemRoot, int nPos)
|
||||||
&ValueSize);
|
&ValueSize);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
// printf(" ImagePath: not found\n");
|
DbgPrint((DPRINT_REACTOS, " ImagePath: not found\n"));
|
||||||
strcpy(ImagePath, szSystemRoot);
|
strcpy(ImagePath, szSystemRoot);
|
||||||
strcat(ImagePath, "system32\\drivers\\");
|
strcat(ImagePath, "system32\\drivers\\");
|
||||||
strcat(ImagePath, ServiceName);
|
strcat(ImagePath, ServiceName);
|
||||||
|
@ -247,15 +246,20 @@ LoadBootDrivers(PCHAR szSystemRoot, int nPos)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// printf(" ImagePath: '%s'\n", ImagePath);
|
DbgPrint((DPRINT_REACTOS, " ImagePath: '%s'\n", ImagePath));
|
||||||
}
|
}
|
||||||
// printf(" Loading driver: '%s'\n", ImagePath);
|
DbgPrint((DPRINT_REACTOS, " Loading driver: '%s'\n", ImagePath));
|
||||||
|
|
||||||
if (nPos < 100)
|
if (nPos < 100)
|
||||||
nPos += 5;
|
nPos += 5;
|
||||||
|
|
||||||
LoadDriver(ImagePath, nPos);
|
LoadDriver(ImagePath, nPos);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DbgPrint((DPRINT_REACTOS, " Skipping driver '%s' with Start %d and Group '%s' (Current group '%s')\n",
|
||||||
|
ImagePath, StartValue, DriverGroup, GroupName));
|
||||||
|
}
|
||||||
Index++;
|
Index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +267,6 @@ LoadBootDrivers(PCHAR szSystemRoot, int nPos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static BOOL
|
static BOOL
|
||||||
LoadNlsFiles(PCHAR szSystemRoot)
|
LoadNlsFiles(PCHAR szSystemRoot)
|
||||||
|
|
|
@ -207,9 +207,25 @@ getKeyValueTypeFromChunk (PCHAR regChunk, PCHAR dataFormat, int *keyValueType)
|
||||||
if (*regChunk == ':')
|
if (*regChunk == ':')
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
// UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *regChunk ? regChunk : 0;
|
return *regChunk ? regChunk : 0;
|
||||||
|
@ -256,9 +272,46 @@ computeKeyValueDataSize (PCHAR regChunk, PCHAR dataFormat)
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
// UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dataSize;
|
return dataSize;
|
||||||
|
@ -331,9 +384,48 @@ getKeyValueDataFromChunk (PCHAR regChunk, PCHAR dataFormat, PCHAR data)
|
||||||
}
|
}
|
||||||
memcpy(data, &ulValue, sizeof(ULONG));
|
memcpy(data, &ulValue, sizeof(ULONG));
|
||||||
}
|
}
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
// UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *regChunk ? regChunk : 0;
|
return *regChunk ? regChunk : 0;
|
||||||
|
@ -365,14 +457,13 @@ setKeyValue (HKEY currentKey,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
RegImportHive(PCHAR ChunkBase,
|
RegImportHive(PCHAR ChunkBase,
|
||||||
ULONG ChunkSize)
|
ULONG ChunkSize)
|
||||||
{
|
{
|
||||||
HKEY currentKey = NULL;
|
HKEY currentKey = INVALID_HANDLE_VALUE;
|
||||||
int newKeySize = 0;
|
|
||||||
char *newKeyName = NULL;
|
char *newKeyName = NULL;
|
||||||
|
int newKeySize;
|
||||||
char dataFormat [10];
|
char dataFormat [10];
|
||||||
int keyValueType;
|
int keyValueType;
|
||||||
int dataSize = 0;
|
int dataSize = 0;
|
||||||
|
@ -380,7 +471,7 @@ RegImportHive(PCHAR ChunkBase,
|
||||||
PVOID data = 0;
|
PVOID data = 0;
|
||||||
PCHAR regChunk;
|
PCHAR regChunk;
|
||||||
|
|
||||||
DbgPrint((DPRINT_REGISTRY, "ChunkBase 0x%x ChunkSize %d\n", ChunkBase, ChunkSize));
|
DbgPrint((DPRINT_REGISTRY, "ChunkBase %p ChunkSize %lx\n", ChunkBase, ChunkSize));
|
||||||
|
|
||||||
regChunk = checkAndSkipMagic (ChunkBase);
|
regChunk = checkAndSkipMagic (ChunkBase);
|
||||||
if (regChunk == 0)
|
if (regChunk == 0)
|
||||||
|
@ -394,13 +485,10 @@ RegImportHive(PCHAR ChunkBase,
|
||||||
|
|
||||||
if (*regChunk == '[')
|
if (*regChunk == '[')
|
||||||
{
|
{
|
||||||
DbgPrint((DPRINT_REGISTRY, "Line: %s\n", regChunk));
|
if (currentKey != INVALID_HANDLE_VALUE)
|
||||||
|
|
||||||
if (currentKey != NULL)
|
|
||||||
{
|
{
|
||||||
DbgPrint((DPRINT_REGISTRY, "Closing current key: 0x%lx\n", currentKey));
|
DbgPrint((DPRINT_REGISTRY, "Closing current key: 0x%lx\n", currentKey));
|
||||||
|
currentKey = INVALID_HANDLE_VALUE;
|
||||||
currentKey = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
regChunk++;
|
regChunk++;
|
||||||
|
@ -417,7 +505,7 @@ RegImportHive(PCHAR ChunkBase,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
currentKey = createNewKey (newKeyName);
|
currentKey = createNewKey (newKeyName);
|
||||||
if (currentKey == NULL)
|
if (currentKey == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
regChunk = skipToNextKeyInChunk (regChunk);
|
regChunk = skipToNextKeyInChunk (regChunk);
|
||||||
continue;
|
continue;
|
||||||
|
@ -427,13 +515,13 @@ RegImportHive(PCHAR ChunkBase,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (currentKey == NULL)
|
if (currentKey == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
regChunk = skipToNextKeyInChunk (regChunk);
|
regChunk = skipToNextKeyInChunk (regChunk);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
newKeySize = computeKeyValueNameSize(regChunk);
|
newKeySize = computeKeyValueNameSize (regChunk);
|
||||||
if (!allocateKeyName (&newKeyName, newKeySize))
|
if (!allocateKeyName (&newKeyName, newKeySize))
|
||||||
{
|
{
|
||||||
regChunk = 0;
|
regChunk = 0;
|
||||||
|
@ -474,10 +562,16 @@ RegImportHive(PCHAR ChunkBase,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentKey != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
DbgPrint((DPRINT_REGISTRY, "Closing current key: 0x%lx\n", currentKey));
|
||||||
|
}
|
||||||
|
|
||||||
if (newKeyName != NULL)
|
if (newKeyName != NULL)
|
||||||
{
|
{
|
||||||
MmFreeMemory(newKeyName);
|
MmFreeMemory(newKeyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
{
|
{
|
||||||
MmFreeMemory(data);
|
MmFreeMemory(data);
|
||||||
|
@ -486,62 +580,9 @@ RegImportHive(PCHAR ChunkBase,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
static PCHAR
|
|
||||||
bprintf(char *buffer, char *format, ... )
|
|
||||||
{
|
|
||||||
int *dataptr = (int *) &format;
|
|
||||||
char c, *ptr, str[16];
|
|
||||||
char *p = buffer;
|
|
||||||
|
|
||||||
dataptr++;
|
|
||||||
|
|
||||||
while ((c = *(format++)))
|
|
||||||
{
|
|
||||||
if (c != '%')
|
|
||||||
{
|
|
||||||
*p = c;
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
switch (c = *(format++))
|
|
||||||
{
|
|
||||||
case 'd': case 'u': case 'x':
|
|
||||||
*convert_to_ascii(str, c, *((unsigned long *) dataptr++)) = 0;
|
|
||||||
|
|
||||||
ptr = str;
|
|
||||||
|
|
||||||
while (*ptr)
|
|
||||||
{
|
|
||||||
*p = *(ptr++);
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'c':
|
|
||||||
*p = (*(dataptr++))&0xff;
|
|
||||||
p++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 's':
|
|
||||||
ptr = (char *)(*(dataptr++));
|
|
||||||
|
|
||||||
while ((c = *(ptr++)))
|
|
||||||
{
|
|
||||||
*p = c;
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(p);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
RegExportHive(PCHAR ChunkBase, PULONG ChunkSize)
|
RegExportHive(PCHAR ChunkBase, PULONG ChunkSize)
|
||||||
{
|
{
|
||||||
|
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -421,7 +421,7 @@ RegQueryValue(HKEY Key,
|
||||||
VALUE,
|
VALUE,
|
||||||
ValueList);
|
ValueList);
|
||||||
|
|
||||||
DbgPrint((DPRINT_REGISTRY, "Value name '%s'\n", Value->Name));
|
DbgPrint((DPRINT_REGISTRY, "Searching for '%s'. Value name '%s'\n", ValueName, Value->Name));
|
||||||
|
|
||||||
if (stricmp(Value->Name, ValueName) == 0)
|
if (stricmp(Value->Name, ValueName) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue