HalSetRealTimeClock
INT8 __fastcall HalSetRealTimeClock(INT16 *a1){
__int64 v2;
unsigned int v3;
_EX_TIMEZONE_STATE *ExTimeZoneState;
signed __int64 v5;
INT64 v6;
__int64 QuadPart;
unsigned int v9;
int v10;
NTSTATUS v11;
INT8 v12;
char v13;
int v14[8];
_LARGE_INTEGER UtcTime;
__int64 v16;
_ACPI_REAL_TIME AcpiRealTime;
UtcTime.QuadPart = 0i64;
v16 = 0i64;
v2 = *(&ExBootDevicesRemovedEvent + 103);
AcpiRealTime = 0i64;
if( *(&ExBootDevicesRemovedEvent + 103) && **(&ExBootDevicesRemovedEvent + 103) )
{
v3 = *(_DWORD *)(*(&ExBootDevicesRemovedEvent + 103) + 4i64);
_InterlockedOr(v14, 0);
if( !RtlpTimeFieldsToTimeNoLeapSeconds(a1, &v16) )
return 0;
v6 = 0i64;
if( !v3 )
{
QuadPart = v16;
goto LABEL_18;
}
ExTimeZoneState = (_EX_TIMEZONE_STATE *)(v2 + 8);
QuadPart = v16;
while( 1 )
{
v5 = *(_QWORD *)&ExTimeZoneState->TimeZoneInformation.tzi.Bias;
if( *(__int64 *)&ExTimeZoneState->TimeZoneInformation.tzi.Bias < 0 )
{
v5 &= ~0x8000000000000000ui64;
if( QuadPart < v5 + 10000000 )
{
if( QuadPart < v5 )
{
LABEL_18:
UtcTime.QuadPart = QuadPart;
goto LABEL_22;
}
return 0;
}
QuadPart -= 10000000i64;
}
else if( QuadPart < v5 + 10000000 )
{
if( QuadPart < v5 )
goto LABEL_18;
QuadPart = 2 * QuadPart - v5;
}
else
{
QuadPart += 10000000i64;
}
v6 = (unsigned int)(v6 + 1);
ExTimeZoneState = (_EX_TIMEZONE_STATE *)((char *)ExTimeZoneState + 8);
if( (unsigned int)v6 >= v3 )
goto LABEL_18;
}
}
if( !RtlpTimeFieldsToTimeNoLeapSeconds(a1, &UtcTime) )
return 0;
QuadPart = UtcTime.QuadPart;
LABEL_22:
if( !*(&stru_140CF2E80 + 1829) )
{
ExTimeZoneState = PsGetCurrentServerSiloGlobals((_KSPIN_LOCK *)v5)->ExTimeZoneState;
UtcTime.QuadPart = ExTimeZoneState->TimeZoneBias.QuadPart + QuadPart;
}
v9 = ((unsigned int)HalpPlatformFlags >> 2) & 1;
if( v9 )
HalpWriteCmosTime((UINT8 *)a1, (INT64)ExTimeZoneState, v6);
v10 = dword_140C49D0C;
v11 = -1073741823;
if( KeGetCurrentIrql() >= 2u
|| dword_140C49D0C
|| (v11 = HalpUtcTimeToAcpiRealTime(&UtcTime, &AcpiRealTime), v11 < 0)
|| (v11 = HalpSetAcpiRealTimeClock(&AcpiRealTime), v11 < 0) )
{
if( (_BYTE)v9 != 1 && byte_140C49D08 && v10 && (HalpPlatformFlags & 8) == 0 )
v11 = HalEfiSetTime(&UtcTime);
}
if( v11 >= 0 )
LOBYTE(v9) = 1;
HalpSetVirtualRtc(&UtcTime);
v12 = v9;
if( v13 )
return 1;
return v12;
}Referenced by:
ExpRefreshSystemTime
ExpSetSystemTime
GetBootSystemTime
NtSetSystemTime