PopBatteryCheckCompositeCapacity
VOID __stdcall PopBatteryCheckCompositeCapacity(
_BATTERY_STATUS *CompositeStatus,
_SYSTEM_POWER_CONDITION AcDc,
INT64 a3,
INT64 a4,
INT64 a5,
INT64 a6,
INT64 a7,
INT64 a8){
unsigned __int8 v11;
unsigned int v12;
const CHAR *v13;
const CHAR *v14;
const CHAR *v15;
const CHAR *v16;
const CHAR *v17;
__int64 Capacity;
unsigned __int64 v19;
int v20;
unsigned int v21;
unsigned int v22;
unsigned int v23;
unsigned int v24;
const CHAR *v25;
bool v26;
const CHAR *v27;
const CHAR *v28;
const CHAR *v29;
unsigned __int8 v30;
const CHAR *v31;
const CHAR *v32;
const CHAR *v33;
const CHAR *v34;
const CHAR *v35;
const CHAR *v36;
const CHAR *v37;
const CHAR *v38;
int v39;
unsigned int v40;
__int64 v41;
unsigned int v42;
unsigned __int64 v43;
const CHAR *v44;
unsigned __int8 v45;
const CHAR *v46;
const CHAR *v47;
const CHAR *v48;
const CHAR *v49;
const CHAR *v50;
const CHAR *v51;
int v52;
__int64 v53;
__int64 v54;
unsigned int v55;
unsigned __int64 v56;
UINT64 MatchingChangeStamp;
UINT64 CheckStamp;
int Buffer;
int v60;
unsigned int v61;
unsigned int v62;
int v63;
int v64;
unsigned int v65;
unsigned int Voltage;
int Rate;
int v68;
__int64 v69;
_EVENT_DATA_DESCRIPTOR v70[2];
int *v71;
__int64 v72;
unsigned int *v73;
__int64 v74;
INT64 v75[2];
INT64 v76[2];
INT64 v77[2];
INT64 v78[2];
INT64 v79[2];
INT64 v80[2];
INT64 v81[2];
int *v82;
__int64 v83;
int *v84;
__int64 v85;
int *v86;
__int64 v87;
int *v88;
__int64 v89;
unsigned int *p_Voltage;
__int64 v91;
int *p_Rate;
__int64 v93;
int *p_Buffer;
__int64 v95;
__int64 *v96;
__int64 v97;
*(_DWORD *)a3 = 0;
if( !(_DWORD)Data )
{
v11 = 0;
*(&stru_140C23628 + 36) = 0;
LABEL_3:
LOBYTE(v12) = 0;
LABEL_4:
*(&stru_140C23628 + 44) = 0;
goto LABEL_5;
}
Capacity = CompositeStatus->Capacity;
LODWORD(v19) = 100000;
if( HIDWORD(qword_140C23580) > (unsigned int)Capacity )
{
if( HIDWORD(qword_140C23580) )
v19 = 100000 * Capacity / (unsigned __int64)HIDWORD(qword_140C23580);
else
LODWORD(v19) = 0;
}
v20 = 0;
if( *(&stru_140C23628 + 33) != -1 )
v20 = v19 - *(&stru_140C23628 + 33);
v21 = ((int)v19 + 500) / 0x3E8u;
v22 = (*(&stru_140C23628 + 33) + 500) / 0x3E8u;
if( v21 != v22 )
*(_DWORD *)a3 = v21 - v22;
v11 = *(&stru_140C23628 + 148);
LOBYTE(v12) = *(&stru_140C23628 + 128);
*(&stru_140C23628 + 33) = v19;
if( AcDc == 1 )
{
v11 = 0;
*(&stru_140C23628 + 36) = 0;
LOBYTE(v12) = 1;
goto LABEL_4;
}
if( AcDc != ((qword_140C23560 & 1) == 0) )
{
v11 = 0;
LABEL_20:
*(&stru_140C23628 + 36) = v19;
goto LABEL_3;
}
if( byte_140C23538 )
{
if( *(&stru_140C23628 + 148) )
goto LABEL_3;
goto LABEL_20;
}
v23 = *(&stru_140C23628 + 36);
if( *(&stru_140C23628 + 36) < (unsigned int)v19 )
{
v23 = v19;
*(&stru_140C23628 + 36) = v19;
}
if( v23 > (int)v19 + WeakChargerChargeDropMilliPercent )
v11 = 1;
v24 = v20 + *(&stru_140C23628 + 44);
*(&stru_140C23628 + 44) = v24;
if( (int)abs32(v24) >= BatteryChargeTrajectoryThresholdMilliPercent )
{
v12 = v24 >> 31;
goto LABEL_4;
}
LABEL_5:
v13 = "AC Power";
v14 = "Battery Discharging";
v15 = "Battery Charging";
v16 = "Battery Critical";
v17 = "Battery charge limiting mode";
if( *(&stru_140C23628 + 148) != v11 )
{
LODWORD(CheckStamp) = 0;
*(&stru_140C23628 + 148) = v11;
LODWORD(MatchingChangeStamp) = 0;
Buffer = v11;
ZwUpdateWnfStateData(&WNF_PO_WEAK_CHARGER, &Buffer, 4ui64, 0i64, 0i64, MatchingChangeStamp, CheckStamp);
if( *(&stru_140C00F40 + 1194) > 5u )
{
if( tlgKeywordOn((__int64)&stru_140C00F40 + 4776, 0x400000000000i64) )
{
v71 = &v60;
v25 = "AC Power";
v61 = Data;
v73 = &v61;
v26 = (CompositeStatus->PowerState & 1) == 0;
v60 = *(&stru_140C23628 + 148);
if( v26 )
v25 = "DC Power";
v72 = 4i64;
v74 = 4i64;
tlgCreate1Sz_char((INT64)v75, v25);
v27 = "Battery Discharging";
if( (CompositeStatus->PowerState & 2) == 0 )
v27 = "-";
tlgCreate1Sz_char((INT64)v76, v27);
v29 = "Battery Charging";
if( ((unsigned __int8)CompositeStatus->PowerState & v30) == 0 )
v29 = v28;
tlgCreate1Sz_char((INT64)v77, v29);
v32 = "Battery Critical";
if( (CompositeStatus->PowerState & 8) == 0 )
v32 = v31;
tlgCreate1Sz_char((INT64)v78, v32);
v34 = "Battery charge limiting mode";
if( (CompositeStatus->PowerState & 0x10) == 0 )
v34 = v33;
tlgCreate1Sz_char((INT64)v79, v34);
v36 = "Battery charging state power supply present";
if( (CompositeStatus->PowerState & 0x20) == 0 )
v36 = v35;
tlgCreate1Sz_char((INT64)v80, v36);
v38 = "Battery charging state adequate";
if( (CompositeStatus->PowerState & 0x40) == 0 )
v38 = v37;
tlgCreate1Sz_char((INT64)v81, v38);
v41 = CompositeStatus->Capacity;
if( HIDWORD(qword_140C23580) )
v42 = (unsigned int)((HIDWORD(qword_140C23580) >> 1) + 100 * v41) / HIDWORD(qword_140C23580);
else
v42 = v40;
v62 = v42;
v82 = (int *)&v62;
v83 = 4i64;
if( HIDWORD(qword_140C23580) )
v43 = 100000 * v41 / (unsigned __int64)HIDWORD(qword_140C23580);
else
LODWORD(v43) = v40;
v63 = v43;
v64 = v41;
v84 = &v63;
v65 = HIDWORD(qword_140C23580);
v86 = &v64;
v85 = 4i64;
v88 = (int *)&v65;
Voltage = CompositeStatus->Voltage;
p_Voltage = &Voltage;
Rate = CompositeStatus->Rate;
p_Rate = &Rate;
p_Buffer = &v68;
v96 = &v69;
v87 = 4i64;
v89 = 4i64;
v91 = 4i64;
v93 = 4i64;
v68 = v39;
v95 = 4i64;
v69 = 0x1000000i64;
v97 = 8i64;
tlgWriteTransfer_EtwWriteTransfer(
(__int64)&stru_140C00F40 + 4776,
(unsigned __int8 *)&word_1400285AE,
0i64,
0i64,
0x13u,
v70);
}
}
}
if( *(&stru_140C23628 + 128) != (_BYTE)v12 )
{
*(&stru_140C23628 + 128) = v12;
v68 = (unsigned __int8)v12;
LODWORD(CheckStamp) = 0;
LODWORD(MatchingChangeStamp) = 0;
ZwUpdateWnfStateData(&WNF_PO_BATTERY_DISCHARGING, &v68, 4ui64, 0i64, 0i64, MatchingChangeStamp, CheckStamp);
if( *(&stru_140C00F40 + 1194) > 5u )
{
if( tlgKeywordOn((__int64)&stru_140C00F40 + 4776, 0x400000000000i64) )
{
v71 = &Rate;
Voltage = Data;
v73 = &Voltage;
v26 = (CompositeStatus->PowerState & 1) == 0;
Rate = *(&stru_140C23628 + 128);
if( v26 )
v13 = "DC Power";
v72 = 4i64;
v74 = 4i64;
tlgCreate1Sz_char((INT64)v75, v13);
if( (CompositeStatus->PowerState & 2) == 0 )
v14 = "-";
tlgCreate1Sz_char((INT64)v76, v14);
if( ((unsigned __int8)CompositeStatus->PowerState & v45) == 0 )
v15 = v44;
tlgCreate1Sz_char((INT64)v77, v15);
if( (CompositeStatus->PowerState & 8) == 0 )
v16 = v46;
tlgCreate1Sz_char((INT64)v78, v16);
if( (CompositeStatus->PowerState & 0x10) == 0 )
v17 = v47;
tlgCreate1Sz_char((INT64)v79, v17);
v49 = "Battery charging state power supply present";
if( (CompositeStatus->PowerState & 0x20) == 0 )
v49 = v48;
tlgCreate1Sz_char((INT64)v80, v49);
v51 = "Battery charging state adequate";
if( (CompositeStatus->PowerState & 0x40) == 0 )
v51 = v50;
tlgCreate1Sz_char((INT64)v81, v51);
v54 = CompositeStatus->Capacity;
if( HIDWORD(qword_140C23580) )
v55 = (unsigned int)((HIDWORD(qword_140C23580) >> 1) + 100 * v54) / HIDWORD(qword_140C23580);
else
v55 = 0;
v65 = v55;
v82 = (int *)&v65;
v83 = v53;
if( HIDWORD(qword_140C23580) )
v56 = 100000 * v54 / (unsigned __int64)HIDWORD(qword_140C23580);
else
LODWORD(v56) = 0;
v64 = v56;
v63 = v54;
v84 = &v64;
v62 = HIDWORD(qword_140C23580);
v86 = &v63;
v85 = v53;
v88 = (int *)&v62;
v61 = CompositeStatus->Voltage;
p_Voltage = &v61;
v60 = CompositeStatus->Rate;
p_Rate = &v60;
p_Buffer = &Buffer;
v87 = v53;
v89 = v53;
v91 = v53;
v93 = v53;
Buffer = v52;
v95 = v53;
tlgWriteTransfer_EtwWriteTransfer(
(__int64)&stru_140C00F40 + 4776,
(unsigned __int8 *)byte_1400283FB,
0i64,
0i64,
0x12u,
v70);
}
}
}
}Referenced by:
PopBatteryApplyCompositeState