PnpShutdownDevices
INT64 __fastcall PnpShutdownDevices(){
unsigned int v0;
volatile signed __int32 *DeviceEventEntry;
_QWORD *v3;
int v4;
_ETHREAD *CurrentThread;
int v6;
unsigned int v7;
_QWORD *v8;
PVOID P;
__int64 v10;
__int64 v11;
char *v12;
char v13;
P = 0i64;
HIDWORD(v11) = 0;
LODWORD(v10) = 0;
KeSetEvent(&PnpShutdownEvent, 0);
v0 = 0;
if( !PnpTearDownPnpStacksOnShutdown && (PopShutdownCleanly & 0x20) == 0 )
return v0;
DeviceEventEntry = PnpCreateDeviceEventEntry(0x189ui64);
if( !DeviceEventEntry )
return 3221225626i64;
KeWaitForSingleObject(&PnpEventQueueEmpty, Executive, 0, 0, 0i64);
KeWaitForSingleObject(&PnpEnumerationLock, Executive, 0, 0, 0i64);
v3 = IopRootDeviceNode;
v12 = &v13;
LODWORD(v11) = 10485760;
PipSetDevNodeUserFlags((__int64)IopRootDeviceNode, 16);
while( 2 )
{
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
--*((_WORD *)CurrentThread + 242);
LOBYTE(v4) = 1;
ExAcquireResourceSharedLite(&PnpRegistryDeviceResource, v4);
v3 = (_QWORD *)v3[1];
while( v3 )
{
v6 = *((_DWORD *)v3 + 100);
if( (v6 & 0x20) != 0 )
{
if( v3 == IopRootDeviceNode )
{
v3 = 0i64;
break;
}
LABEL_17:
v8 = (_QWORD *)*v3;
if( *v3 )
goto LABEL_19;
v3 = (_QWORD *)v3[2];
PipSetDevNodeUserFlags((__int64)v3, 32);
}
else
{
if( (v6 & 0x10) == 0 )
break;
v8 = (_QWORD *)v3[1];
if( !v8 )
{
PipSetDevNodeUserFlags((__int64)v3, 32);
goto LABEL_17;
}
LABEL_19:
v3 = v8;
}
}
ExReleaseResourceLite(&PnpRegistryDeviceResource);
KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
if( v3 )
{
PnpInitializeTargetDeviceRemoveEvent(
(void *)DeviceEventEntry,
0x189ui64,
(PVOID)v3[4],
0,
1,
0,
0,
46,
0,
0i64,
0i64,
(__int64)&v10,
(__int64)&v11);
P = (PVOID)DeviceEventEntry;
v7 = PnpProcessQueryRemoveAndEject((const void **)&P);
v4 = (int)P;
v0 = v7;
if( P != DeviceEventEntry && _InterlockedExchangeAdd((volatile signed __int32 *)P + 16, 0xFFFFFFFF) == 1 )
ExFreePoolWithTag(P, 0x4B706E50u);
continue;
}
break;
}
if( _InterlockedExchangeAdd(DeviceEventEntry + 16, 0xFFFFFFFF) == 1 )
ExFreePoolWithTag((PVOID)DeviceEventEntry, 0x4B706E50u);
return v0;
}Referenced by:
IoShutdownSystem