HalpQueryDebuggerInformation

NTSTATUS __stdcall HalpQueryDebuggerInformation(
        _DEBUGGING_DEVICE_IN_USE_INFORMATION *OutputBuffer,
        UINT64 Size,
        UINT64 *ReturnedLength){
  __int64 **v3; 
  int v4; 
  unsigned int v6; 
  __int64 *v9; 
  __int64 v10; 
  int v11; 
  char *v12; 
  unsigned int v13; 
  unsigned int v14; 
  int v15; 
  unsigned int v16; 
  wchar_t *v17; 

  *(_DWORD *)ReturnedLength = 4;
  v3 = (__int64 **)*(&CmpDummyThreadEvent + 529);
  v4 = 0;
  v6 = Size;
  if( (_UNKNOWN *)*(&CmpDummyThreadEvent + 529) == (_UNKNOWN *)((char *)&CmpDummyThreadEvent + 4232) )
    return -1073741823;
  do
  {
    v9 = v3[2];
    v10 = *(unsigned int *)ReturnedLength;
    v11 = *((_DWORD *)v9 + 55);
    v12 = (char *)OutputBuffer + v10;
    if( v11 )
    {
      if( v11 != 1 )
        return -1073741823;
      v14 = *((_DWORD *)v9 + 58) + 2;
      v15 = *((_DWORD *)v9 + 58) + 22;
      v16 = v15 + v10;
      *(_DWORD *)ReturnedLength = v16;
      if( v16 <= v6 )
      {
        *(_DWORD *)v12 = 1;
        *((_DWORD *)v12 + 1) = v15;
        *((_DWORD *)v12 + 2) = *((_DWORD *)v9 + 58);
        if( *((_DWORD *)v9 + 58) )
        {
          v17 = (wchar_t *)v9[28];
          if( v17 )
            wcscpy_s((PWCHAR)v12 + 6, (unsigned __int64)v14 >> 1, v17);
        }
      }
    }
    else
    {
      v13 = v10 + 20;
      *(_DWORD *)ReturnedLength = v13;
      if( v13 <= v6 )
      {
        *(_DWORD *)v12 = 0;
        *((_DWORD *)v12 + 1) = 20;
        *((_DWORD *)v12 + 3) = *(_DWORD *)v9;
        *((_DWORD *)v12 + 4) = *((_DWORD *)v9 + 1);
        *((_WORD *)v12 + 4) = *((_WORD *)v9 + 4);
      }
    }
    v3 = (__int64 **)*v3;
    ++v4;
  }
  while( v3 != (__int64 **)((char *)&CmpDummyThreadEvent + 4232) );
  if( !v4 )
    return -1073741823;
  if( *(_DWORD *)ReturnedLength > v6 )
    return -2147483643;
  OutputBuffer->DeviceCount = *(&CmpDummyThreadEvent + 1056);
  return 0;
}

Referenced by:

HaliQuerySystemInformation