HalpKdSetupDebuggingDevice

NTSTATUS __stdcall HalpKdSetupDebuggingDevice(_LOADER_PARAMETER_BLOCK *LoaderBlock, DEBUG_DEVICE_DESCRIPTOR *Device){
  DEBUG_DEVICE_DESCRIPTOR **v2; 
  NTSTATUS result; 
  __int128 v6; 
  __int128 v7; 
  int v8; 
  __int64 *v9; 
  __int64 v10; 
  __int64 **v11; 
  if( !Device )
    return -1073741811;
  if( Device->Initialized )
    return 0;
  v6 = *(_OWORD *)&Device->Memory.Start.LowPart;
  v7 = *(_OWORD *)&Device->Memory.VirtualAddress;
  if( Device->Configured
    || (result = HalpKdEnumerateDebuggingDevices(0i64, Device, KdConfigureDeviceAndContinue, v2), result >= 0) )
  {
    if( Device->Memory.VirtualAddress
      || (*(_OWORD *)&Device->Memory.Start.LowPart = v6,
          *(_OWORD *)&Device->Memory.VirtualAddress = v7,
          result = HalpAllocateScratchMemory(LoaderBlock, Device),
          result >= 0) )
    {
      Device->Initialized = 1;
      v8 = HalpRegisterDeviceInUse(Device);
      if( v8 < 0 && Device->NameSpace != KdNameSpaceNone )
      {
        v9 = HalpFindDevice((__int64)Device);
        if( v9 )
        {
          v10 = *v9;
          if( *(__int64 **)(*v9 + 8) != v9 || (v11 = (__int64 **)v9[1], *v11 != v9) )
            __fastfail(3u);
          *v11 = (__int64 *)v10;
          *(_QWORD *)(v10 + 8) = v11;
          --DevicesList;
        }
      }
      return v8;
    }
  }
  return result;
}

Referenced by:

No references.