Guest User

Untitled

a guest
Jul 9th, 2026
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.22 KB | None | 0 0
  1. UINT64 __stdcall MiChargeCommit(_MI_PARTITION *Partition, UINT64 QuotaCharge, UINT64 CommitFlags){
  2.   CHAR v3;
  3.   _MI_PARTITION *v5;
  4.   struct _KPRCB *CurrentPrcb;
  5.   UINT64 v7;
  6.   signed __int32 v8;
  7.   CHAR v10;
  8.   INT64 v11;
  9.   unsigned __int64 v12;
  10.   unsigned __int64 v13;
  11.   unsigned __int64 v14;
  12.   signed __int64 v15;
  13.   unsigned __int64 v16;
  14.   unsigned __int64 v17;
  15.   unsigned __int64 v18;
  16.   unsigned __int64 v19;
  17.   unsigned __int64 v20;
  18.   unsigned __int64 v21;
  19.   unsigned __int64 v22;
  20.   unsigned __int64 v23;
  21.   unsigned __int64 v24;
  22.   int v25;
  23.   bool v26;
  24.   char *v27;
  25.   unsigned __int64 v28;
  26.   __int64 v29;
  27.   int v30;
  28.   v3 = CommitFlags;
  29.   v5 = Partition;
  30.   while( 2 )
  31.   {
  32.     CurrentPrcb = KeGetCurrentPrcb();
  33.     if( v5 == (_MI_PARTITION *)&MiSystemPartition )
  34.     {
  35.       _m_prefetchw((char *)CurrentPrcb + 33560);
  36.       v7 = *((unsigned int *)CurrentPrcb + 8390);
  37.       if( QuotaCharge <= v7 )
  38.       {
  39.         do
  40.         {
  41.           v8 = _InterlockedCompareExchange((volatile signed __int32 *)CurrentPrcb + 8390, v7 - QuotaCharge, v7);
  42.           Partition = (_MI_PARTITION *)v8;
  43.           if( v8 == v7 )
  44.             return 1i64;
  45.           v7 = v8;
  46.         }
  47.         while( QuotaCharge <= v8 );
  48.       }
  49.     }
  50.     v30 = 0;
  51.     v10 = v3 | 2;
  52.     if( (v3 & 4) == 0 )
  53.       v10 = v3;
  54.     if( (v10 & 8) == 0 )
  55.     {
  56.       if( (v10 & 7) != 0 )
  57.         v11 = 0i64;
  58.       else
  59.         v11 = *((_QWORD *)v5 + 782);
  60.       goto LABEL_12;
  61.     }
  62.     v10 |= 2u;
  63.     Partition = (_MI_PARTITION *)*((unsigned int *)KeGetCurrentThread() + 325);
  64.     if( ((unsigned __int8)Partition & 2) != 0 && (*((_DWORD *)KeGetPcr() + 3243) & 0x10001) == 0 )
  65.     {
  66.       v10 |= 4u;
  67.       v11 = 0i64;
  68. LABEL_12:
  69.       v29 = v11;
  70.       goto LABEL_13;
  71.     }
  72.     v11 = 64i64;
  73.     v29 = 64i64;
  74.     if( v5 != (_MI_PARTITION *)&MiSystemPartition && *((_QWORD *)v5 + 866) >> 6 < 0x40ui64 )
  75.     {
  76.       v11 = *((_QWORD *)v5 + 866) >> 6;
  77.       v29 = v11;
  78.     }
  79.     while( 1 )
  80.     {
  81. LABEL_13:
  82.       while( 1 )
  83.       {
  84.         v12 = *((_QWORD *)v5 + 933);
  85.         v13 = v12 + QuotaCharge;
  86.         if( v12 + QuotaCharge <= v12 || v11 + v13 < v13 )
  87.           break;
  88.         v14 = *((_QWORD *)v5 + 949);
  89.         if( v11 + v13 <= v14 )
  90.         {
  91.           if( !v30 && v13 >= 95 * (v14 / 0x64) )
  92.           {
  93.             MiApplyCommitDelay((INT64)v5, v10, *((_QWORD *)v5 + 949));
  94.             v11 = v29;
  95.             v30 = 1;
  96.           }
  97.           goto LABEL_19;
  98.         }
  99.         v24 = *((_QWORD *)v5 + 780);
  100.         if( v13 >= v24 && v12 < v24 )
  101.         {
  102.           MiPulseCommitSignal(v5);
  103.           v11 = v29;
  104.         }
  105.         if( (v10 & 4) != 0 )
  106.         {
  107.           if( !v11 )
  108.             ++dword_140C4E4FC;
  109.           goto LABEL_61;
  110.         }
  111.         if( (v10 & 2) != 0 )
  112.           return 0i64;
  113.         if( v14 == *((_QWORD *)v5 + 777) )
  114.         {
  115.           ++*((_DWORD *)v5 + 1911);
  116.           if( v5 != (_MI_PARTITION *)&MiSystemPartition )
  117.             return 0i64;
  118.           v25 = MiIssuePageExtendRequest(v5, QuotaCharge, 2 * (v10 & 1u) + 8, 0i64);
  119.           if( (v10 & 1) != 0 )
  120.             return 0i64;
  121.           if( !v25 )
  122.           {
  123.             MiCauseOverCommitPopup(v5);
  124.             return 0i64;
  125.           }
  126.           v11 = v29;
  127.           goto LABEL_19;
  128.         }
  129.         if( (v10 & 1) != 0 )
  130.         {
  131.           ++*((_DWORD *)v5 + 1912);
  132.           MiIssuePageExtendRequest(v5, 0x1000ui64, 2ui64, 0i64);
  133.           return 0i64;
  134.         }
  135.         if( !(unsigned int)MiIssuePageExtendRequest(v5, QuotaCharge, 0i64, 0xFFui64) )
  136.         {
  137.           ++*((_DWORD *)v5 + 1910);
  138.           MiCauseOverCommitPopup(v5);
  139.           return 0i64;
  140.         }
  141.         v11 = v29;
  142.       }
  143.       if( (v10 & 4) == 0 )
  144.       {
  145.         if( (v10 & 2) == 0 )
  146.         {
  147.           ++*((_DWORD *)v5 + 1913);
  148.           if( (v10 & 1) == 0 )
  149.             MiCauseOverCommitPopup(v5);
  150.           MiPulseCommitSignal(v5);
  151.         }
  152.         return 0i64;
  153.       }
  154.       if( !v11 )
  155.         ++dword_140C4E500;
  156. LABEL_61:
  157.       if( QuotaCharge )
  158.         break;
  159. LABEL_19:
  160.       v15 = _InterlockedCompareExchange64((volatile signed __int64 *)v5 + 933, v13, v12);
  161.       if( v12 == v15 )
  162.       {
  163.         v16 = *((_QWORD *)v5 + 780);
  164.         v17 = QuotaCharge + v15;
  165.         if( v17 >= v16 && v12 < v16 || (v18 = *((_QWORD *)v5 + 779), v17 >= v18) && v12 < v18 )
  166.         {
  167.           MiSyncCommitSignals(v5, 0i64);
  168.           v11 = v29;
  169.         }
  170.         if( v17 > *((_QWORD *)v5 + 776) )
  171.           *((_QWORD *)v5 + 776) = v17;
  172.         if( (v10 & 2) != 0 )
  173.           return 1i64;
  174.         v19 = *((_QWORD *)v5 + 949);
  175.         v20 = v19 / 0xA;
  176.         if( v17 < 9 * (v19 / 0xA) )
  177.         {
  178. LABEL_26:
  179.           if( v5 == (_MI_PARTITION *)&MiSystemPartition )
  180.           {
  181.             if( (v10 & 1) == 0 && v17 >= *((_QWORD *)v5 + 780) && v19 == *((_QWORD *)v5 + 777) )
  182.             {
  183.               MiFreeExcessSegments((UINT64)Partition);
  184.               v11 = v29;
  185.             }
  186.             v21 = *((unsigned int *)CurrentPrcb + 8390);
  187.             if( v21 < 0x80 )
  188.             {
  189.               v22 = v17;
  190.               v23 = 256 - v21 + v17;
  191.               if( v23 > v22 && v11 + v23 > v22 && v11 + v23 <= v19 )
  192.                 MiReplenishLocalCommit((__int64)v5, (__int64)CurrentPrcb, v22, 256 - v21);
  193.             }
  194.           }
  195.           return 1i64;
  196.         }
  197.         v26 = v17 <= v19;
  198.         if( v17 < v19 )
  199.         {
  200.           if( v19 - v17 >= 0x400000 )
  201.             goto LABEL_26;
  202.           v26 = v17 <= v19;
  203.         }
  204.         if( v26 )
  205.         {
  206.           Partition = (_MI_PARTITION *)*((_QWORD *)v5 + 777);
  207.           if( v19 < (unsigned __int64)Partition && v17 < (unsigned __int64)Partition )
  208.           {
  209.             if( v20 > 0x40000 )
  210.               v20 = 0x40000i64;
  211.             v27 = (char *)Partition - v19;
  212.             v28 = v20 - v17;
  213.             if( v28 + v19 <= (unsigned __int64)v27 )
  214.               v27 = (char *)(v28 + v19);
  215.             MiIssuePageExtendRequest(v5, (UINT64)v27, 2ui64, 0i64);
  216.             v11 = v29;
  217.           }
  218.         }
  219.         goto LABEL_26;
  220.       }
  221.     }
  222.     if( !(unsigned int)MiConsumeOverCommit((UINT64 *)v5, QuotaCharge, v11) )
  223.       continue;
  224.     return 1i64;
  225.   }
  226. }
Advertisement
Add Comment
Please, Sign In to add comment