StEtaIoStart

UINT64 __stdcall StEtaIoStart(_ST_ETA_CONTEXT *EtaContext, UINT64 IoSize, _ST_IO_TYPE IoType, VOID *Context){
  unsigned int v4; 
  __int64 v5; 
  unsigned __int64 v6; 
  __int64 v8; 
  unsigned __int32 v9; 
  signed __int32 v10; 
  int v11; 
  signed __int32 v12; 
  bool v13; 
  unsigned __int16 v14; 
  unsigned __int16 v15; 

  v4 = 0;
  v5 = IoType;
  v6 = (unsigned __int64)Context;
  v8 = *(_QWORD *)&EtaContext[2 * IoType + 4];
  if( ((unsigned __int8)Context & 1) != 0 )
  {
    v6 = (unsigned __int64)Context & 0xFFFFFFFFFFFFFFFEui64;
    while( *(_DWORD *)v8 < (unsigned int)IoSize )
      v8 += 32i64;
  }
  else
  {
    while( *(_DWORD *)v8 < (unsigned int)IoSize )
      v8 += 32i64;
    *(_WORD *)(v8 + 4) = 0;
  }
  v9 = *(_DWORD *)(v8 + 8);
  v10 = EtaContext[3];
  v11 = _InterlockedIncrement(EtaContext + 2);
  if( v11 == 1 )
  {
    *(_QWORD *)EtaContext = KeQueryPerformanceCounter(0i64);
    v12 = _InterlockedCompareExchange(EtaContext + 3, v9, v10);
    if( v10 != v12 )
    {
      v13 = v12 <= v10;
      do
      {
        if( !v13 )
          v9 += v12 - v10;
        v10 = v12;
        v12 = _InterlockedCompareExchange(EtaContext + 3, v9, v12);
        v13 = v12 <= v10;
      }
      while( v12 != v10 );
      return v4;
    }
  }
  else
  {
    _InterlockedExchangeAdd(EtaContext + 3, v9);
    if( v11 > 1 )
      return v4;
  }
  v14 = *(_WORD *)(v8 + 6) + 1;
  *(_WORD *)(v8 + 6) = v14;
  if( v14 < LOWORD(EtaContext[v5 + 8]) || (v15 = HIWORD(EtaContext[v5 + 8])) != 0 && (v15 & v14) == 0 )
  {
    *(_QWORD *)(v8 + 16) = KeQueryPerformanceCounter(0i64);
    v4 = 1;
    *(_QWORD *)(v8 + 24) = v6;
  }
  return v4;
}

Referenced by:

ST_STORE::StDeviceIoIssue
ST_STORE::StStagingRegionIssueIo