PiDevCfgClearDeviceMigrationNode
INT64 __fastcall PiDevCfgClearDeviceMigrationNode(INT64 a1, const WCHAR *a2){
char *v3;
__int64 v5;
int v6;
unsigned int v7;
int v8;
char *v9;
__int64 v10;
__int64 v11;
void *v12;
char *v13;
__int64 v14;
__int64 v15;
__int64 v16;
wchar_t *Buffer;
char **v18;
__int64 v19;
int v20;
__int64 v21;
__int64 v22;
__int64 v23;
__int64 v24;
int v26;
int v27;
int v28;
struct _UNICODE_STRING UnicodeString;
int v30;
HANDLE Handle;
struct _UNICODE_STRING v32;
struct _UNICODE_STRING DestinationString;
HANDLE KeyHandle;
HANDLE v35;
INT64 result;
int v37;
const wchar_t *v38;
struct _UNICODE_STRING *p_UnicodeString;
int v40;
int v41;
const wchar_t *v42;
struct _UNICODE_STRING *v43;
int v44;
int v45;
const wchar_t *v46;
int *v47;
int v48;
v3 = *(char **)(a1 + 8);
Handle = 0i64;
KeyHandle = 0i64;
v35 = 0i64;
*(_QWORD *)&UnicodeString.Length = 0i64;
UnicodeString.Buffer = 0i64;
*(_QWORD *)&v32.Length = 0i64;
v32.Buffer = 0i64;
v30 = 0;
if( PiPnpRtlCtx )
v5 = *(_QWORD *)(PiPnpRtlCtx + 224);
else
v5 = 0i64;
v6 = SysCtxRegOpenKey(v5, v3, a2, 0, 0x20019u, &Handle);
v7 = v6;
if( v6 == -1073741772 )
{
LABEL_5:
v7 = 0;
goto LABEL_59;
}
if( v6 >= 0 )
{
memset((INT64)&result, 0i64);
v38 = L"ClassGuid";
v40 = 0x1000000;
v37 = 288;
p_UnicodeString = &UnicodeString;
v45 = 288;
v42 = L"LocationPaths";
v44 = 117440512;
v43 = &v32;
v46 = L"Persist";
v47 = &v30;
v41 = 304;
v48 = 0x4000000;
LOBYTE(v8) = RtlpQueryRegistryValues((_KTRAP_FRAME *)0xC0000000i64, (_KEXCEPTION_FRAME *)Handle);
v7 = v8;
if( v8 >= 0 )
{
if( !UnicodeString.Length && UnicodeString.Buffer )
RtlFreeAnsiString(&UnicodeString);
if( v32.Buffer && !PnpValidateMultiSzData(v32.Buffer, v32.Length) )
RtlFreeAnsiString(&v32);
if( v30 )
goto LABEL_5;
ZwClose(Handle);
v9 = *(char **)(a1 + 8);
Handle = 0i64;
if( PiPnpRtlCtx && (v10 = *(_QWORD *)(PiPnpRtlCtx + 224)) != 0 )
v11 = *(_QWORD *)(v10 + 8);
else
v11 = 0i64;
RegRtlDeletePathInternal(v9, a2, 1, v11, v26);
v12 = *(void **)(a1 + 24);
if( v12 )
{
DestinationString = 0i64;
if( (int)RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)a2) >= 0 )
ZwDeleteValueKey(v12, &DestinationString);
}
v13 = *(char **)(a1 + 16);
if( v13 && UnicodeString.Buffer )
{
v14 = 0i64;
if( PiPnpRtlCtx )
v14 = *(_QWORD *)(PiPnpRtlCtx + 224);
if( (int)SysCtxRegOpenKey(v14, v13, UnicodeString.Buffer, 0, 0xF003Fu, &KeyHandle) >= 0 )
{
DestinationString = 0i64;
if( (int)RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)a2) >= 0 )
ZwDeleteValueKey(KeyHandle, &DestinationString);
ZwClose(KeyHandle);
}
if( PiPnpRtlCtx && (v15 = *(_QWORD *)(PiPnpRtlCtx + 224)) != 0 )
v16 = *(_QWORD *)(v15 + 8);
else
v16 = 0i64;
RegRtlDeletePathInternal(*(char **)(a1 + 16), UnicodeString.Buffer, 0, v16, v27);
}
Buffer = v32.Buffer;
if( v32.Buffer )
{
v18 = (char **)(a1 + 32);
if( !*(_QWORD *)(a1 + 32) )
{
v19 = 0i64;
if( PiPnpRtlCtx )
v19 = *(_QWORD *)(PiPnpRtlCtx + 224);
v20 = SysCtxRegOpenKey(v19, *(char **)a1, L"Locations", 0, 0xF003Fu, (void **)(a1 + 32));
if( v20 == -1073741772 )
{
*v18 = 0i64;
}
else if( v20 < 0 )
{
v7 = v20;
goto LABEL_59;
}
Buffer = v32.Buffer;
if( !*v18 )
goto LABEL_59;
}
while( *Buffer )
{
v21 = 0i64;
if( PiPnpRtlCtx )
v21 = *(_QWORD *)(PiPnpRtlCtx + 224);
if( (int)SysCtxRegOpenKey(v21, *v18, Buffer, 0, 0xF003Fu, &v35) >= 0 )
{
DestinationString = 0i64;
if( (int)RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)a2) >= 0 )
ZwDeleteValueKey(v35, &DestinationString);
ZwClose(v35);
}
if( PiPnpRtlCtx && (v22 = *(_QWORD *)(PiPnpRtlCtx + 224)) != 0 )
v23 = *(_QWORD *)(v22 + 8);
else
v23 = 0i64;
RegRtlDeletePathInternal(*v18, Buffer, 0, v23, v28);
v24 = -1i64;
do
++v24;
while( Buffer[v24] );
Buffer += v24 + 1;
}
}
}
}
LABEL_59:
RtlFreeAnsiString(&UnicodeString);
RtlFreeAnsiString(&v32);
if( Handle )
ZwClose(Handle);
return v7;
}Referenced by:
PiDevCfgFindDeviceMigrationNode
PiDevCfgMigrateDevice