NTAPI
CmpGetIntelBrandString(OUT PCHAR CpuString)
{
- ULONG BrandId, Ebx, Signature, Dummy;
-
+ CPU_INFO CpuInfo;
+ ULONG BrandId, Signature;
+
/* Get the Brand Id */
- CPUID(0x00000001, &Signature, &Ebx, &Dummy, &Dummy);
- BrandId = Ebx & 0xFF;
+ KiCpuId(&CpuInfo, 0x00000001);
+ Signature = CpuInfo.Eax;
+ BrandId = CpuInfo.Ebx & 0xFF;
switch (BrandId)
{
HANDLE KeyHandle, BiosHandle, SystemHandle, FpuHandle, SectionHandle;
CONFIGURATION_COMPONENT_DATA ConfigData;
CHAR Buffer[128];
- ULONG VendorId, ExtendedId, Dummy;
+ CPU_INFO CpuInfo;
+ ULONG VendorId, ExtendedId;
PKPRCB Prcb;
USHORT IndexTable[MaximumType + 1] = {0};
ANSI_STRING TempString;
NULL,
NULL);
Status = NtOpenKey(&SystemHandle, KEY_READ | KEY_WRITE, &ObjectAttributes);
- if (!NT_SUCCESS(Status)) return Status;
+ if (!NT_SUCCESS(Status))
+ return Status;
/* Create the BIOS Information key */
RtlInitUnicodeString(&KeyName,
NULL,
REG_OPTION_NON_VOLATILE,
&Disposition);
- if (ExpInTextModeSetup)
+ if (!NT_SUCCESS(Status))
{
- if (!NT_SUCCESS(Status))
- BiosHandle = NULL;
- }
- else if (!NT_SUCCESS(Status))
+ NtClose(SystemHandle);
return Status;
+ }
/* Create the CPU Key, and check if it already existed */
RtlInitUnicodeString(&KeyName, L"CentralProcessor");
CmpConfigurationData = ExAllocatePoolWithTag(PagedPool,
CmpConfigurationAreaSize,
TAG_CM);
- if (!CmpConfigurationData) return STATUS_INSUFFICIENT_RESOURCES;
+ if (!CmpConfigurationData)
+ {
+ // FIXME: Cleanup stuff!!
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
/* Loop all CPUs */
for (i = 0; i < KeNumberProcessors; i++)
Prcb = KiProcessorBlock[i];
/* Setup the Configuration Entry for the Processor */
- RtlZeroMemory(&ConfigData, sizeof (ConfigData));
+ RtlZeroMemory(&ConfigData, sizeof(ConfigData));
ConfigData.ComponentEntry.Class = ProcessorClass;
ConfigData.ComponentEntry.Type = CentralProcessor;
ConfigData.ComponentEntry.Key = i;
InterfaceTypeUndefined,
0xFFFFFFFF,
IndexTable);
- if (!NT_SUCCESS(Status)) return(Status);
+ if (!NT_SUCCESS(Status))
+ {
+ NtClose(BiosHandle);
+ NtClose(SystemHandle);
+ return Status;
+ }
/* Check if we have an FPU */
if (KeI386NpxPresent)
IndexTable);
if (!NT_SUCCESS(Status))
{
- /* Failed, close the CPU handle and return */
+ /* We failed, close all the opened handles and return */
NtClose(KeyHandle);
+ NtClose(BiosHandle);
+ NtClose(SystemHandle);
return Status;
}
else
{
/* Check if we have extended CPUID that supports name ID */
- CPUID(0x80000000, &ExtendedId, &Dummy, &Dummy, &Dummy);
+ KiCpuId(&CpuInfo, 0x80000000);
+ ExtendedId = CpuInfo.Eax;
if (ExtendedId >= 0x80000004)
{
/* Do all the CPUIDs required to get the full name */
for (ExtendedId = 2; ExtendedId <= 4; ExtendedId++)
{
/* Do the CPUID and save the name string */
- CPUID(0x80000000 | ExtendedId,
- (PULONG)PartialString,
- (PULONG)PartialString + 1,
- (PULONG)PartialString + 2,
- (PULONG)PartialString + 3);
+ KiCpuId(&CpuInfo, 0x80000000 | ExtendedId);
+ ((PULONG)PartialString)[0] = CpuInfo.Eax;
+ ((PULONG)PartialString)[1] = CpuInfo.Ebx;
+ ((PULONG)PartialString)[2] = CpuInfo.Ecx;
+ ((PULONG)PartialString)[3] = CpuInfo.Edx;
/* Go to the next name string */
PartialString += 16;
}
else
{
- CPUID(0x00000000, &Dummy, &VendorId, &Dummy, &Dummy);
+ KiCpuId(&CpuInfo, 0x00000000);
+ VendorId = CpuInfo.Ebx;
PartialString = CpuString;
switch (VendorId)
{
Status = ZwOpenSection(&SectionHandle,
SECTION_ALL_ACCESS,
&ObjectAttributes);
- if (!NT_SUCCESS(Status)) goto Quickie;
+ if (!NT_SUCCESS(Status))
+ {
+ /* We failed, close all the opened handles and return */
+ // NtClose(KeyHandle);
+ NtClose(BiosHandle);
+ NtClose(SystemHandle);
+ /* 'Quickie' closes KeyHandle */
+ goto Quickie;
+ }
/* Map the first 1KB of memory to get the IVT */
ViewSize = PAGE_SIZE;
if (BiosVersion) ExFreePoolWithTag(BiosVersion, TAG_CM);
Quickie:
- /* Close the procesor handle */
+ /* Close the processor handle */
NtClose(KeyHandle);
return STATUS_SUCCESS;
}