PipMigratePnpState
INT64 __fastcall PipMigratePnpState(){
char v0;
void *v1;
int v2;
__int64 v3;
int CachedContextBaseKey;
int v6;
int v7;
int v8;
int v9;
__int64 v10;
int v11;
int MatchingDeviceList;
int v13;
int v14;
void *v15;
void *v16;
char *v17;
int v18;
__int64 Source2;
__int64 v20;
void *v21;
void *v22;
__int64 Source1[8];
int v24;
int v25;
int v26;
int v27;
v16 = 0i64;
v17 = 0i64;
v20 = 0i64;
v0 = 0;
v25 = 0;
v1 = 0i64;
v26 = 0;
v27 = 0;
v15 = 0i64;
Source1[0] = 0i64;
Source2 = 0i64;
v22 = 0i64;
v21 = 0i64;
v18 = 0;
v2 = PnpCtxRegOpenKey(PiPnpRtlCtx, (char *)0x80000002i64, L"System\\Setup\\Upgrade\\PnP", 0, 0x2001Fu, &v16);
CachedContextBaseKey = v2;
if( v2 == -1073741772 )
goto LABEL_2;
if( v2 >= 0 )
{
v24 = 4;
v6 = PnpCtxRegQueryValue(v3, v16, L"MigrationStatus", &v25, &v26, (__int64)&v24);
CachedContextBaseKey = v6;
if( v6 != -1073741772 )
{
if( v6 < 0 )
goto LABEL_3;
if( v25 != 4 || v24 != 4 )
{
CachedContextBaseKey = -1073741823;
goto LABEL_47;
}
}
v7 = PnpCtxRegOpenKey(PiPnpRtlCtx, (char *)v16, L"CurrentControlSet", 0, 0x2001Fu, (void **)&v17);
CachedContextBaseKey = v7;
if( v7 == -1073741772 )
{
LABEL_2:
CachedContextBaseKey = 0;
goto LABEL_3;
}
if( v7 >= 0 )
{
CachedContextBaseKey = PnpCtxRegOpenKey(PiPnpRtlCtx, v17, L"Control\\DeviceMigration", 0, 0x20019u, &v15);
if( CachedContextBaseKey >= 0 )
{
v24 = 8;
CachedContextBaseKey = PnpCtxRegQueryValue(v3, v15, L"MigrationTime", &v25, &Source2, (__int64)&v24);
if( CachedContextBaseKey >= 0 )
{
if( v25 == 3 && v24 == 8 )
{
PnpCtxRegCloseKey(v3, v15);
v15 = 0i64;
CachedContextBaseKey = PnpCtxGetCachedContextBaseKey(PiPnpRtlCtx, 4, &v20);
if( CachedContextBaseKey < 0 )
goto LABEL_3;
CachedContextBaseKey = PnpCtxRegCreateKey(
PiPnpRtlCtx,
v20,
L"Control\\DeviceMigration",
0,
0x20006u,
0i64,
&v15,
0i64);
if( CachedContextBaseKey < 0 )
goto LABEL_3;
v24 = 8;
v8 = PnpCtxRegQueryValue(v3, v15, L"MigrationTime", &v25, Source1, (__int64)&v24);
CachedContextBaseKey = v8;
if( v8 == -1073741772 )
goto LABEL_32;
if( v8 < 0 )
goto LABEL_3;
if( v25 == 3 && v24 == 8 )
{
if( RtlCompareMemory(Source1, &Source2, 8ui64) == 8 )
{
CachedContextBaseKey = -1073741791;
goto LABEL_3;
}
LABEL_32:
v26 = 259;
CachedContextBaseKey = PnpCtxRegSetValue(v3, v16, L"MigrationStatus", 4u, &v26, 4u);
if( CachedContextBaseKey < 0 )
goto LABEL_3;
CachedContextBaseKey = PnpCtxRegSetValue(v3, v15, L"MigrationTime", 3u, &Source2, 8u);
if( CachedContextBaseKey < 0 )
goto LABEL_3;
v24 = 4;
v0 = 1;
CachedContextBaseKey = PnpCtxRegQueryValue(v3, v16, L"TargetVersion", &v25, &v27, (__int64)&v24);
if( CachedContextBaseKey < 0 )
goto LABEL_50;
if( v25 != 4 || v24 != 4 )
{
CachedContextBaseKey = -1073741823;
goto LABEL_50;
}
if( (v27 & 0xFFFF0000) != 167772160 )
{
CachedContextBaseKey = -1073741735;
goto LABEL_50;
}
CachedContextBaseKey = PnpCtxRegCopyTree(v3, v17, 0i64, v20, 0i64);
if( CachedContextBaseKey < 0 )
goto LABEL_50;
v9 = PnpCtxRegOpenKey(PiPnpRtlCtx, v17, L"Services", 0, 0x20019u, &v22);
CachedContextBaseKey = v9;
if( v9 != -1073741772 )
{
if( v9 < 0 )
goto LABEL_50;
CachedContextBaseKey = PnpCtxRegEnumKeyWithCallback(
PiPnpRtlCtx,
v22,
(__int64)PipMigrateCleanServiceCallback,
0i64);
if( CachedContextBaseKey < 0 )
goto LABEL_50;
}
v11 = PnpCtxOpenMachine(v3, 0i64, v10, -1i64, v13, v14, &v21);
v1 = v21;
CachedContextBaseKey = v11;
if( v11 < 0 )
goto LABEL_50;
MatchingDeviceList = CmGetMatchingDeviceList(
(__int64)v21,
(__int64)PipMigrateResetDeviceCallback,
0i64,
0i64,
0,
(__int64)&v18,
0);
CachedContextBaseKey = MatchingDeviceList;
if( MatchingDeviceList == -1073741789 )
{
CachedContextBaseKey = 0;
goto LABEL_50;
}
if( MatchingDeviceList < 0 )
goto LABEL_50;
LABEL_47:
if( !v0 )
{
LABEL_51:
if( v1 )
PnpCtxCloseMachine(v1);
goto LABEL_3;
}
LABEL_50:
v26 = CachedContextBaseKey;
PnpCtxRegSetValue(v3, v16, L"MigrationStatus", 4u, &v26, 4u);
goto LABEL_51;
}
}
CachedContextBaseKey = -1073741823;
}
}
}
}
LABEL_3:
if( v22 )
PnpCtxRegCloseKey(v3, v22);
if( v15 )
PnpCtxRegCloseKey(v3, v15);
if( v17 )
PnpCtxRegCloseKey(v3, v17);
if( v16 )
PnpCtxRegCloseKey(v3, v16);
return(unsigned int)CachedContextBaseKey;
}Referenced by:
IopInitializePlugPlayServices