ExpWaitForResource

VOID __stdcall ExpWaitForResource(_ERESOURCE *Resource, VOID *Object){
  void(__fastcall *v2)(_ERESOURCE *); 
  void(__fastcall *v3)(_ERESOURCE *); 
  int v6; 
  unsigned int v7; 
  VOID **PoolWithTag; 
  _LARGE_INTEGER v9; 

  v3 = v2;
  __incgsdword(0x8668u);
  v6 = 0;
  v7 = 0;
  ++Resource->ContentionCount;
  v9.QuadPart = -5000000i64;
  while( KeWaitForSingleObject((UINT64)Object + 24, 27, 0, 0, (INT64)&v9) == 258 )
  {
    ++v6;
    ++v7;
    v9 = (_LARGE_INTEGER)*(&WheapDeferredInternalLogsEventLock + 87);
    if( *(&stru_140CF2E80 + 1831) && v7 > *(&stru_140CF2E80 + 1831) )
    {
      v7 = 0;
      DbgPrintEx(0, 0, "Possible deadlock. Use !locks %p to determine the resource owner\n", Resource);
      PoolWithTag = ExAllocatePoolWithTag(0x200ui64, 0x38ui64, 1867801938i64);
      if( PoolWithTag )
      {
        PoolWithTag[2] = ExpResourceTimeoutCaptureLiveDump;
        PoolWithTag[3] = PoolWithTag;
        *PoolWithTag = 0i64;
        PoolWithTag[4] = KeGetCurrentThread();
        PoolWithTag[5] = Resource;
        *((_DWORD *)PoolWithTag + 12) = Resource->ContentionCount;
        *((_DWORD *)PoolWithTag + 13) = *(&stru_140CF2E80 + 1831);
        ExQueueWorkItem((PWORK_QUEUE_ITEM)PoolWithTag, DelayedWorkQueue);
      }
      __debugbreak();
    }
    if( v3 )
      v3(Resource);
  }
}

Referenced by:

ExAcquireFastResourceExclusive
ExAcquireFastResourceShared
ExAcquireFastResourceSharedStarveExclusive
ExAcquireResourceExclusiveLite
ExAcquireSharedWaitForExclusive
ExpAcquireResourceExclusiveLite
ExpAcquireResourceSharedLite
ExpAcquireSharedStarveExclusive