PipUpdateDeviceProducts

VOID __fastcall PipUpdateDeviceProducts(VOID *a1){
  ULONG v1; 
  void *v2; 
  void *v3; 
  wchar_t *v4; 
  WCHAR *v5; 
  __int64 v6; 
  int v7; 
  __int64 v8; 
  unsigned int v9; 
  unsigned int v10; 
  unsigned int v11; 
  int v12; 
  void *v13; 
  ULONG v14; 
  int v15; 
  ULONG v16; 
  __int64 v17; 
  __int64 v18; 
  UINT64 v19; 
  UINT64 v20; 
  SIZE_T NumberOfBytes; 
  int v22; 
  void *v23; 
  PVOID P; 
  void *v25; 
  unsigned int v26; 
  int v27; 
  void *v28; 
  _LARGE_INTEGER BootTime; 
  void *v30; 
  unsigned int v31; 
  unsigned int v32; 
  ULONG v33; 
  void *v34; 
  char *PoolWithTag; 
  UINT64 BootTimeBias; 
  wchar_t Str1[8]; 
  v1 = 0;
  P = a1;
  v2 = a1;
  BootTime.QuadPart = 0i64;
  BootTimeBias = 0i64;
  v3 = 0i64;
  v30 = 0i64;
  v4 = 0i64;
  v25 = 0i64;
  PoolWithTag = 0i64;
  v5 = 0i64;
  v28 = 0i64;
  v34 = 0i64;
  LODWORD(NumberOfBytes) = 0;
  v26 = 0;
  v27 = 0;
  v31 = 0;
  v32 = 0;
  v33 = 0;
  v22 = 0;
  v23 = 0i64;
  if( (int)PnpCtxGetCachedContextBaseKey(PiPnpRtlCtx, 15, (__int64 *)&PoolWithTag) < 0
    || (unsigned int)PnpCtxRegOpenKey(0i64, PoolWithTag, L"Current\\ProductIds", 0, 0x20019u, &v34) == -1073741772
    || (LODWORD(v19) = 0,
        (unsigned int)RtlGetPersistedStateLocation(
                        (WCHAR *)L"DynamicInstalledProducts",
                        0i64,
                        L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Update\\TargetingInfo\\DynamicInstalled",
                        0i64,
                        0i64,
                        v19,
                        &NumberOfBytes) != -2147483643) )
  {
    v13 = 0i64;
    goto LABEL_36;
  }
  v7 = NumberOfBytes;
  PoolWithTag = (char *)ExAllocatePoolWithTag(PagedPool, (unsigned int)NumberOfBytes, 0x6E697050ui64);
  v4 = (wchar_t *)PoolWithTag;
  if( !PoolWithTag )
    goto LABEL_72;
  LODWORD(v20) = v7;
  if( (int)RtlGetPersistedStateLocation(
              (WCHAR *)L"DynamicInstalledProducts",
              0i64,
              L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Update\\TargetingInfo\\DynamicInstalled",
              0i64,
              PoolWithTag,
              v20,
              &NumberOfBytes) < 0 )
    goto LABEL_72;
  if( (unsigned int)PnpCtxRegCreateTree(0i64, 0i64, v4, 0, 0x2001Fu, 0i64, (__int64)&v30, 0i64) )
    goto LABEL_72;
  KeQueryBootTimeValues((_LARGE_INTEGER *)&NumberOfBytes, &BootTime, &BootTimeBias);
  BootTime.QuadPart -= BootTimeBias;
  if( (unsigned int)PnpCtxRegQueryInfoKey(v8, v30, &v31, &v26, 0i64, 0i64, 0i64) )
    goto LABEL_72;
  v9 = v31;
  if( !v31 )
    goto LABEL_22;
  v10 = v26 + 1;
  v5 = (WCHAR *)ExAllocatePoolWithTag(PagedPool, 2i64 * (v26 + 1), 0x6E697050ui64);
  if( !v5 )
  {
LABEL_72:
    v13 = 0i64;
    goto LABEL_35;
  }
  if( !v9 )
    goto LABEL_22;
  do
  {
    v26 = v10;
    if( v25 )
    {
      PnpCtxRegCloseKey(v6, v25);
      v25 = 0i64;
    }
    if( (int)PnpCtxRegEnumKey(v6, v30, v1, (char *)v5, &v26) >= 0
      && (int)PnpCtxRegOpenKey(0i64, (char *)v30, v5, 0, 0x2001Fu, &v25) >= 0 )
    {
      LODWORD(NumberOfBytes) = 14;
      if( (int)PnpCtxRegQueryValue(v6, v25, L"Source", &v22, Str1, (__int64)&NumberOfBytes) >= 0
        && v22 == 1
        && (_DWORD)NumberOfBytes == 14
        && !wcsicmp(Str1, L"SMBIOS") )
      {
        LODWORD(NumberOfBytes) = 0;
        if( (unsigned int)PnpCtxRegQueryValue(v6, v34, v5, 0i64, 0i64, (__int64)&NumberOfBytes) == -1073741772 )
        {
          if( v3 )
          {
            ExFreePoolWithTag(v3, 0);
            v3 = 0i64;
          }
          LODWORD(NumberOfBytes) = 0;
          v15 = PnpCtxRegQueryValue(v6, v25, L"Version", &v22, v3, (__int64)&NumberOfBytes);
          if( v15 == -1073741789 )
          {
            v16 = NumberOfBytes;
            v3 = ExAllocatePoolWithTag(PagedPool, (unsigned int)NumberOfBytes, 0x6E697050ui64);
            if( !v3 )
            {
LABEL_66:
              PnpCtxRegSetValue(v6, v25, L"DeactivationTime", 3u, &BootTime, 8u);
              if( v3 )
                PnpCtxRegSetValue(v17, v25, L"DeactivationVersion", 1u, v3, v16);
              PnpCtxRegDeleteValue(v17, v25, L"Version");
              goto LABEL_20;
            }
            v15 = PnpCtxRegQueryValue(v6, v25, L"Version", &v22, v3, (__int64)&NumberOfBytes);
          }
          if( v15 == -1073741772 )
            goto LABEL_20;
          v16 = NumberOfBytes;
          if( (v15 < 0 || v22 != 1 || (unsigned int)NumberOfBytes < 2) && v3 )
          {
            ExFreePoolWithTag(v3, 0);
            v3 = 0i64;
          }
          goto LABEL_66;
        }
      }
    }
LABEL_20:
    ++v1;
  }
  while( v1 < v9 );
  v4 = (wchar_t *)PoolWithTag;
LABEL_22:
  if( (unsigned int)PnpCtxRegQueryInfoKey(v6, v34, 0i64, 0i64, &v32, &v27, 0i64) || (v11 = v32) == 0 )
  {
    v13 = v23;
  }
  else
  {
    v12 = v27 + 1;
    v13 = ExAllocatePoolWithTag(PagedPool, 2i64 * (unsigned int)(v27 + 1), 0x6E697050ui64);
    if( v13 )
    {
      v14 = 0;
      if( v11 )
      {
        do
        {
          v27 = v12;
          if( v28 )
          {
            PnpCtxRegCloseKey(v6, v28);
            v28 = 0i64;
          }
          if( (int)PnpCtxRegEnumValue(v6, v34, v14, v13, &v27, 0i64, 0i64, 0i64) >= 0
            && (int)PnpCtxRegCreateKey(0i64, (__int64)v30, (const WCHAR *)v13, 0, 0x20006u, 0i64, &v28, &v33) >= 0 )
          {
            if( v33 == 1 )
              PnpCtxRegSetValue(v6, v28, L"CreationTime", 3u, &BootTime, 8u);
            LODWORD(NumberOfBytes) = 0;
            if( (unsigned int)PnpCtxRegQueryValue(v6, v28, L"Version", 0i64, 0i64, (__int64)&NumberOfBytes) == -1073741772
              && PnpCtxRegSetValue(v6, v28, L"Version", 1u, L"0.0.0.0", 0x10u) >= 0 )
            {
              PnpCtxRegSetValue(v6, v28, L"ActivationTime", 3u, &BootTime, 8u);
              PnpCtxRegSetValue(v18, v28, L"Source", 1u, (void *)L"SMBIOS", 0xEu);
            }
          }
          ++v14;
        }
        while( v14 < v11 );
        v4 = (wchar_t *)PoolWithTag;
      }
    }
  }
LABEL_35:
  v2 = P;
LABEL_36:
  if( v28 )
    PnpCtxRegCloseKey(v6, v28);
  if( v34 )
    PnpCtxRegCloseKey(v6, v34);
  if( v25 )
    PnpCtxRegCloseKey(v6, v25);
  if( v30 )
    PnpCtxRegCloseKey(v6, v30);
  if( v13 )
    ExFreePoolWithTag(v13, 0);
  if( v5 )
    ExFreePoolWithTag(v5, 0);
  if( v3 )
    ExFreePoolWithTag(v3, 0);
  if( v4 )
    ExFreePoolWithTag(v4, 0);
  if( v2 )
    ExFreePoolWithTag(v2, 0);
}

Referenced by:

No references.