- 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
} __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;
/* Set 'Component Information' value */
Error = RegSetValue(ComponentKey,
- "Component Information",
+ L"Component Information",
REG_BINARY,
(PCHAR)&CompInfo,
sizeof(CM_COMPONENT_INFORMATION));
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;
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);
/* 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));
/* Set 'Configuration Data' value */
Error = RegSetValue(BusKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
DiskGeometry->BytesPerSector));
Error = RegSetValue(DiskKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
ULONG i;
ULONG Checksum;
ULONG Signature;
- CHAR Identifier[20];
+ WCHAR Identifier[20];
LONG Error;
/* Read the MBR */
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];
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,
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
PCM_INT13_DRIVE_PARAMETER Int13Drives;
GEOMETRY Geometry;
- CHAR Buffer[80];
+ WCHAR Buffer[80];
FRLDRHKEY DiskKey;
ULONG DiskCount;
ULONG Size;
/* Set 'Configuration Data' value */
Error = RegSetValue(SystemKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
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,
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);
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;
Ptr = GetInt1eTable();
- sprintf(KeyName, "FloppyDiskPeripheral\\%u", FloppyNumber);
+ swprintf(KeyName, L"FloppyDiskPeripheral\\%u", FloppyNumber);
Error = RegCreateKey(ControllerKey,
- "FloppyDiskPeripheral\\0",
+ KeyName,
&PeripheralKey);
if (Error != ERROR_SUCCESS)
{
return;
}
- DbgPrint((DPRINT_HWDETECT, "Created key: %s\n", KeyName));
+ DbgPrint((DPRINT_HWDETECT, "Created key: %S\n", KeyName));
/* Set 'ComponentInformation' value */
SetComponentInformation(PeripheralKey,
/* Set 'Configuration Data' value */
Error = RegSetValue(PeripheralKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
}
/* 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,
return;
Error = RegCreateKey(BusKey,
- "DiskController\\0",
+ L"DiskController\\0",
&ControllerKey);
if (Error != ERROR_SUCCESS)
{
/* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
{
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,
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;
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)
{
FullResourceDescriptor.PartialResourceList.Count = 0;
Error = RegSetValue(PeripheralKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)&FullResourceDescriptor,
sizeof(CM_FULL_RESOURCE_DESCRIPTOR) -
/* 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,
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;
Base));
/* Create controller key */
- sprintf(Buffer,
- "SerialController\\%u",
+ swprintf(Buffer,
+ L"SerialController\\%u",
ControllerNumber);
Error = RegCreateKey(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,
/* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
}
/* 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,
"Created value: Identifier %s\n",
Buffer));
- /* Detect serial mouse */
- DetectSerialPointerPeripheral(ControllerKey, Base);
+ if (!Rs232PortInUse(Base))
+ {
+ /* Detect serial mouse */
+ DetectSerialPointerPeripheral(ControllerKey, Base);
+ }
ControllerNumber++;
}
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;
Base));
/* Create controller key */
- sprintf(Buffer,
- "ParallelController\\%u",
- ControllerNumber);
+ swprintf(Buffer,
+ L"ParallelController\\%u",
+ ControllerNumber);
Error = RegCreateKey(BusKey,
Buffer,
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,
/* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
}
/* 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,
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
PCM_KEYBOARD_DEVICE_DATA KeyboardData;
FRLDRHKEY PeripheralKey;
- char Buffer[80];
ULONG Size;
LONG Error;
{
/* Create controller key */
Error = RegCreateKey(ControllerKey,
- "KeyboardPeripheral\\0",
+ L"KeyboardPeripheral\\0",
&PeripheralKey);
if (Error != ERROR_SUCCESS)
{
/* Set 'Configuration Data' value */
Error = RegSetValue(PeripheralKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)FullResourceDescriptor,
Size);
}
/* 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,
/* Create controller key */
Error = RegCreateKey(BusKey,
- "KeyboardController\\0",
+ L"KeyboardController\\0",
&ControllerKey);
if (Error != ERROR_SUCCESS)
{
/* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)FullResourceDescriptor,
Size);
/* Create controller key */
Error = RegCreateKey(BusKey,
- "PointerController\\0",
+ L"PointerController\\0",
&ControllerKey);
if (Error != ERROR_SUCCESS)
{
/* Set 'Configuration Data' value */
Error = RegSetValue(ControllerKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)&FullResourceDescriptor,
sizeof(CM_FULL_RESOURCE_DESCRIPTOR));
/* Create peripheral key */
Error = RegCreateKey(ControllerKey,
- "PointerPeripheral\\0",
+ L"PointerPeripheral\\0",
&PeripheralKey);
if (Error != ERROR_SUCCESS)
{
/* Set 'Configuration Data' value */
Error = RegSetValue(PeripheralKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR)&FullResourceDescriptor,
sizeof(CM_FULL_RESOURCE_DESCRIPTOR) -
/* 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,
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)
{
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,
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);
/* 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));
/* Set 'Configuration Data' value */
Error = RegSetValue(BusKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
/* Create the 'System' key */
Error = RegCreateKey(NULL,
- "\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
+ L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
&SystemKey);
if (Error != ERROR_SUCCESS)
{
VOID
DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
{
- char Buffer[80];
+ WCHAR Buffer[80];
FRLDRHKEY BiosKey;
LONG Error;
{
AcpiPresent = TRUE;
/* Create new bus key */
- sprintf(Buffer,
- "MultifunctionAdapter\\%u", *BusNumber);
+ swprintf(Buffer,
+ L"MultifunctionAdapter\\%u", *BusNumber);
Error = RegCreateKey(SystemKey,
Buffer,
&BiosKey);
/* 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));
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);
/* 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));
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;
/* Create the CPU instance key */
Error = RegCreateKey(CpuKey,
- "0",
+ L"0",
&CpuInstKey);
if (Error != ERROR_SUCCESS)
{
/* Create the FPU instance key */
Error = RegCreateKey(FpuKey,
- "0",
+ L"0",
&FpuInstKey);
if (Error != ERROR_SUCCESS)
{
/* 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;
{
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));
DbgPrint((DPRINT_HWDETECT, "FeatureSet: %x\n", FeatureSet));
Error = RegSetValue(CpuInstKey,
- "FeatureSet",
+ L"FeatureSet",
REG_DWORD,
(PCHAR)&FeatureSet,
sizeof(ULONG));
}
/* 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));
CpuSpeed = GetCpuSpeed();
Error = RegSetValue(CpuInstKey,
- "~MHz",
+ L"~MHz",
REG_DWORD,
(PCHAR)&CpuSpeed,
sizeof(ULONG));
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;
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,
/* 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));
DbgPrint((DPRINT_HWDETECT, "FeatureSet: %x\n", FeatureSet));
Error = RegSetValue(CpuInstKey,
- "FeatureSet",
+ L"FeatureSet",
REG_DWORD,
(PCHAR)&FeatureSet,
sizeof(ULONG));
}
/* 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));
CpuSpeed = GetCpuSpeed();
Error = RegSetValue(CpuInstKey,
- "~MHz",
+ L"~MHz",
REG_DWORD,
(PCHAR)&CpuSpeed,
sizeof(ULONG));
/* Create the 'CentralProcessor' key */
Error = RegCreateKey(SystemKey,
- "CentralProcessor",
+ L"CentralProcessor",
&CpuKey);
if (Error != ERROR_SUCCESS)
{
/* Create the 'FloatingPointProcessor' key */
Error = RegCreateKey(SystemKey,
- "FloatingPointProcessor",
+ L"FloatingPointProcessor",
&FpuKey);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_HWDETECT, "Table size: %u\n", Table->Size));
Error = RegCreateKey(BusKey,
- "RealModeIrqRoutingTable\\0",
+ L"RealModeIrqRoutingTable\\0",
&TableKey);
if (Error != ERROR_SUCCESS)
{
/* 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));
/* Set 'Configuration Data' value */
Error = RegSetValue(TableKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
{
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
CM_PCI_BUS_DATA BusData;
- char Buffer[80];
+ WCHAR Buffer[80];
FRLDRHKEY BiosKey;
ULONG Size;
LONG Error;
if (FindPciBios(&BusData))
{
/* Create new bus key */
- sprintf(Buffer,
- "MultifunctionAdapter\\%u", *BusNumber);
+ swprintf(Buffer,
+ L"MultifunctionAdapter\\%u", *BusNumber);
Error = RegCreateKey(SystemKey,
Buffer,
&BiosKey);
/* 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));
/* Set 'Configuration Data' value */
Error = RegSetValue(BiosKey,
- "Configuration Data",
+ L"Configuration Data",
REG_FULL_RESOURCE_DESCRIPTOR,
(PCHAR) FullResourceDescriptor,
Size);
/* 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);
/* 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));
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
/* MACROS *******************************************************************/
-#ifndef DEBUG
+#ifdef DEBUG
#define DEFAULT_BAUD_RATE 19200
}
#endif
+
+BOOL Rs232PortInUse(ULONG Base)
+{
+#ifdef DEBUG
+ return PortInitialized && Rs232PortBase == (PUCHAR)Base ? TRUE : FALSE;
+#else
+ return FALSE;
+#endif
+}
#include <freeldr.h>
+#include <debug.h>
+
#ifdef DEBUG
//#define DEBUG_ALL
VOID DebugInit(VOID)
{
- if (DebugPort == RS232)
+ if (DebugPort & RS232)
{
Rs232PortInitialize(ComPort, BaudRate);
}
}
}
-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))
DebugStartOfLine = FALSE;
}
- DebugPrintV(format, ++dataptr);
+ vsprintf(Buffer, format, (PVOID)(++dataptr));
+ while (*ptr)
+ {
+ DebugPrintChar(*ptr++);
+ }
}
VOID DebugPrint1(char *format, ...)
{
int *dataptr = (int *) &format;
-
- DebugPrintV(format, ++dataptr);
+ char Buffer[4096];
+ char *ptr = Buffer;
+
+ vsprintf(Buffer, format, (PVOID)(++dataptr));
+ while (*ptr)
+ {
+ DebugPrintChar(*ptr++);
+ }
}
VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)
-<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>
<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>
<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>
<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>
<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>
BOOL Rs232PortGetByte(PUCHAR ByteRecieved);
BOOL Rs232PortPollByte(PUCHAR ByteRecieved);
VOID Rs232PortPutByte(UCHAR ByteToSend);
-
+BOOL Rs232PortInUse(ULONG Base);
#endif // defined __RS232_H
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_)
/* 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")
ULONG ValueCount;
ULONG NameSize;
- PCHAR Name;
+ PWCHAR Name;
/* default data */
ULONG DataType;
/* value name */
ULONG NameSize;
- PCHAR Name;
+ PWCHAR Name;
/* value data */
ULONG DataType;
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,
ULONG ChunkSize);
BOOL
-RegExportBinaryHive (PCSTR KeyName,
+RegExportBinaryHive (PCWSTR KeyName,
PCHAR ChunkBase,
ULONG* ChunkSize);
/*
* FreeLoader
- * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
+ * Copyright (C) 1998-2005 Brian Palmer <brianp@sginet.com>
*
* 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
/* just some stuff */
-#define VERSION "FreeLoader v2.0"
-#define COPYRIGHT "Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>"
+#define VERSION "FreeLoader v2.1"
+#define COPYRIGHT "Copyright (C) 1998-2005 Brian Palmer <brianp@sginet.com>"
#define AUTHOR_EMAIL "<brianp@sginet.com>"
#define BY_AUTHOR "by Brian Palmer"
// 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
/* Key cell identifier "kn" (0x6b6e) */
USHORT Id;
- /* ? */
- USHORT Type;
+ /* Flags */
+ USHORT Flags;
/* Time of last flush */
ULONGLONG LastWriteTime; /* FILETIME */
/* 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 :
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;
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;
HashBlock->Table[i].KeyOffset = NKBOffset;
memcpy (&HashBlock->Table[i].HashValue,
NewKeyCell->Name,
- 4);
+ min(NewKeyCell->NameSize, sizeof(ULONG)));
ParentKeyCell->NumberOfSubKeys++;
return TRUE;
}
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,
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;
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,
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));
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))
{
}
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;
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"));
/* 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;
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,
static BOOL
CmiExportHive (PREGISTRY_HIVE Hive,
- PCSTR KeyName)
+ PCWSTR KeyName)
{
PKEY_CELL KeyCell;
FRLDRHKEY Key;
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)
{
{
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)
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;
}
}
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;
}
PKEY_CELL SubKeyCell;
PVALUE_LIST_CELL ValueListCell;
PVALUE_CELL ValueCell = NULL;
- PCHAR cName;
+ PWCHAR wName;
FRLDRHKEY SubKey;
LONG Error;
ULONG i;
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"));
/* Open 'System' key */
Error = RegOpenKey(NULL,
- "\\Registry\\Machine\\SYSTEM",
+ L"\\Registry\\Machine\\SYSTEM",
&SystemKey);
if (Error != ERROR_SUCCESS)
{
BOOL
-RegExportBinaryHive(PCSTR KeyName,
+RegExportBinaryHive(PCWSTR KeyName,
PCHAR ChunkBase,
ULONG* ChunkSize)
{
{
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) {
}
/* 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) {
}
/* 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")) {
}
/* 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) {
}
/* 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")) {
/* 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) {
}
/* 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) {
}
/* 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")) {
{
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) {
/* 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) {
/* enumerate drivers */
rc = RegOpenKey(NULL,
- "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
+ L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
&hServiceKey);
if (rc != ERROR_SUCCESS) {
/* 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);
/* 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));
}
} 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));
}
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;
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));
} 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));
}
}
/* Move to the next group name */
- GroupName = GroupName + strlen(GroupName) + 1;
+ GroupName = GroupName + wcslen(GroupName) + 1;
}
}
* 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...");
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;
/* 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);
LONG
RegInitCurrentControlSet(BOOL LastKnownGood)
{
- CHAR ControlSetKeyName[80];
+ WCHAR ControlSetKeyName[80];
FRLDRHKEY SelectKey;
FRLDRHKEY SystemKey;
FRLDRHKEY ControlSetKey;
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));
DataSize = sizeof(ULONG);
Error = RegQueryValue(SelectKey,
- "Default",
+ L"Default",
NULL,
(PUCHAR)&DefaultSet,
&DataSize);
DataSize = sizeof(ULONG);
Error = RegQueryValue(SelectKey,
- "LastKnownGood",
+ L"LastKnownGood",
NULL,
(PUCHAR)&LastKnownGoodSet,
&DataSize);
}
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)
{
}
Error = RegCreateKey(SystemKey,
- "CurrentControlSet",
+ L"CurrentControlSet",
&LinkKey);
if (Error != ERROR_SUCCESS)
{
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;
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;
}
else
{
- subkeyLength = strlen(KeyName);
+ subkeyLength = wcslen(KeyName);
stringLength = subkeyLength;
name = KeyName;
}
-
+ NameSize = (subkeyLength + 1) * sizeof(WCHAR);
+
Ptr = CurrentKey->SubKeyList.Flink;
while (Ptr != &CurrentKey->SubKeyList)
{
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;
/* 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);
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;
}
LONG
RegDeleteKey(FRLDRHKEY Key,
- PCSTR Name)
+ PCWSTR Name)
{
- if (strchr(Name, '\\') != NULL)
+ if (wcschr(Name, L'\\') != NULL)
return(ERROR_INVALID_PARAMETER);
LONG
RegEnumKey(FRLDRHKEY Key,
ULONG Index,
- PCHAR Name,
+ PWCHAR Name,
ULONG* NameSize)
{
PLIST_ENTRY Ptr;
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;
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;
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;
}
else
{
- subkeyLength = strlen(KeyName);
+ subkeyLength = wcslen(KeyName);
stringLength = subkeyLength;
name = KeyName;
}
+ NameSize = (subkeyLength + 1) * sizeof(WCHAR);
Ptr = CurrentKey->SubKeyList.Flink;
while (Ptr != &CurrentKey->SubKeyList)
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;
LONG
RegSetValue(FRLDRHKEY Key,
- PCSTR ValueName,
+ PCWSTR ValueName,
ULONG Type,
PCSTR Data,
ULONG DataSize)
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))
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;
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;
LONG
RegQueryValue(FRLDRHKEY Key,
- PCSTR ValueName,
+ PCWSTR ValueName,
ULONG* Type,
PUCHAR Data,
ULONG* DataSize)
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;
LONG
RegDeleteValue(FRLDRHKEY Key,
- PCSTR ValueName)
+ PCWSTR ValueName)
{
PLIST_ENTRY Ptr;
PVALUE Value = NULL;
Value = CONTAINING_RECORD(Ptr,
VALUE,
ValueList);
- if (_stricmp(Value->Name, ValueName) == 0)
+ if (_wcsicmp(Value->Name, ValueName) == 0)
break;
Ptr = Ptr->Flink;
LONG
RegEnumValue(FRLDRHKEY Key,
ULONG Index,
- PCHAR ValueName,
+ PWCHAR ValueName,
ULONG* NameSize,
ULONG* Type,
PUCHAR Data,
/* 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
/* 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"))