NtAlpcSetInformation
NTSTATUS __stdcall NtAlpcSetInformation(
VOID *PortHandle,
_ALPC_PORT_INFORMATION_CLASS PortInformationClass,
VOID *PortInformation,
UINT64 Length){
size_t v4;
_ETHREAD *CurrentThread;
int v8;
signed int v9;
char PreviousMode;
__int64 v11;
__int64 *v12;
__int32 v13;
__int32 v14;
__int32 v15;
__int32 v16;
int v17;
int v18;
int v19;
_DWORD *v20;
_EX_PUSH_LOCK *v21;
_EX_PUSH_LOCK *v22;
_QWORD *v23;
_EX_PUSH_LOCK *v24;
_EX_PUSH_LOCK *v25;
_ALPC_PORT *v26;
_EX_PUSH_LOCK *v27;
_ALPC_PORT *v28;
_EX_PUSH_LOCK *v29;
VOID *v30;
__m128i v31;
NTSTATUS v32;
PVOID *Object;
POBJECT_HANDLE_INFORMATION HandleInformation;
char v36;
PVOID v37;
__int64 *v38;
_HANDLE Handle[2];
__int64 *v40;
__int64 v41[10];
v4 = Length;
*(_QWORD *)Handle = PortHandle;
v38 = (__int64 *)PortInformation;
memset(v41, 0i64, 0x48u);
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
--CurrentThread->Tcb.KernelApcDisable;
v8 = 0;
if( PortHandle
&& (v38
|| PortInformationClass == AlpcUnregisterCompletionListInformation
|| PortInformationClass == AlpcCompletionListRundownInformation) )
{
PreviousMode = KeGetCurrentThread()->PreviousMode;
v36 = PreviousMode;
v11 = (__int64)v38;
v12 = v38;
v40 = v38;
if( v4 && PreviousMode )
{
if( v4 > 0x48 )
{
v9 = -1073741820;
goto LABEL_65;
}
if( (unsigned __int64)v38 >= 0x7FFFFFFF0000i64 )
v11 = 0x7FFFFFFF0000i64;
v38 = (__int64 *)v11;
memmove(v41, (const VOID *)v11, v4);
v12 = v41;
v40 = v41;
}
v37 = 0i64;
v9 = ObReferenceObjectByHandle(*(VOID **)Handle, 1ui64, AlpcPortObjectType, PreviousMode, &v37, 0i64);
if( v9 < 0 )
goto LABEL_65;
v13 = PortInformationClass - 1;
if( v13 )
{
v14 = v13 - 1;
if( v14 )
{
v15 = v14 - 3;
if( !v15 )
{
v9 = v4 != 16 ? 0xC000000D : 0;
goto LABEL_64;
}
v16 = v15 - 1;
if( v16 )
{
v17 = v16 - 1;
if( v17 )
{
v18 = v17 - 1;
if( !v18 )
{
if( v4 == 4 && *(_DWORD *)v12 )
{
v26 = (_ALPC_PORT *)v37;
v27 = (_EX_PUSH_LOCK *)((char *)v37 + 352);
ExAcquirePushLockSharedEx((_EX_PUSH_LOCK *)v37 + 44, 0i64);
if( v26->CompletionList )
{
AlpcpAdjustCompletionListConcurrencyCount(v26, *(unsigned int *)v12);
v9 = 0;
}
else
{
v9 = -1073741811;
}
if( _InterlockedCompareExchange64(&v27->_bf_0, 0i64, 17i64) != 17 )
ExfReleasePushLockShared(v27);
v22 = v27;
goto LABEL_29;
}
LABEL_52:
v9 = -1073741811;
goto LABEL_64;
}
v19 = v18 - 1;
if( v19 )
{
if( v19 == 1 && !v4 )
{
v20 = v37;
v21 = (_EX_PUSH_LOCK *)((char *)v37 + 352);
ExAcquirePushLockExclusiveEx((_EX_PUSH_LOCK *)v37 + 44, 0i64);
if( *((_QWORD *)v20 + 45) )
{
v20[104] &= ~0x10000u;
v9 = 0;
}
else
{
v9 = -1073741811;
}
if( (_InterlockedExchangeAdd64(&v21->_bf_0, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
ExfTryToWakePushLock(v21);
v22 = v21;
LABEL_29:
KeAbPostRelease(v22);
LABEL_64:
HalPutDmaAdapter((PADAPTER_OBJECT)v37);
goto LABEL_65;
}
goto LABEL_52;
}
if( v36 )
goto LABEL_52;
ObfReferenceObject(*(PVOID *)v11);
v23 = v37;
v24 = (_EX_PUSH_LOCK *)((char *)v37 + 352);
ExAcquirePushLockExclusiveEx((_EX_PUSH_LOCK *)v37 + 44, 0i64);
v23[46] = *(_QWORD *)v11;
v23[47] = *(_QWORD *)(v11 + 8);
if( (_InterlockedExchangeAdd64(&v24->_bf_0, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
ExfTryToWakePushLock(v24);
v25 = v24;
}
else
{
if( v4 )
goto LABEL_52;
v28 = (_ALPC_PORT *)v37;
v29 = (_EX_PUSH_LOCK *)((char *)v37 + 352);
ExAcquirePushLockExclusiveEx((_EX_PUSH_LOCK *)v37 + 44, 0i64);
if( v28->CompletionList )
AlpcpFreeCompletionList(v28);
if( (_InterlockedExchangeAdd64(&v29->_bf_0, 0xFFFFFFFFFFFFFFFFui64) & 6) == 2 )
ExfTryToWakePushLock(v29);
v25 = v29;
}
KeAbPostRelease(v25);
v9 = 0;
goto LABEL_64;
}
if( (*((_DWORD *)v37 + 104) & 6) != 2 )
goto LABEL_52;
if( v4 == 16 )
{
v31 = *(__m128i *)v12;
v12 = v41;
v30 = (VOID *)v31.m128i_u32[0];
v41[0] = v31.m128i_u32[0];
LODWORD(v41[1]) = v31.m128i_i32[1];
*(__int64 *)((char *)&v41[1] + 4) = _mm_srli_si128(v31, 8).m128i_u64[0];
v8 = 1;
}
else
{
if( v4 != 24 )
goto LABEL_52;
v30 = (VOID *)*v12;
}
LODWORD(HandleInformation) = v8;
LODWORD(Object) = *((_DWORD *)v12 + 4);
v32 = AlpcpInitializeCompletionList(
(_ALPC_PORT *)v37,
v30,
*((unsigned int *)v12 + 2),
*((unsigned int *)v12 + 3),
(UINT64)Object,
(UINT64)HandleInformation);
LABEL_59:
v9 = v32;
goto LABEL_64;
}
if( v4 == 16 )
{
v32 = AlpcpAssociateIoCompletionPort((_ALPC_PORT *)v37, (VOID *)v12[1], (VOID *)*v12);
goto LABEL_59;
}
}
else if( v4 == 72 )
{
if( (*(_DWORD *)v12 & 0xFC00FFFF) == 0 )
{
*((_DWORD *)v37 + 64) ^= (*((_DWORD *)v37 + 64) ^ *(_DWORD *)v12) & 0x20000;
goto LABEL_64;
}
goto LABEL_52;
}
v9 = -1073741820;
goto LABEL_64;
}
v9 = -1073741811;
LABEL_65:
KeLeaveCriticalRegionThread(KeGetCurrentThread());
return v9;
}Referenced by:
No references.