PiDevCfgInitDeviceContext

NTSTATUS __stdcall PiDevCfgInitDeviceContext(
        WCHAR *DeviceInstanceId,
        VOID *DeviceInstanceKeyHandle,
        PI_DEVCFG_DEVICE_CONTEXT *DeviceContext){
  UINT64 *v6; 
  __int64 v7; 
  DEVPROPKEY **v8; 
  PI_DEVCFG_DEVICE_CONTEXT *v9; 
  UINT64 v10; 
  int ObjectProperties; 
  unsigned int v12; 
  int *v13; 
  UINT64 DesiredAccess; 
  UINT64 Create; 
  UINT64 PropertyCount[16]; 

  memset(DeviceContext, 0i64, 0x48u);
  *((_QWORD *)DeviceContext + 1) = DeviceInstanceId;
  if( DeviceInstanceKeyHandle )
  {
    *((_QWORD *)DeviceContext + 2) = DeviceInstanceKeyHandle;
  }
  else
  {
    LODWORD(DesiredAccess) = 983103;
    ObjectProperties = CmOpenDeviceRegKey(
                         *(&stru_140CF2E80 + 607),
                         DeviceInstanceId,
                         CM_KEY_TYPE_DEVICE_INSTANCE,
                         0i64,
                         DesiredAccess,
                         0,
                         (VOID **)DeviceContext + 2,
                         0i64);
    if( ObjectProperties < 0 )
    {
LABEL_13:
      PiDevCfgFreeDeviceContext(DeviceContext);
      return ObjectProperties;
    }
    *DeviceContext |= 0x80000000;
  }
  memset(PropertyCount, 0i64, 0x78u);
  v6 = &PropertyCount[1];
  v7 = 3i64;
  v8 = off_140D2C778;
  v9 = DeviceContext + 6;
  do
  {
    v10 = (UINT64)*v8++;
    v6[1] = (UINT64)v9;
    v9 += 4;
    *(v6 - 1) = v10;
    *(_DWORD *)v6 = 8210;
    *((_DWORD *)v6 + 5) = 6;
    v6 += 5;
    --v7;
  }
  while( v7 );
  LODWORD(Create) = 3;
  ObjectProperties = PiDevCfgQueryObjectProperties(
                       (WCHAR *)v6,
                       *((_QWORD *)DeviceContext + 1),
                       (VOID *)1,
                       *((PI_DEVCFG_QUERY_PROPERTY_PARAM **)DeviceContext + 2),
                       (UINT64)PropertyCount,
                       Create);
  if( ObjectProperties < 0 )
    goto LABEL_13;
  v12 = 0;
  v13 = (int *)&PropertyCount[4];
  do
  {
    if( *v13 < 0 )
      RtlInitUnicodeString((PUNICODE_STRING)&DeviceContext[4 * v12 + 6], 0i64);
    ++v12;
    v13 += 10;
  }
  while( v12 < 3 );
  return ObjectProperties;
}

Referenced by:

PiDevCfgInitDeviceCallback
PiDevCfgProcessDevice
PiDevCfgProcessDeviceCallback
PpDevCfgCheckDeviceNeedsUpdate
PpDevCfgProcessDeviceExtensions
PpDevCfgProcessDeviceOperations
PpDevCfgProcessDeviceReset