TtmpSessionWorker

VOID __stdcall TtmpSessionWorker(PVOID Parameter){
  char v2; 
  _ETHREAD *CurrentThread; 
  void *v4; 
  unsigned int v5; 
  unsigned int v6; 
  void *v7; 
  unsigned int v8; 
  INT64 v9; 
  INT64 v10; 
  INT64 v11; 
  NTSTATUS v12; 
  unsigned int i; 
  unsigned int v14; 
  unsigned int v15; 
  unsigned int v16; 
  char v17; 
  unsigned int v18; 
  int v19; 
  int v20; 
  char v21; 
  char v22[7]; 
  KAPC_STATE ApcState; 
  memset(&ApcState, 0, sizeof(ApcState));
  v22[0] = 0;
  v2 = 0;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  v4 = 0i64;
  v21 = 0;
  --*((_WORD *)CurrentThread + 242);
  ExAcquireResourceExclusiveLite(&TtmpSessionLock, 1u);
  v5 = *(_DWORD *)Parameter;
  TtmiLogSessionWorkerStart(*(unsigned int *)Parameter);
  v6 = *((_DWORD *)Parameter + 1) & 0xFFFFFFFC | 2;
  *((_DWORD *)Parameter + 1) = v6;
  *((_QWORD *)Parameter + 29) = KeGetCurrentThread();
  if( (v6 & 4) == 0 )
  {
    LODWORD(v7) = MmGetSessionById(v5);
    v4 = v7;
    if( !v7 )
    {
      v8 = -1073740715;
      v9 = 0xFFFFFFFFi64;
      v10 = 3221226581i64;
      v11 = 2914i64;
LABEL_4:
      TtmiLogError((PSTR)"TtmpSessionWorker", v11, v9, v10);
      goto LABEL_25;
    }
    v12 = MmAttachSession(v7, &ApcState);
    v8 = v12;
    if( v12 < 0 )
    {
      v10 = (unsigned int)v12;
      v9 = (unsigned int)v12;
      v11 = 2923i64;
      goto LABEL_4;
    }
    v2 = 1;
  }
  v8 = 0;
  for( i = 1; ; ++i )
  {
    v20 = *((_DWORD *)Parameter + 56);
    *((_DWORD *)Parameter + 56) = 0;
    v15 = v20 & 7;
    if( !v15 )
      break;
    TtmiLogSessionWorkerPass(v5, v15, i);
    if( (v15 & 2) != 0 )
    {
      TtmiSessionTerminalListWorker((__int64)Parameter, &v21, v22);
      v14 = (v15 & 0xFD ^ (v15 & 0xFD | (unsigned __int8)(4 * v21))) & 4 ^ v15 & 0xFFFFFFFD;
      v15 = ((unsigned __int8)v14 ^ (unsigned __int8)(v14 | v22[0])) & 1 ^ v14;
    }
    v16 = v15;
    v17 = v15 & 0xFB;
    v18 = v16 >> 2;
    if( (_BYTE)v18 )
    {
      if( (*((_DWORD *)Parameter + 1) & 0x10) != 0 )
      {
        v8 = TtmpActivateSessionWorker((UINT64 *)Parameter);
        if( v8 != 259 )
        {
          v19 = *((_DWORD *)Parameter + 1);
          if( (v19 & 0x1000) != 0 )
          {
            v17 = 1;
            *((_DWORD *)Parameter + 1) = v19 & 0xFFFFEFFF;
          }
        }
      }
    }
    if( (v17 & 1) != 0 )
      TtmiSessionDeviceListWorker((__int64)Parameter);
    if( (_BYTE)v18 && (*((_DWORD *)Parameter + 1) & 0x20) != 0 )
      v8 = TtmpDeactivateSessionWorker((UINT64 *)Parameter);
  }
  if( v2 )
    MmDetachSession(v4, &ApcState);
LABEL_25:
  *((_DWORD *)Parameter + 1) &= ~2u;
  *((_QWORD *)Parameter + 29) = 0i64;
  ExReleaseResourceLite(&TtmpSessionLock);
  KeLeaveCriticalRegion();
  TtmpDereferenceSessionMaybeLast((volatile INT32 *)Parameter);
  TtmiLogSessionWorkerStop(v5, v8);
}

Referenced by:

No references.