DbgkOpenProcessDebugPort

NTSTATUS __stdcall DbgkOpenProcessDebugPort(_EPROCESS *Process, INT8 PreviousMode, VOID **Handle){
  int v6; 
  _ADAPTER_OBJECT *DebugPort; 
  _KPROCESSOR_MODE AccessMode; 

  v6 = -1073740973;
  if( Process->DebugPort )
  {
    ExAcquireFastMutex(&DbgkpProcessDebugPortMutex);
    DebugPort = (_ADAPTER_OBJECT *)Process->DebugPort;
    if( DebugPort )
      ObfReferenceObject(Process->DebugPort);
    KeReleaseGuardedMutex(&DbgkpProcessDebugPortMutex);
    if( DebugPort )
    {
      if( PsTestProtectedProcessIncompatibility(PreviousMode, KeGetCurrentThread()->ApcState.Process, Process) )
      {
        v6 = -1073740014;
LABEL_8:
        HalPutDmaAdapter(DebugPort);
        return v6;
      }
      LOBYTE(AccessMode) = PreviousMode;
      v6 = ObOpenObjectByPointer(
             DebugPort,
             PreviousMode == 0 ? 0x200 : 0,
             0i64,
             0x2000000,
             DbgkDebugObjectType,
             AccessMode,
             Handle);
      if( v6 < 0 )
        goto LABEL_8;
    }
  }
  return v6;
}

Referenced by:

NtQueryInformationProcess