PiSwIrpCleanup
void __fastcall PiSwIrpCleanup(__int64 a1){
__int64 v1;
_ETHREAD *CurrentThread;
__int64 v4;
char v5;
wchar_t *v6;
WCHAR v7;
struct _DMA_ADAPTER *v8;
__int64 v9;
INT64 SwDevice;
struct _UNICODE_STRING DestinationString;
v1 = 0i64;
DestinationString = 0i64;
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
--*((_WORD *)CurrentThread + 242);
ExAcquireResourceExclusiveLite((ERESOURCE *)PiSwLockObj, 1u);
if( !*(_DWORD *)(a1 + 180) )
goto LABEL_11;
v4 = *(_QWORD *)(a1 + 112);
v5 = 0;
while( 1 )
{
v6 = *(wchar_t **)(v4 + 8);
if( wcsnicmp(v6, L"SWD\\", 4ui64) )
break;
SwDevice = PiSwFindSwDevice(v6);
if( !SwDevice )
goto LABEL_11;
if( !*(_DWORD *)(SwDevice + 180) && (*(_DWORD *)(SwDevice + 4) & 2) == 0 )
goto LABEL_6;
v4 = *(_QWORD *)(SwDevice + 112);
}
RtlInitUnicodeString(&DestinationString, v6, v7);
v8 = (struct _DMA_ADAPTER *)PnpDeviceObjectFromDeviceInstanceWithTag((INT64)&DestinationString, 0x746C6644ui64);
if( v8 )
HalPutDmaAdapter(v8);
else
LABEL_11:
v5 = 1;
LABEL_6:
v9 = *(_QWORD *)(a1 + 144);
if( v9 && _InterlockedExchange64((volatile __int64 *)(v9 + 104), 0i64) )
{
v1 = *(_QWORD *)(a1 + 144);
*(_QWORD *)(a1 + 144) = 0i64;
}
*(_DWORD *)(a1 + 4) &= ~1u;
if( v5 )
{
PiSwCloseDescendants((UNICODE_STRING *)(a1 + 72));
PiSwCloseDevice((CHAR *)a1);
}
ExReleaseResourceLite((PERESOURCE)PiSwLockObj);
KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
if( v1 )
{
*(_QWORD *)(v1 + 56) = 0i64;
*(_DWORD *)(v1 + 48) = -1073741536;
IofCompleteRequest((_IRP *)v1, 0);
}
}Referenced by:
PiSwDispatch
PiSwIrpStartCreateWorker