SmKmStoreDelete
NTSTATUS __stdcall SmKmStoreDelete(_SMKM_STORE_LIST *StoreMgr, UINT64 StoreId, INT64 RequestorMode, VOID **StoreOut){
unsigned int v4;
unsigned int v5;
char v6;
NTSTATUS v8;
_EX_PUSH_LOCK *v9;
_ETHREAD *CurrentThread;
_EX_PUSH_LOCK *v11;
__int16 bf_0;
__int64 v13;
UINT64 *v14;
REGHANDLE *v15;
_ETHREAD *v16;
v4 = StoreId;
v5 = StoreId & 0x3FF;
v6 = RequestorMode;
v8 = 0;
v9 = (_EX_PUSH_LOCK *)SmKmStoreRefFromStoreIndex((__int64)StoreMgr, v5);
if( !v9 )
return -1073741735;
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
--CurrentThread->Tcb.KernelApcDisable;
v11 = v9 + 2;
ExAcquirePushLockExclusiveEx(v9 + 2, 0i64);
bf_0 = v9[4]._bf_0;
if( v4 >> 10 != (bf_0 & 0x3F) )
goto LABEL_21;
v13 = v9->_bf_0;
if( (unsigned __int64)(v9->_bf_0 - 1) > 0xFFFFFFFFFFFFFFFDui64 )
goto LABEL_21;
if( !v6 )
{
LABEL_5:
(*((void(__fastcall **)(_SMKM_STORE_LIST *, __int64, __int64))StoreMgr + 32))(StoreMgr, v9->_bf_0, 7i64);
ExWaitForRundownProtectionRelease((_EX_RUNDOWN_REF *)&v9[1]);
v14 = (UINT64 *)SmEtwEnabled(SmEtwKeywordStoreOps);
v15 = v14;
if( v14 )
{
SmKmEtwLogStoreStats(v14, v9->Ptr);
SmKmEtwLogStoreChange(v15, v9->_bf_0, SmEventStoreDelete);
}
(*((void(__fastcall **)(_SMKM_STORE_LIST *, __int64, __int64))StoreMgr + 32))(StoreMgr, v13, 2i64);
v9->_bf_0 = 0i64;
v16 = (_ETHREAD *)KeGetCurrentThread();
--v16->Tcb.KernelApcDisable;
ExAcquirePushLockExclusiveEx((_EX_PUSH_LOCK *)StoreMgr + 52, 0i64);
if( StoreMgr[108] == v5 )
StoreMgr[108] = -1;
if( StoreMgr[106]-- == 1 )
(*((void(__fastcall **)(_SMKM_STORE_LIST *, _QWORD, __int64))StoreMgr + 32))(StoreMgr, 0i64, 4i64);
if( (_InterlockedExchangeAdd64((volatile signed __int64 *)StoreMgr + 52, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
ExfTryToWakePushLock((_EX_PUSH_LOCK *)StoreMgr + 52);
KeAbPostRelease(StoreMgr + 104);
KeLeaveCriticalRegion();
if( (_InterlockedExchangeAdd64(&v11->_bf_0, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
ExfTryToWakePushLock(v11);
KeAbPostRelease(v11);
KeLeaveCriticalRegion();
(*((void(__fastcall **)(_SMKM_STORE_LIST *, __int64, __int64))StoreMgr + 32))(StoreMgr, v13, 1i64);
return v8;
}
if( (bf_0 & 0x40) != 0 )
{
LABEL_21:
v8 = -1073741735;
}
else
{
if( (bf_0 & 0x80u) == 0 )
goto LABEL_5;
v8 = -1073741790;
}
if( (_InterlockedExchangeAdd64(&v11->_bf_0, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
ExfTryToWakePushLock(v9 + 2);
KeAbPostRelease(&v9[2]);
KeLeaveCriticalRegion();
return v8;
}Referenced by:
SmKmStoreDeleteWhenEmptyWorker
SmProcessDeleteRequest