PiProcessNewDeviceNode
VOID __stdcall PiProcessNewDeviceNode(_DEVICE_NODE *DeviceNode){
INT64 v2;
int v3;
HANDLE v4;
ULONG_PTR v5;
int v6;
WCHAR *v7;
NTSTATUS v8;
int v9;
char v10;
int v11;
WCHAR **v12;
WCHAR **v13;
int v14;
int GloballyUniqueId;
WCHAR *v16;
INT64 v17;
INT64 v18;
int v19;
INT64 v20;
int v21;
_PNP_DEVNODE_STATE *v22;
BOOL v23;
INT64 v24;
_QWORD *v25;
const WCHAR *v26;
ULONG_PTR v27;
unsigned int v28;
_ETHREAD *v29;
const wchar_t *v30;
unsigned int v31;
NTSTATUS v32;
int v33;
int v34;
WCHAR *v35;
WCHAR v36;
WCHAR *v37;
BOOL v38;
__int16 v39;
__int64 v40;
_ETHREAD *v41;
BOOL v42;
_ETHREAD *v43;
_ETHREAD *v44;
HANDLE v45;
WCHAR *v46;
PVOID v47;
unsigned int v48;
int v49;
char v50;
int v51;
unsigned int v52;
void *v53;
int AlternateStringData;
unsigned int v55;
BOOL v56;
_ETHREAD *v57;
int v58;
__int64 v59;
__int64 v60;
PVOID v61;
PVOID v62;
__int64 v63;
_ETHREAD *CurrentThread;
int v65;
int FailedInstallProblemStatus;
char v67;
__int64 v68;
__int64 v69;
const WCHAR *v70;
int v71;
bool v72;
int v73;
int v74;
unsigned int v75;
int v76;
__int16 *v77;
_WORD *v78;
PVOID *v79;
PVOID *v80;
__int64 v81;
__int64 v82;
__int64 v83;
_WORD *v84;
__int64 v85;
__int16 *v86;
_WORD *v87;
PVOID *v88;
PVOID *v89;
__int64 v90;
__int64 v91;
__int64 v92;
_WORD *v93;
__int64 v94;
int v95;
int v96;
int v97;
unsigned int v98;
char v99;
unsigned int v100;
int v101;
unsigned int v102;
int v103;
int v104;
bool v105;
char v106[3];
unsigned int v107;
int v108;
int v109;
__int64 v110;
HANDLE Handle;
int v112;
UINT64 v113;
UINT64 ConfigFlagsUpdate;
int v115;
PCWSTR SourceString;
PVOID v117;
PVOID v118;
PVOID v119;
int v120;
char v121[12];
PVOID P;
WCHAR *v123;
PVOID v124;
UINT64 IDLength;
__int64 v126;
PVOID v127;
wchar_t *Str;
const WCHAR *v129;
PVOID v130;
struct _UNICODE_STRING DestinationString;
__int64 v132;
INTERFACE Interface;
void(__fastcall *v134)(void *, __int64 *);
DEVICE_CAPABILITIES result;
GUID Guid;
SourceString = 0i64;
memset((INT64)&result, 0i64);
Guid = 0i64;
v118 = 0i64;
DestinationString = 0i64;
LODWORD(v113) = 0;
v130 = 0i64;
P = 0i64;
memset(v121, 0, sizeof(v121));
v117 = 0i64;
HIDWORD(IDLength) = 0;
v127 = 0i64;
v129 = 0i64;
v112 = 0;
v120 = 0;
LOBYTE(v108) = 0;
v123 = 0i64;
if( (byte_140C130BB & 8) != 0 )
McTemplateK0p_EtwWriteTransfer(v2, (EVENT_DESCRIPTOR *)&KMPnPEvt_ProcessNewDevice_Start, 0i64, DeviceNode);
BYTE4(v113) = 0;
v105 = 0;
v115 = 0;
v3 = 0;
v109 = 0;
v4 = 0i64;
v5 = *((_QWORD *)DeviceNode + 4);
v132 = *(_QWORD *)&KUSER_SHARED_DATA.SystemTime.LowPart;
v107 = 0;
LODWORD(ConfigFlagsUpdate) = 0;
v106[0] = 0;
Handle = 0i64;
v110 = 0i64;
PiPnpRtlBeginOperation((__int64 **)&v130);
PipClearDevNodeFlags(DeviceNode, 0x2000000ui64);
Str = 0i64;
LODWORD(IDLength) = 0;
v124 = 0i64;
v119 = 0i64;
PnpQueryID(DeviceNode, BusQueryDeviceID, &Str, &IDLength);
if( v6 < 0 )
{
v71 = v6;
if( v6 == -1073479624 )
v71 = -1073741823;
v109 = v71;
}
else
{
v124 = Str;
v7 = wcschr(Str, 0x5Cu);
*v7 = 0;
v119 = v7 + 1;
}
v8 = PpIrpQueryCapabilities((DEVICE_OBJECT *)v5, &result);
PipClearDevNodeUserFlags((__int64)DeviceNode, 2);
v10 = 0;
if( v8 >= 0 )
{
if( (*((_DWORD *)&result + 1) & 0x20000) != 0 )
PipSetDevNodeUserFlags((__int64)DeviceNode, 2);
if( (*((_BYTE *)&result + 4) & 0x40) != 0 )
v10 = 1;
}
if( (*((_BYTE *)&result + 4) & 0x20) != 0 )
{
if( *((_DWORD *)DeviceNode + 142) == 4 )
PpProfileCancelTransitioningDock((__int64)DeviceNode, v9);
v11 = 1;
}
else
{
v11 = 0;
}
*((_DWORD *)DeviceNode + 142) = v11;
v126 = -1i64;
v134 = 0i64;
memset(&Interface, 0, sizeof(Interface));
if( PnpQueryInterface((DEVICE_OBJECT *)v5, &GUID_PNP_EXTENDED_ADDRESS_INTERFACE, 1u, 0x28u, 0i64, &Interface) >= 0 )
{
if( v134 )
{
if( Interface.Version == 1 )
{
v134(Interface.Context, &v126);
if( Interface.InterfaceDereference )
Interface.InterfaceDereference(Interface.Context);
}
}
}
PnpQueryDeviceText(*((DEVICE_OBJECT **)DeviceNode + 4), DeviceTextDescription, v12);
PnpQueryDeviceText(*((DEVICE_OBJECT **)DeviceNode + 4), DeviceTextLocationInformation, v13);
PnpQueryID(DeviceNode, BusQueryInstanceID, (WCHAR **)&v117, (UINT64 *)((char *)&IDLength + 4));
GloballyUniqueId = v14;
if( v10 )
{
if( v14 == -1073741637 )
{
PipSetDevNodeProblem((__int64)DeviceNode, 9, -1073741637);
PipSetDevNodeFlags(*((_QWORD *)DeviceNode + 2), 0x200000);
PnpSetInvalidIDEvent((PUNICODE_STRING)(*((_QWORD *)DeviceNode + 2) + 40i64));
}
}
else if( ((*((_DWORD *)DeviceNode + 99) & 0x2000) == 0 || *((_DWORD *)DeviceNode + 101) != 9)
&& *((PVOID *)DeviceNode + 2) != IopRootDeviceNode )
{
v16 = (WCHAR *)v117;
goto LABEL_134;
}
v16 = (WCHAR *)v117;
while( 1 )
{
if( GloballyUniqueId < 0 )
{
v72 = (*((_DWORD *)DeviceNode + 99) & 0x2000) == 0;
v109 = GloballyUniqueId;
if( v72 || *((_DWORD *)DeviceNode + 101) != 9 )
{
if( GloballyUniqueId == -1073741670 )
{
v73 = 3;
v74 = -1073741670;
}
else
{
v74 = GloballyUniqueId;
v73 = 19;
}
PipSetDevNodeProblem((__int64)DeviceNode, v73, v74);
}
}
v19 = PiBuildDeviceNodeInstancePath((__int64)DeviceNode, (__int64)v124, (__int64)v119, (__int64)v16);
if( v19 >= 0 )
{
if( (byte_140C130BB & 8) != 0 )
McTemplateK0pz_EtwWriteTransfer(v18, v17, v20, DeviceNode, *((_QWORD *)DeviceNode + 6));
v19 = PiCreateDeviceInstanceKey((__int64)DeviceNode, &Handle, (_DWORD *)&v110 + 1);
v21 = 0;
if( v19 < 0 )
{
PipSetDevNodeProblem((__int64)DeviceNode, 19, v19);
v3 = HIDWORD(v110);
v4 = Handle;
}
else
{
v3 = HIDWORD(v110);
v4 = Handle;
if( HIDWORD(v110) == 1 )
v21 = 0x20000;
LODWORD(v110) = v21;
}
}
if( v19 >= 0 )
v19 = v109;
v109 = v19;
PpMarkDeviceStackExtensionFlag((DEVICE_OBJECT *)v5, 0x10ui64, 1u);
PipSetDevNodeState(DeviceNode, DeviceNodeInitialized, v22);
if( (*((_DWORD *)DeviceNode + 99) & 0x2000) != 0 )
{
v75 = *((_DWORD *)DeviceNode + 101);
if( v75 <= 0x13 )
{
v76 = 524808;
if( _bittest(&v76, v75) )
break;
}
}
if( v3 == 1 )
{
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
--*((_WORD *)CurrentThread + 242);
LOBYTE(v23) = 1;
ExAcquireResourceSharedLite(&PnpRegistryDeviceResource, v23);
v4 = Handle;
if( Handle && *(_QWORD *)&v121[4] )
{
v69 = -1i64;
do
++v69;
while( *(_WORD *)(*(_QWORD *)&v121[4] + 2 * v69) );
CmSetDeviceRegProp(
PiPnpRtlCtx,
*((const WCHAR **)DeviceNode + 6),
(__int64)Handle,
1u,
1u,
*(__int64 *)&v121[4],
2 * v69 + 2,
v110);
}
ExReleaseResourceLite(&PnpRegistryDeviceResource);
KeLeaveCriticalRegion();
v3 = HIDWORD(v110);
goto LABEL_31;
}
v25 = PnpDeviceObjectFromDeviceInstanceWithTag((INT64)DeviceNode + 40, 0x65706E50ui64);
v27 = (ULONG_PTR)v25;
if( !v25 )
goto LABEL_30;
if( v25 == (_QWORD *)v5 )
{
ObfDereferenceObjectWithTag(v25, 0x65706E50ui64);
LABEL_30:
v19 = v109;
LABEL_31:
if( (*((_DWORD *)DeviceNode + 99) & 0x2000) != 0 && *((_DWORD *)DeviceNode + 101) == 42 )
PipClearDevNodeProblem((INT64)DeviceNode, v26, v24);
break;
}
if( !v10 )
{
PpvUtilFailDriver(0i64, *(const void **)(*(_QWORD *)(v5 + 8) + 328i64), (const void *)v5, v25);
IoAddTriageDumpDataBlock((PVOID)v5, *(unsigned __int16 *)(v5 + 2));
v77 = *(__int16 **)(v5 + 8);
if( v77 )
{
IoAddTriageDumpDataBlock(v77, (unsigned int)v77[1]);
v78 = (_WORD *)(*(_QWORD *)(v5 + 8) + 56i64);
if( *v78 )
{
IoAddTriageDumpDataBlock(v78, 2ui64);
IoAddTriageDumpDataBlock(
*(PVOID *)(*(_QWORD *)(v5 + 8) + 64i64),
*(unsigned __int16 *)(*(_QWORD *)(v5 + 8) + 56i64));
}
}
v79 = *(PVOID **)(*(_QWORD *)(v5 + 312) + 40i64);
if( v79 )
{
v80 = v79 + 5;
IoAddTriageDumpDataBlock(v79, 0x310ui64);
if( *(_WORD *)v80 )
{
IoAddTriageDumpDataBlock(v80, 2ui64);
IoAddTriageDumpDataBlock(v80[1], *(unsigned __int16 *)v80);
}
v81 = *(_QWORD *)(v5 + 312);
v82 = *(_QWORD *)(v81 + 40);
if( *(_WORD *)(v82 + 56) )
{
IoAddTriageDumpDataBlock((PVOID)(v82 + 56), 2ui64);
IoAddTriageDumpDataBlock(
*(PVOID *)(*(_QWORD *)(*(_QWORD *)(v5 + 312) + 40i64) + 64i64),
*(unsigned __int16 *)(*(_QWORD *)(*(_QWORD *)(v5 + 312) + 40i64) + 56i64));
v81 = *(_QWORD *)(v5 + 312);
}
v83 = *(_QWORD *)(*(_QWORD *)(v81 + 40) + 16i64);
if( v83 )
{
v84 = (_WORD *)(v83 + 56);
if( *v84 )
{
IoAddTriageDumpDataBlock(v84, 2ui64);
v85 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(v5 + 312) + 40i64) + 16i64);
IoAddTriageDumpDataBlock(*(PVOID *)(v85 + 64), *(unsigned __int16 *)(v85 + 56));
}
}
}
IoAddTriageDumpDataBlock((PVOID)v27, *(unsigned __int16 *)(v27 + 2));
v86 = *(__int16 **)(v27 + 8);
if( v86 )
{
IoAddTriageDumpDataBlock(v86, (unsigned int)v86[1]);
v87 = (_WORD *)(*(_QWORD *)(v27 + 8) + 56i64);
if( *v87 )
{
IoAddTriageDumpDataBlock(v87, 2ui64);
IoAddTriageDumpDataBlock(
*(PVOID *)(*(_QWORD *)(v27 + 8) + 64i64),
*(unsigned __int16 *)(*(_QWORD *)(v27 + 8) + 56i64));
}
}
v88 = *(PVOID **)(*(_QWORD *)(v27 + 312) + 40i64);
if( v88 )
{
v89 = v88 + 5;
IoAddTriageDumpDataBlock(v88, 0x310ui64);
if( *(_WORD *)v89 )
{
IoAddTriageDumpDataBlock(v89, 2ui64);
IoAddTriageDumpDataBlock(v89[1], *(unsigned __int16 *)v89);
}
v90 = *(_QWORD *)(v27 + 312);
v91 = *(_QWORD *)(v90 + 40);
if( *(_WORD *)(v91 + 56) )
{
IoAddTriageDumpDataBlock((PVOID)(v91 + 56), 2ui64);
IoAddTriageDumpDataBlock(
*(PVOID *)(*(_QWORD *)(*(_QWORD *)(v27 + 312) + 40i64) + 64i64),
*(unsigned __int16 *)(*(_QWORD *)(*(_QWORD *)(v27 + 312) + 40i64) + 56i64));
v90 = *(_QWORD *)(v27 + 312);
}
v92 = *(_QWORD *)(*(_QWORD *)(v90 + 40) + 16i64);
if( v92 )
{
v93 = (_WORD *)(v92 + 56);
if( *v93 )
{
IoAddTriageDumpDataBlock(v93, 2ui64);
v94 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(v27 + 312) + 40i64) + 16i64);
IoAddTriageDumpDataBlock(*(PVOID *)(v94 + 64), *(unsigned __int16 *)(v94 + 56));
}
}
}
KeBugCheckEx(0xCAu, 1ui64, v5, v27, 0i64);
}
ZwClose(v4);
*((_DWORD *)&result + 1) &= ~0x40u;
Handle = 0i64;
v4 = 0i64;
v10 = 0;
PipSetDevNodeProblem((__int64)DeviceNode, 42, 0);
PnpLogDuplicateDevice((WCHAR *)v124, v16);
if( *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(v27 + 312) + 40i64) + 16i64) == *((_QWORD *)DeviceNode + 2) )
PpvUtilFailDriver(0i64, *(const void **)(*(_QWORD *)(v5 + 8) + 328i64), (const void *)v5, (const void *)v27);
ObfDereferenceObjectWithTag((PVOID)v27, 0x65706E50ui64);
LABEL_134:
GloballyUniqueId = PipMakeGloballyUniqueId();
if( v16 )
ExFreePoolWithTag(v16, 0);
v16 = v123;
v117 = v123;
}
if( v4 )
{
if( v3 != 1 )
PnpClearDeviceTemporaryProperties(*((PWCHAR *)DeviceNode + 6), v4);
v28 = v110;
PnpSetObjectProperty(
PiPnpRtlCtx,
*((_QWORD *)DeviceNode + 6),
1u,
(__int64)v4,
0i64,
(__int64)DEVPKEY_Device_LastKnownParent,
18,
*(_QWORD *)(*((_QWORD *)DeviceNode + 2) + 48i64),
*(unsigned __int16 *)(*((_QWORD *)DeviceNode + 2) + 40i64) + 2,
v110);
PnpSetObjectProperty(
PiPnpRtlCtx,
*((_QWORD *)DeviceNode + 6),
1u,
(__int64)v4,
0i64,
(__int64)&DEVPKEY_Device_LastArrivalDate,
16,
(__int64)&v132,
8u,
v110);
PnpSetObjectProperty(
PiPnpRtlCtx,
*((_QWORD *)DeviceNode + 6),
1u,
(__int64)v4,
0i64,
(__int64)&DEVPKEY_Device_LastRemovalDate,
0,
0i64,
0,
v110);
PnpSetObjectProperty(
PiPnpRtlCtx,
*((_QWORD *)DeviceNode + 6),
1u,
(__int64)v4,
0i64,
(__int64)DEVPKEY_Device_HardwareConfigurationIndex,
7,
(__int64)&PnpCurrentHardwareConfigurationIndex,
4u,
v110);
}
else
{
v28 = v110;
}
if( (*((_WORD *)&result + 2) & 0x4000) != 0 )
{
if( (*((_DWORD *)DeviceNode + 99) & 0x2000) == 0 || (v95 = *((_DWORD *)DeviceNode + 101), v95 != 1) && v95 != 14 )
PnpDisableDevice((__int64)DeviceNode, (const WCHAR *)0x1D, v24);
}
if( (*((_DWORD *)DeviceNode + 99) & 0x2000) == 0
|| (v96 = *((_DWORD *)DeviceNode + 101), v109 = v19, v96 != 9) && (v109 = v19, v96 != 3) && (v109 = v19, v96 != 19) )
{
v29 = (_ETHREAD *)KeGetCurrentThread();
--*((_WORD *)v29 + 242);
ExAcquireResourceSharedLite(&PnpRegistryDeviceResource, 1);
v4 = Handle;
if( Handle && v127 )
{
v68 = -1i64;
do
++v68;
while( *((_WORD *)v127 + v68) );
CmSetDeviceRegProp(
PiPnpRtlCtx,
*((const WCHAR **)DeviceNode + 6),
(__int64)Handle,
0xEu,
1u,
(__int64)v127,
2 * v68 + 2,
v28);
}
v3 = HIDWORD(v110);
PnpSaveDeviceCapabilities((__int64)DeviceNode, &result, HIDWORD(v110) == 1);
if( v126 != -1 )
PnpSetObjectProperty(
PiPnpRtlCtx,
*((_QWORD *)DeviceNode + 6),
1u,
(__int64)v4,
0i64,
(__int64)&DEVPKEY_Device_ExtendedAddress,
9,
(__int64)&v126,
8u,
v28);
v30 = (const wchar_t *)*((_QWORD *)DeviceNode + 6);
v112 = 4;
v105 = v3 == 1;
if( (int)CmGetDeviceRegProp(PiPnpRtlCtx, v30, (__int64)v4, 11, (__int64)&v120, (__int64)&v107, (__int64)&v112, 0) >= 0
&& v120 == 4
&& v112 == 4 )
{
v31 = v107;
if( (v107 & 0x20) == 0 )
{
if( (v107 & 0x40) == 0 )
{
LABEL_47:
v32 = PnpMapDeviceObjectToDeviceInstance(
*((DEVICE_OBJECT **)DeviceNode + 4),
(UNICODE_STRING *)((char *)DeviceNode + 40));
v33 = v19;
if( v32 < 0 )
v33 = v32;
v109 = v33;
if( PnpBootMode )
{
*((_DWORD *)DeviceNode + 176) |= 0x1000u;
v115 = 2;
}
else
{
v34 = BYTE4(v113);
if( (v107 & 0x40000) != 0 )
v34 = 1;
HIDWORD(v113) = v34;
}
ExReleaseResourceLite(&PnpRegistryDeviceResource);
KeLeaveCriticalRegion();
goto LABEL_54;
}
v65 = 28;
LABEL_145:
if( (*((_WORD *)&result + 2) & 0x100) != 0 )
{
v70 = (const WCHAR *)*((_QWORD *)DeviceNode + 6);
v107 = v31 | 0x400;
CmSetDeviceRegProp(PiPnpRtlCtx, v70, (__int64)v4, 0xBu, 4u, (__int64)&v107, 4u, v28);
}
else
{
if( v65 == 28 )
{
FailedInstallProblemStatus = PiDevCfgGetFailedInstallProblemStatus(*((WCHAR **)DeviceNode + 6), v4);
v65 = 28;
}
else
{
FailedInstallProblemStatus = 0;
}
PipSetDevNodeProblem((__int64)DeviceNode, v65, FailedInstallProblemStatus);
}
goto LABEL_47;
}
v65 = 18;
if( (v107 & 1) != 0 )
goto LABEL_145;
}
else
{
v31 = 0;
v107 = 0;
v65 = 1;
}
v105 = 1;
goto LABEL_145;
}
LABEL_54:
PnpQueryID(DeviceNode, BusQueryHardwareIDs, (WCHAR **)&P, (UINT64 *)v121);
v35 = (WCHAR *)P;
KseAddHardwareId((PWCHAR)P);
PnpQueryID(DeviceNode, BusQueryCompatibleIDs, (WCHAR **)&v118, &v113);
PnpGenerateDeviceIdsHash(v35, (PWCHAR)v118, (UINT64 *)((char *)DeviceNode + 684));
PnpIrpQueryID(*((DEVICE_OBJECT **)DeviceNode + 4), BusQueryContainerID, (WCHAR **)&SourceString);
v37 = (WCHAR *)SourceString;
if( SourceString )
{
RtlInitUnicodeString(&DestinationString, SourceString, v36);
if( RtlGUIDFromString(&DestinationString, &Guid) < 0 )
{
ExFreePoolWithTag(v37, 0);
v37 = 0i64;
SourceString = 0i64;
}
}
if( (int)PiQueryRemovableDeviceOverride((__int64)DeviceNode, (__int64)v35, v118, (__int64)&v108) >= 0 )
{
LOBYTE(v39) = v108;
}
else
{
if( (*((_BYTE *)&result + 4) & 0x20) != 0
|| (*((_DWORD *)&result + 1) & 0x40000) != 0
|| (*((_BYTE *)&result + 4) & 0x10) == 0 )
{
LOBYTE(v39) = 0;
}
else
{
v39 = 1;
}
if( v37 )
goto LABEL_67;
}
v40 = 0i64;
if( v3 != 1 )
v40 = (__int64)v4;
if( (int)PipGenerateContainerID((__int64)DeviceNode, v40, v39, v37, &v129) >= 0 )
{
if( v37 )
ExFreePoolWithTag(v37, 0);
v37 = (WCHAR *)v129;
SourceString = v129;
}
LABEL_67:
if( !v37
|| (RtlInitUnicodeString(&DestinationString, v37, v39),
RtlGUIDFromString(&DestinationString, (GUID *)((char *)DeviceNode + 664)) < 0) )
{
*(_OWORD *)((char *)DeviceNode + 664) = 0i64;
}
v41 = (_ETHREAD *)KeGetCurrentThread();
--*((_WORD *)v41 + 242);
LOBYTE(v38) = 1;
ExAcquireResourceSharedLite(&PnpRegistryDeviceResource, v38);
PipSetDevNodeFlags((__int64)DeviceNode, 32);
ExReleaseResourceLite(&PnpRegistryDeviceResource);
KeLeaveCriticalRegion();
if( Handle && SourceString )
{
v43 = (_ETHREAD *)KeGetCurrentThread();
--*((_WORD *)v43 + 242);
ExAcquireResourceExclusiveLite(&PnpRegistryDeviceResource, 1u);
PiDcUpdateDeviceContainerMembership(*((PWCHAR *)DeviceNode + 6), Handle, (PWCHAR)SourceString);
ExReleaseResourceLite(&PnpRegistryDeviceResource);
KeLeaveCriticalRegion();
}
v44 = (_ETHREAD *)KeGetCurrentThread();
--*((_WORD *)v44 + 242);
LOBYTE(v42) = 1;
ExAcquireResourceSharedLite(&PnpRegistryDeviceResource, v42);
v45 = Handle;
v46 = (WCHAR *)v118;
v47 = P;
if( Handle )
{
v48 = *(_DWORD *)v121;
if( v105 || HIDWORD(v110) == 1 )
{
v50 = v106[0];
}
else
{
v49 = PnpCheckDeviceIdsChanged((__int64)DeviceNode, Handle, (const WCHAR *)P, *(int *)v121, 1, (__int64)v106);
v50 = v106[0];
if( v49 < 0 )
v50 = 0;
v106[0] = v50;
if( !v50 )
{
v51 = PnpCheckDeviceIdsChanged((__int64)DeviceNode, v45, v46, v113, 0, (__int64)v106);
v50 = v106[0];
if( v51 < 0 )
v50 = 0;
}
}
if( v47 )
CmSetDeviceRegProp(PiPnpRtlCtx, *((const WCHAR **)DeviceNode + 6), (__int64)v45, 2u, 7u, (__int64)v47, v48, v110);
v52 = v110;
if( v46 )
CmSetDeviceRegProp(PiPnpRtlCtx, *((const WCHAR **)DeviceNode + 6), (__int64)v45, 3u, 7u, (__int64)v46, v113, v110);
if( v50 || BYTE4(v113) )
{
if( v105 )
{
v98 = v107;
v99 = ConfigFlagsUpdate;
}
else
{
v97 = PpDevCfgCheckDeviceNeedsUpdate(*((WCHAR **)DeviceNode + 6), v45, &ConfigFlagsUpdate);
v98 = v107;
if( v97 < 0 )
{
v99 = 0;
}
else
{
v99 = ConfigFlagsUpdate;
v98 = ConfigFlagsUpdate | v107;
v107 |= ConfigFlagsUpdate;
}
}
if( (v99 & 0x20) != 0 || (v98 & 0x40000) != 0 )
{
v107 = v98 & 0xFFFBFFFF;
CmSetDeviceRegProp(
PiPnpRtlCtx,
*((const WCHAR **)DeviceNode + 6),
(__int64)v45,
0xBu,
4u,
(__int64)&v107,
4u,
v52);
LOBYTE(v98) = v107;
}
if( (v98 & 0x20) != 0 )
{
v105 = 1;
PipSetDevNodeProblem((__int64)DeviceNode, 18, 0);
}
}
}
ExReleaseResourceLite(&PnpRegistryDeviceResource);
KeLeaveCriticalRegion();
v53 = *(void **)&v121[4];
if( v45 )
{
v119 = 0i64;
AlternateStringData = 0;
HIDWORD(ConfigFlagsUpdate) = 0;
v55 = 0;
if( *(_QWORD *)&v121[4] )
{
v63 = -1i64;
do
++v63;
while( *(_WORD *)(*(_QWORD *)&v121[4] + 2 * v63) );
v55 = 2 * v63 + 2;
AlternateStringData = PnpFindAlternateStringData(
*(WCHAR **)&v121[4],
v55,
(WCHAR **)&v119,
(UINT64 *)((char *)&ConfigFlagsUpdate + 4));
}
PnpSetObjectProperty(
PiPnpRtlCtx,
*((_QWORD *)DeviceNode + 6),
1u,
(__int64)v45,
0i64,
(__int64)&DEVPKEY_Device_BusReportedDeviceDesc,
AlternateStringData != 0 ? 25 : 18,
(__int64)v53,
v55,
v110);
if( (int)PnpGetDeviceLocationStrings((__int64)DeviceNode, (__int64 *)&v119, (_DWORD *)&ConfigFlagsUpdate + 1) >= 0 )
{
v62 = v119;
PnpSetObjectProperty(
PiPnpRtlCtx,
*((_QWORD *)DeviceNode + 6),
1u,
(__int64)v45,
0i64,
(__int64)&DEVPKEY_Device_LocationPaths,
8210,
(__int64)v119,
2 * HIDWORD(ConfigFlagsUpdate),
v110);
ExFreePoolWithTag(v62, 0);
}
}
PnpQueryBusInformation((__int64)DeviceNode);
PiDmaGuardProcessNewDeviceNode((UINT32)DeviceNode);
if( (*((_WORD *)&result + 2) & 0x4000) == 0
&& ((*((_DWORD *)DeviceNode + 99) & 0x2000) == 0 || *((_DWORD *)DeviceNode + 101) != 14) )
{
if( v105 )
{
v67 = v115;
if( HIDWORD(v110) == 1 )
v67 = v115 | 1;
PpDevCfgProcessDevice((__int64)DeviceNode, (__int64)v45, v67);
}
else if( v45 )
{
PpDevCfgProcessDeviceOperations((__int64)DeviceNode, v45);
}
}
PiQueryResourceRequirements((__int64)DeviceNode);
if( (*((_DWORD *)DeviceNode + 99) & 0x2000) == 0
|| (v100 = *((_DWORD *)DeviceNode + 101), v100 > 0x1D)
|| (v101 = 541606408, !_bittest(&v101, v100)) )
{
PnpIsDeviceInstanceEnabled(v45, (UNICODE_STRING *)((char *)DeviceNode + 40), 1ui64);
}
if( v45 )
PnpInitializeSessionId((__int64)DeviceNode, (__int64)v45, HIDWORD(v110) == 1);
PiQueryAndAllocateBootResources(DeviceNode);
if( (*((_DWORD *)DeviceNode + 99) & 0x2000) == 0
|| (v102 = *((_DWORD *)DeviceNode + 101), v102 > 0x13)
|| (v103 = 524808, !_bittest(&v103, v102)) )
{
v57 = (_ETHREAD *)KeGetCurrentThread();
--*((_WORD *)v57 + 242);
LOBYTE(v56) = 1;
ExAcquireResourceSharedLite(&PnpRegistryDeviceResource, v56);
PnpSaveDeviceCapabilities((__int64)DeviceNode, &result, HIDWORD(v110) == 1);
ExReleaseResourceLite(&PnpRegistryDeviceResource);
KeLeaveCriticalRegion();
PpHotSwapUpdateRemovalPolicy((__int64)DeviceNode);
v58 = PpDeviceRegistration(
(UNICODE_STRING *)((char *)DeviceNode + 40),
1u,
(UNICODE_STRING *)((char *)DeviceNode + 56),
0);
if( v58 < 0 )
PipSetDevNodeProblem((__int64)DeviceNode, 19, v58);
v45 = Handle;
v47 = P;
v53 = *(void **)&v121[4];
v46 = (WCHAR *)v118;
}
if( (*((_DWORD *)DeviceNode + 99) & 0x2000) == 0 || (v104 = *((_DWORD *)DeviceNode + 101), v104 != 9) && v104 != 3 )
{
PnpIrpDeviceEnumerated((PDEVICE_OBJECT)v5);
if( v45 )
PiUpdateDevicePanel((INT64)DeviceNode, v45);
PnpRaiseNtPlugPlayDevicePropertyChangeEvent(v59, *((_QWORD *)DeviceNode + 6), 1);
PnpRaiseNtPlugPlayDevicePropertyChangeEvent(v60, *((_QWORD *)DeviceNode + 6), 14);
PnpSetPlugPlayEvent(&GUID_DEVICE_ENUMERATED, (DEVICE_OBJECT *)v5);
PnpNewDeviceNodeDependencyCheck((__int64)DeviceNode);
}
if( v47 )
ExFreePoolWithTag(v47, 0);
if( v46 )
ExFreePoolWithTag(v46, 0);
if( SourceString )
ExFreePoolWithTag((PVOID)SourceString, 0);
if( v45 )
ZwClose(v45);
if( v117 )
ExFreePoolWithTag(v117, 0);
if( v127 )
ExFreePoolWithTag(v127, 0);
if( v53 )
ExFreePoolWithTag(v53, 0);
if( v124 )
ExFreePoolWithTag(v124, 0);
v61 = v130;
if( v130 )
PiPnpRtlEndOperation(v130);
if( (byte_140C130BB & 8) != 0 )
McTemplateK0p_EtwWriteTransfer((INT64)v61, (EVENT_DESCRIPTOR *)&KMPnPEvt_ProcessNewDevice_Stop, 0i64, DeviceNode);
if( *((_DWORD *)DeviceNode + 142) )
PnpTraceDockDeviceEnumeration();
}Referenced by:
PipProcessDevNodeTree