HalpPiix4Detect
CHAR __stdcall HalpPiix4Detect(CHAR a1){
int v1;
INT64 v3;
NTSTATUS BusData;
CHAR CpuInfo;
ULONG v6;
UINT8 v7;
INT64 v8;
unsigned int v9;
NTSTATUS v10;
unsigned __int8 v11;
ULONG v12;
bool v13;
ULONG v14;
INT64 v15;
VOID *v16;
_UNICODE_STRING *Class;
_UNICODE_STRING *Classa;
UINT64 CreateOptions;
UINT64 CreateOptionsa;
UINT64 *Disposition;
INT64 v23;
UINT8 v24[8];
VOID *Handle;
UINT64 v26;
VOID *KeyHandle;
UINT64 ObjectAttributes[7];
__int64 v29[2];
__int64 v30[2];
__int64 v31[2];
_UNICODE_STRING ValueName;
__int16 Buffer[32];
__int128 KeyValueInformation;
int v35;
v1 = 0;
KeyHandle = 0i64;
v24[0] = 0;
LODWORD(v26) = 0;
v24[1] = 0;
*(_DWORD *)&v24[4] = 0;
Handle = 0i64;
v24[2] = 0;
LODWORD(ObjectAttributes[0]) = 0;
memset(&ObjectAttributes[1], 0, 48);
memset(Buffer, 0i64, sizeof(Buffer));
*(_QWORD *)&ValueName.Length = 2490404i64;
ValueName.Buffer = L"EnableBXWorkAround";
v31[0] = 3276848i64;
v31[1] = (__int64)L"Services\\ACPI\\Parameters";
v30[0] = 1572886i64;
v30[1] = (__int64)L"Control\\HAL";
v29[0] = 5636180i64;
v29[1] = (__int64)L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET";
LOBYTE(BusData) = 0;
v35 = 0;
KeyValueInformation = 0i64;
if( a1 )
{
LODWORD(ObjectAttributes[1]) = 48;
ObjectAttributes[3] = (UINT64)v29;
ObjectAttributes[2] = 0i64;
LODWORD(ObjectAttributes[4]) = 64;
*(_OWORD *)&ObjectAttributes[5] = 0i64;
BusData = ZwOpenKey(
&KeyHandle,
0x20019ui64,
(_OBJECT_ATTRIBUTES *)&ObjectAttributes[1],
v3,
(INT64)Class,
CreateOptions,
(INT64)Disposition,
v23);
if( BusData < 0 )
return BusData;
ObjectAttributes[2] = (UINT64)KeyHandle;
LODWORD(ObjectAttributes[1]) = 48;
ObjectAttributes[3] = (UINT64)v30;
LODWORD(ObjectAttributes[4]) = 64;
LODWORD(CreateOptionsa) = 0;
*(_OWORD *)&ObjectAttributes[5] = 0i64;
BusData = ZwCreateKey(
&Handle,
0x20019ui64,
(_OBJECT_ATTRIBUTES *)&ObjectAttributes[1],
0i64,
0i64,
CreateOptionsa,
&v26);
if( BusData < 0 )
goto LABEL_74;
}
else if( !*(&CmpDummyThreadEvent + 4985) )
{
return BusData;
}
CpuInfo = HalpGetCpuInfo(0i64, 0i64, 0i64, v24);
v6 = 0;
v7 = CpuInfo != 0 ? v24[0] : 0;
v24[0] = 0;
LABEL_7:
LODWORD(v8) = 0;
v9 = 0;
while( 1 )
{
v8 = v9 & 0x1F | v8 & 0xFFFFFF00 | (32 * (v1 & 7u));
BusData = HalGetBusData(4i64, v6, v8, (INT64)Buffer, 2u);
if( !BusData )
break;
LOBYTE(BusData) = LOBYTE(Buffer[0]) - 1;
if( (unsigned __int16)(Buffer[0] - 1) > 0xFFFDu )
{
v13 = v1 == 0;
LABEL_57:
if( !v13 )
goto LABEL_58;
LABEL_59:
++v9;
v1 = 0;
if( v9 >= 0x20 )
{
if( ++v6 >= 0x100 )
break;
goto LABEL_7;
}
}
else
{
BusData = HalGetBusData(4i64, v6, (unsigned int)v8, (INT64)Buffer, 0x10u);
if( !BusData )
goto LABEL_58;
v10 = HalpInterruptModel();
v11 = Buffer[4];
v12 = 1;
if( v10 == 1 )
{
if( !a1 )
goto LABEL_51;
if( !v6 && !v9 && !v1 && Buffer[0] == 4358 && LOBYTE(Buffer[4]) < 0x80u )
HalpInterruptSetMsiOverride(0);
}
if( !a1 )
goto LABEL_51;
if( Buffer[0] == -32634 && ((Buffer[1] - 29072) & 0xFFFD) == 0 && v11 <= 2u )
{
v24[2] = v12;
HalGetBusDataByOffset(PCIConfiguration, v6, v8, &v24[1], 0x57u, v12);
v11 = Buffer[4];
if( ((v24[1] >> 5) & ((v24[1] & 0x18) != 0)) != 0 )
byte_140C49D28 = 1;
}
if( (int)HalpGetChipHacks(Buffer[0], Buffer[1], v11, &v24[4]) >= 0 )
{
if( (v24[4] & 2) != 0 )
byte_140C49EF4 = 1;
if( (v24[4] & 8) != 0 )
HalpWhackICHUsbSmi(v6, v8);
}
if( v7 != 2 || v24[0] )
goto LABEL_51;
LOBYTE(BusData) = -122;
if( Buffer[0] != -32634 )
goto LABEL_54;
if( v6 )
goto LABEL_52;
LOWORD(BusData) = Buffer[1];
if( v9 == 17 )
{
if( !v1 && Buffer[1] == -26416 )
goto LABEL_50;
if( v1 != 1 )
goto LABEL_53;
if( Buffer[1] == -26415 )
goto LABEL_50;
}
if( v9 != 16 )
goto LABEL_53;
if( v1 == 6 && Buffer[1] == -24368 || v1 == 7 && Buffer[1] == -24367 )
goto LABEL_50;
if( v1 == 6 )
{
if( Buffer[1] != 17360 )
goto LABEL_53;
if( !LOBYTE(Buffer[4]) )
goto LABEL_50;
}
if( v1 == 7 && Buffer[1] == 17361 )
{
if( LOBYTE(Buffer[4]) )
goto LABEL_58;
LABEL_50:
v24[0] = 1;
HalpInterruptSetLineSpecificOverride(0x17ui64);
HalpInterruptSetLineSpecificOverride(0x16ui64);
LABEL_51:
LOBYTE(BusData) = -122;
if( Buffer[0] != -32634 )
goto LABEL_54;
LABEL_52:
LOWORD(BusData) = Buffer[1];
}
LABEL_53:
if( (_WORD)BusData == 28944 )
{
*(&CmpDummyThreadEvent + 4985) = 1;
v14 = v8 & 0xFFFFFF1F | 0x60;
HalGetBusData(4i64, v6, v14, (INT64)Buffer, 0x40u);
LOBYTE(v15) = Buffer[4];
byte_140C49D48 = Buffer[4];
if( (dword_140C49EF0 & 2) == 0 )
KeBugCheckEx(0x5Cu, (PVOID)0x111, "minkernel\\hals\\lib\\acpi\\xxacpi.c", (PVOID)0x66D, 0i64);
if( LOBYTE(Buffer[4]) <= 1u )
{
BusNumber = v6;
SlotNumber = v14;
HalGetBusDataByOffset(PCIConfiguration, v6, v14, &dword_140C49D44, 0x58u, 4u);
*(_DWORD *)&dword_140C49D44 |= 0x23u;
HalSetBusDataByOffset(PCIConfiguration, BusNumber, SlotNumber, &dword_140C49D44, 0x58u, 4u);
}
LOBYTE(BusData) = HalpUsbLegacyStopUhciInterrupt(v15, v6, v14 & 0xFFFFFF5F, 1);
break;
}
LABEL_54:
if( !v1 )
{
v13 = SLOBYTE(Buffer[7]) >= 0;
goto LABEL_57;
}
LABEL_58:
if( (unsigned int)++v1 >= 8 )
goto LABEL_59;
}
}
if( a1 )
{
v16 = Handle;
if( Handle )
{
LOBYTE(BusData) = ZwClose((_HANDLE)Handle);
v16 = 0i64;
Handle = 0i64;
}
if( v24[2] )
{
ObjectAttributes[2] = (UINT64)KeyHandle;
LODWORD(ObjectAttributes[1]) = 48;
ObjectAttributes[3] = (UINT64)v31;
LODWORD(ObjectAttributes[4]) = 64;
LODWORD(CreateOptions) = 0;
*(_OWORD *)&ObjectAttributes[5] = 0i64;
BusData = ZwCreateKey(
&Handle,
0x20019ui64,
(_OBJECT_ATTRIBUTES *)&ObjectAttributes[1],
0i64,
0i64,
CreateOptions,
&v26);
if( BusData >= 0 )
{
LODWORD(Classa) = 20;
BusData = ZwQueryValueKey(
Handle,
&ValueName,
KeyValuePartialInformation,
&KeyValueInformation,
(UINT64)Classa,
ObjectAttributes);
if( BusData >= 0 )
{
if( DWORD2(KeyValueInformation) )
{
LOBYTE(BusData) = BYTE12(KeyValueInformation);
byte_140C49D28 = BYTE12(KeyValueInformation);
}
}
}
LABEL_74:
v16 = Handle;
}
if( v16 )
LOBYTE(BusData) = ZwClose((_HANDLE)v16);
if( KeyHandle )
LOBYTE(BusData) = ZwClose((_HANDLE)KeyHandle);
}
return BusData;
}Referenced by:
HaliInitPowerManagement
HalpAcpiPostSleep