PiDqIrpPropertySet

NTSTATUS __stdcall PiDqIrpPropertySet(_IRP *Irp){
  __int64 v1; 
  __int64 v2; 
  _IO_STACK_LOCATION *CurrentStackLocation; 
  char v5; 
  char v6; 
  union {_IRP *MasterIrp;int IrpCount;void *SystemBuffer;} v7; 
  int v8; 
  WCHAR *v9; 
  _PNP_OBJECT_TYPE PnpObjectType; 
  unsigned int v11; 
  _DWORD *v12; 
  __int64 v13; 
  unsigned int i; 
  UINT64 PropertyType; 
  UINT8 *v16; 
  WCHAR *v17; 
  _DEVPROPKEY *PropertyKey; 
  UINT8 *PropertyBuffer; 
  UINT64 *PropertySize; 
  UINT64 *PropertySizea; 
  UINT64 v23; 
  UINT64 v24; 
  WCHAR *PropertyLocaleName; 
  VOID *Handle; 
  __int64 v27; 
  HPNPOPCTX *hPnpOpCtx; 
  INT64 a4[11]; 
  PVOID P; 

  CurrentStackLocation = Irp->Tail.CurrentStackLocation;
  v27 = 0i64;
  PropertyLocaleName = 0i64;
  Handle = 0i64;
  P = 0i64;
  v5 = 0;
  v6 = 0;
  hPnpOpCtx = 0i64;
  v7.MasterIrp = (_IRP *)Irp->AssociatedIrp;
  if( !v7.MasterIrp )
    goto LABEL_45;
  v8 = MesDecodeBufferHandleCreate(v7.MasterIrp, CurrentStackLocation->Parameters.Options, &v27);
  if( v8 < 0 )
    goto LABEL_28;
  NdrMesTypeDecode3(v27, "TP 3\a", &off_140001290, (char *)&stru_140C00F40 + 2832, 2, &P);
  if( !P
    || !*((_QWORD *)P + 1)
    || !*((_QWORD *)P + 3)
    || !*((_DWORD *)P + 4)
    || (PnpObjectType = PiDqGetPnpObjectType(*(_DEV_OBJECT_TYPE *)P)) == PNP_OBJECT_TYPE_NONE )
  {
LABEL_45:
    v8 = -1073741811;
    goto LABEL_28;
  }
  v8 = PiDqOpenObjectRegKey(
         DEVPROP_STORE_SYSTEM,
         v9,
         PnpObjectType,
         7ui64,
         0,
         0i64,
         (VOID **)&PropertyLocaleName,
         PropertySize,
         v23);
  if( v8 < 0 )
    goto LABEL_28;
  v11 = *((_DWORD *)P + 4);
  if( v11 )
  {
    v12 = (_DWORD *)(*((_QWORD *)P + 3) + 20i64);
    v13 = v11;
    do
    {
      if( !*v12 )
        v5 = 1;
      if( *v12 == 1 )
        v6 = 1;
      v12 += 12;
      --v13;
    }
    while( v13 );
  }
  if( v5 && !PiAuDoesClientHaveAccess(2ui64) )
    goto LABEL_39;
  if( v6 )
  {
    if( PiAuDoesClientHaveAccess(0x100ui64) )
    {
      v8 = PiDqOpenObjectRegKey(
             DEVPROP_STORE_USER,
             *((WCHAR **)P + 1),
             PnpObjectType,
             7ui64,
             1u,
             0i64,
             &Handle,
             PropertySizea,
             v24);
      if( v8 < 0 )
        goto LABEL_28;
      goto LABEL_20;
    }
LABEL_39:
    v8 = -1073741790;
    goto LABEL_28;
  }
LABEL_20:
  v8 = PiPnpRtlBeginOperation(&hPnpOpCtx);
  if( v8 >= 0 )
  {
    for( i = 0; i < *((_DWORD *)P + 4); ++i )
    {
      PropertyType = *((_QWORD *)P + 3) + 48i64 * i;
      v16 = *(UINT8 **)(PropertyType + 40);
      v17 = *(WCHAR **)(PropertyType + 24);
      if( *(_DWORD *)(PropertyType + 20) )
      {
        LODWORD(PropertyBuffer) = *(_DWORD *)(PropertyType + 36);
        LODWORD(PropertyKey) = *(_DWORD *)(PropertyType + 32);
        v8 = PnpSetGenericStoreProperty(
               *(&stru_140CF2E80 + 607),
               Handle,
               v17,
               (_DEVPROPKEY *)PropertyType,
               (UINT64)PropertyKey,
               v16,
               (UINT64)PropertyBuffer);
        if( v8 >= 0 )
        {
          a4[0] = 0i64;
          a4[1] = *(_QWORD *)(PropertyType + 24);
          a4[2] = PropertyType;
          LODWORD(PropertyKey) = 1;
          PiPnpRtlObjectEventWorker(*((WCHAR **)P + 1), PnpObjectType, 4i64, (INT64)a4, (INT64)PropertyKey);
        }
      }
      else
      {
        LODWORD(PropertyBuffer) = *(_DWORD *)(PropertyType + 32);
        v8 = PiPnpRtlSetObjectProperty(
               *(&stru_140CF2E80 + 607),
               *((_QWORD *)P + 1),
               (VOID *)(unsigned int)PnpObjectType,
               PropertyLocaleName,
               (_DEVPROPKEY *)v17,
               PropertyType,
               PropertyBuffer,
               (UINT64)v16);
      }
      if( v8 == -1073741275 )
        v8 = *(_DWORD *)(PropertyType + 32) != 0 ? 0xC0000225 : 0;
      if( v8 < 0 )
        break;
    }
  }
LABEL_28:
  if( PropertyLocaleName )
    ZwClose((_HANDLE)PropertyLocaleName);
  if( Handle )
    ZwClose((_HANDLE)Handle);
  if( P )
    ExFreePoolWithTag(P, 0x6370726Bu);
  if( v27 )
    MesHandleFree(v27, v1, v2);
  if( hPnpOpCtx )
    PiPnpRtlEndOperation(hPnpOpCtx);
  Irp->IoStatus.Status = v8;
  IofCompleteRequest(Irp, 0);
  return v8;
}

Referenced by:

PiDqDispatch