CmDevicePanelEnumSubkeyCallback

__int64 __fastcall CmDevicePanelEnumSubkeyCallback(__int64 a1, char *a2, const wchar_t *a3, int *a4){
  int v5; 
  WCHAR *v9; 
  int v10; 
  int v11; 
  bool v12; 
  WCHAR *PoolWithTag; 
  WCHAR *v14; 
  wchar_t *v15; 
  UINT64 v16; 
  size_t v17; 
  NTSTATUS v18; 
  __int64 v19; 
  WCHAR *v20; 
  unsigned __int8(__fastcall *v22)(__int64, WCHAR *, __int64, _QWORD); 
  unsigned int v23; 
  unsigned int v24; 
  UINT64 dwFlags; 
  UINT64 dwFlagsa; 
  wchar_t *EndPtr; 
  HANDLE Handle; 
  size_t pcchRemaining; 
  struct _UNICODE_STRING DestinationString; 
  GUID Guid; 
  v5 = *a4;
  EndPtr = 0i64;
  pcchRemaining = 0i64;
  Handle = 0i64;
  v9 = 0i64;
  DestinationString = 0i64;
  Guid = 0i64;
  v10 = v5 - 1;
  if( v10 )
  {
    v11 = v10 - 1;
    if( v11 )
    {
      if( v11 != 1 )
        return 0i64;
      v12 = (unsigned int)wcstoul(a3, &EndPtr, 16i64) <= 7;
    }
    else
    {
      v12 = (unsigned int)wcstoul(a3, &EndPtr, 16i64) <= 0xFFFF;
    }
    if( v12 && EndPtr && !*EndPtr )
    {
LABEL_7:
      PoolWithTag = (WCHAR *)ExAllocatePoolWithTag(PagedPool, 0x72ui64, 0x52504E50ui64);
      v14 = PoolWithTag;
      if( !PoolWithTag )
        goto LABEL_22;
      v15 = PoolWithTag;
      v16 = 57i64;
      if( *((_WORD *)a4 + 2) )
      {
        LODWORD(dwFlags) = 2304;
        if( (int)RtlStringCchCopyExW(PoolWithTag, 0x39ui64, (WCHAR *)a4 + 2, &EndPtr, &pcchRemaining, dwFlags) < 0 )
          goto LABEL_21;
        v17 = pcchRemaining;
        if( pcchRemaining < 2 )
          goto LABEL_21;
        *EndPtr = 92;
        v16 = v17 - 2;
        *++EndPtr = 0;
        v15 = EndPtr;
      }
      else
      {
        EndPtr = PoolWithTag;
      }
      v18 = RtlStringCchCopyW(v15, v16, (PWCHAR)a3);
      v19 = 0i64;
      if( v18 >= 0 )
      {
        if( (unsigned int)*a4 < 3 )
        {
          if( a1 )
            v19 = *(_QWORD *)(a1 + 224);
          if( (int)SysCtxRegOpenKey(v19, a2, a3, 8u, 0x20019u, &Handle) < 0 )
            goto LABEL_21;
          v20 = (WCHAR *)ExAllocatePoolWithTag(PagedPool, 0xA0ui64, 0x52504E50ui64);
          v9 = v20;
          if( !v20 )
            goto LABEL_21;
          memset((INT64)v20, 0i64);
          LODWORD(dwFlagsa) = 2304;
          *(_DWORD *)v9 = *a4 + 1;
          RtlStringCchCopyExW(v9 + 2, 0x39ui64, v14, 0i64, 0i64, dwFlagsa);
          *((_QWORD *)v9 + 15) = *((_QWORD *)a4 + 15);
          *((_QWORD *)v9 + 16) = *((_QWORD *)a4 + 16);
          *((_QWORD *)v9 + 17) = *((_QWORD *)a4 + 17);
          *((_DWORD *)v9 + 36) = a4[36];
          *((_DWORD *)v9 + 37) = a4[37];
          PnpCtxRegEnumKeyWithCallback(a1, Handle, (__int64)CmDevicePanelEnumSubkeyCallback, (__int64)v9);
          a4[37] = *((_DWORD *)v9 + 37);
          *((_QWORD *)a4 + 17) = *((_QWORD *)v9 + 17);
          a4[36] = *((_DWORD *)v9 + 36);
          goto LABEL_19;
        }
        if( (int)RtlInitUnicodeStringEx(&DestinationString, v14) >= 0 )
        {
          v22 = (unsigned __int8(__fastcall *)(__int64, WCHAR *, __int64, _QWORD))*((_QWORD *)a4 + 15);
          v23 = DestinationString.MaximumLength >> 1;
          if( !v22 || v22(a1, v14, 6i64, *((_QWORD *)a4 + 16)) )
          {
            a4[37] += v23;
            v24 = a4[36];
            if( v24 > v23 )
            {
              LODWORD(dwFlags) = 2304;
              RtlStringCchCopyExW(*((WCHAR **)a4 + 17), v24, v14, 0i64, 0i64, dwFlags);
              *((_QWORD *)a4 + 17) += 2i64 * v23;
              a4[36] -= v23;
LABEL_19:
              if( v9 )
                ExFreePoolWithTag(v9, 0);
            }
          }
        }
      }
LABEL_21:
      ExFreePoolWithTag(v14, 0);
    }
  }
  else
  {
    RtlInitUnicodeString(&DestinationString, a3, (WCHAR)a3);
    if( RtlGUIDFromString(&DestinationString, &Guid) >= 0 )
      goto LABEL_7;
  }
LABEL_22:
  if( Handle )
    ZwClose(Handle);
  return 0i64;
}

Referenced by:

No references.