diff --git a/freeldr/freeldr/reactos/hwdetect.c b/freeldr/freeldr/reactos/hwdetect.c index 7d90b093a63..5c530baf865 100644 --- a/freeldr/freeldr/reactos/hwdetect.c +++ b/freeldr/freeldr/reactos/hwdetect.c @@ -20,20 +20,9 @@ #include #include - -//#define NDEBUG +#include VOID DetectHardware(VOID) { - -#ifndef NDEBUG - printf("DetectHardware() called\n"); -#endif - - -#ifndef NDEBUG - printf("DetectHardware() done\n"); -#endif -//for(;;); } diff --git a/freeldr/freeldr/reactos/reactos.c b/freeldr/freeldr/reactos/reactos.c index 4ec8ef195ce..fc0c36453dd 100644 --- a/freeldr/freeldr/reactos/reactos.c +++ b/freeldr/freeldr/reactos/reactos.c @@ -157,7 +157,7 @@ LoadBootDrivers(PCHAR szSystemRoot, int nPos) { LONG rc = 0; HKEY hGroupKey, hServiceKey, hDriverKey; - char ValueBuffer[256]; + char ValueBuffer[512]; char ServiceName[256]; ULONG BufferSize; ULONG Index; @@ -175,7 +175,7 @@ LoadBootDrivers(PCHAR szSystemRoot, int nPos) rc = RegOpenKey(NULL, "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder", &hGroupKey); -// printf("RegOpenKey(): rc %d\n", (int)rc); + DbgPrint((DPRINT_REACTOS, "RegOpenKey(): rc %d\n", (int)rc)); if (rc != ERROR_SUCCESS) return; @@ -183,51 +183,50 @@ LoadBootDrivers(PCHAR szSystemRoot, int nPos) rc = RegOpenKey(NULL, "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services", &hServiceKey); -// printf("RegOpenKey(): rc %d\n", (int)rc); + DbgPrint((DPRINT_REACTOS, "RegOpenKey(): rc %d\n", (int)rc)); if (rc != ERROR_SUCCESS) return; -// printf("hKey: %x\n", (int)hKey); + DbgPrint((DPRINT_REACTOS, "hServiceKey: %x\n", (int)hServiceKey)); - BufferSize = 256; - rc = RegQueryValue(hGroupKey, "List", NULL, (PUCHAR)ValueBuffer, &BufferSize); -// printf("RegQueryValue(): rc %d\n", (int)rc); + BufferSize = sizeof(ValueBuffer); + rc = RegQueryValue(hGroupKey, "List", NULL, (PUCHAR)&ValueBuffer, &BufferSize); + DbgPrint((DPRINT_REACTOS, "RegQueryValue(): rc %d\n", (int)rc)); if (rc != ERROR_SUCCESS) return; + DbgPrint((DPRINT_REACTOS, "BufferSize: %d \n", (int)BufferSize)); -// printf("BufferSize: %d \n", (int)BufferSize); - -// printf("ValueBuffer: '%s' \n", ValueBuffer); + DbgPrint((DPRINT_REACTOS, "ValueBuffer: '%s' \n", ValueBuffer)); GroupName = ValueBuffer; while (*GroupName) { -// printf("Driver group: '%s'\n", GroupName); + DbgPrint((DPRINT_REACTOS, "Driver group: '%s'\n", GroupName)); /* enumerate all drivers */ Index = 0; while (TRUE) { - ValueSize = 256; + ValueSize = sizeof(ValueBuffer); 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) break; if (rc != ERROR_SUCCESS) return; -// printf("Service %d: '%s'\n", (int)Index, ServiceName); + DbgPrint((DPRINT_REACTOS, "Service %d: '%s'\n", (int)Index, ServiceName)); /* open driver Key */ rc = RegOpenKey(hServiceKey, ServiceName, &hDriverKey); ValueSize = sizeof(ULONG); rc = RegQueryValue(hDriverKey, "Start", &ValueType, (PUCHAR)&StartValue, &ValueSize); -// printf(" Start: %x \n", (int)StartValue); + DbgPrint((DPRINT_REACTOS, " Start: %x \n", (int)StartValue)); DriverGroupSize = 256; 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)) { @@ -239,7 +238,7 @@ LoadBootDrivers(PCHAR szSystemRoot, int nPos) &ValueSize); if (rc != ERROR_SUCCESS) { -// printf(" ImagePath: not found\n"); + DbgPrint((DPRINT_REACTOS, " ImagePath: not found\n")); strcpy(ImagePath, szSystemRoot); strcat(ImagePath, "system32\\drivers\\"); strcat(ImagePath, ServiceName); @@ -247,15 +246,20 @@ LoadBootDrivers(PCHAR szSystemRoot, int nPos) } 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) nPos += 5; 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++; } @@ -263,7 +267,6 @@ LoadBootDrivers(PCHAR szSystemRoot, int nPos) } } - #if 0 static BOOL LoadNlsFiles(PCHAR szSystemRoot) diff --git a/freeldr/freeldr/reactos/reghive.c b/freeldr/freeldr/reactos/reghive.c index 7a1fed3f21f..73ec1151f92 100644 --- a/freeldr/freeldr/reactos/reghive.c +++ b/freeldr/freeldr/reactos/reghive.c @@ -207,9 +207,25 @@ getKeyValueTypeFromChunk (PCHAR regChunk, PCHAR dataFormat, int *keyValueType) 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; + UNIMPLEMENTED; } return *regChunk ? regChunk : 0; @@ -256,9 +272,46 @@ computeKeyValueDataSize (PCHAR regChunk, PCHAR dataFormat) 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; + UNIMPLEMENTED; } return dataSize; @@ -331,9 +384,48 @@ getKeyValueDataFromChunk (PCHAR regChunk, PCHAR dataFormat, PCHAR data) } 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 { -// UNIMPLEMENTED; + UNIMPLEMENTED; } return *regChunk ? regChunk : 0; @@ -365,14 +457,13 @@ setKeyValue (HKEY currentKey, return TRUE; } - VOID RegImportHive(PCHAR ChunkBase, ULONG ChunkSize) { - HKEY currentKey = NULL; - int newKeySize = 0; + HKEY currentKey = INVALID_HANDLE_VALUE; char *newKeyName = NULL; + int newKeySize; char dataFormat [10]; int keyValueType; int dataSize = 0; @@ -380,7 +471,7 @@ RegImportHive(PCHAR ChunkBase, PVOID data = 0; 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); if (regChunk == 0) @@ -394,13 +485,10 @@ RegImportHive(PCHAR ChunkBase, if (*regChunk == '[') { - DbgPrint((DPRINT_REGISTRY, "Line: %s\n", regChunk)); - - if (currentKey != NULL) + if (currentKey != INVALID_HANDLE_VALUE) { DbgPrint((DPRINT_REGISTRY, "Closing current key: 0x%lx\n", currentKey)); - - currentKey = NULL; + currentKey = INVALID_HANDLE_VALUE; } regChunk++; @@ -417,7 +505,7 @@ RegImportHive(PCHAR ChunkBase, continue; currentKey = createNewKey (newKeyName); - if (currentKey == NULL) + if (currentKey == INVALID_HANDLE_VALUE) { regChunk = skipToNextKeyInChunk (regChunk); continue; @@ -427,13 +515,13 @@ RegImportHive(PCHAR ChunkBase, } else { - if (currentKey == NULL) + if (currentKey == INVALID_HANDLE_VALUE) { regChunk = skipToNextKeyInChunk (regChunk); continue; } - newKeySize = computeKeyValueNameSize(regChunk); + newKeySize = computeKeyValueNameSize (regChunk); if (!allocateKeyName (&newKeyName, newKeySize)) { 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) { MmFreeMemory(newKeyName); } + if (data != NULL) { MmFreeMemory(data); @@ -486,62 +580,9 @@ RegImportHive(PCHAR ChunkBase, 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 RegExportHive(PCHAR ChunkBase, PULONG ChunkSize) { - return(TRUE); } diff --git a/freeldr/freeldr/reactos/registry.c b/freeldr/freeldr/reactos/registry.c index 44df8b81a6d..ccded9fec2b 100644 --- a/freeldr/freeldr/reactos/registry.c +++ b/freeldr/freeldr/reactos/registry.c @@ -421,7 +421,7 @@ RegQueryValue(HKEY Key, VALUE, 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) break;