Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UINT64 __stdcall MiChargeCommit(_MI_PARTITION *Partition, UINT64 QuotaCharge, UINT64 CommitFlags){
- CHAR v3;
- _MI_PARTITION *v5;
- struct _KPRCB *CurrentPrcb;
- UINT64 v7;
- signed __int32 v8;
- CHAR v10;
- INT64 v11;
- unsigned __int64 v12;
- unsigned __int64 v13;
- unsigned __int64 v14;
- signed __int64 v15;
- unsigned __int64 v16;
- unsigned __int64 v17;
- unsigned __int64 v18;
- unsigned __int64 v19;
- unsigned __int64 v20;
- unsigned __int64 v21;
- unsigned __int64 v22;
- unsigned __int64 v23;
- unsigned __int64 v24;
- int v25;
- bool v26;
- char *v27;
- unsigned __int64 v28;
- __int64 v29;
- int v30;
- v3 = CommitFlags;
- v5 = Partition;
- while( 2 )
- {
- CurrentPrcb = KeGetCurrentPrcb();
- if( v5 == (_MI_PARTITION *)&MiSystemPartition )
- {
- _m_prefetchw((char *)CurrentPrcb + 33560);
- v7 = *((unsigned int *)CurrentPrcb + 8390);
- if( QuotaCharge <= v7 )
- {
- do
- {
- v8 = _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8390, v7 - QuotaCharge, v7);
- Partition = (_MI_PARTITION *)v8;
- if( v8 == v7 )
- return 1i64;
- v7 = v8;
- }
- while( QuotaCharge <= v8 );
- }
- }
- v30 = 0;
- v10 = v3 | 2;
- if( (v3 & 4) == 0 )
- v10 = v3;
- if( (v10 & 8) == 0 )
- {
- if( (v10 & 7) != 0 )
- v11 = 0i64;
- else
- v11 = *((_QWORD *)v5 + 782);
- goto LABEL_12;
- }
- v10 |= 2u;
- Partition = (_MI_PARTITION *)*((unsigned int *)KeGetCurrentThread() + 325);
- if( ((unsigned __int8)Partition & 2) != 0 && (*((_DWORD *)KeGetPcr() + 3243) & 0x10001) == 0 )
- {
- v10 |= 4u;
- v11 = 0i64;
- LABEL_12:
- v29 = v11;
- goto LABEL_13;
- }
- v11 = 64i64;
- v29 = 64i64;
- if( v5 != (_MI_PARTITION *)&MiSystemPartition && *((_QWORD *)v5 + 866) >> 6 < 0x40ui64 )
- {
- v11 = *((_QWORD *)v5 + 866) >> 6;
- v29 = v11;
- }
- while( 1 )
- {
- LABEL_13:
- while( 1 )
- {
- v12 = *((_QWORD *)v5 + 933);
- v13 = v12 + QuotaCharge;
- if( v12 + QuotaCharge <= v12 || v11 + v13 < v13 )
- break;
- v14 = *((_QWORD *)v5 + 949);
- if( v11 + v13 <= v14 )
- {
- if( !v30 && v13 >= 95 * (v14 / 0x64) )
- {
- MiApplyCommitDelay((INT64)v5, v10, *((_QWORD *)v5 + 949));
- v11 = v29;
- v30 = 1;
- }
- goto LABEL_19;
- }
- v24 = *((_QWORD *)v5 + 780);
- if( v13 >= v24 && v12 < v24 )
- {
- MiPulseCommitSignal(v5);
- v11 = v29;
- }
- if( (v10 & 4) != 0 )
- {
- if( !v11 )
- ++dword_140C4E4FC;
- goto LABEL_61;
- }
- if( (v10 & 2) != 0 )
- return 0i64;
- if( v14 == *((_QWORD *)v5 + 777) )
- {
- ++*((_DWORD *)v5 + 1911);
- if( v5 != (_MI_PARTITION *)&MiSystemPartition )
- return 0i64;
- v25 = MiIssuePageExtendRequest(v5, QuotaCharge, 2 * (v10 & 1u) + 8, 0i64);
- if( (v10 & 1) != 0 )
- return 0i64;
- if( !v25 )
- {
- MiCauseOverCommitPopup(v5);
- return 0i64;
- }
- v11 = v29;
- goto LABEL_19;
- }
- if( (v10 & 1) != 0 )
- {
- ++*((_DWORD *)v5 + 1912);
- MiIssuePageExtendRequest(v5, 0x1000ui64, 2ui64, 0i64);
- return 0i64;
- }
- if( !(unsigned int)MiIssuePageExtendRequest(v5, QuotaCharge, 0i64, 0xFFui64) )
- {
- ++*((_DWORD *)v5 + 1910);
- MiCauseOverCommitPopup(v5);
- return 0i64;
- }
- v11 = v29;
- }
- if( (v10 & 4) == 0 )
- {
- if( (v10 & 2) == 0 )
- {
- ++*((_DWORD *)v5 + 1913);
- if( (v10 & 1) == 0 )
- MiCauseOverCommitPopup(v5);
- MiPulseCommitSignal(v5);
- }
- return 0i64;
- }
- if( !v11 )
- ++dword_140C4E500;
- LABEL_61:
- if( QuotaCharge )
- break;
- LABEL_19:
- v15 = _InterlockedCompareExchange64((volatile signed __int64 *)v5 + 933, v13, v12);
- if( v12 == v15 )
- {
- v16 = *((_QWORD *)v5 + 780);
- v17 = QuotaCharge + v15;
- if( v17 >= v16 && v12 < v16 || (v18 = *((_QWORD *)v5 + 779), v17 >= v18) && v12 < v18 )
- {
- MiSyncCommitSignals(v5, 0i64);
- v11 = v29;
- }
- if( v17 > *((_QWORD *)v5 + 776) )
- *((_QWORD *)v5 + 776) = v17;
- if( (v10 & 2) != 0 )
- return 1i64;
- v19 = *((_QWORD *)v5 + 949);
- v20 = v19 / 0xA;
- if( v17 < 9 * (v19 / 0xA) )
- {
- LABEL_26:
- if( v5 == (_MI_PARTITION *)&MiSystemPartition )
- {
- if( (v10 & 1) == 0 && v17 >= *((_QWORD *)v5 + 780) && v19 == *((_QWORD *)v5 + 777) )
- {
- MiFreeExcessSegments((UINT64)Partition);
- v11 = v29;
- }
- v21 = *((unsigned int *)CurrentPrcb + 8390);
- if( v21 < 0x80 )
- {
- v22 = v17;
- v23 = 256 - v21 + v17;
- if( v23 > v22 && v11 + v23 > v22 && v11 + v23 <= v19 )
- MiReplenishLocalCommit((__int64)v5, (__int64)CurrentPrcb, v22, 256 - v21);
- }
- }
- return 1i64;
- }
- v26 = v17 <= v19;
- if( v17 < v19 )
- {
- if( v19 - v17 >= 0x400000 )
- goto LABEL_26;
- v26 = v17 <= v19;
- }
- if( v26 )
- {
- Partition = (_MI_PARTITION *)*((_QWORD *)v5 + 777);
- if( v19 < (unsigned __int64)Partition && v17 < (unsigned __int64)Partition )
- {
- if( v20 > 0x40000 )
- v20 = 0x40000i64;
- v27 = (char *)Partition - v19;
- v28 = v20 - v17;
- if( v28 + v19 <= (unsigned __int64)v27 )
- v27 = (char *)(v28 + v19);
- MiIssuePageExtendRequest(v5, (UINT64)v27, 2ui64, 0i64);
- v11 = v29;
- }
- }
- goto LABEL_26;
- }
- }
- if( !(unsigned int)MiConsumeOverCommit((UINT64 *)v5, QuotaCharge, v11) )
- continue;
- return 1i64;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment