PiDqActionDataCreate

INT64 __fastcall PiDqActionDataCreate(INT64 a1, INT64 a2, INT64 a3, CHAR **a4){
  int PWSTR; 
  CHAR **v8; 
  _DWORD *PoolWithTag; 
  INT64 *v10; 
  unsigned int PnpObjectType; 
  int v12; 
  unsigned int v13; 
  int v14; 
  char v15; 
  bool v16; 
  __int64 v17; 
  int RequestedProperties; 
  __int64 v20; 
  int AllPropertiesInBestLanguage; 
  UINT64 MaxPropertyCount; 
  int a8[18]; 
  PWSTR = 0;
  a8[0] = 0;
  *a4 = 0i64;
  v8 = a4;
  PoolWithTag = ExAllocatePoolWithTag(PagedPool, 0x28ui64, 0x58706E50ui64);
  if( !PoolWithTag )
    return(unsigned int)-1073741670;
  *(_OWORD *)PoolWithTag = 0i64;
  *((_OWORD *)PoolWithTag + 1) = 0i64;
  *((_QWORD *)PoolWithTag + 4) = 0i64;
  if( *(_QWORD *)(a3 + 16) )
  {
    v10 = (INT64 *)(PoolWithTag + 4);
    *PoolWithTag = *(_DWORD *)(a3 + 32);
    PoolWithTag[2] = *(_DWORD *)(a1 + 16);
    PWSTR = PnpAllocatePWSTR(
              *(WCHAR **)(*(_QWORD *)(a3 + 16) + 16i64),
              0x7FFFFFFFui64,
              0x58706E50ui64,
              (WCHAR **)PoolWithTag + 2);
    if( PWSTR >= 0 )
    {
      if( !*(_DWORD *)(a1 + 64) && (*(_DWORD *)(a1 + 40) & 2) == 0 || (unsigned int)(*PoolWithTag - 1) > 1 )
        goto LABEL_10;
      PnpObjectType = PiDqGetPnpObjectType(*(unsigned int *)(a1 + 16));
      v14 = *(_DWORD *)(a1 + 40);
      if( (v14 & 2) == 0 )
      {
        v15 = v14 & 4;
        v16 = v12 == 1;
        v17 = *v10;
        if( v16 )
        {
          RequestedProperties = PiDqActionDataGetRequestedProperties(
                                  a2,
                                  PnpObjectType,
                                  v17,
                                  v15,
                                  *(const wchar_t **)(a1 + 56),
                                  *(_QWORD *)(a1 + 72),
                                  v13,
                                  (_QWORD *)PoolWithTag + 4,
                                  PoolWithTag + 6);
        }
        else
        {
          LODWORD(MaxPropertyCount) = v13;
          RequestedProperties = PiDqActionDataGetChangedProperties(
                                  (VOID *)a2,
                                  PnpObjectType,
                                  v17,
                                  v15,
                                  *(_QWORD *)(a1 + 56),
                                  *(_QWORD *)(a1 + 72),
                                  MaxPropertyCount,
                                  *(_QWORD *)(a3 + 24),
                                  (INT64)(PoolWithTag + 8),
                                  (INT64)(PoolWithTag + 6));
        }
        goto LABEL_9;
      }
      if( v12 != 1 )
      {
        LODWORD(MaxPropertyCount) = 0;
        RequestedProperties = PiDqActionDataGetChangedProperties(
                                (VOID *)a2,
                                PnpObjectType,
                                *v10,
                                v14 & 4,
                                *(_QWORD *)(a1 + 56),
                                0i64,
                                MaxPropertyCount,
                                *(_QWORD *)(a3 + 24),
                                (INT64)(PoolWithTag + 8),
                                (INT64)(PoolWithTag + 6));
LABEL_9:
        v8 = a4;
        PWSTR = RequestedProperties;
        goto LABEL_10;
      }
      v20 = *v10;
      if( (v14 & 4) != 0 )
      {
        PWSTR = PiDqActionDataGetAllPropertiesInBestLanguage(
                  a2,
                  0,
                  PnpObjectType,
                  v20,
                  *(NTSTRSAFE_PCWSTR *)(a1 + 56),
                  (const void **)PoolWithTag + 4,
                  PoolWithTag + 6,
                  (unsigned int *)a8);
        if( PWSTR >= 0 )
        {
          AllPropertiesInBestLanguage = PiDqActionDataGetAllPropertiesInBestLanguage(
                                          a2,
                                          1,
                                          PnpObjectType,
                                          *v10,
                                          *(NTSTRSAFE_PCWSTR *)(a1 + 56),
                                          (const void **)PoolWithTag + 4,
                                          PoolWithTag + 6,
                                          (unsigned int *)a8);
          goto LABEL_28;
        }
      }
      else
      {
        PWSTR = PiDqActionDataGetAllPropertiesInAllLanguages(
                  a2,
                  0,
                  PnpObjectType,
                  v20,
                  (const void **)PoolWithTag + 4,
                  PoolWithTag + 6,
                  (unsigned int *)a8);
        if( PWSTR >= 0 )
        {
          AllPropertiesInBestLanguage = PiDqActionDataGetAllPropertiesInAllLanguages(
                                          a2,
                                          1,
                                          PnpObjectType,
                                          *v10,
                                          (const void **)PoolWithTag + 4,
                                          PoolWithTag + 6,
                                          (unsigned int *)a8);
LABEL_28:
          v8 = a4;
          PWSTR = AllPropertiesInBestLanguage;
          if( AllPropertiesInBestLanguage == -1073741772 )
            PWSTR = 0;
          goto LABEL_10;
        }
      }
    }
LABEL_31:
    PiDqActionDataFree(PoolWithTag);
    return(unsigned int)PWSTR;
  }
  PoolWithTag[2] = 1;
LABEL_10:
  if( PWSTR < 0 || *PoolWithTag == 2 && !PoolWithTag[6] )
    goto LABEL_31;
  *v8 = (CHAR *)PoolWithTag;
  return(unsigned int)PWSTR;
}

Referenced by:

PiDqQuerySerializeActionQueue