PiDqActionDataCreate

__int64 __fastcall PiDqActionDataCreate(__int64 a1, _SECURITY_SUBJECT_CONTEXT *a2, __int64 a3, _QWORD *a4){
  int PWSTR; 
  _QWORD *v8; 
  VOID **PoolWithTag; 
  WCHAR **v10; 
  PNP_OBJECT_TYPE PnpObjectType; 
  int v12; 
  int v13; 
  int v14; 
  UINT8 v15; 
  bool v16; 
  WCHAR *v17; 
  NTSTATUS RequestedProperties; 
  WCHAR *v20; 
  NTSTATUS AllPropertiesInBestLanguage; 
  UINT64 RequestedPropertyCount; 
  _DEVPROPERTY **Properties; 
  _DEVPROPERTY **Propertiesa; 
  UINT64 MaxPropertyCount[9]; 

  PWSTR = 0;
  LODWORD(MaxPropertyCount[0]) = 0;
  *a4 = 0i64;
  v8 = a4;
  PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x28ui64, 1483763280i64);
  if( !PoolWithTag )
    return(unsigned int)-1073741670;
  *(_OWORD *)PoolWithTag = 0i64;
  *((_OWORD *)PoolWithTag + 1) = 0i64;
  PoolWithTag[4] = 0i64;
  if( *(_QWORD *)(a3 + 16) )
  {
    v10 = (WCHAR **)(PoolWithTag + 2);
    *(_DWORD *)PoolWithTag = *(_DWORD *)(a3 + 32);
    *((_DWORD *)PoolWithTag + 2) = *(_DWORD *)(a1 + 16);
    PWSTR = PnpAllocatePWSTR(*(WCHAR **)(*(_QWORD *)(a3 + 16) + 16i64), 0x7FFFFFFFui64, 0x58706E50u, PoolWithTag + 2);
    if( PWSTR >= 0 )
    {
      if( !*(_DWORD *)(a1 + 64) && (*(_DWORD *)(a1 + 40) & 2) == 0 || (unsigned int)(*(_DWORD *)PoolWithTag - 1) > 1 )
        goto LABEL_10;
      PnpObjectType = PiDqGetPnpObjectType(*(_DEV_OBJECT_TYPE *)(a1 + 16));
      v14 = *(_DWORD *)(a1 + 40);
      if( (v14 & 2) == 0 )
      {
        v15 = v14 & 4;
        v16 = v12 == 1;
        v17 = *v10;
        if( v16 )
        {
          LODWORD(RequestedPropertyCount) = v13;
          RequestedProperties = PiDqActionDataGetRequestedProperties(
                                  a2,
                                  PnpObjectType,
                                  v17,
                                  v15,
                                  *(WCHAR **)(a1 + 56),
                                  *(_DEVPROPCOMPKEY **)(a1 + 72),
                                  RequestedPropertyCount,
                                  (_DEVPROPERTY **)PoolWithTag + 4,
                                  (UINT64 *)PoolWithTag + 3);
        }
        else
        {
          LODWORD(RequestedPropertyCount) = v13;
          RequestedProperties = PiDqActionDataGetChangedProperties(
                                  a2,
                                  PnpObjectType,
                                  v17,
                                  v15,
                                  *(WCHAR **)(a1 + 56),
                                  *(_DEVPROPCOMPKEY **)(a1 + 72),
                                  RequestedPropertyCount,
                                  *(PI_PNPRTL_OBJECT_EVENT **)(a3 + 24),
                                  (_DEVPROPERTY **)PoolWithTag + 4,
                                  (UINT64 *)PoolWithTag + 3);
        }
        goto LABEL_9;
      }
      if( v12 != 1 )
      {
        LODWORD(RequestedPropertyCount) = 0;
        RequestedProperties = PiDqActionDataGetChangedProperties(
                                a2,
                                PnpObjectType,
                                *v10,
                                v14 & 4,
                                *(WCHAR **)(a1 + 56),
                                0i64,
                                RequestedPropertyCount,
                                *(PI_PNPRTL_OBJECT_EVENT **)(a3 + 24),
                                (_DEVPROPERTY **)PoolWithTag + 4,
                                (UINT64 *)PoolWithTag + 3);
LABEL_9:
        v8 = a4;
        PWSTR = RequestedProperties;
        goto LABEL_10;
      }
      v20 = *v10;
      if( (v14 & 4) != 0 )
      {
        PWSTR = PiDqActionDataGetAllPropertiesInBestLanguage(
                  a2,
                  DEVPROP_STORE_SYSTEM,
                  PnpObjectType,
                  v20,
                  *(WCHAR **)(a1 + 56),
                  (const VOID **)PoolWithTag + 4,
                  (UINT64 *)PoolWithTag + 3,
                  MaxPropertyCount);
        if( PWSTR >= 0 )
        {
          AllPropertiesInBestLanguage = PiDqActionDataGetAllPropertiesInBestLanguage(
                                          a2,
                                          DEVPROP_STORE_USER,
                                          PnpObjectType,
                                          *v10,
                                          *(WCHAR **)(a1 + 56),
                                          (const VOID **)PoolWithTag + 4,
                                          (UINT64 *)PoolWithTag + 3,
                                          MaxPropertyCount);
          goto LABEL_28;
        }
      }
      else
      {
        PWSTR = PiDqActionDataGetAllPropertiesInAllLanguages(
                  a2,
                  DEVPROP_STORE_SYSTEM,
                  PnpObjectType,
                  v20,
                  (const VOID **)PoolWithTag + 4,
                  (UINT64 *)PoolWithTag + 3,
                  MaxPropertyCount,
                  (UINT64 *)Properties);
        if( PWSTR >= 0 )
        {
          AllPropertiesInBestLanguage = PiDqActionDataGetAllPropertiesInAllLanguages(
                                          a2,
                                          DEVPROP_STORE_USER,
                                          PnpObjectType,
                                          *v10,
                                          (const VOID **)PoolWithTag + 4,
                                          (UINT64 *)PoolWithTag + 3,
                                          MaxPropertyCount,
                                          (UINT64 *)Propertiesa);
LABEL_28:
          v8 = a4;
          PWSTR = AllPropertiesInBestLanguage;
          if( AllPropertiesInBestLanguage == -1073741772 )
            PWSTR = 0;
          goto LABEL_10;
        }
      }
    }
LABEL_31:
    PiDqActionDataFree((_DEV_QUERY_RESULT_ACTION_DATA *)PoolWithTag);
    return(unsigned int)PWSTR;
  }
  *((_DWORD *)PoolWithTag + 2) = 1;
LABEL_10:
  if( PWSTR < 0 || *(_DWORD *)PoolWithTag == 2 && !*((_DWORD *)PoolWithTag + 6) )
    goto LABEL_31;
  *v8 = PoolWithTag;
  return(unsigned int)PWSTR;
}

Referenced by:

PiDqQuerySerializeActionQueue