PiSwCompleteCreate
VOID __stdcall PiSwCompleteCreate(_DEVICE_OBJECT *DeviceObject){
INT64 v1;
UINT64 v2;
_ETHREAD *CurrentThread;
__int64 v5;
_DEVICE_OBJECT *v6;
_DWORD *DeviceExtension;
__int64 v8;
void *v9;
WCHAR **v10;
WCHAR *v11;
UINT64 v12;
int PWSTR;
__int64 v14;
__int64 v15;
__int64 v16;
__int64 *v17;
__int64 *i;
WCHAR *v19;
_DEVPROPERTY *v20;
_LIST_ENTRY *j;
_LIST_ENTRY *Blink;
_LIST_ENTRY *v23;
WCHAR *v24;
NTSTATUS DeviceInterfaceReferenceString;
char v26;
UINT64 PropertyCount;
_LIST_ENTRY InterfaceList;
__int64 v29;
WCHAR *SourceString;
_PI_SWD_INTERFACE *Interface;
_DEVPROPERTY *Properties;
WCHAR **v33;
UINT64 pcbLength[3];
_UNICODE_STRING UnicodeString;
_GUID InterfaceClassGuid;
__int16 ReferenceStringLength[264];
v2 = 0i64;
InterfaceList.Blink = &InterfaceList;
v33 = 0i64;
InterfaceList.Flink = &InterfaceList;
InterfaceClassGuid = 0i64;
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
v5 = 0i64;
Properties = 0i64;
LODWORD(PropertyCount) = 0;
v6 = 0i64;
LODWORD(v29) = 0;
--CurrentThread->Tcb.KernelApcDisable;
memset(pcbLength, 0, sizeof(pcbLength));
Interface = 0i64;
UnicodeString = 0i64;
ExAcquireResourceExclusiveLite((UINT64)&PiSwLockObj, 1, v1);
DeviceExtension = DeviceObject->DeviceExtension;
v8 = *(_QWORD *)DeviceExtension;
if( *(_QWORD *)DeviceExtension )
{
DeviceExtension[2] &= 0xFFFFFFF9;
v9 = *(void **)(v8 + 80);
v10 = (WCHAR **)((char *)DeviceObject->DeviceObjectExtension->DeviceNode + 40);
v33 = v10;
if( v9 )
{
ExFreePoolWithTag(v9, 0x57706E50u);
*(_OWORD *)(v8 + 72) = 0i64;
}
v11 = v10[1];
v12 = ((unsigned __int64)*(unsigned __int16 *)v10 >> 1) + 1;
SourceString = 0i64;
PWSTR = PnpAllocatePWSTR(v11, v12, 0x57706E50u, (PVOID *)&SourceString);
if( PWSTR >= 0 )
{
RtlInitUnicodeString((PUNICODE_STRING)(v8 + 72), SourceString);
*(_DWORD *)(v8 + 4) |= 4u;
if( !*(_QWORD *)(v8 + 88) )
{
v15 = *(_QWORD *)(v8 + 144);
if( !v15
|| !_InterlockedExchange64((volatile __int64 *)(v15 + 104), 0i64)
|| (v5 = *(_QWORD *)(v8 + 144), *(_QWORD *)(v8 + 144) = 0i64, !v5)
|| (v16 = *(_QWORD *)(v5 + 184),
PWSTR = RtlStringCbCopyW(*(WCHAR **)(v5 + 24), *(unsigned int *)(v16 + 8), *(WCHAR **)(v8 + 80)),
PWSTR >= 0)
&& (PWSTR = RtlStringCbLengthW(*(WCHAR **)(v5 + 24), *(unsigned int *)(v16 + 8), pcbLength), PWSTR >= 0) )
{
PWSTR = PnpCopyDevPropertyArray(
*(unsigned int *)(v8 + 176),
*(_QWORD *)(v8 + 168),
v14,
&PropertyCount,
(__int64)&Properties);
if( PWSTR >= 0 )
{
v17 = (__int64 *)(v8 + 184);
for( i = *(__int64 **)(v8 + 184); i != v17; i = (__int64 *)*i )
{
PWSTR = PiSwInterfaceCreate(
(WCHAR *)i[2],
(_DEVPROPERTY *)i[3],
*((unsigned int *)i + 8),
(VOID **)&Interface);
if( PWSTR < 0 )
goto LABEL_15;
Blink = InterfaceList.Blink;
if( InterfaceList.Blink->Flink != &InterfaceList )
__fastfail(3u);
v23 = (_LIST_ENTRY *)Interface;
*(_QWORD *)Interface = &InterfaceList;
v23->Blink = Blink;
Blink->Flink = v23;
InterfaceList.Blink = v23;
}
v6 = DeviceObject;
ObfReferenceObject(DeviceObject);
}
}
}
}
}
else
{
PWSTR = -1073741811;
}
LABEL_15:
ExReleaseResourceLite(&PiSwLockObj);
KeLeaveCriticalRegionThread(KeGetCurrentThread());
v20 = Properties;
if( PWSTR >= 0 )
{
if( !Properties
|| (PWSTR = PiSwPropertySet(
v33[1],
(VOID *)1,
(const INT64)Properties,
(_DEVPROPERTY *)(unsigned int)PropertyCount),
PWSTR >= 0) )
{
for( j = InterfaceList.Flink; j != &InterfaceList; j = j->Flink )
{
PWSTR = CmGetDeviceInterfaceClassGuid(v19, (_GUID *)j[1].Flink);
if( PWSTR < 0 )
break;
DeviceInterfaceReferenceString = CmGetDeviceInterfaceReferenceString(
v24,
(WCHAR *)j[1].Flink,
(UINT64)ReferenceStringLength,
(UINT64 *)0x104);
PWSTR = DeviceInterfaceReferenceString;
if( DeviceInterfaceReferenceString == -1073741772 )
{
v26 = 0;
}
else
{
if( DeviceInterfaceReferenceString < 0 )
break;
v26 = 1;
RtlInitUnicodeString((PUNICODE_STRING)&pcbLength[1], (PCWSTR)ReferenceStringLength);
}
PWSTR = IoRegisterDeviceInterface(
v6,
&InterfaceClassGuid,
(_UNICODE_STRING *)((unsigned __int64)&pcbLength[1] & -(__int64)(v26 != 0)),
&UnicodeString);
if( PWSTR < 0 )
break;
PWSTR = PiSwPropertySet(
(WCHAR *)j[1].Flink,
(VOID *)3,
(const INT64)j[1].Blink,
(_DEVPROPERTY *)LODWORD(j[2].Flink));
if( PWSTR < 0 )
break;
}
}
}
if( v6 )
HalPutDmaAdapter((PADAPTER_OBJECT)v6);
if( v20 )
PnpFreeDevPropertyArray(PropertyCount, v20, 0x57706E50u);
PiSwFreeInterfaceList(&InterfaceList);
RtlFreeAnsiString(&UnicodeString);
if( v5 )
{
if( PWSTR >= 0 )
v2 = pcbLength[0] + 2;
*(_QWORD *)(v5 + 56) = v2;
*(_DWORD *)(v5 + 48) = PWSTR;
IofCompleteRequest((PIRP)v5, 0);
}
}Referenced by:
PiSwPdoPnPDispatch