NtReleaseMutant

NTSTATUS __stdcall NtReleaseMutant(VOID *MutantHandle, INT64 *PreviousCount){
  char PreviousMode; 
  NTSTATUS v5; 
  int v6; 
  _ADAPTER_OBJECT *v7; 
  int v8; 
  __int64 v10; 
  PVOID v11; 
  PVOID v12; 
  INT64 v13; 
  NTSTATUS v14; 
  PVOID Object; 

  LODWORD(v13) = 0;
  PreviousMode = KeGetCurrentThread()->PreviousMode;
  if( PreviousCount && PreviousMode )
  {
    v10 = 0x7FFFFFFF0000i64;
    if( (unsigned __int64)PreviousCount < 0x7FFFFFFF0000i64 )
      v10 = (__int64)PreviousCount;
    *(_DWORD *)v10 = *(_DWORD *)v10;
  }
  Object = 0i64;
  v5 = ObReferenceObjectByHandle(MutantHandle, 0i64, ExMutantObjectType, PreviousMode, &Object, 0i64);
  v6 = v5;
  v7 = (_ADAPTER_OBJECT *)Object;
  v12 = Object;
  v14 = v5;
  if( v5 < 0 )
  {
    if( v5 == -1073741788 )
    {
      if( *(&WheapDeferredInternalLogsEventLock + 56) )
      {
        v11 = 0i64;
        v6 = ObReferenceObjectByHandle(
               MutantHandle,
               0i64,
               *(&WheapDeferredInternalLogsEventLock + 56),
               PreviousMode,
               &v11,
               0i64);
        v7 = (_ADAPTER_OBJECT *)v11;
        v12 = v11;
        v14 = v6;
        if( v6 >= 0 )
        {
          v6 = ExpReleaseCrossVmMutant((INT64)v11, (INT64)&v13);
          v14 = v6;
        }
      }
    }
    v8 = v13;
  }
  else
  {
    v8 = KeReleaseMutant((_KMUTANT *)Object, 1i64, 0, 0);
    LODWORD(v13) = v8;
  }
  if( v6 >= 0 && PreviousCount )
    *(_DWORD *)PreviousCount = v8;
  if( v7 )
    HalPutDmaAdapter(v7);
  return v6;
}

Referenced by:

No references.