PiDevCfgMigrateDevice
__int64 __fastcall PiDevCfgMigrateDevice(
__int64 a1,
__int64 a2,
unsigned __int16 *a3,
__int64 a4,
_DWORD *a5,
_DWORD *a6){
__int64 v8;
int v9;
int inited;
char *v12;
__int64 v13;
int v14;
const WCHAR *v15;
__int64 v16;
int v17;
__int64 v18;
int DeviceMigrationNode;
int v20;
unsigned int *v21;
__int64 v22;
__int64 v23;
__int64 v24;
WCHAR *v25;
void *v26;
const wchar_t **v27;
INT64 a6a;
INT64 a6b;
INT64 a8;
INT64 a8a;
INT64 a10;
INT64 a11;
PVOID P;
ULONG v35;
int a7;
HANDLE Handle;
struct _UNICODE_STRING DestinationString;
INT64 a3a[2];
VOID *v40[2];
__int128 v41;
__int64 v42;
v42 = 0i64;
P = 0i64;
Handle = 0i64;
*(_QWORD *)&DestinationString.Length = 0i64;
v8 = a1;
a7 = 0;
v9 = 0;
v35 = 0;
*(_OWORD *)a3a = 0i64;
*(_OWORD *)v40 = 0i64;
v41 = 0i64;
if( a5 )
*a5 = 0;
if( a6 )
*a6 = 0;
inited = PiDevCfgInitMigrationContext((INT64)a3, a4, (INT64)a3a);
if( inited < 0 )
goto LABEL_8;
if( !a3a[0] )
{
inited = 0;
goto LABEL_8;
}
if( (unsigned int)PnpGetObjectProperty(
PiPnpRtlCtx,
*(_QWORD *)(a2 + 8),
1i64,
*(_QWORD *)(a2 + 16),
0i64,
(__int64)&DEVPKEY_Device_MigrationRank,
&a7,
0i64,
0,
&v35,
0) == -1073741789
&& a7 == 9
&& v35 == 8 )
{
goto LABEL_50;
}
if( a3a[1] )
{
inited = PiDevCfgQueryDeviceMigrationNode((INT64)a3a, *(const WCHAR **)(a2 + 8), (CHAR **)&P);
if( inited < 0 )
{
P = 0i64;
if( inited == -1073741772 )
inited = 0;
}
else
{
*((_QWORD *)P + 23) = 0i64;
}
}
if( P )
{
LABEL_51:
v20 = *((_DWORD *)P + 4);
if( (v20 & 1) != 0 )
{
inited = -1073740007;
}
else if( (v20 & 2) != 0 )
{
inited = -1073740719;
}
else
{
if( IopGetRegistryValue(
*((PVOID *)P + 5),
(PWCHAR)L"ConfigFlags",
0i64,
(KEY_VALUE_FULL_INFORMATION **)&DestinationString) >= 0 )
{
if( PnpValidateRegistryDword(*(KEY_VALUE_FULL_INFORMATION **)&DestinationString.Length) )
v9 = *(unsigned int *)((char *)v21 + v21[2]);
ExFreePoolWithTag(v21, 0);
}
v22 = *(_QWORD *)(a2 + 16);
v23 = *(_QWORD *)(a2 + 8);
v35 = 0;
if( (unsigned int)PnpGetObjectProperty(
PiPnpRtlCtx,
v23,
1i64,
v22,
0i64,
(__int64)&DEVPKEY_Device_ClassGuid,
&a7,
0i64,
0,
&v35,
0) != -1073741789
|| a7 != 13
|| v35 != 16 )
{
if( a3 )
{
PiDevCfgSetDeviceRegProp(v24, a2, 9, 1, *((_QWORD *)a3 + 1), *a3 + 2);
}
else
{
LODWORD(a11) = 0;
LODWORD(a10) = 16;
LODWORD(a8) = 13;
PiDevCfgSetObjectProperty(
PiPnpRtlCtx,
(_DWORD *)a2,
*(WCHAR **)(a2 + 8),
1ui64,
*(_QWORD *)(a2 + 16),
a6a,
(INT64)&DEVPKEY_Device_ClassGuid,
a8,
(WCHAR *)P + 40,
a10,
a11);
}
}
inited = PiDevCfgConfigureDeviceDriverConfiguration(v8, a2, *((void **)P + 5), -1, 0i64, 0i64, a5, a6);
if( inited >= 0 )
{
if( a5 )
*a5 |= v9;
v25 = (WCHAR *)P;
if( *((_QWORD *)P + 23) )
{
v26 = *(void **)(a2 + 16);
DestinationString = 0i64;
if( (int)RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)L"ParentIdPrefix") >= 0 )
{
ZwDeleteValueKey(v26, &DestinationString);
v25 = (WCHAR *)P;
}
}
LODWORD(a11) = 0;
LODWORD(a10) = 8;
LODWORD(a8a) = 9;
PiDevCfgSetObjectProperty(
PiPnpRtlCtx,
(_DWORD *)a2,
*(WCHAR **)(a2 + 8),
1ui64,
*(_QWORD *)(a2 + 16),
a6b,
(INT64)&DEVPKEY_Device_MigrationRank,
a8a,
v25 + 92,
a10,
a11);
}
}
PiDevCfgLogDeviceMigrated(a2, (INT64)P, (unsigned int)inited);
v27 = (const wchar_t **)P;
if( (*((_DWORD *)P + 4) & 1) == 0 )
{
PiDevCfgClearDeviceMigrationNode((INT64)a3a, *((const WCHAR **)P + 4));
v27 = (const wchar_t **)P;
}
if( !v27 || wcsicmp(*(const wchar_t **)(a2 + 8), v27[4]) )
goto LABEL_76;
goto LABEL_8;
}
if( CmIsRootEnumeratedDevice(*(PCWSTR *)(a2 + 8)) )
goto LABEL_50;
if( !*(_QWORD *)(a2 + 64) )
goto LABEL_45;
v12 = (char *)v41;
if( !(_QWORD)v41 )
{
v13 = 0i64;
if( PiPnpRtlCtx )
v13 = *(_QWORD *)(PiPnpRtlCtx + 224);
v14 = SysCtxRegOpenKey(v13, (char *)a3a[0], L"Locations", 0, 0x20019u, (void **)&v41);
if( v14 == -1073741772 )
{
*(_QWORD *)&v41 = 0i64;
goto LABEL_45;
}
if( v14 < 0 )
{
inited = v14;
goto LABEL_8;
}
v12 = (char *)v41;
if( !(_QWORD)v41 )
goto LABEL_45;
}
v15 = *(const WCHAR **)(a2 + 64);
if( !*v15 )
goto LABEL_43;
while( 1 )
{
v16 = 0i64;
if( PiPnpRtlCtx )
v16 = *(_QWORD *)(PiPnpRtlCtx + 224);
v17 = SysCtxRegOpenKey(v16, v12, v15, 0, 0x20019u, &Handle);
if( v17 == -1073741772 )
goto LABEL_38;
if( v17 < 0 )
break;
inited = PiDevCfgFindDeviceMigrationNode((INT64)a3a, a2, Handle, 0x11201ui64, (INT64 **)&P);
ZwClose(Handle);
if( inited >= 0 )
goto LABEL_44;
P = 0i64;
if( inited == -1073741275 )
inited = 0;
LABEL_38:
v18 = -1i64;
do
++v18;
while( v15[v18] );
v15 += v18 + 1;
if( !*v15 )
goto LABEL_43;
v12 = (char *)v41;
}
inited = v17;
LABEL_43:
if( inited >= 0 )
{
LABEL_44:
v8 = a1;
LABEL_45:
if( P )
goto LABEL_51;
if( v40[1] )
{
DeviceMigrationNode = PiDevCfgFindDeviceMigrationNode((INT64)a3a, a2, v40[1], 0x11021ui64, (INT64 **)&P);
inited = DeviceMigrationNode;
if( DeviceMigrationNode < 0 )
{
P = 0i64;
if( DeviceMigrationNode == -1073741275 )
inited = 0;
}
LABEL_50:
if( P )
goto LABEL_51;
}
LABEL_76:
PiDevCfgClearDeviceMigrationNode((INT64)a3a, *(const WCHAR **)(a2 + 8));
}
LABEL_8:
if( P )
PiDevCfgFreeDeviceMigrationNode(P);
PiDevCfgFreeMigrationContext((__int64)a3a);
return(unsigned int)inited;
}Referenced by:
PiDevCfgConfigureDevice
PiDevCfgMigrateRootDevice
PpDevCfgProcessDeviceReset