PopRequestRead

VOID __fastcall PopRequestRead(INT64 BugCheckParameter3, INT64 a2, CHAR a3){
  __int64 v3; 
  unsigned int v4; 
  PRODUCER_CONSUMER_WAIT_FLAGS v5; 
  __int64 v6; 
  int v8; 
  unsigned __int64 v9; 
  unsigned __int64 v10; 
  __int64 v11; 
  bool v12; 
  __int64 v13; 
  unsigned __int64 v14; 
  int v15; 
  void *v16; 
  unsigned __int64 v17; 
  _LARGE_INTEGER IoLocation; 
  __int64 v19; 
  UINT64 v20; 
  UINT64 v21; 
  UINT64 v22; 
  INT8 *Buffer; 
  INT8 *v24; 
  unsigned __int64 v25; 
  __int64 v26; 
  unsigned __int64 v27; 
  char v28; 
  int v29; 
  unsigned __int64 v30; 
  UINT64 v31; 
  UINT64 v32; 
  UINT64 MaxTransferLength; 
  INT64 v34; 

  v34 = a2;
  v3 = *(_QWORD *)(BugCheckParameter3 + 320);
  v4 = 0;
  v5 = a3;
  v6 = a2;
  MaxTransferLength = 0i64;
  if( *(_QWORD *)(BugCheckParameter3 + 400) )
  {
    v8 = *(_DWORD *)(BugCheckParameter3 + 328);
    do
    {
      if( v8 )
      {
        if( v8 != 1 )
        {
          PopHiberChecksumHiberFileData(
            (_POP_HIBER_CONTEXT *)BugCheckParameter3,
            0,
            *(_QWORD *)(BugCheckParameter3 + 376),
            *(VOID **)(BugCheckParameter3 + 384),
            *(_QWORD *)(BugCheckParameter3 + 360));
          v9 = __rdtsc();
          *(&stru_140C23628 + 88) += v9 - *(_QWORD *)(BugCheckParameter3 + 336);
          ProducerConsumerBufferComplete(
            v6,
            v6 + 32,
            *(_QWORD *)(BugCheckParameter3 + 384),
            *(_DWORD *)(BugCheckParameter3 + 360));
          v10 = __rdtsc();
          *(&stru_140C23628 + 94) += (((unsigned __int64)HIDWORD(v10) << 32) | (unsigned int)v10) - v9;
          v11 = *(_QWORD *)(BugCheckParameter3 + 360);
          v12 = *(_QWORD *)(BugCheckParameter3 + 400) == v11;
          *(_QWORD *)(BugCheckParameter3 + 400) -= v11;
          if( v12 )
            *(_QWORD *)(v6 + 32) = *(_QWORD *)(v6 + 40);
          v13 = *(_QWORD *)(BugCheckParameter3 + 352);
          v8 = 0;
          *(_QWORD *)(BugCheckParameter3 + 376) += v13;
          *(_QWORD *)(BugCheckParameter3 + 344) += v13;
          *(_QWORD *)(BugCheckParameter3 + 352) = 0i64;
          *(_DWORD *)(BugCheckParameter3 + 328) = 0;
          continue;
        }
        ++*(&stru_140C23628 + 90);
        v14 = __rdtsc();
        v15 = (*(__int64(__fastcall **)(__int64, INT64, __int64))(*(_QWORD *)(BugCheckParameter3 + 168) + 160i64))(
                2i64,
                BugCheckParameter3 + 368,
                v3);
        v16 = (void *)v15;
        if( v15 < 0 )
        {
          PopCheckpointSystemSleep(PopSleepCheckpointHiberReadFailed);
          PopInternalAddToDumpFile((VOID *)BugCheckParameter3, 0x1C8ui64, 0i64);
          PopInternalAddToDumpFile(*(VOID **)(BugCheckParameter3 + 168), 0x178ui64, 0i64);
          KeBugCheckEx(0xA0u, (PVOID)0x10A, (PVOID)0xA, (PVOID)BugCheckParameter3, v16);
        }
        v17 = __rdtsc();
        *(&stru_140C23628 + 93) += (((unsigned __int64)HIDWORD(v17) << 32) | (unsigned int)v17) - v14;
        if( (_DWORD)v16 == 259 )
          return;
        *(_DWORD *)(BugCheckParameter3 + 328) = 2;
        v8 = 2;
      }
      else
      {
        PopHiberCheckForDebugBreak();
        IoLocation = PopGetIoLocation(
                       *(POP_MCB_CONTEXT **)(BugCheckParameter3 + 160),
                       *(_QWORD *)(BugCheckParameter3 + 376),
                       &MaxTransferLength);
        v19 = *(unsigned int *)(BugCheckParameter3 + 408);
        *(_LARGE_INTEGER *)(BugCheckParameter3 + 368) = IoLocation;
        v20 = *(_QWORD *)(BugCheckParameter3 + 400);
        v21 = (v19 << 12) - *(_QWORD *)(BugCheckParameter3 + 344) % (unsigned __int64)(v19 << 12);
        if( v21 >= MaxTransferLength )
          v21 = MaxTransferLength;
        v22 = (unsigned int)v21;
        if( v21 >= v20 )
          v22 = (unsigned int)v20;
        Buffer = ProducerGetBuffer((PRODUCER_CONSUMER_CONTEXT *)v6, (unsigned int)v21, v22, v5);
        v24 = Buffer;
        if( !Buffer )
          return;
        *(_QWORD *)(BugCheckParameter3 + 384) = Buffer;
        *(_QWORD *)v3 = 0i64;
        *(_DWORD *)(v3 + 40) = v21;
        *(_QWORD *)(v3 + 24) = Buffer;
        *(_WORD *)(v3 + 10) = 1;
        v25 = (((unsigned __int16)Buffer & 0xFFF) + v21 + 4095) >> 12;
        *(_QWORD *)(v3 + 32) = (unsigned __int64)Buffer & 0xFFFFFFFFFFFFF000ui64;
        *(_DWORD *)(v3 + 44) = (unsigned __int16)Buffer & 0xFFF;
        *(_WORD *)(v3 + 8) = 8 * (v25 + 6);
        if( v25 )
        {
          v26 = 0i64;
          do
          {
            LODWORD(v27) = MmGetPhysicalAddress((UINT64)&v24[4096 * v26]);
            ++v4;
            *(_QWORD *)(v3 + 8 * v26 + 48) = v27 >> 12;
            v26 = v4;
          }
          while( v4 < v25 );
        }
        v28 = *(_BYTE *)(BugCheckParameter3 + 392);
        v4 = 0;
        *(_QWORD *)(BugCheckParameter3 + 336) = __rdtsc();
        v29 = (*(__int64(__fastcall **)(bool, INT64, __int64))(*(_QWORD *)(BugCheckParameter3 + 168) + 160i64))(
                v28 != 0,
                BugCheckParameter3 + 368,
                v3);
        if( v29 == -1073741637 )
        {
          if( !v28 )
            goto LABEL_34;
          *(_BYTE *)(BugCheckParameter3 + 392) = 0;
          *(_QWORD *)(BugCheckParameter3 + 336) = __rdtsc();
          v29 = (*(__int64(__fastcall **)(_QWORD, INT64, __int64))(*(_QWORD *)(BugCheckParameter3 + 168) + 160i64))(
                  0i64,
                  BugCheckParameter3 + 368,
                  v3);
        }
        if( v29 < 0 || *(&stru_140C23628 + 583) == 8 )
        {
LABEL_34:
          PopCheckpointSystemSleep(PopSleepCheckpointHiberReadFailed);
          PopInternalAddToDumpFile(*(VOID **)(BugCheckParameter3 + 168), 0x178ui64, 0i64);
          KeBugCheckEx(0xA0u, (PVOID)0x10A, (PVOID)0xA, (PVOID)BugCheckParameter3, (PVOID)v29);
        }
        v30 = __rdtsc();
        *(&stru_140C23628 + 93) += (((unsigned __int64)HIDWORD(v30) << 32) | (unsigned int)v30)
                                 - *(_QWORD *)(BugCheckParameter3 + 336);
        v31 = v21;
        v32 = *(_QWORD *)(BugCheckParameter3 + 400);
        *(_QWORD *)(BugCheckParameter3 + 352) = v21;
        if( v21 >= v32 )
          v31 = v32;
        *(_QWORD *)(BugCheckParameter3 + 360) = v31;
        if( !v28 || !v29 )
        {
          v6 = v34;
          v8 = 2;
          *(_DWORD *)(BugCheckParameter3 + 328) = 2;
          continue;
        }
        *(_DWORD *)(BugCheckParameter3 + 328) = 1;
        v8 = 1;
      }
      v6 = v34;
    }
    while( *(_QWORD *)(BugCheckParameter3 + 400) );
  }
}

Referenced by:

PopDecompressCallback
PopRestoreHiberContext