[NTOS:CONFIG] Do not ignore Rtl*String functions return value

CORE-17637
This commit is contained in:
Jérôme Gardou 2021-06-17 18:19:04 +02:00 committed by Jérôme Gardou
parent 3ad38f29b5
commit d924cb8271

View file

@ -472,22 +472,27 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
{ {
/* Convert it to Unicode */ /* Convert it to Unicode */
RtlInitAnsiString(&TempString, CpuString); RtlInitAnsiString(&TempString, CpuString);
RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE); if (NT_SUCCESS(RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE)))
{
/* Add it to the registry */
RtlInitUnicodeString(&ValueName, L"ProcessorNameString");
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_SZ,
Data.Buffer,
Data.Length + sizeof(UNICODE_NULL));
/* Add it to the registry */ /* ROS: Save a copy for bugzilla reporting */
RtlInitUnicodeString(&ValueName, L"ProcessorNameString"); if (!RtlCreateUnicodeString(&KeRosProcessorName, Data.Buffer))
Status = NtSetValueKey(KeyHandle, {
&ValueName, /* Do not fail for this */
0, KeRosProcessorName.Length = 0;
REG_SZ, }
Data.Buffer,
Data.Length + sizeof(UNICODE_NULL));
/* ROS: Save a copy for bugzilla reporting */ /* Free the temporary buffer */
RtlCreateUnicodeString(&KeRosProcessorName, Data.Buffer); RtlFreeUnicodeString(&Data);
}
/* Free the temporary buffer */
RtlFreeUnicodeString(&Data);
} }
/* Check if we had a Vendor ID */ /* Check if we had a Vendor ID */
@ -495,19 +500,20 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
{ {
/* Convert it to Unicode */ /* Convert it to Unicode */
RtlInitAnsiString(&TempString, Prcb->VendorString); RtlInitAnsiString(&TempString, Prcb->VendorString);
RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE); if (NT_SUCCESS(RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE)))
{
/* Add it to the registry */
RtlInitUnicodeString(&ValueName, L"VendorIdentifier");
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_SZ,
Data.Buffer,
Data.Length + sizeof(UNICODE_NULL));
/* Add it to the registry */ /* Free the temporary buffer */
RtlInitUnicodeString(&ValueName, L"VendorIdentifier"); RtlFreeUnicodeString(&Data);
Status = NtSetValueKey(KeyHandle, }
&ValueName,
0,
REG_SZ,
Data.Buffer,
Data.Length + sizeof(UNICODE_NULL));
/* Free the temporary buffer */
RtlFreeUnicodeString(&Data);
} }
/* Check if we have features bits */ /* Check if we have features bits */
@ -638,19 +644,20 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
{ {
/* Convert it to Unicode */ /* Convert it to Unicode */
RtlInitAnsiString(&TempString, Buffer); RtlInitAnsiString(&TempString, Buffer);
RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE); if (NT_SUCCESS(RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE)))
{
/* Write the date into the registry */
RtlInitUnicodeString(&ValueName, L"SystemBiosDate");
Status = NtSetValueKey(SystemHandle,
&ValueName,
0,
REG_SZ,
Data.Buffer,
Data.Length + sizeof(UNICODE_NULL));
/* Write the date into the registry */ /* Free the string */
RtlInitUnicodeString(&ValueName, L"SystemBiosDate"); RtlFreeUnicodeString(&Data);
Status = NtSetValueKey(SystemHandle, }
&ValueName,
0,
REG_SZ,
Data.Buffer,
Data.Length + sizeof(UNICODE_NULL));
/* Free the string */
RtlFreeUnicodeString(&Data);
if (BiosHandle) if (BiosHandle)
{ {
@ -672,7 +679,8 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
Data.Length + sizeof(UNICODE_NULL)); Data.Length + sizeof(UNICODE_NULL));
/* ROS: Save a copy for bugzilla reporting */ /* ROS: Save a copy for bugzilla reporting */
RtlCreateUnicodeString(&KeRosBiosDate, Data.Buffer); if (!RtlCreateUnicodeString(&KeRosBiosDate, Data.Buffer))
KeRosBiosDate.Length = 0;
/* Free the string */ /* Free the string */
RtlFreeUnicodeString(&Data); RtlFreeUnicodeString(&Data);
@ -692,7 +700,9 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
{ {
/* Convert to Unicode */ /* Convert to Unicode */
RtlInitAnsiString(&TempString, Buffer); RtlInitAnsiString(&TempString, Buffer);
RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE); Status = RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE);
if (!NT_SUCCESS(Status))
break;
/* Calculate the length of this string and copy it in */ /* Calculate the length of this string and copy it in */
Length = Data.Length + sizeof(UNICODE_NULL); Length = Data.Length + sizeof(UNICODE_NULL);
@ -732,7 +742,8 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
TotalLength); TotalLength);
/* ROS: Save a copy for bugzilla reporting */ /* ROS: Save a copy for bugzilla reporting */
RtlCreateUnicodeString(&KeRosBiosVersion, (PWCH)BiosVersion); if (!RtlCreateUnicodeString(&KeRosBiosVersion, (PWCH)BiosVersion))
KeRosBiosVersion.Length = 0;
} }
} }
@ -763,22 +774,24 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
{ {
/* Convert it to Unicode */ /* Convert it to Unicode */
RtlInitAnsiString(&TempString, Buffer); RtlInitAnsiString(&TempString, Buffer);
RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE); if (NT_SUCCESS(RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE)))
{
/* Write the date into the registry */
RtlInitUnicodeString(&ValueName, L"VideoBiosDate");
Status = NtSetValueKey(SystemHandle,
&ValueName,
0,
REG_SZ,
Data.Buffer,
Data.Length + sizeof(UNICODE_NULL));
/* Write the date into the registry */ /* ROS: Save a copy for bugzilla reporting */
RtlInitUnicodeString(&ValueName, L"VideoBiosDate"); if (!RtlCreateUnicodeString(&KeRosVideoBiosDate, Data.Buffer))
Status = NtSetValueKey(SystemHandle, KeRosVideoBiosDate.Length = 0;
&ValueName,
0,
REG_SZ,
Data.Buffer,
Data.Length + sizeof(UNICODE_NULL));
/* ROS: Save a copy for bugzilla reporting */ /* Free the string */
RtlCreateUnicodeString(&KeRosVideoBiosDate, Data.Buffer); RtlFreeUnicodeString(&Data);
}
/* Free the string */
RtlFreeUnicodeString(&Data);
} }
/* Get the Video BIOS Version */ /* Get the Video BIOS Version */
@ -790,7 +803,8 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
{ {
/* Convert to Unicode */ /* Convert to Unicode */
RtlInitAnsiString(&TempString, Buffer); RtlInitAnsiString(&TempString, Buffer);
RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE); if (!NT_SUCCESS(RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE)))
break;
/* Calculate the length of this string and copy it in */ /* Calculate the length of this string and copy it in */
Length = Data.Length + sizeof(UNICODE_NULL); Length = Data.Length + sizeof(UNICODE_NULL);
@ -830,7 +844,8 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
TotalLength); TotalLength);
/* ROS: Save a copy for bugzilla reporting */ /* ROS: Save a copy for bugzilla reporting */
RtlCreateUnicodeString(&KeRosVideoBiosVersion, (PWCH)BiosVersion); if (!RtlCreateUnicodeString(&KeRosVideoBiosVersion, (PWCH)BiosVersion))
KeRosVideoBiosVersion.Length = 0;
} }
} }