ExAcquireResourceExclusiveLite

UINT8 __stdcall ExAcquireResourceExclusiveLite(ERESOURCE *Resource, UINT8 Wait){
  unsigned __int8 v4; 
  __int16 v5; 
  _ETHREAD *v6; 
  INT64 v7; 
  CHAR v8; 
  unsigned int v9; 
  unsigned __int8 CurrentIrql; 
  _ETHREAD *CurrentThread; 
  struct _KLOCK_QUEUE_HANDLE LockHandle; 
  INT64 Object[2]; 
  __int128 v15; 
  __int128 v16; 
  v4 = (Wait == 0) + 1;
  if( (Resource->Flag & 0x41) == 1 )
    KeBugCheckEx(0x1C6u, 0xFui64, (ULONG_PTR)Resource, 0i64, 0i64);
  v5 = Resource->Flag & 1;
  if( v5 )
  {
    CurrentIrql = KeGetCurrentIrql();
    CurrentThread = (_ETHREAD *)KeGetCurrentThread();
    if( CurrentIrql > v4 )
      KeBugCheckEx(0x1C6u, 0i64, CurrentIrql, v4, 0i64);
    if( CurrentIrql >= 2u && (*((_DWORD *)KeGetPcr() + 3243) & 0x10001) != 0 )
      KeBugCheckEx(0x1C6u, 5ui64, 0i64, 0i64, 0i64);
    if( (*((_BYTE *)CurrentThread + 192) & 2) != 0 )
      KeBugCheckEx(0x1C6u, 6ui64, 0i64, 0i64, 0i64);
    if( !CurrentIrql && (*((_DWORD *)CurrentThread + 29) & 0x400) == 0 && !*((_DWORD *)CurrentThread + 121) )
      KeBugCheckEx(0x1C6u, 7ui64, 0i64, 0i64, 0i64);
  }
  if( !v5 )
  {
    memset(&LockHandle, 0, sizeof(LockHandle));
    *(_OWORD *)Object = 0i64;
    v15 = 0i64;
    v16 = 0i64;
    v6 = (_ETHREAD *)KeGetCurrentThread();
    __incgsdword(0x8678u);
    KeAcquireInStackQueuedSpinLock(&Resource->SpinLock, &LockHandle);
    v8 = ExpTryAcquireResourceExclusive((INT64)Resource);
    if( v8 )
    {
      v9 = Resource->OwnerEntry.TableSize & 7;
      Resource->OwnerEntry.OwnerThread = (unsigned __int64)v6;
      Resource->OwnerEntry.TableSize = v9 | 8;
      KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
      __writecr8(LockHandle.OldIrql);
      __incgsdword(0x867Cu);
      __incgsdword(0x8664u);
    }
    else
    {
      if( (Resource->ReservedLowFlags & 0x80u) != 0 && (_ETHREAD *)Resource->OwnerEntry.OwnerThread == v6 )
      {
        Resource->OwnerEntry.TableSize += 8;
        KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
        __writecr8(LockHandle.OldIrql);
        __incgsdword(0x8680u);
        __incgsdword(0x8664u);
      }
      else
      {
        if( !Wait )
        {
          KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
          __writecr8(LockHandle.OldIrql);
          __incgsdword(0x8688u);
          return 0;
        }
        ExpPrepareToWaitForResourceExclusive(v7, (INT64)v6, (INT64)Object);
        KeReleaseInStackQueuedSpinLockFromDpcLevel(&LockHandle);
        __writecr8(LockHandle.OldIrql);
        __incgsdword(0x8684u);
        ExpApplyPrewaitBoost();
        ExpWaitForResource(Resource, Object);
        ExpBoostIoAfterAcquire(Resource, (UINT64)v6);
        __incgsdword(0x867Cu);
        __incgsdword(0x8664u);
      }
      return 1;
    }
    return v8;
  }
  return ExpFastResourceLegacyAcquireExclusive(Resource);
}

Referenced by:

AdtpBuildAccessesString
CcAcquireByteRangeForWrite
CcPinFileData
CcUnpinRepinnedBcb
CmGetDeviceSoftwareKey
CmpAccountForLogReservation
CmpLockRegistryExclusive
CmpStartRMLog
CmpStopRMLog
CmpTransWriteLog
DrvDbAcquireDatabaseNodeBaseKey
DrvDbOpenDriverDatabaseRegKey
DrvDbReleaseDatabaseNodeBaseKey
DrvDbSetDriverDatabaseMappedProperty
ExAcquireTimeRefreshLock
ExEnterPriorityRegionAndAcquireResourceExclusive
ExpQuerySingleModuleInformation
ExpQuerySystemInformation
ExpRegisterFirmwareTableInformationHandler
FsRtlAcquireFileExclusiveCommon
FsRtlAcquireFileForCcFlushEx
FsRtlAcquireFileForModWriteEx
FsRtlCopyWrite
FsRtlPrepareMdlWriteDev
FsRtlpHeatRegisterVolume
FsRtlpHeatUnregisterVolume
IoCaptureLiveDump
IoConfigureCrashDump
IoEnumerateRegisteredFiltersList
IoGetDeviceInterfaceAlias
IoInitializeCrashDump
IoOpenDeviceInterfaceRegistryKey
IoOpenDeviceRegistryKey
IoRegisterFileSystem
IoRegisterFsRegistrationChangeMountAware
IoReportDetectedDevice
IoReportRootDevice
IoSetDeviceInterfaceState
IoShutdownSystem
IoUnregisterFsRegistrationChange
IoUpdateDumpPhysicalRanges
IopBootLog
IopBootLogToFile
IopCopyBootLogRegistryToFile
IopDoDeferredSetInterfaceState
IopGetDeviceInterfaces
IopGetRootDevices
IopGetSetSecurityObject
IopInitCrashDumpRegCallback
IopInitializeBootLogging
IopLoadDriver
IopRegisterDeviceInterface
IopSetDeviceSecurityDescriptor
MiCancelPhase0Locking
MiInitializeKernelCfg
MiProcessLoaderEntry
MiRememberUnloadedDriver
MiUnlockBootPageSections
MiWriteProtectSystemImages
MmChangeImageProtection
MmFreeBootDriverInitializationCode
MmLockPagableDataSection
NtAdjustGroupsToken
NtAdjustPrivilegesToken
NtCreateLowBoxToken
NtCreateTimer
NtFlushInstallUILanguage
NtGetMUIRegistryInfo
NtMapCMFModule
NtSetInformationJobObject
NtSetInformationToken
PfSnCheckActionsNeeded
PfSnPrefetchCacheEntryUpdate
PiCMCreateDevice
PiCMDeleteDevice
PiCMGenerateDeviceInstance
PiCMUnregisterDeviceInterface
PiDcHandleCustomDeviceEvent
PiDmAddCacheReferenceForObject
PiDmRemoveCacheReferenceForObject
PiDmaGuardQueueFlush
PiDmaGuardQueueRemoveEntry
PiDqObjectManagerServiceActionQueue
PiDrvDbLoadNode
PiDrvDbUnloadNode
PiDrvDbUnloadNodeWaitWorkerCallback
PiDrvDbUnloadNodeWorkerCallback
PiGetDeviceRegistryProperty
PiInitializeDevice
PiPnpRtlBeginOperation
PiPnpRtlObjectEventWorker
PiPnpRtlSetDeviceRegProperty
PiPnpRtlSetObjectProperty
PiProcessNewDeviceNode
PiSwCompleteCreate
PiSwDeviceFree
PiSwIrpCancelStartCreate
PiSwIrpCleanup
PiSwIrpGetLifetime
PiSwIrpInterfacePropertySet
PiSwIrpPropertySet
PiSwIrpSetLifetime
PiSwLock
PiSwPdoPnPDispatch
PiSwProcessParentRemoveIrp
PiSwProcessParentStartIrp
PiSwStopDestroy
PipDgqInsertEntry
PipKsrNotifyDrivers
PipResetDevices
PnpAcquireDependencyRelationsLock
PnpChainDereferenceComplete
PnpCtxCloseMachine
PnpDelayedRemoveWorker
PnpDeleteDeviceInterfaces
PnpDisableDeviceInterfaces
PnpGetDeviceInstanceRegistryValue
PnpNotifyDeviceClassChange
PnpNotifyHwProfileChange
PnpNotifyTargetDeviceChange
PnpNotifyTargetDeviceChangeNotifyEntry
PnpQueuePendingSurpriseRemoval
PnpSetDeviceInterfacePropertyData
PnpSetDevicePropertyData
PnpUnlinkDeviceRemovalRelations
PnpUnregisterPlugPlayNotification
PopAcquireAdaptiveLock
PopAcquirePolicyLock
PopDripsWatchdogAcquireContextLock
PopDripsWatchdogDiagnosticWorker
PopDripsWatchdogNotifySessionStart
PopDripsWatchdogStartWatchdog
PopDripsWatchdogStopWatchdog
PpCheckInDriverDatabase
PpDevCfgProcessDevices
PpDevNodeLockTree
PpDeviceRegistration
PpReleaseBootDDB
PspAllocateAndQueryNotificationChannel
PspApplyWorkingSetLimitsToProcess
PspFreezeJobTree
PspGetMemoryPartitionFromJobList
PspLockJobChain
PspLockJobConditionally
PspLockJobExclusive
PspLockJobsAndProcessExclusive
PspLockRootJobExclusive
PspSetBackgroundJobTree
PspSetEnergyTrackingStateJobTree
PspSetJobMemoryPartition
PspSetQuotaLimits
RtlZeroHeap
RtlpAllocateHeap
RtlpFreeHeap
RtlpSetupExtendedBlock
SeExchangePrimaryToken
SeMarkLogonSessionForTerminationNotificationEx
SeSetMandatoryPolicyToken
SeSetPrivateNameSpaceToken
SeSetSecurityAttributesTokenEx
SeSetSessionIdToken
SeSetVirtualizationToken
SeTokenSetNoChildProcessRestricted
SeTokenSetRedirectionTrustPolicy
SepAddTokenLogonSession
SepBlockAccessForLogonSession
SepCreateLogonSessionTrack
SepDeReferenceLogonSession
SepDeleteLogonSessionTrack
SepDeleteUnreferencedLogonSessionsInSilo
SepInternalSetSecurityAttributesToken
SepMakeLogonSessionsSiblings
SepQueueWorkItem
SepReferenceLogonSessionSilo
SepRemoveTokenLogonSession
SepRmCallLsa
SepRmCommandServerThread
SepRmGlobalSaclSetWrkr
SepSetServerSiloToken
SepUpdateLogonSessionTrack
TtmInitCurrentSession
TtmiCloseEventQueue
TtmiRetrieveEventFromQueue
TtmiWriteEventToSingleQueue
TtmpAcquireSessionById
TtmpAcquireSessionFromTerminalHandle
TtmpCloseTerminalHandle
TtmpDeleteQueue
TtmpInitiateModernStandbyTransition
TtmpScheduledEvaluationWorker
TtmpSessionPowerControl
TtmpSessionWorker
TtmpStopCallout
TtmpTerminal0PowerSettingCallback
WmiAcquireSmbiosLockExclusive