- Changed all registry functions to WCHAR.

- Implemented packed/unpacked names for keys and values.    
- Fixed the hash values for very short data.  
- Fixed the debug build.    
- Don't search for a serial mouse, if the port is used for debug prints.

svn path=/trunk/; revision=19329
This commit is contained in:
Hartmut Birr
2005-11-18 22:04:17 +00:00
parent 0bfe9a412e
commit aebe29f1ef
21 changed files with 580 additions and 585 deletions
+119 -116
View File
@@ -117,7 +117,7 @@ typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK
} __attribute__((packed)) CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK;
static char Hex[] = "0123456789ABCDEF";
static WCHAR Hex[] = L"0123456789ABCDEF";
static unsigned int delay_count = 1;
@@ -247,7 +247,7 @@ SetComponentInformation(FRLDRHKEY ComponentKey,
/* Set 'Component Information' value */
Error = RegSetValue(ComponentKey,
"Component Information",
L"Component Information",
REG_BINARY,
(PCHAR)&CompInfo,
sizeof(CM_COMPONENT_INFORMATION));
@@ -264,7 +264,7 @@ DetectPnpBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PNP_BIOS_DEVICE_NODE DeviceNode;
PCM_PNP_BIOS_INSTALLATION_CHECK InstData;
char Buffer[80];
WCHAR Buffer[80];
FRLDRHKEY BusKey;
ULONG x;
ULONG NodeSize = 0;
@@ -302,8 +302,8 @@ DetectPnpBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
DbgPrint((DPRINT_HWDETECT, "Estimated buffer size %u\n", NodeSize * NodeCount));
/* Create new bus key */
sprintf(Buffer,
"MultifunctionAdapter\\%u", *BusNumber);
swprintf(Buffer,
L"MultifunctionAdapter\\%u", *BusNumber);
Error = RegCreateKey(SystemKey,
Buffer,
&BusKey);
@@ -324,10 +324,10 @@ DetectPnpBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
/* Set 'Identifier' value */
Error = RegSetValue(BusKey,
"Identifier",
L"Identifier",
REG_SZ,
"PNP BIOS",
9);
(PCHAR)L"PNP BIOS",
9 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@@ -402,7 +402,7 @@ DetectPnpBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
/* Set 'Configuration Data' value */
Error = RegSetValue(BusKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
@@ -484,7 +484,7 @@ SetHarddiskConfigurationData(FRLDRHKEY DiskKey,
DiskGeometry->BytesPerSector));
Error = RegSetValue(DiskKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
@@ -507,7 +507,7 @@ SetHarddiskIdentifier(FRLDRHKEY DiskKey,
ULONG i;
ULONG Checksum;
ULONG Signature;
CHAR Identifier[20];
WCHAR Identifier[20];
LONG Error;
/* Read the MBR */
@@ -541,7 +541,7 @@ SetHarddiskIdentifier(FRLDRHKEY DiskKey,
Identifier[5] = Hex[(Checksum >> 8) & 0x0F];
Identifier[6] = Hex[(Checksum >> 4) & 0x0F];
Identifier[7] = Hex[Checksum & 0x0F];
Identifier[8] = '-';
Identifier[8] = L'-';
Identifier[9] = Hex[(Signature >> 28) & 0x0F];
Identifier[10] = Hex[(Signature >> 24) & 0x0F];
Identifier[11] = Hex[(Signature >> 20) & 0x0F];
@@ -550,17 +550,17 @@ SetHarddiskIdentifier(FRLDRHKEY DiskKey,
Identifier[14] = Hex[(Signature >> 8) & 0x0F];
Identifier[15] = Hex[(Signature >> 4) & 0x0F];
Identifier[16] = Hex[Signature & 0x0F];
Identifier[17] = '-';
Identifier[18] = 'A';
Identifier[17] = L'-';
Identifier[18] = L'A';
Identifier[19] = 0;
DbgPrint((DPRINT_HWDETECT, "Identifier: %x\n", Identifier));
DbgPrint((DPRINT_HWDETECT, "Identifier: %S\n", Identifier));
/* Set identifier */
Error = RegSetValue(DiskKey,
"Identifier",
L"Identifier",
REG_SZ,
Identifier,
20);
(PCHAR)Identifier,
sizeof(Identifier));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
@@ -577,7 +577,7 @@ DetectBiosDisks(FRLDRHKEY SystemKey,
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_INT13_DRIVE_PARAMETER Int13Drives;
GEOMETRY Geometry;
CHAR Buffer[80];
WCHAR Buffer[80];
FRLDRHKEY DiskKey;
ULONG DiskCount;
ULONG Size;
@@ -662,7 +662,7 @@ DetectBiosDisks(FRLDRHKEY SystemKey,
/* Set 'Configuration Data' value */
Error = RegSetValue(SystemKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
@@ -679,9 +679,9 @@ DetectBiosDisks(FRLDRHKEY SystemKey,
for (i = 0; i < DiskCount; i++)
{
/* Create disk key */
sprintf (Buffer,
"DiskController\\0\\DiskPeripheral\\%u",
i);
swprintf (Buffer,
L"DiskController\\0\\DiskPeripheral\\%u",
i);
Error = RegCreateKey(BusKey,
Buffer,
@@ -691,7 +691,7 @@ DetectBiosDisks(FRLDRHKEY SystemKey,
DbgPrint((DPRINT_HWDETECT, "Failed to create drive key\n"));
continue;
}
DbgPrint((DPRINT_HWDETECT, "Created key: %s\n", Buffer));
DbgPrint((DPRINT_HWDETECT, "Created key: %S\n", Buffer));
/* Set disk values */
SetHarddiskConfigurationData(DiskKey, 0x80 + i);
@@ -745,8 +745,8 @@ DetectBiosFloppyPeripheral(FRLDRHKEY ControllerKey)
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
PCM_FLOPPY_DEVICE_DATA FloppyData;
char KeyName[32];
char Identifier[20];
WCHAR KeyName[32];
WCHAR Identifier[20];
FRLDRHKEY PeripheralKey;
ULONG Size;
LONG Error;
@@ -766,10 +766,10 @@ DetectBiosFloppyPeripheral(FRLDRHKEY ControllerKey)
Ptr = GetInt1eTable();
sprintf(KeyName, "FloppyDiskPeripheral\\%u", FloppyNumber);
swprintf(KeyName, L"FloppyDiskPeripheral\\%u", FloppyNumber);
Error = RegCreateKey(ControllerKey,
"FloppyDiskPeripheral\\0",
KeyName,
&PeripheralKey);
if (Error != ERROR_SUCCESS)
{
@@ -777,7 +777,7 @@ DetectBiosFloppyPeripheral(FRLDRHKEY ControllerKey)
return;
}
DbgPrint((DPRINT_HWDETECT, "Created key: %s\n", KeyName));
DbgPrint((DPRINT_HWDETECT, "Created key: %S\n", KeyName));
/* Set 'ComponentInformation' value */
SetComponentInformation(PeripheralKey,
@@ -818,7 +818,7 @@ DetectBiosFloppyPeripheral(FRLDRHKEY ControllerKey)
/* Set 'Configuration Data' value */
Error = RegSetValue(PeripheralKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
@@ -832,12 +832,12 @@ DetectBiosFloppyPeripheral(FRLDRHKEY ControllerKey)
}
/* Set 'Identifier' value */
sprintf(Identifier, "FLOPPY%u", FloppyNumber + 1);
swprintf(Identifier, L"FLOPPY%u", FloppyNumber + 1);
Error = RegSetValue(PeripheralKey,
"Identifier",
L"Identifier",
REG_SZ,
(PCHAR)Identifier,
strlen(Identifier) + 1);
(wcslen(Identifier) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
@@ -868,7 +868,7 @@ DetectBiosFloppyController(FRLDRHKEY SystemKey,
return;
Error = RegCreateKey(BusKey,
"DiskController\\0",
L"DiskController\\0",
&ControllerKey);
if (Error != ERROR_SUCCESS)
{
@@ -928,7 +928,7 @@ DetectBiosFloppyController(FRLDRHKEY SystemKey,
/* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
@@ -1112,12 +1112,13 @@ DetectSerialPointerPeripheral(FRLDRHKEY ControllerKey,
{
CM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
char Buffer[256];
char Identifier[256];
WCHAR Identifier[256];
FRLDRHKEY PeripheralKey;
ULONG MouseType;
ULONG Length;
ULONG i;
ULONG j;
ULONG k;
LONG Error;
DbgPrint((DPRINT_HWDETECT,
@@ -1150,12 +1151,13 @@ DetectSerialPointerPeripheral(FRLDRHKEY ControllerKey,
Buffer));
/* Copy PnpId string */
memcpy(&Identifier[0],
&Buffer[3],
7);
memcpy(&Identifier[7],
" - ",
4);
for (i = 0; i < 7; i++)
{
Identifier[i] = Buffer[3+i];
}
memcpy(&Identifier[7],
L" - ",
3 * sizeof(WCHAR));
/* Skip device serial number */
i = 10;
@@ -1209,43 +1211,44 @@ DetectSerialPointerPeripheral(FRLDRHKEY ControllerKey,
i -= 3;
if (i > j + 1)
{
memcpy(&Identifier[10],
&Buffer[j],
i - j);
for (k = 0; k < i - j; k++)
{
Identifier[k + 10] = Buffer[k + j];
}
Identifier[10 + (i-j)] = 0;
}
}
DbgPrint((DPRINT_HWDETECT,
"Identifier string: %s\n",
"Identifier string: %S\n",
Identifier));
}
if (Length == 0 || strlen(Identifier) < 11)
if (Length == 0 || wcslen(Identifier) < 11)
{
switch (MouseType)
{
case MOUSE_TYPE_LOGITECH:
strcpy (Identifier,
"LOGITECH SERIAL MOUSE");
wcscpy (Identifier,
L"LOGITECH SERIAL MOUSE");
break;
case MOUSE_TYPE_WHEELZ:
strcpy (Identifier,
"MICROSOFT SERIAL MOUSE WITH WHEEL");
wcscpy (Identifier,
L"MICROSOFT SERIAL MOUSE WITH WHEEL");
break;
case MOUSE_TYPE_MICROSOFT:
default:
strcpy (Identifier,
"MICROSOFT SERIAL MOUSE");
wcscpy (Identifier,
L"MICROSOFT SERIAL MOUSE");
break;
}
}
/* Create 'PointerPeripheral' key */
Error = RegCreateKey(ControllerKey,
"PointerPeripheral\\0",
L"PointerPeripheral\\0",
&PeripheralKey);
if (Error != ERROR_SUCCESS)
{
@@ -1269,7 +1272,7 @@ DetectSerialPointerPeripheral(FRLDRHKEY ControllerKey,
FullResourceDescriptor.PartialResourceList.Count = 0;
Error = RegSetValue(PeripheralKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)&FullResourceDescriptor,
sizeof(CM_FULL_RESOURCE_DESCRIPTOR) -
@@ -1283,10 +1286,10 @@ DetectSerialPointerPeripheral(FRLDRHKEY ControllerKey,
/* Set 'Identifier' value */
Error = RegSetValue(PeripheralKey,
"Identifier",
L"Identifier",
REG_SZ,
Identifier,
strlen(Identifier) + 1);
(PCHAR)Identifier,
(wcslen(Identifier) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
@@ -1305,7 +1308,7 @@ DetectSerialPorts(FRLDRHKEY BusKey)
PCM_SERIAL_DEVICE_DATA SerialDeviceData;
ULONG Irq[4] = {4, 3, 4, 3};
ULONG Base;
char Buffer[80];
WCHAR Buffer[80];
PUSHORT BasePtr;
ULONG ControllerNumber = 0;
FRLDRHKEY ControllerKey;
@@ -1329,8 +1332,8 @@ DetectSerialPorts(FRLDRHKEY BusKey)
Base));
/* Create controller key */
sprintf(Buffer,
"SerialController\\%u",
swprintf(Buffer,
L"SerialController\\%u",
ControllerNumber);
Error = RegCreateKey(BusKey,
@@ -1341,7 +1344,7 @@ DetectSerialPorts(FRLDRHKEY BusKey)
DbgPrint((DPRINT_HWDETECT, "Failed to create controller key\n"));
continue;
}
DbgPrint((DPRINT_HWDETECT, "Created key: %s\n", Buffer));
DbgPrint((DPRINT_HWDETECT, "Created key: %S\n", Buffer));
/* Set 'ComponentInformation' value */
SetComponentInformation(ControllerKey,
@@ -1398,7 +1401,7 @@ DetectSerialPorts(FRLDRHKEY BusKey)
/* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
@@ -1411,14 +1414,14 @@ DetectSerialPorts(FRLDRHKEY BusKey)
}
/* Set 'Identifier' value */
sprintf(Buffer,
"COM%u",
i + 1);
swprintf(Buffer,
L"COM%u",
i + 1);
Error = RegSetValue(ControllerKey,
"Identifier",
L"Identifier",
REG_SZ,
Buffer,
strlen(Buffer) + 1);
(PCHAR)Buffer,
(wcslen(Buffer) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
@@ -1430,8 +1433,11 @@ DetectSerialPorts(FRLDRHKEY BusKey)
"Created value: Identifier %s\n",
Buffer));
/* Detect serial mouse */
DetectSerialPointerPeripheral(ControllerKey, Base);
if (!Rs232PortInUse(Base))
{
/* Detect serial mouse */
DetectSerialPointerPeripheral(ControllerKey, Base);
}
ControllerNumber++;
}
@@ -1444,7 +1450,7 @@ DetectParallelPorts(FRLDRHKEY BusKey)
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
ULONG Irq[3] = {7, 5, (ULONG)-1};
char Buffer[80];
WCHAR Buffer[80];
FRLDRHKEY ControllerKey;
PUSHORT BasePtr;
ULONG Base;
@@ -1469,9 +1475,9 @@ DetectParallelPorts(FRLDRHKEY BusKey)
Base));
/* Create controller key */
sprintf(Buffer,
"ParallelController\\%u",
ControllerNumber);
swprintf(Buffer,
L"ParallelController\\%u",
ControllerNumber);
Error = RegCreateKey(BusKey,
Buffer,
@@ -1481,7 +1487,7 @@ DetectParallelPorts(FRLDRHKEY BusKey)
DbgPrint((DPRINT_HWDETECT, "Failed to create controller key\n"));
continue;
}
DbgPrint((DPRINT_HWDETECT, "Created key: %s\n", Buffer));
DbgPrint((DPRINT_HWDETECT, "Created key: %S\n", Buffer));
/* Set 'ComponentInformation' value */
SetComponentInformation(ControllerKey,
@@ -1531,7 +1537,7 @@ DetectParallelPorts(FRLDRHKEY BusKey)
/* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
@@ -1544,14 +1550,14 @@ DetectParallelPorts(FRLDRHKEY BusKey)
}
/* Set 'Identifier' value */
sprintf(Buffer,
"PARALLEL%u",
swprintf(Buffer,
L"PARALLEL%u",
i + 1);
Error = RegSetValue(ControllerKey,
"Identifier",
L"Identifier",
REG_SZ,
Buffer,
strlen(Buffer) + 1);
(PCHAR)Buffer,
(wcslen(Buffer) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
@@ -1637,7 +1643,6 @@ DetectKeyboardPeripheral(FRLDRHKEY ControllerKey)
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
PCM_KEYBOARD_DEVICE_DATA KeyboardData;
FRLDRHKEY PeripheralKey;
char Buffer[80];
ULONG Size;
LONG Error;
@@ -1645,7 +1650,7 @@ DetectKeyboardPeripheral(FRLDRHKEY ControllerKey)
{
/* Create controller key */
Error = RegCreateKey(ControllerKey,
"KeyboardPeripheral\\0",
L"KeyboardPeripheral\\0",
&PeripheralKey);
if (Error != ERROR_SUCCESS)
{
@@ -1691,7 +1696,7 @@ DetectKeyboardPeripheral(FRLDRHKEY ControllerKey)
/* Set 'Configuration Data' value */
Error = RegSetValue(PeripheralKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)FullResourceDescriptor,
Size);
@@ -1704,13 +1709,11 @@ DetectKeyboardPeripheral(FRLDRHKEY ControllerKey)
}
/* Set 'Identifier' value */
strcpy(Buffer,
"PCAT_ENHANCED");
Error = RegSetValue(PeripheralKey,
"Identifier",
L"Identifier",
REG_SZ,
Buffer,
strlen(Buffer) + 1);
(PCHAR)L"PCAT_ENHANCED",
14 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
@@ -1732,7 +1735,7 @@ DetectKeyboardController(FRLDRHKEY BusKey)
/* Create controller key */
Error = RegCreateKey(BusKey,
"KeyboardController\\0",
L"KeyboardController\\0",
&ControllerKey);
if (Error != ERROR_SUCCESS)
{
@@ -1793,7 +1796,7 @@ DetectKeyboardController(FRLDRHKEY BusKey)
/* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)FullResourceDescriptor,
Size);
@@ -1929,7 +1932,7 @@ DetectPS2Mouse(FRLDRHKEY BusKey)
/* Create controller key */
Error = RegCreateKey(BusKey,
"PointerController\\0",
L"PointerController\\0",
&ControllerKey);
if (Error != ERROR_SUCCESS)
{
@@ -1961,7 +1964,7 @@ DetectPS2Mouse(FRLDRHKEY BusKey)
/* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)&FullResourceDescriptor,
sizeof(CM_FULL_RESOURCE_DESCRIPTOR));
@@ -1980,7 +1983,7 @@ DetectPS2Mouse(FRLDRHKEY BusKey)
/* Create peripheral key */
Error = RegCreateKey(ControllerKey,
"PointerPeripheral\\0",
L"PointerPeripheral\\0",
&PeripheralKey);
if (Error != ERROR_SUCCESS)
{
@@ -2003,7 +2006,7 @@ DetectPS2Mouse(FRLDRHKEY BusKey)
/* Set 'Configuration Data' value */
Error = RegSetValue(PeripheralKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)&FullResourceDescriptor,
sizeof(CM_FULL_RESOURCE_DESCRIPTOR) -
@@ -2018,10 +2021,10 @@ DetectPS2Mouse(FRLDRHKEY BusKey)
/* Set 'Identifier' value */
Error = RegSetValue(PeripheralKey,
"Identifier",
L"Identifier",
REG_SZ,
"MICROSOFT PS2 MOUSE",
20);
(PCHAR)L"MICROSOFT PS2 MOUSE",
20 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
@@ -2037,13 +2040,13 @@ DetectPS2Mouse(FRLDRHKEY BusKey)
static VOID
DetectDisplayController(FRLDRHKEY BusKey)
{
CHAR Buffer[80];
WCHAR Buffer[80];
FRLDRHKEY ControllerKey;
USHORT VesaVersion;
LONG Error;
Error = RegCreateKey(BusKey,
"DisplayController\\0",
L"DisplayController\\0",
&ControllerKey);
if (Error != ERROR_SUCCESS)
{
@@ -2076,21 +2079,21 @@ DetectDisplayController(FRLDRHKEY BusKey)
if (VesaVersion >= 0x0200)
{
strcpy(Buffer,
"VBE Display");
wcscpy(Buffer,
L"VBE Display");
}
else
{
strcpy(Buffer,
"VGA Display");
wcscpy(Buffer,
L"VGA Display");
}
/* Set 'Identifier' value */
Error = RegSetValue(ControllerKey,
"Identifier",
L"Identifier",
REG_SZ,
Buffer,
strlen(Buffer) + 1);
(PCHAR)Buffer,
(wcslen(Buffer) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT,
@@ -2107,14 +2110,14 @@ static VOID
DetectIsaBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
char Buffer[80];
WCHAR Buffer[80];
FRLDRHKEY BusKey;
ULONG Size;
LONG Error;
/* Create new bus key */
sprintf(Buffer,
"MultifunctionAdapter\\%u", *BusNumber);
swprintf(Buffer,
L"MultifunctionAdapter\\%u", *BusNumber);
Error = RegCreateKey(SystemKey,
Buffer,
&BusKey);
@@ -2135,10 +2138,10 @@ DetectIsaBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
/* Set 'Identifier' value */
Error = RegSetValue(BusKey,
"Identifier",
L"Identifier",
REG_SZ,
"ISA",
4);
(PCHAR)L"ISA",
4 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@@ -2164,7 +2167,7 @@ DetectIsaBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
/* Set 'Configuration Data' value */
Error = RegSetValue(BusKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
@@ -2207,7 +2210,7 @@ PcHwDetect(VOID)
/* Create the 'System' key */
Error = RegCreateKey(NULL,
"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
&SystemKey);
if (Error != ERROR_SUCCESS)
{
@@ -53,7 +53,7 @@ FindAcpiBios(VOID)
VOID
DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
char Buffer[80];
WCHAR Buffer[80];
FRLDRHKEY BiosKey;
LONG Error;
@@ -61,8 +61,8 @@ DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
AcpiPresent = TRUE;
/* Create new bus key */
sprintf(Buffer,
"MultifunctionAdapter\\%u", *BusNumber);
swprintf(Buffer,
L"MultifunctionAdapter\\%u", *BusNumber);
Error = RegCreateKey(SystemKey,
Buffer,
&BiosKey);
@@ -85,10 +85,10 @@ DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
/* Set 'Identifier' value */
Error = RegSetValue(BiosKey,
"Identifier",
L"Identifier",
REG_SZ,
"ACPI BIOS",
10);
(PCHAR)L"ACPI BIOS",
10 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@@ -56,15 +56,15 @@ FindApmBios(VOID)
VOID
DetectApmBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
char Buffer[80];
WCHAR Buffer[80];
FRLDRHKEY BiosKey;
LONG Error;
if (FindApmBios())
{
/* Create new bus key */
sprintf(Buffer,
"MultifunctionAdapter\\%u", *BusNumber);
swprintf(Buffer,
L"MultifunctionAdapter\\%u", *BusNumber);
Error = RegCreateKey(SystemKey,
Buffer,
&BiosKey);
@@ -87,10 +87,10 @@ DetectApmBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
/* Set 'Identifier' value */
Error = RegSetValue(BiosKey,
"Identifier",
L"Identifier",
REG_SZ,
"APM",
4);
(PCHAR)L"APM",
4 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
+54 -50
View File
@@ -105,8 +105,9 @@ static VOID
DetectCPU(FRLDRHKEY CpuKey,
FRLDRHKEY FpuKey)
{
CHAR VendorIdentifier[13];
CHAR Identifier[64];
WCHAR VendorIdentifier[13];
CHAR tmpVendorIdentifier[13];
WCHAR Identifier[64];
ULONG FeatureSet;
FRLDRHKEY CpuInstKey;
FRLDRHKEY FpuInstKey;
@@ -122,7 +123,7 @@ DetectCPU(FRLDRHKEY CpuKey,
/* Create the CPU instance key */
Error = RegCreateKey(CpuKey,
"0",
L"0",
&CpuInstKey);
if (Error != ERROR_SUCCESS)
{
@@ -132,7 +133,7 @@ DetectCPU(FRLDRHKEY CpuKey,
/* Create the FPU instance key */
Error = RegCreateKey(FpuKey,
"0",
L"0",
&FpuInstKey);
if (Error != ERROR_SUCCESS)
{
@@ -147,21 +148,22 @@ DetectCPU(FRLDRHKEY CpuKey,
/* Get vendor identifier */
GetCpuid(0, &eax, &ebx, &ecx, &edx);
VendorIdentifier[12] = 0;
Ptr = (ULONG*)&VendorIdentifier[0];
tmpVendorIdentifier[12] = 0;
Ptr = (ULONG*)&tmpVendorIdentifier[0];
*Ptr = ebx;
Ptr++;
*Ptr = edx;
Ptr++;
*Ptr = ecx;
swprintf(VendorIdentifier, L"%s", tmpVendorIdentifier);
/* Get Identifier */
GetCpuid(1, &eax, &ebx, &ecx, &edx);
sprintf(Identifier,
"x86 Family %u Model %u Stepping %u",
(unsigned int)((eax >> 8) & 0x0F),
(unsigned int)((eax >> 4) & 0x0F),
(unsigned int)(eax & 0x0F));
swprintf(Identifier,
L"x86 Family %u Model %u Stepping %u",
(unsigned int)((eax >> 8) & 0x0F),
(unsigned int)((eax >> 4) & 0x0F),
(unsigned int)(eax & 0x0F));
FeatureSet = edx;
if (((eax >> 8) & 0x0F) >= 5)
SupportTSC = TRUE;
@@ -170,9 +172,9 @@ DetectCPU(FRLDRHKEY CpuKey,
{
DbgPrint((DPRINT_HWDETECT, "CPUID not supported\n"));
strcpy(VendorIdentifier, "Unknown");
sprintf(Identifier,
"x86 Family %u Model %u Stepping %u",
wcscpy(VendorIdentifier, L"Unknown");
swprintf(Identifier,
L"x86 Family %u Model %u Stepping %u",
(unsigned int)((eax >> 8) & 0x0F),
(unsigned int)((eax >> 4) & 0x0F),
(unsigned int)(eax & 0x0F));
@@ -187,7 +189,7 @@ DetectCPU(FRLDRHKEY CpuKey,
DbgPrint((DPRINT_HWDETECT, "FeatureSet: %x\n", FeatureSet));
Error = RegSetValue(CpuInstKey,
"FeatureSet",
L"FeatureSet",
REG_DWORD,
(PCHAR)&FeatureSet,
sizeof(ULONG));
@@ -197,36 +199,36 @@ DetectCPU(FRLDRHKEY CpuKey,
}
/* Set 'Identifier' value (CPU and FPU) */
DbgPrint((DPRINT_HWDETECT, "Identifier: %s\n", Identifier));
DbgPrint((DPRINT_HWDETECT, "Identifier: %S\n", Identifier));
Error = RegSetValue(CpuInstKey,
"Identifier",
L"Identifier",
REG_SZ,
Identifier,
strlen(Identifier) + 1);
(PCHAR)Identifier,
(wcslen(Identifier) + 1)* sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
}
Error = RegSetValue(FpuInstKey,
"Identifier",
L"Identifier",
REG_SZ,
Identifier,
strlen(Identifier) + 1);
(PCHAR)Identifier,
(wcslen(Identifier) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
}
/* Set 'VendorIdentifier' value (CPU only) */
DbgPrint((DPRINT_HWDETECT, "Vendor Identifier: %s\n", VendorIdentifier));
DbgPrint((DPRINT_HWDETECT, "Vendor Identifier: %S\n", VendorIdentifier));
Error = RegSetValue(CpuInstKey,
"VendorIdentifier",
L"VendorIdentifier",
REG_SZ,
VendorIdentifier,
strlen(VendorIdentifier) + 1);
(PCHAR)VendorIdentifier,
(wcslen(VendorIdentifier) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@@ -242,7 +244,7 @@ DetectCPU(FRLDRHKEY CpuKey,
CpuSpeed = GetCpuSpeed();
Error = RegSetValue(CpuInstKey,
"~MHz",
L"~MHz",
REG_DWORD,
(PCHAR)&CpuSpeed,
sizeof(ULONG));
@@ -259,9 +261,10 @@ SetMpsProcessor(FRLDRHKEY CpuKey,
FRLDRHKEY FpuKey,
PMP_PROCESSOR_ENTRY CpuEntry)
{
char VendorIdentifier[13];
char Identifier[64];
char Buffer[8];
WCHAR VendorIdentifier[13];
CHAR tmpVendorIdentifier[13];
WCHAR Identifier[64];
WCHAR Buffer[8];
ULONG FeatureSet;
FRLDRHKEY CpuInstKey;
FRLDRHKEY FpuInstKey;
@@ -274,7 +277,7 @@ SetMpsProcessor(FRLDRHKEY CpuKey,
ULONG CpuSpeed;
/* Get processor instance number */
sprintf(Buffer, "%u", CpuEntry->LocalApicId);
swprintf(Buffer, L"%u", CpuEntry->LocalApicId);
/* Create the CPU instance key */
Error = RegCreateKey(CpuKey,
@@ -298,17 +301,18 @@ SetMpsProcessor(FRLDRHKEY CpuKey,
/* Get 'VendorIdentifier' */
GetCpuid(0, &eax, &ebx, &ecx, &edx);
VendorIdentifier[12] = 0;
Ptr = (ULONG*)&VendorIdentifier[0];
tmpVendorIdentifier[12] = 0;
Ptr = (ULONG*)&tmpVendorIdentifier[0];
*Ptr = ebx;
Ptr++;
*Ptr = edx;
Ptr++;
*Ptr = ecx;
swprintf(VendorIdentifier, L"%s", tmpVendorIdentifier);
/* Get 'Identifier' */
sprintf(Identifier,
"x86 Family %u Model %u Stepping %u",
swprintf(Identifier,
L"x86 Family %u Model %u Stepping %u",
(ULONG)((CpuEntry->CpuSignature >> 8) & 0x0F),
(ULONG)((CpuEntry->CpuSignature >> 4) & 0x0F),
(ULONG)(CpuEntry->CpuSignature & 0x0F));
@@ -331,7 +335,7 @@ SetMpsProcessor(FRLDRHKEY CpuKey,
DbgPrint((DPRINT_HWDETECT, "FeatureSet: %x\n", FeatureSet));
Error = RegSetValue(CpuInstKey,
"FeatureSet",
L"FeatureSet",
REG_DWORD,
(PCHAR)&FeatureSet,
sizeof(ULONG));
@@ -341,36 +345,36 @@ SetMpsProcessor(FRLDRHKEY CpuKey,
}
/* Set 'Identifier' value (CPU and FPU) */
DbgPrint((DPRINT_HWDETECT, "Identifier: %s\n", Identifier));
DbgPrint((DPRINT_HWDETECT, "Identifier: %S\n", Identifier));
Error = RegSetValue(CpuInstKey,
"Identifier",
L"Identifier",
REG_SZ,
Identifier,
strlen(Identifier) + 1);
(PCHAR)Identifier,
(wcslen(Identifier) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
}
Error = RegSetValue(FpuInstKey,
"Identifier",
L"Identifier",
REG_SZ,
Identifier,
strlen(Identifier) + 1);
(PCHAR)Identifier,
(wcslen(Identifier) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
}
/* Set 'VendorIdentifier' value (CPU only) */
DbgPrint((DPRINT_HWDETECT, "Vendor Identifier: %s\n", VendorIdentifier));
DbgPrint((DPRINT_HWDETECT, "Vendor Identifier: %S\n", VendorIdentifier));
Error = RegSetValue(CpuInstKey,
"VendorIdentifier",
L"VendorIdentifier",
REG_SZ,
VendorIdentifier,
strlen(VendorIdentifier) + 1);
(PCHAR)VendorIdentifier,
(wcslen(VendorIdentifier) + 1) * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@@ -386,7 +390,7 @@ SetMpsProcessor(FRLDRHKEY CpuKey,
CpuSpeed = GetCpuSpeed();
Error = RegSetValue(CpuInstKey,
"~MHz",
L"~MHz",
REG_DWORD,
(PCHAR)&CpuSpeed,
sizeof(ULONG));
@@ -601,7 +605,7 @@ DetectCPUs(FRLDRHKEY SystemKey)
/* Create the 'CentralProcessor' key */
Error = RegCreateKey(SystemKey,
"CentralProcessor",
L"CentralProcessor",
&CpuKey);
if (Error != ERROR_SUCCESS)
{
@@ -611,7 +615,7 @@ DetectCPUs(FRLDRHKEY SystemKey)
/* Create the 'FloatingPointProcessor' key */
Error = RegCreateKey(SystemKey,
"FloatingPointProcessor",
L"FloatingPointProcessor",
&FpuKey);
if (Error != ERROR_SUCCESS)
{
+16 -16
View File
@@ -155,7 +155,7 @@ DetectPciIrqRoutingTable(FRLDRHKEY BusKey)
DbgPrint((DPRINT_HWDETECT, "Table size: %u\n", Table->Size));
Error = RegCreateKey(BusKey,
"RealModeIrqRoutingTable\\0",
L"RealModeIrqRoutingTable\\0",
&TableKey);
if (Error != ERROR_SUCCESS)
{
@@ -171,10 +171,10 @@ DetectPciIrqRoutingTable(FRLDRHKEY BusKey)
/* Set 'Identifier' value */
Error = RegSetValue(TableKey,
"Identifier",
L"Identifier",
REG_SZ,
"PCI Real-mode IRQ Routing Table",
32);
(PCHAR)L"PCI Real-mode IRQ Routing Table",
32 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@@ -209,7 +209,7 @@ DetectPciIrqRoutingTable(FRLDRHKEY BusKey)
/* Set 'Configuration Data' value */
Error = RegSetValue(TableKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
@@ -230,7 +230,7 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
CM_PCI_BUS_DATA BusData;
char Buffer[80];
WCHAR Buffer[80];
FRLDRHKEY BiosKey;
ULONG Size;
LONG Error;
@@ -243,8 +243,8 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
if (FindPciBios(&BusData))
{
/* Create new bus key */
sprintf(Buffer,
"MultifunctionAdapter\\%u", *BusNumber);
swprintf(Buffer,
L"MultifunctionAdapter\\%u", *BusNumber);
Error = RegCreateKey(SystemKey,
Buffer,
&BiosKey);
@@ -265,10 +265,10 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
/* Set 'Identifier' value */
Error = RegSetValue(BiosKey,
"Identifier",
L"Identifier",
REG_SZ,
"PCI BIOS",
9);
(PCHAR)L"PCI BIOS",
9 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
@@ -294,7 +294,7 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
/* Set 'Configuration Data' value */
Error = RegSetValue(BiosKey,
"Configuration Data",
L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
@@ -319,8 +319,8 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
/* Report PCI buses */
for (i = 0; i < (ULONG)BusData.BusCount; i++)
{
sprintf(Buffer,
"MultifunctionAdapter\\%u", *BusNumber);
swprintf(Buffer,
L"MultifunctionAdapter\\%u", *BusNumber);
Error = RegCreateKey(SystemKey,
Buffer,
&BusKey);
@@ -343,10 +343,10 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
/* Set 'Identifier' value */
Error = RegSetValue(BusKey,
"Identifier",
L"Identifier",
REG_SZ,
(PUCHAR)"PCI",
4);
4 * sizeof(WCHAR));
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
+1 -1
View File
@@ -162,7 +162,7 @@ BOOL CacheReadDiskSectors(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount
RtlCopyMemory(Buffer,
(PVOID)((ULONG_PTR)CacheBlock->BlockData + (SectorOffsetInStartBlock * CacheManagerDrive.BytesPerSector)),
(CopyLengthInStartBlock * CacheManagerDrive.BytesPerSector));
DbgPrint((DPRINT_CACHE, "1 - RtlCopyMemory(0x%x, 0x%x, %d)\n", Buffer, (CacheBlock->BlockData + (SectorOffsetInStartBlock * CacheManagerDrive.BytesPerSector)), (CopyLengthInStartBlock * CacheManagerDrive.BytesPerSector)));
DbgPrint((DPRINT_CACHE, "1 - RtlCopyMemory(0x%x, 0x%x, %d)\n", Buffer, ((ULONG_PTR)CacheBlock->BlockData + (SectorOffsetInStartBlock * CacheManagerDrive.BytesPerSector)), (CopyLengthInStartBlock * CacheManagerDrive.BytesPerSector)));
//
// Update the buffer address
+10 -1
View File
@@ -23,7 +23,7 @@
/* MACROS *******************************************************************/
#ifndef DEBUG
#ifdef DEBUG
#define DEFAULT_BAUD_RATE 19200
@@ -276,3 +276,12 @@ VOID Rs232PortPutByte(UCHAR ByteToSend)
}
#endif
BOOL Rs232PortInUse(ULONG Base)
{
#ifdef DEBUG
return PortInitialized && Rs232PortBase == (PUCHAR)Base ? TRUE : FALSE;
#else
return FALSE;
#endif
}
+17 -80
View File
@@ -19,6 +19,8 @@
#include <freeldr.h>
#include <debug.h>
#ifdef DEBUG
//#define DEBUG_ALL
@@ -64,7 +66,7 @@ BOOL DebugStartOfLine = TRUE;
VOID DebugInit(VOID)
{
if (DebugPort == RS232)
if (DebugPort & RS232)
{
Rs232PortInitialize(ComPort, BaudRate);
}
@@ -227,86 +229,11 @@ VOID DebugPrintHeader(ULONG Mask)
}
}
static VOID DebugPrintV(char *format, int *dataptr)
{
char c, *ptr, str[16];
int ll;
ll = 0;
while ((c = *(format++)))
{
if (c != '%')
{
DebugPrintChar(c);
}
else
{
if (*format == 'I' && *(format+1) == '6' && *(format+2) == '4')
{
ll = 1;
format += 3;
}
else
{
ll = 0;
}
switch (c = *(format++))
{
case 'd': case 'u': case 'x':
if (ll)
{
*convert_i64_to_ascii(str, c, *((unsigned long long*) dataptr)) = 0;
dataptr += 2;
}
else
{
*convert_to_ascii(str, c, *((unsigned long *) dataptr++)) = 0;
}
ptr = str;
while (*ptr)
{
DebugPrintChar(*(ptr++));
}
break;
case 'c':
DebugPrintChar((*(dataptr++))&0xff);
break;
case 's':
ptr = (char *)(*(dataptr++));
while ((c = *(ptr++)))
{
DebugPrintChar(c);
}
break;
case '%':
DebugPrintChar(c);
break;
default:
DebugPrint(DPRINT_WARNING, "\nDebugPrint() invalid format specifier - %%%c\n", c);
break;
}
}
}
if (DebugPort == SCREEN)
{
//getch();
}
}
VOID DebugPrint(ULONG Mask, char *format, ...)
{
int *dataptr = (int *) &format;
char Buffer[4096];
char *ptr = Buffer;
// Mask out unwanted debug messages
if (!(Mask & DebugPrintMask))
@@ -321,14 +248,24 @@ VOID DebugPrint(ULONG Mask, char *format, ...)
DebugStartOfLine = FALSE;
}
DebugPrintV(format, ++dataptr);
vsprintf(Buffer, format, (PVOID)(++dataptr));
while (*ptr)
{
DebugPrintChar(*ptr++);
}
}
VOID DebugPrint1(char *format, ...)
{
int *dataptr = (int *) &format;
char Buffer[4096];
char *ptr = Buffer;
DebugPrintV(format, ++dataptr);
vsprintf(Buffer, format, (PVOID)(++dataptr));
while (*ptr)
{
DebugPrintChar(*ptr++);
}
}
VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
@@ -1,8 +1,11 @@
<module name="freeldr_base" type="objectlibrary" allowwarnings="true">
<module name="freeldr_base" type="objectlibrary">
<include base="freeldr_base">include</include>
<include base="freeldr_base">cache</include>
<include base="ntoskrnl">include</include>
<define name="__USE_W32API" />
<!--
<define name="DEBUG" />
-->
<compilerflag>-ffreestanding</compilerflag>
<compilerflag>-fno-builtin</compilerflag>
<compilerflag>-fno-inline</compilerflag>
@@ -71,11 +74,11 @@
<file>mm.c</file>
</directory>
<directory name="reactos">
<file>registry.c</file>
<file>arcname.c</file>
<file>binhive.c</file>
<file>loader.c</file>
<file>reactos.c</file>
<file>registry.c</file>
</directory>
<directory name="rtl">
<file>list.c</file>
@@ -2,6 +2,9 @@
<include base="freeldr_base64k">include</include>
<include base="ntoskrnl">include</include>
<define name="__USE_W32API" />
<!--
<define name="DEBUG" />
-->
<compilerflag>-ffreestanding</compilerflag>
<compilerflag>-fno-builtin</compilerflag>
<compilerflag>-fno-inline</compilerflag>
@@ -2,6 +2,9 @@
<include base="freeldr_main">include</include>
<include base="ntoskrnl">include</include>
<define name="__USE_W32API" />
<!--
<define name="DEBUG" />
-->
<compilerflag>-ffreestanding</compilerflag>
<compilerflag>-fno-builtin</compilerflag>
<compilerflag>-fno-inline</compilerflag>
@@ -2,6 +2,9 @@
<include base="freeldr_startup">include</include>
<include base="ntoskrnl">include</include>
<define name="__USE_W32API" />
<!--
<define name="DEBUG" />
-->
<compilerflag>-ffreestanding</compilerflag>
<compilerflag>-fno-builtin</compilerflag>
<compilerflag>-fno-inline</compilerflag>
+1 -1
View File
@@ -26,7 +26,7 @@ BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate);
BOOL Rs232PortGetByte(PUCHAR ByteRecieved);
BOOL Rs232PortPollByte(PUCHAR ByteRecieved);
VOID Rs232PortPutByte(UCHAR ByteToSend);
BOOL Rs232PortInUse(ULONG Base);
#endif // defined __RS232_H
+3 -1
View File
@@ -41,7 +41,9 @@
VOID DebugPrint1(char *format, ...);
VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length);
#define DbgPrint(_x_) DebugPrint _x_ ;
#define DbgPrint(_x_) _DbgPrint _x_ ;
#define _DbgPrint(_m_,_x_...) { DebugPrint(_m_, "(%s:%d)", __FILE__, __LINE__); DebugPrint(_m_,_x_);}while(0)
#define DPRINT1 DebugPrint1
#define BugCheck(_x_) { DebugPrint(DPRINT_WARNING, "Fatal Error: %s:%d(%s)\n", __FILE__, __LINE__, __FUNCTION__); DebugPrint _x_ ; for (;;); }
#define DbgDumpBuffer(_x_, _y_, _z_) DebugDumpBuffer(_x_, _y_, _z_)
@@ -70,6 +70,8 @@
/* Externals */
#include <reactos/rossym.h>
#include <reactos/buildno.h>
/* Needed if debuging is enabled */
#include <comm.h>
#define Ke386EraseFlags(x) __asm__ __volatile__("pushl $0 ; popfl\n")
+11 -11
View File
@@ -31,7 +31,7 @@ typedef struct _REG_KEY
ULONG ValueCount;
ULONG NameSize;
PCHAR Name;
PWCHAR Name;
/* default data */
ULONG DataType;
@@ -46,7 +46,7 @@ typedef struct _REG_VALUE
/* value name */
ULONG NameSize;
PCHAR Name;
PWCHAR Name;
/* value data */
ULONG DataType;
@@ -72,47 +72,47 @@ RegInitCurrentControlSet(BOOL LastKnownGood);
LONG
RegCreateKey(FRLDRHKEY ParentKey,
PCSTR KeyName,
PCWSTR KeyName,
PFRLDRHKEY Key);
LONG
RegDeleteKey(FRLDRHKEY Key,
PCSTR Name);
PCWSTR Name);
LONG
RegEnumKey(FRLDRHKEY Key,
ULONG Index,
PCHAR Name,
PWCHAR Name,
ULONG* NameSize);
LONG
RegOpenKey(FRLDRHKEY ParentKey,
PCSTR KeyName,
PCWSTR KeyName,
PFRLDRHKEY Key);
LONG
RegSetValue(FRLDRHKEY Key,
PCSTR ValueName,
PCWSTR ValueName,
ULONG Type,
PCSTR Data,
ULONG DataSize);
LONG
RegQueryValue(FRLDRHKEY Key,
PCSTR ValueName,
PCWSTR ValueName,
ULONG* Type,
PUCHAR Data,
ULONG* DataSize);
LONG
RegDeleteValue(FRLDRHKEY Key,
PCSTR ValueName);
PCWSTR ValueName);
LONG
RegEnumValue(FRLDRHKEY Key,
ULONG Index,
PCHAR ValueName,
PWCHAR ValueName,
ULONG* NameSize,
ULONG* Type,
PUCHAR Data,
@@ -130,7 +130,7 @@ RegImportBinaryHive (PCHAR ChunkBase,
ULONG ChunkSize);
BOOL
RegExportBinaryHive (PCSTR KeyName,
RegExportBinaryHive (PCWSTR KeyName,
PCHAR ChunkBase,
ULONG* ChunkSize);
@@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2003 Brian Palmer <[email protected]>
* Copyright (C) 1998-2005 Brian Palmer <[email protected]>
*
* 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
@@ -22,8 +22,8 @@
/* just some stuff */
#define VERSION "FreeLoader v2.0"
#define COPYRIGHT "Copyright (C) 1998-2003 Brian Palmer <[email protected]>"
#define VERSION "FreeLoader v2.1"
#define COPYRIGHT "Copyright (C) 1998-2005 Brian Palmer <[email protected]>"
#define AUTHOR_EMAIL "<[email protected]>"
#define BY_AUTHOR "by Brian Palmer"
@@ -35,7 +35,7 @@
// If you add major functionality then you increment the major version and zero the minor & patch versions
//
#define FREELOADER_MAJOR_VERSION 2
#define FREELOADER_MINOR_VERSION 0
#define FREELOADER_MINOR_VERSION 1
#define FREELOADER_PATCH_VERSION 0
+159 -149
View File
@@ -129,8 +129,8 @@ typedef struct _KEY_CELL
/* Key cell identifier "kn" (0x6b6e) */
USHORT Id;
/* ? */
USHORT Type;
/* Flags */
USHORT Flags;
/* Time of last flush */
ULONGLONG LastWriteTime; /* FILETIME */
@@ -181,8 +181,8 @@ typedef struct _KEY_CELL
/* KEY_CELL.Type constants */
#define REG_LINK_KEY_CELL_TYPE 0x10
#define REG_KEY_CELL_TYPE 0x20
#define REG_ROOT_KEY_CELL_TYPE 0x2c
#define REG_KEY_NAME_PACKED 0x20
#define REG_ROOT_KEY_CELL_TYPE 0x0c
// hash record :
@@ -323,22 +323,34 @@ CmiCreateDefaultBinCell (PHBIN BinCell)
static VOID
CmiCreateDefaultRootKeyCell (PKEY_CELL RootKeyCell, PCSTR KeyName)
CmiCreateDefaultRootKeyCell (PKEY_CELL RootKeyCell, PCWSTR KeyName)
{
PCHAR BaseKeyName;
PWCHAR BaseKeyName;
ULONG NameSize;
ULONG CellSize;
ULONG i;
BOOL Packable = TRUE;
assert (RootKeyCell);
BaseKeyName = strrchr(KeyName, '\\') + 1;
NameSize = strlen(BaseKeyName);
CellSize = ROUND_UP(sizeof(KEY_CELL) + NameSize - 1, 16);
BaseKeyName = wcsrchr(KeyName, L'\\') + 1;
NameSize = wcslen(BaseKeyName);
for (i = 0; i < NameSize; i++)
{
if (KeyName[i] & 0xFF00)
{
Packable = FALSE;
NameSize *= sizeof(WCHAR);
break;
}
}
CellSize = ROUND_UP(sizeof(KEY_CELL) + NameSize, 16);
memset (RootKeyCell, 0, CellSize);
RootKeyCell->CellSize = -CellSize;
RootKeyCell->Id = REG_KEY_CELL_ID;
RootKeyCell->Type = REG_ROOT_KEY_CELL_TYPE;
RootKeyCell->Flags = REG_ROOT_KEY_CELL_TYPE;
RootKeyCell->LastWriteTime = 0ULL;
RootKeyCell->ParentKeyOffset = 0;
RootKeyCell->NumberOfSubKeys = 0;
@@ -349,12 +361,23 @@ CmiCreateDefaultRootKeyCell (PKEY_CELL RootKeyCell, PCSTR KeyName)
RootKeyCell->ClassNameOffset = -1;
RootKeyCell->NameSize = NameSize;
RootKeyCell->ClassSize = 0;
memcpy (RootKeyCell->Name, BaseKeyName, NameSize);
if (Packable)
{
for(i = 0; i < NameSize; i++)
{
((PCHAR)RootKeyCell->Name)[i] = BaseKeyName[i];
}
RootKeyCell->Flags |= REG_KEY_NAME_PACKED;
}
else
{
memcpy (RootKeyCell->Name, BaseKeyName, NameSize);
}
}
static PREGISTRY_HIVE
CmiCreateHive (PCSTR KeyName)
CmiCreateHive (PCWSTR KeyName)
{
PREGISTRY_HIVE Hive;
PCELL_HEADER FreeCell;
@@ -886,7 +909,7 @@ CmiAddKeyToParentHashTable (PREGISTRY_HIVE Hive,
HashBlock->Table[i].KeyOffset = NKBOffset;
memcpy (&HashBlock->Table[i].HashValue,
NewKeyCell->Name,
4);
min(NewKeyCell->NameSize, sizeof(ULONG)));
ParentKeyCell->NumberOfSubKeys++;
return TRUE;
}
@@ -925,13 +948,24 @@ static BOOL
CmiAllocateValueCell(PREGISTRY_HIVE Hive,
PVALUE_CELL *ValueCell,
BLOCK_OFFSET *ValueCellOffset,
PCHAR ValueName)
PWCHAR ValueName)
{
PVALUE_CELL NewValueCell;
ULONG NameSize;
BOOL Status;
BOOLEAN Packable = TRUE;
ULONG i;
NameSize = (ValueName == NULL) ? 0 : strlen (ValueName);
NameSize = (ValueName == NULL) ? 0 : wcslen (ValueName);
for (i = 0; i < NameSize; i++)
{
if (ValueName[i] & 0xFF00)
{
NameSize *= sizeof(WCHAR);
Packable = FALSE;
break;
}
}
Status = CmiAllocateCell (Hive,
sizeof(VALUE_CELL) + NameSize,
(PVOID*)(PVOID)&NewValueCell,
@@ -944,12 +978,23 @@ CmiAllocateValueCell(PREGISTRY_HIVE Hive,
NewValueCell->Id = REG_VALUE_CELL_ID;
NewValueCell->NameSize = NameSize;
NewValueCell->Flags = 0;
if (NameSize > 0)
{
memcpy (NewValueCell->Name,
ValueName,
NameSize);
NewValueCell->Flags = REG_VALUE_NAME_PACKED;
if (Packable)
{
for (i = 0; i < NameSize; i++)
{
((PCHAR)NewValueCell->Name)[i] = (CHAR)ValueName[i];
}
NewValueCell->Flags |= REG_VALUE_NAME_PACKED;
}
else
{
memcpy (NewValueCell->Name,
ValueName,
NameSize);
}
}
NewValueCell->DataType = 0;
NewValueCell->DataSize = 0;
@@ -989,19 +1034,6 @@ CmiAddValueToKeyValueList(PREGISTRY_HIVE Hive,
return TRUE;
}
static VOID
memexpand (PWCHAR Dst,
PCHAR Src,
ULONG Length)
{
ULONG i;
for (i = 0; i < Length; i++)
Dst[i] = (WCHAR)Src[i];
}
static BOOL
CmiExportValue (PREGISTRY_HIVE Hive,
BLOCK_OFFSET KeyCellOffset,
@@ -1012,13 +1044,11 @@ CmiExportValue (PREGISTRY_HIVE Hive,
BLOCK_OFFSET DataCellOffset;
PVALUE_CELL ValueCell;
PDATA_CELL DataCell;
ULONG SrcDataSize;
ULONG DstDataSize;
ULONG DataSize;
ULONG DataType;
PCHAR Data;
BOOL Expand = FALSE;
DbgPrint((DPRINT_REGISTRY, "CmiExportValue('%s') called\n",
DbgPrint((DPRINT_REGISTRY, "CmiExportValue('%S') called\n",
(Value == NULL) ? "<default>" : (PCHAR)Value->Name));
DbgPrint((DPRINT_REGISTRY, "DataSize %lu\n",
(Value == NULL) ? Key->DataSize : Value->DataSize));
@@ -1037,47 +1067,29 @@ CmiExportValue (PREGISTRY_HIVE Hive,
if (Value == NULL)
{
DataType = Key->DataType;
SrcDataSize = Key->DataSize;
DataSize = Key->DataSize;
Data = Key->Data;
}
else
{
DataType = Value->DataType;
SrcDataSize = Value->DataSize;
DataSize = Value->DataSize;
Data = Value->Data;
}
DstDataSize = SrcDataSize;
if (DataType == REG_SZ ||
DataType == REG_EXPAND_SZ ||
DataType == REG_MULTI_SZ)
if (DataSize <= sizeof(BLOCK_OFFSET))
{
DstDataSize *= sizeof(WCHAR);
Expand = TRUE;
}
if (DstDataSize <= sizeof(BLOCK_OFFSET))
{
ValueCell->DataSize = DstDataSize | REG_DATA_IN_OFFSET;
ValueCell->DataSize = DataSize | REG_DATA_IN_OFFSET;
ValueCell->DataType = DataType;
if (Expand)
{
memexpand ((PWCHAR)&ValueCell->DataOffset,
(PCHAR)&Data,
SrcDataSize);
}
else
{
memcpy (&ValueCell->DataOffset,
&Data,
SrcDataSize);
}
memcpy (&ValueCell->DataOffset,
Data,
DataSize);
}
else
{
/* Allocate data cell */
if (!CmiAllocateCell (Hive,
sizeof(CELL_HEADER) + DstDataSize,
sizeof(CELL_HEADER) + DataSize,
(PVOID *)(PVOID)&DataCell,
&DataCellOffset))
{
@@ -1085,30 +1097,12 @@ CmiExportValue (PREGISTRY_HIVE Hive,
}
ValueCell->DataOffset = DataCellOffset;
ValueCell->DataSize = DstDataSize;
ValueCell->DataSize = DataSize;
ValueCell->DataType = DataType;
if (Expand)
{
if (SrcDataSize <= sizeof(BLOCK_OFFSET))
{
memexpand ((PWCHAR)DataCell->Data,
(PCHAR)&Data,
SrcDataSize);
}
else
{
memexpand ((PWCHAR)DataCell->Data,
Data,
SrcDataSize);
}
}
else
{
memcpy (DataCell->Data,
Data,
SrcDataSize);
}
memcpy (DataCell->Data,
Data,
DataSize);
}
return TRUE;
@@ -1129,15 +1123,29 @@ CmiExportSubKey (PREGISTRY_HIVE Hive,
PLIST_ENTRY Entry;
FRLDRHKEY SubKey;
PVALUE Value;
BOOLEAN Packable = TRUE;
ULONG i;
ULONG NameSize;
DbgPrint((DPRINT_REGISTRY, "CmiExportSubKey('%s') called\n", Key->Name));
DbgPrint((DPRINT_REGISTRY, "CmiExportSubKey('%S') called\n", Key->Name));
/* Don't export links */
if (Key->DataType == REG_LINK)
return TRUE;
NameSize = (Key->NameSize - sizeof(WCHAR)) / sizeof(WCHAR);
for (i = 0; i < NameSize; i++)
{
if (Key->Name[i] & 0xFF00)
{
Packable = FALSE;
NameSize *= sizeof(WCHAR);
break;
}
}
/* Allocate key cell */
KeyCellSize = sizeof(KEY_CELL) + Key->NameSize - 1;
KeyCellSize = sizeof(KEY_CELL) + NameSize;
if (!CmiAllocateCell (Hive, KeyCellSize, (PVOID)&NewKeyCell, &NKBOffset))
{
DbgPrint((DPRINT_REGISTRY, "CmiAllocateCell() failed\n"));
@@ -1146,7 +1154,7 @@ CmiExportSubKey (PREGISTRY_HIVE Hive,
/* Initialize key cell */
NewKeyCell->Id = REG_KEY_CELL_ID;
NewKeyCell->Type = REG_KEY_CELL_TYPE;
NewKeyCell->Flags = 0;
NewKeyCell->LastWriteTime = 0ULL;
NewKeyCell->ParentKeyOffset = ParentKeyOffset;
NewKeyCell->NumberOfSubKeys = 0;
@@ -1155,11 +1163,23 @@ CmiExportSubKey (PREGISTRY_HIVE Hive,
NewKeyCell->ValueListOffset = -1;
NewKeyCell->SecurityKeyOffset = -1;
NewKeyCell->ClassNameOffset = -1;
NewKeyCell->NameSize = Key->NameSize - 1;
NewKeyCell->NameSize = NameSize;
NewKeyCell->ClassSize = 0;
memcpy (NewKeyCell->Name,
Key->Name,
Key->NameSize - 1);
if (Packable)
{
for (i = 0; i < NameSize; i++)
{
((PCHAR)NewKeyCell->Name)[i] = (CHAR)Key->Name[i];
}
NewKeyCell->Flags |= REG_KEY_NAME_PACKED;
}
else
{
memcpy (NewKeyCell->Name,
Key->Name,
NameSize);
}
/* Add key cell to the parent key's hash table */
if (!CmiAddKeyToParentHashTable (Hive,
@@ -1255,7 +1275,7 @@ CmiCalcHiveChecksum (PREGISTRY_HIVE Hive)
static BOOL
CmiExportHive (PREGISTRY_HIVE Hive,
PCSTR KeyName)
PCWSTR KeyName)
{
PKEY_CELL KeyCell;
FRLDRHKEY Key;
@@ -1265,7 +1285,7 @@ CmiExportHive (PREGISTRY_HIVE Hive,
FRLDRHKEY SubKey;
PVALUE Value;
DbgPrint((DPRINT_REGISTRY, "CmiExportHive(%x, '%s') called\n", Hive, KeyName));
DbgPrint((DPRINT_REGISTRY, "CmiExportHive(%x, '%S') called\n", Hive, KeyName));
if (RegOpenKey (NULL, KeyName, &Key) != ERROR_SUCCESS)
{
@@ -1355,11 +1375,8 @@ RegImportValue (PHBIN RootBin,
{
PDATA_CELL DataCell;
PWCHAR wName;
PCHAR cName;
LONG Error;
ULONG DataSize;
PCHAR cBuffer;
PWCHAR wBuffer;
ULONG i;
if (ValueCell->CellSize >= 0 || ValueCell->Id != REG_VALUE_CELL_ID)
@@ -1370,37 +1387,38 @@ RegImportValue (PHBIN RootBin,
if (ValueCell->Flags & REG_VALUE_NAME_PACKED)
{
cName = MmAllocateMemory (ValueCell->NameSize + 1);
memcpy (cName,
ValueCell->Name,
ValueCell->NameSize);
cName[ValueCell->NameSize] = 0;
wName = MmAllocateMemory ((ValueCell->NameSize + 1)*sizeof(WCHAR));
for (i = 0; i < ValueCell->NameSize; i++)
{
wName[i] = ((PCHAR)ValueCell->Name)[i];
}
wName[ValueCell->NameSize] = 0;
}
else
{
wName = (PWCHAR)ValueCell->Name;
cName = MmAllocateMemory (ValueCell->NameSize / 2 + 1);
for (i = 0; i < ValueCell->NameSize / 2; i++)
cName[i] = (CHAR)wName[i];
cName[ValueCell->NameSize / 2] = 0;
wName = MmAllocateMemory (ValueCell->NameSize + sizeof(WCHAR));
memcpy (wName,
ValueCell->Name,
ValueCell->NameSize);
wName[ValueCell->NameSize / sizeof(WCHAR)] = 0;
}
DataSize = ValueCell->DataSize & REG_DATA_SIZE_MASK;
DbgPrint((DPRINT_REGISTRY, "ValueName: '%s'\n", cName));
DbgPrint((DPRINT_REGISTRY, "ValueName: '%S'\n", wName));
DbgPrint((DPRINT_REGISTRY, "DataSize: %u\n", DataSize));
if (DataSize <= sizeof(BLOCK_OFFSET) && (ValueCell->DataSize & REG_DATA_IN_OFFSET))
{
Error = RegSetValue(Key,
cName,
wName,
ValueCell->DataType,
(PCHAR)&ValueCell->DataOffset,
DataSize);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_REGISTRY, "RegSetValue() failed!\n"));
MmFreeMemory (cName);
MmFreeMemory (wName);
return FALSE;
}
}
@@ -1412,44 +1430,25 @@ RegImportValue (PHBIN RootBin,
if (DataCell->CellSize >= 0)
{
DbgPrint((DPRINT_REGISTRY, "Invalid data cell size!\n"));
MmFreeMemory (cName);
MmFreeMemory (wName);
return FALSE;
}
if (ValueCell->DataType == REG_SZ ||
ValueCell->DataType == REG_EXPAND_SZ ||
ValueCell->DataType == REG_MULTI_SZ)
{
wBuffer = (PWCHAR)DataCell->Data;
cBuffer = MmAllocateMemory(DataSize/2);
for (i = 0; i < DataSize / 2; i++)
cBuffer[i] = (CHAR)wBuffer[i];
Error = RegSetValue (Key,
cName,
ValueCell->DataType,
cBuffer,
DataSize/2);
MmFreeMemory(cBuffer);
}
else
{
Error = RegSetValue (Key,
cName,
ValueCell->DataType,
DataCell->Data,
DataSize);
}
Error = RegSetValue (Key,
wName,
ValueCell->DataType,
DataCell->Data,
DataSize);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_REGISTRY, "RegSetValue() failed!\n"));
MmFreeMemory (cName);
MmFreeMemory (wName);
return FALSE;
}
}
MmFreeMemory (cName);
MmFreeMemory (wName);
return TRUE;
}
@@ -1464,7 +1463,7 @@ RegImportSubKey(PHBIN RootBin,
PKEY_CELL SubKeyCell;
PVALUE_LIST_CELL ValueListCell;
PVALUE_CELL ValueCell = NULL;
PCHAR cName;
PWCHAR wName;
FRLDRHKEY SubKey;
LONG Error;
ULONG i;
@@ -1479,20 +1478,31 @@ RegImportSubKey(PHBIN RootBin,
return FALSE;
}
/* FIXME: implement packed key names */
cName = MmAllocateMemory (KeyCell->NameSize + 1);
memcpy (cName,
KeyCell->Name,
KeyCell->NameSize);
cName[KeyCell->NameSize] = 0;
if (KeyCell->Flags & REG_KEY_NAME_PACKED)
{
wName = MmAllocateMemory ((KeyCell->NameSize + 1) * sizeof(WCHAR));
for (i = 0; i < KeyCell->NameSize; i++)
{
wName[i] = ((PCHAR)KeyCell->Name)[i];
}
wName[KeyCell->NameSize] = 0;
}
else
{
wName = MmAllocateMemory (KeyCell->NameSize + sizeof(WCHAR));
memcpy (wName,
KeyCell->Name,
KeyCell->NameSize);
wName[KeyCell->NameSize/sizeof(WCHAR)] = 0;
}
DbgPrint((DPRINT_REGISTRY, "KeyName: '%s'\n", cName));
DbgPrint((DPRINT_REGISTRY, "KeyName: '%S'\n", wName));
/* Create new sub key */
Error = RegCreateKey (ParentKey,
cName,
wName,
&SubKey);
MmFreeMemory (cName);
MmFreeMemory (wName);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_REGISTRY, "RegCreateKey() failed!\n"));
@@ -1589,7 +1599,7 @@ RegImportBinaryHive(PCHAR ChunkBase,
/* Open 'System' key */
Error = RegOpenKey(NULL,
"\\Registry\\Machine\\SYSTEM",
L"\\Registry\\Machine\\SYSTEM",
&SystemKey);
if (Error != ERROR_SUCCESS)
{
@@ -1621,7 +1631,7 @@ RegImportBinaryHive(PCHAR ChunkBase,
BOOL
RegExportBinaryHive(PCSTR KeyName,
RegExportBinaryHive(PCWSTR KeyName,
PCHAR ChunkBase,
ULONG* ChunkSize)
{
+57 -71
View File
@@ -186,14 +186,14 @@ FrLdrLoadNlsFiles(PCHAR szSystemRoot,
{
LONG rc = ERROR_SUCCESS;
FRLDRHKEY hKey;
CHAR szIdBuffer[80];
CHAR szNameBuffer[80];
WCHAR szIdBuffer[80];
WCHAR szNameBuffer[80];
CHAR szFileName[256];
ULONG BufferSize;
/* open the codepage key */
rc = RegOpenKey(NULL,
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage",
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage",
&hKey);
if (rc != ERROR_SUCCESS) {
@@ -202,15 +202,15 @@ FrLdrLoadNlsFiles(PCHAR szSystemRoot,
}
/* get ANSI codepage */
BufferSize = 80;
rc = RegQueryValue(hKey, "ACP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
BufferSize = sizeof(szIdBuffer);
rc = RegQueryValue(hKey, L"ACP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
if (rc != ERROR_SUCCESS) {
strcpy(szErrorOut, "Couldn't get ACP NLS setting");
return(FALSE);
}
BufferSize = 80;
BufferSize = sizeof(szNameBuffer);
rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)szNameBuffer, &BufferSize);
if (rc != ERROR_SUCCESS) {
@@ -219,9 +219,7 @@ FrLdrLoadNlsFiles(PCHAR szSystemRoot,
}
/* load ANSI codepage table */
strcpy(szFileName, szSystemRoot);
strcat(szFileName, "system32\\");
strcat(szFileName, szNameBuffer);
sprintf(szFileName,"%ssystem32\\%S", szSystemRoot, szNameBuffer);
DbgPrint((DPRINT_REACTOS, "ANSI file: %s\n", szFileName));
if (!FrLdrLoadNlsFile(szFileName, "ansi.nls")) {
@@ -230,15 +228,15 @@ FrLdrLoadNlsFiles(PCHAR szSystemRoot,
}
/* get OEM codepage */
BufferSize = 80;
rc = RegQueryValue(hKey, "OEMCP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
BufferSize = sizeof(szIdBuffer);
rc = RegQueryValue(hKey, L"OEMCP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
if (rc != ERROR_SUCCESS) {
strcpy(szErrorOut, "Couldn't get OEMCP NLS setting");
return(FALSE);
}
BufferSize = 80;
BufferSize = sizeof(szNameBuffer);
rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)szNameBuffer, &BufferSize);
if (rc != ERROR_SUCCESS) {
@@ -247,9 +245,7 @@ FrLdrLoadNlsFiles(PCHAR szSystemRoot,
}
/* load OEM codepage table */
strcpy(szFileName, szSystemRoot);
strcat(szFileName, "system32\\");
strcat(szFileName, szNameBuffer);
sprintf(szFileName, "%ssystem32\\%S", szSystemRoot, szNameBuffer);
DbgPrint((DPRINT_REACTOS, "Oem file: %s\n", szFileName));
if (!FrLdrLoadNlsFile(szFileName, "oem.nls")) {
@@ -259,7 +255,7 @@ FrLdrLoadNlsFiles(PCHAR szSystemRoot,
/* open the language key */
rc = RegOpenKey(NULL,
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
&hKey);
if (rc != ERROR_SUCCESS) {
@@ -268,15 +264,15 @@ FrLdrLoadNlsFiles(PCHAR szSystemRoot,
}
/* get the Unicode case table */
BufferSize = 80;
rc = RegQueryValue(hKey, "Default", NULL, (PUCHAR)szIdBuffer, &BufferSize);
BufferSize = sizeof(szIdBuffer);
rc = RegQueryValue(hKey, L"Default", NULL, (PUCHAR)szIdBuffer, &BufferSize);
if (rc != ERROR_SUCCESS) {
strcpy(szErrorOut, "Couldn't get Language Default setting");
return(FALSE);
}
BufferSize = 80;
BufferSize = sizeof(szNameBuffer);
rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)szNameBuffer, &BufferSize);
if (rc != ERROR_SUCCESS) {
@@ -285,9 +281,7 @@ FrLdrLoadNlsFiles(PCHAR szSystemRoot,
}
/* load Unicode case table */
strcpy(szFileName, szSystemRoot);
strcat(szFileName, "system32\\");
strcat(szFileName, szNameBuffer);
sprintf(szFileName, "%ssystem32\\%S", szSystemRoot, szNameBuffer);
DbgPrint((DPRINT_REACTOS, "Casemap file: %s\n", szFileName));
if (!FrLdrLoadNlsFile(szFileName, "casemap.nls")) {
@@ -347,27 +341,27 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
{
LONG rc = 0;
FRLDRHKEY hGroupKey, hOrderKey, hServiceKey, hDriverKey;
CHAR GroupNameBuffer[512];
CHAR ServiceName[256];
WCHAR GroupNameBuffer[512];
WCHAR ServiceName[256];
ULONG OrderList[128];
ULONG BufferSize;
ULONG Index;
ULONG TagIndex;
LPSTR GroupName;
LPWSTR GroupName;
ULONG ValueSize;
ULONG ValueType;
ULONG StartValue;
ULONG TagValue;
CHAR DriverGroup[256];
WCHAR DriverGroup[256];
ULONG DriverGroupSize;
CHAR ImagePath[256];
CHAR TempImagePath[256];
WCHAR TempImagePath[256];
/* get 'service group order' key */
rc = RegOpenKey(NULL,
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder",
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder",
&hGroupKey);
if (rc != ERROR_SUCCESS) {
@@ -377,7 +371,7 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
/* get 'group order list' key */
rc = RegOpenKey(NULL,
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\GroupOrderList",
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\GroupOrderList",
&hOrderKey);
if (rc != ERROR_SUCCESS) {
@@ -387,7 +381,7 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
/* enumerate drivers */
rc = RegOpenKey(NULL,
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
&hServiceKey);
if (rc != ERROR_SUCCESS) {
@@ -397,16 +391,16 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
/* Get the Name Group */
BufferSize = sizeof(GroupNameBuffer);
rc = RegQueryValue(hGroupKey, "List", NULL, (PUCHAR)GroupNameBuffer, &BufferSize);
rc = RegQueryValue(hGroupKey, L"List", NULL, (PUCHAR)GroupNameBuffer, &BufferSize);
DbgPrint((DPRINT_REACTOS, "RegQueryValue(): rc %d\n", (int)rc));
if (rc != ERROR_SUCCESS) return;
DbgPrint((DPRINT_REACTOS, "BufferSize: %d \n", (int)BufferSize));
DbgPrint((DPRINT_REACTOS, "GroupNameBuffer: '%s' \n", GroupNameBuffer));
DbgPrint((DPRINT_REACTOS, "GroupNameBuffer: '%S' \n", GroupNameBuffer));
/* Loop through each group */
GroupName = GroupNameBuffer;
while (*GroupName) {
DbgPrint((DPRINT_REACTOS, "Driver group: '%s'\n", GroupName));
DbgPrint((DPRINT_REACTOS, "Driver group: '%S'\n", GroupName));
/* Query the Order */
BufferSize = sizeof(OrderList);
@@ -428,49 +422,45 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
/* Makre sure it's valid, and check if we're done */
if (rc == ERROR_NO_MORE_ITEMS) break;
if (rc != ERROR_SUCCESS) return;
DbgPrint((DPRINT_REACTOS, "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);
/* Read the Start Value */
ValueSize = sizeof(ULONG);
rc = RegQueryValue(hDriverKey, "Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
rc = RegQueryValue(hDriverKey, L"Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
if (rc != ERROR_SUCCESS) StartValue = (ULONG)-1;
DbgPrint((DPRINT_REACTOS, " Start: %x \n", (int)StartValue));
/* Read the Tag */
ValueSize = sizeof(ULONG);
rc = RegQueryValue(hDriverKey, "Tag", &ValueType, (PUCHAR)&TagValue, &ValueSize);
rc = RegQueryValue(hDriverKey, L"Tag", &ValueType, (PUCHAR)&TagValue, &ValueSize);
if (rc != ERROR_SUCCESS) TagValue = (ULONG)-1;
DbgPrint((DPRINT_REACTOS, " Tag: %x \n", (int)TagValue));
/* Read the driver's group */
DriverGroupSize = 256;
rc = RegQueryValue(hDriverKey, "Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
DbgPrint((DPRINT_REACTOS, " Group: '%s' \n", DriverGroup));
DriverGroupSize = sizeof(DriverGroup);
rc = RegQueryValue(hDriverKey, L"Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
DbgPrint((DPRINT_REACTOS, " Group: '%S' \n", DriverGroup));
/* Make sure it should be started */
if ((StartValue == 0) &&
(TagValue == OrderList[TagIndex]) &&
(_stricmp(DriverGroup, GroupName) == 0)) {
(_wcsicmp(DriverGroup, GroupName) == 0)) {
/* Get the Driver's Location */
ValueSize = 256;
rc = RegQueryValue(hDriverKey, "ImagePath", NULL, (PUCHAR)TempImagePath, &ValueSize);
ValueSize = sizeof(TempImagePath);
rc = RegQueryValue(hDriverKey, L"ImagePath", NULL, (PUCHAR)TempImagePath, &ValueSize);
/* Write the whole path if it suceeded, else prepare to fail */
if (rc != ERROR_SUCCESS) {
DbgPrint((DPRINT_REACTOS, " ImagePath: not found\n"));
strcpy(ImagePath, szSystemRoot);
strcat(ImagePath, "system32\\drivers\\");
strcat(ImagePath, ServiceName);
strcat(ImagePath, ".sys");
} else if (TempImagePath[0] != '\\') {
strcpy(ImagePath, szSystemRoot);
strcat(ImagePath, TempImagePath);
sprintf(ImagePath, "%s\\system32\\drivers\\%S.sys", szSystemRoot, ServiceName);
} else if (TempImagePath[0] != L'\\') {
sprintf(ImagePath, "%s%S", szSystemRoot, TempImagePath);
} else {
strcpy(ImagePath, TempImagePath);
sprintf(ImagePath, "%S", TempImagePath);
DbgPrint((DPRINT_REACTOS, " ImagePath: '%s'\n", ImagePath));
}
@@ -483,7 +473,7 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
} else {
DbgPrint((DPRINT_REACTOS, " Skipping driver '%s' with Start %d, Tag %d and Group '%s' (Current Tag %d, current group '%s')\n",
DbgPrint((DPRINT_REACTOS, " Skipping driver '%S' with Start %d, Tag %d and Group '%S' (Current Tag %d, current group '%S')\n",
ServiceName, StartValue, TagValue, DriverGroup, OrderList[TagIndex], GroupName));
}
@@ -501,27 +491,27 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
DbgPrint((DPRINT_REACTOS, "RegEnumKey(): rc %d\n", (int)rc));
if (rc == ERROR_NO_MORE_ITEMS) break;
if (rc != ERROR_SUCCESS) return;
DbgPrint((DPRINT_REACTOS, "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);
/* Read the Start Value */
ValueSize = sizeof(ULONG);
rc = RegQueryValue(hDriverKey, "Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
rc = RegQueryValue(hDriverKey, L"Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
if (rc != ERROR_SUCCESS) StartValue = (ULONG)-1;
DbgPrint((DPRINT_REACTOS, " Start: %x \n", (int)StartValue));
/* Read the Tag */
ValueSize = sizeof(ULONG);
rc = RegQueryValue(hDriverKey, "Tag", &ValueType, (PUCHAR)&TagValue, &ValueSize);
rc = RegQueryValue(hDriverKey, L"Tag", &ValueType, (PUCHAR)&TagValue, &ValueSize);
if (rc != ERROR_SUCCESS) TagValue = (ULONG)-1;
DbgPrint((DPRINT_REACTOS, " Tag: %x \n", (int)TagValue));
/* Read the driver's group */
DriverGroupSize = 256;
rc = RegQueryValue(hDriverKey, "Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
DbgPrint((DPRINT_REACTOS, " Group: '%s' \n", DriverGroup));
DriverGroupSize = sizeof(DriverGroup);
rc = RegQueryValue(hDriverKey, L"Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
DbgPrint((DPRINT_REACTOS, " Group: '%S' \n", DriverGroup));
for (TagIndex = 1; TagIndex <= OrderList[0]; TagIndex++) {
if (TagValue == OrderList[TagIndex]) break;
@@ -529,21 +519,17 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
if ((StartValue == 0) &&
(TagIndex > OrderList[0]) &&
(_stricmp(DriverGroup, GroupName) == 0)) {
(_wcsicmp(DriverGroup, GroupName) == 0)) {
ValueSize = 256;
rc = RegQueryValue(hDriverKey, "ImagePath", NULL, (PUCHAR)TempImagePath, &ValueSize);
ValueSize = sizeof(TempImagePath);
rc = RegQueryValue(hDriverKey, L"ImagePath", NULL, (PUCHAR)TempImagePath, &ValueSize);
if (rc != ERROR_SUCCESS) {
DbgPrint((DPRINT_REACTOS, " ImagePath: not found\n"));
strcpy(ImagePath, szSystemRoot);
strcat(ImagePath, "system32\\drivers\\");
strcat(ImagePath, ServiceName);
strcat(ImagePath, ".sys");
} else if (TempImagePath[0] != '\\') {
strcpy(ImagePath, szSystemRoot);
strcat(ImagePath, TempImagePath);
sprintf(ImagePath, "%ssystem32\\drivers\\%S.sys", szSystemRoot, ServiceName);
} else if (TempImagePath[0] != L'\\') {
sprintf(ImagePath, "%s%S", szSystemRoot, TempImagePath);
} else {
strcpy(ImagePath, TempImagePath);
sprintf(ImagePath, "%S", TempImagePath);
DbgPrint((DPRINT_REACTOS, " ImagePath: '%s'\n", ImagePath));
}
DbgPrint((DPRINT_REACTOS, " Loading driver: '%s'\n", ImagePath));
@@ -554,7 +540,7 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
} else {
DbgPrint((DPRINT_REACTOS, " Skipping driver '%s' with Start %d, Tag %d and Group '%s' (Current group '%s')\n",
DbgPrint((DPRINT_REACTOS, " Skipping driver '%S' with Start %d, Tag %d and Group '%S' (Current group '%S')\n",
ServiceName, StartValue, TagValue, DriverGroup, GroupName));
}
@@ -562,7 +548,7 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
}
/* Move to the next group name */
GroupName = GroupName + strlen(GroupName) + 1;
GroupName = GroupName + wcslen(GroupName) + 1;
}
}
@@ -841,7 +827,7 @@ LoadAndBootReactOS(PCSTR OperatingSystemName)
* Export the hardware hive
*/
Base = FrLdrCreateModule ("HARDWARE");
RegExportBinaryHive ("\\Registry\\Machine\\HARDWARE", (PCHAR)Base, &Size);
RegExportBinaryHive (L"\\Registry\\Machine\\HARDWARE", (PCHAR)Base, &Size);
FrLdrCloseModule (Base, Size);
UiDrawProgressBarCenter(20, 100, (PCHAR)"Loading ReactOS...");
+75 -69
View File
@@ -43,9 +43,9 @@ RegInitializeRegistry (VOID)
RootKey->SubKeyCount = 0;
RootKey->ValueCount = 0;
RootKey->NameSize = 2;
RootKey->Name = MmAllocateMemory (2);
strcpy (RootKey->Name, "\\");
RootKey->NameSize = 4;
RootKey->Name = MmAllocateMemory (4);
wcscpy (RootKey->Name, L"\\");
RootKey->DataType = 0;
RootKey->DataSize = 0;
@@ -53,37 +53,37 @@ RegInitializeRegistry (VOID)
/* Create 'SYSTEM' key */
RegCreateKey (RootKey,
"Registry\\Machine\\SYSTEM",
L"Registry\\Machine\\SYSTEM",
NULL);
/* Create 'HARDWARE' key */
RegCreateKey (RootKey,
"Registry\\Machine\\HARDWARE",
L"Registry\\Machine\\HARDWARE",
NULL);
/* Create 'HARDWARE\DESCRIPTION' key */
RegCreateKey (RootKey,
"Registry\\Machine\\HARDWARE\\DESCRIPTION",
L"Registry\\Machine\\HARDWARE\\DESCRIPTION",
NULL);
/* Create 'HARDWARE\DEVICEMAP' key */
RegCreateKey (RootKey,
"Registry\\Machine\\HARDWARE\\DEVICEMAP",
L"Registry\\Machine\\HARDWARE\\DEVICEMAP",
NULL);
/* Create 'HARDWARE\RESOURCEMAP' key */
RegCreateKey (RootKey,
"Registry\\Machine\\HARDWARE\\RESOURCEMAP",
L"Registry\\Machine\\HARDWARE\\RESOURCEMAP",
NULL);
/* Testcode */
#if 0
RegCreateKey (RootKey,
"Registry\\Machine\\HARDWARE\\DESCRIPTION\\TestKey",
L"Registry\\Machine\\HARDWARE\\DESCRIPTION\\TestKey",
&TestKey);
RegSetValue (TestKey,
"TestValue",
L"TestValue",
REG_SZ,
(PUCHAR)"TestString",
11);
@@ -94,7 +94,7 @@ RegInitializeRegistry (VOID)
LONG
RegInitCurrentControlSet(BOOL LastKnownGood)
{
CHAR ControlSetKeyName[80];
WCHAR ControlSetKeyName[80];
FRLDRHKEY SelectKey;
FRLDRHKEY SystemKey;
FRLDRHKEY ControlSetKey;
@@ -106,8 +106,8 @@ RegInitCurrentControlSet(BOOL LastKnownGood)
LONG Error;
Error = RegOpenKey(NULL,
"\\Registry\\Machine\\SYSTEM\\Select",
&SelectKey);
L"\\Registry\\Machine\\SYSTEM\\Select",
&SelectKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_REGISTRY, "RegOpenKey() failed (Error %u)\n", (int)Error));
@@ -116,7 +116,7 @@ RegInitCurrentControlSet(BOOL LastKnownGood)
DataSize = sizeof(ULONG);
Error = RegQueryValue(SelectKey,
"Default",
L"Default",
NULL,
(PUCHAR)&DefaultSet,
&DataSize);
@@ -128,7 +128,7 @@ RegInitCurrentControlSet(BOOL LastKnownGood)
DataSize = sizeof(ULONG);
Error = RegQueryValue(SelectKey,
"LastKnownGood",
L"LastKnownGood",
NULL,
(PUCHAR)&LastKnownGoodSet,
&DataSize);
@@ -139,28 +139,28 @@ RegInitCurrentControlSet(BOOL LastKnownGood)
}
CurrentSet = (LastKnownGood == TRUE) ? LastKnownGoodSet : DefaultSet;
strcpy(ControlSetKeyName, "ControlSet");
wcscpy(ControlSetKeyName, L"ControlSet");
switch(CurrentSet)
{
case 1:
strcat(ControlSetKeyName, "001");
wcscat(ControlSetKeyName, L"001");
break;
case 2:
strcat(ControlSetKeyName, "002");
wcscat(ControlSetKeyName, L"002");
break;
case 3:
strcat(ControlSetKeyName, "003");
wcscat(ControlSetKeyName, L"003");
break;
case 4:
strcat(ControlSetKeyName, "004");
wcscat(ControlSetKeyName, L"004");
break;
case 5:
strcat(ControlSetKeyName, "005");
wcscat(ControlSetKeyName, L"005");
break;
}
Error = RegOpenKey(NULL,
"\\Registry\\Machine\\SYSTEM",
L"\\Registry\\Machine\\SYSTEM",
&SystemKey);
if (Error != ERROR_SUCCESS)
{
@@ -178,7 +178,7 @@ RegInitCurrentControlSet(BOOL LastKnownGood)
}
Error = RegCreateKey(SystemKey,
"CurrentControlSet",
L"CurrentControlSet",
&LinkKey);
if (Error != ERROR_SUCCESS)
{
@@ -203,21 +203,22 @@ RegInitCurrentControlSet(BOOL LastKnownGood)
LONG
RegCreateKey(FRLDRHKEY ParentKey,
PCSTR KeyName,
PCWSTR KeyName,
PFRLDRHKEY Key)
{
PLIST_ENTRY Ptr;
FRLDRHKEY SearchKey = NULL;
FRLDRHKEY CurrentKey;
FRLDRHKEY NewKey;
PCHAR p;
PCSTR name;
PWCHAR p;
PCWSTR name;
int subkeyLength;
int stringLength;
ULONG NameSize;
DbgPrint((DPRINT_REGISTRY, "KeyName '%s'\n", KeyName));
DbgPrint((DPRINT_REGISTRY, "KeyName '%S'\n", KeyName));
if (*KeyName == '\\')
if (*KeyName == L'\\')
{
KeyName++;
CurrentKey = RootKey;
@@ -239,11 +240,11 @@ RegCreateKey(FRLDRHKEY ParentKey,
while (*KeyName != 0)
{
DbgPrint((DPRINT_REGISTRY, "KeyName '%s'\n", KeyName));
DbgPrint((DPRINT_REGISTRY, "KeyName '%S'\n", KeyName));
if (*KeyName == '\\')
if (*KeyName == L'\\')
KeyName++;
p = strchr(KeyName, '\\');
p = wcschr(KeyName, L'\\');
if ((p != NULL) && (p != KeyName))
{
subkeyLength = p - KeyName;
@@ -252,11 +253,12 @@ RegCreateKey(FRLDRHKEY ParentKey,
}
else
{
subkeyLength = strlen(KeyName);
subkeyLength = wcslen(KeyName);
stringLength = subkeyLength;
name = KeyName;
}
NameSize = (subkeyLength + 1) * sizeof(WCHAR);
Ptr = CurrentKey->SubKeyList.Flink;
while (Ptr != &CurrentKey->SubKeyList)
{
@@ -266,8 +268,9 @@ RegCreateKey(FRLDRHKEY ParentKey,
KEY,
KeyList);
DbgPrint((DPRINT_REGISTRY, "SearchKey 0x%x\n", SearchKey));
DbgPrint((DPRINT_REGISTRY, "Searching '%s'\n", SearchKey->Name));
if (_strnicmp(SearchKey->Name, name, subkeyLength) == 0)
DbgPrint((DPRINT_REGISTRY, "Searching '%S'\n", SearchKey->Name));
if (SearchKey->NameSize == NameSize &&
_wcsnicmp(SearchKey->Name, name, subkeyLength) == 0)
break;
Ptr = Ptr->Flink;
@@ -278,7 +281,7 @@ RegCreateKey(FRLDRHKEY ParentKey,
/* no key found -> create new subkey */
NewKey = (FRLDRHKEY)MmAllocateMemory(sizeof(KEY));
if (NewKey == NULL)
return(ERROR_OUTOFMEMORY);
return(ERROR_OUTOFMEMORY);
InitializeListHead(&NewKey->SubKeyList);
InitializeListHead(&NewKey->ValueList);
@@ -293,15 +296,15 @@ RegCreateKey(FRLDRHKEY ParentKey,
InsertTailList(&CurrentKey->SubKeyList, &NewKey->KeyList);
CurrentKey->SubKeyCount++;
NewKey->NameSize = subkeyLength + 1;
NewKey->Name = (PCHAR)MmAllocateMemory(NewKey->NameSize);
NewKey->NameSize = NameSize;
NewKey->Name = (PWCHAR)MmAllocateMemory(NewKey->NameSize);
if (NewKey->Name == NULL)
return(ERROR_OUTOFMEMORY);
memcpy(NewKey->Name, name, subkeyLength);
return(ERROR_OUTOFMEMORY);
memcpy(NewKey->Name, name, NewKey->NameSize - sizeof(WCHAR));
NewKey->Name[subkeyLength] = 0;
DbgPrint((DPRINT_REGISTRY, "NewKey 0x%x\n", NewKey));
DbgPrint((DPRINT_REGISTRY, "NewKey '%s' Length %d\n", NewKey->Name, NewKey->NameSize));
DbgPrint((DPRINT_REGISTRY, "NewKey '%S' Length %d\n", NewKey->Name, NewKey->NameSize));
CurrentKey = NewKey;
}
@@ -328,11 +331,11 @@ RegCreateKey(FRLDRHKEY ParentKey,
LONG
RegDeleteKey(FRLDRHKEY Key,
PCSTR Name)
PCWSTR Name)
{
if (strchr(Name, '\\') != NULL)
if (wcschr(Name, L'\\') != NULL)
return(ERROR_INVALID_PARAMETER);
@@ -344,7 +347,7 @@ RegDeleteKey(FRLDRHKEY Key,
LONG
RegEnumKey(FRLDRHKEY Key,
ULONG Index,
PCHAR Name,
PWCHAR Name,
ULONG* NameSize)
{
PLIST_ENTRY Ptr;
@@ -369,7 +372,7 @@ RegEnumKey(FRLDRHKEY Key,
KEY,
KeyList);
DbgPrint((DPRINT_REGISTRY, "Name '%s' Length %d\n", SearchKey->Name, SearchKey->NameSize));
DbgPrint((DPRINT_REGISTRY, "Name '%S' Length %d\n", SearchKey->Name, SearchKey->NameSize));
Size = min(SearchKey->NameSize, *NameSize);
*NameSize = Size;
@@ -381,22 +384,23 @@ RegEnumKey(FRLDRHKEY Key,
LONG
RegOpenKey(FRLDRHKEY ParentKey,
PCSTR KeyName,
PCWSTR KeyName,
PFRLDRHKEY Key)
{
PLIST_ENTRY Ptr;
FRLDRHKEY SearchKey = NULL;
FRLDRHKEY CurrentKey;
PCHAR p;
PCSTR name;
PWCHAR p;
PCWSTR name;
int subkeyLength;
int stringLength;
ULONG NameSize;
DbgPrint((DPRINT_REGISTRY, "KeyName '%s'\n", KeyName));
DbgPrint((DPRINT_REGISTRY, "KeyName '%S'\n", KeyName));
*Key = NULL;
if (*KeyName == '\\')
if (*KeyName == L'\\')
{
KeyName++;
CurrentKey = RootKey;
@@ -418,11 +422,11 @@ RegOpenKey(FRLDRHKEY ParentKey,
while (*KeyName != 0)
{
DbgPrint((DPRINT_REGISTRY, "KeyName '%s'\n", KeyName));
DbgPrint((DPRINT_REGISTRY, "KeyName '%S'\n", KeyName));
if (*KeyName == '\\')
if (*KeyName == L'\\')
KeyName++;
p = strchr(KeyName, '\\');
p = wcschr(KeyName, L'\\');
if ((p != NULL) && (p != KeyName))
{
subkeyLength = p - KeyName;
@@ -431,10 +435,11 @@ RegOpenKey(FRLDRHKEY ParentKey,
}
else
{
subkeyLength = strlen(KeyName);
subkeyLength = wcslen(KeyName);
stringLength = subkeyLength;
name = KeyName;
}
NameSize = (subkeyLength + 1) * sizeof(WCHAR);
Ptr = CurrentKey->SubKeyList.Flink;
while (Ptr != &CurrentKey->SubKeyList)
@@ -446,9 +451,10 @@ RegOpenKey(FRLDRHKEY ParentKey,
KeyList);
DbgPrint((DPRINT_REGISTRY, "SearchKey 0x%x\n", SearchKey));
DbgPrint((DPRINT_REGISTRY, "Searching '%s'\n", SearchKey->Name));
DbgPrint((DPRINT_REGISTRY, "Searching '%S'\n", SearchKey->Name));
if (_strnicmp(SearchKey->Name, name, subkeyLength) == 0)
if (SearchKey->NameSize == NameSize &&
_wcsnicmp(SearchKey->Name, name, subkeyLength) == 0)
break;
Ptr = Ptr->Flink;
@@ -481,7 +487,7 @@ RegOpenKey(FRLDRHKEY ParentKey,
LONG
RegSetValue(FRLDRHKEY Key,
PCSTR ValueName,
PCWSTR ValueName,
ULONG Type,
PCSTR Data,
ULONG DataSize)
@@ -489,7 +495,7 @@ RegSetValue(FRLDRHKEY Key,
PLIST_ENTRY Ptr;
PVALUE Value = NULL;
DbgPrint((DPRINT_REGISTRY, "Key 0x%x, ValueName '%s', Type %d, Data 0x%x, DataSize %d\n",
DbgPrint((DPRINT_REGISTRY, "Key 0x%x, ValueName '%S', Type %d, Data 0x%x, DataSize %d\n",
(int)Key, ValueName, (int)Type, (int)Data, (int)DataSize));
if ((ValueName == NULL) || (*ValueName == 0))
@@ -524,9 +530,9 @@ RegSetValue(FRLDRHKEY Key,
VALUE,
ValueList);
DbgPrint((DPRINT_REGISTRY, "Value->Name '%s'\n", Value->Name));
DbgPrint((DPRINT_REGISTRY, "Value->Name '%S'\n", Value->Name));
if (_stricmp(Value->Name, ValueName) == 0)
if (_wcsicmp(Value->Name, ValueName) == 0)
break;
Ptr = Ptr->Flink;
@@ -544,11 +550,11 @@ RegSetValue(FRLDRHKEY Key,
InsertTailList(&Key->ValueList, &Value->ValueList);
Key->ValueCount++;
Value->NameSize = strlen(ValueName)+1;
Value->Name = (PCHAR)MmAllocateMemory(Value->NameSize);
Value->NameSize = (wcslen(ValueName)+1)*sizeof(WCHAR);
Value->Name = (PWCHAR)MmAllocateMemory(Value->NameSize);
if (Value->Name == NULL)
return(ERROR_OUTOFMEMORY);
strcpy(Value->Name, ValueName);
wcscpy(Value->Name, ValueName);
Value->DataType = REG_NONE;
Value->DataSize = 0;
Value->Data = NULL;
@@ -582,7 +588,7 @@ RegSetValue(FRLDRHKEY Key,
LONG
RegQueryValue(FRLDRHKEY Key,
PCSTR ValueName,
PCWSTR ValueName,
ULONG* Type,
PUCHAR Data,
ULONG* DataSize)
@@ -629,9 +635,9 @@ RegQueryValue(FRLDRHKEY Key,
VALUE,
ValueList);
DbgPrint((DPRINT_REGISTRY, "Searching for '%s'. Value name '%s'\n", ValueName, Value->Name));
DbgPrint((DPRINT_REGISTRY, "Searching for '%S'. Value name '%S'\n", ValueName, Value->Name));
if (_stricmp(Value->Name, ValueName) == 0)
if (_wcsicmp(Value->Name, ValueName) == 0)
break;
Ptr = Ptr->Flink;
@@ -669,7 +675,7 @@ RegQueryValue(FRLDRHKEY Key,
LONG
RegDeleteValue(FRLDRHKEY Key,
PCSTR ValueName)
PCWSTR ValueName)
{
PLIST_ENTRY Ptr;
PVALUE Value = NULL;
@@ -692,7 +698,7 @@ RegDeleteValue(FRLDRHKEY Key,
Value = CONTAINING_RECORD(Ptr,
VALUE,
ValueList);
if (_stricmp(Value->Name, ValueName) == 0)
if (_wcsicmp(Value->Name, ValueName) == 0)
break;
Ptr = Ptr->Flink;
@@ -727,7 +733,7 @@ RegDeleteValue(FRLDRHKEY Key,
LONG
RegEnumValue(FRLDRHKEY Key,
ULONG Index,
PCHAR ValueName,
PWCHAR ValueName,
ULONG* NameSize,
ULONG* Type,
PUCHAR Data,
@@ -447,7 +447,7 @@ VOID RunLoader(VOID)
/* Export the hardware hive */
Base = FrLdrCreateModule ("HARDWARE");
RegExportBinaryHive ("\\Registry\\Machine\\HARDWARE", (PVOID)Base, &Size);
RegExportBinaryHive (L"\\Registry\\Machine\\HARDWARE", (PVOID)Base, &Size);
FrLdrCloseModule (Base, Size);
#if 0
@@ -598,6 +598,30 @@ for(;;);
/* Load buslogic.sys (depends on hardware detection) */
if (!LoadDriver(SourcePath, "buslogic.sys"))
return;
/*
* Load aic78u2.sys (depends on hardware detection)
*/
if (!LoadDriver(SourcePath, "aic78u2.sys"))
/*return*/;
/*
* Load trm390w.sys (depends on hardware detection)
*/
if (!LoadDriver(SourcePath, "trm390w.sys"))
/*return*/;
/*
* Load hpt3xx.sys (depends on hardware detection)
*/
if (!LoadDriver(SourcePath, "hpt3xx.sys"))
/*return*/;
/*
* Load inia100.sys (depends on hardware detection)
*/
if (!LoadDriver(SourcePath, "inia100.sys"))
/*return*/;
/* Load class2.sys */
if (!LoadDriver(SourcePath, "class2.sys"))