HalpConstructScatterGatherListThin
NTSTATUS __stdcall HalpConstructScatterGatherListThin(INT64 a1){
__int64 v1;
int v2;
void(__fastcall *v4)(_QWORD, _QWORD, _QWORD, _QWORD);
INT64 v5;
void *v6;
INT64 v7;
__int64 *v8;
unsigned int v9;
__int64 v10;
char v11;
INT64 v12;
__int64 v13;
__int64 v14;
unsigned int v15;
INT64 v16;
unsigned __int64 v17;
NTSTATUS v18;
void(__fastcall *v20)(_QWORD, _QWORD, _QWORD, _QWORD);
__int64 v21;
__int64 v22;
unsigned int v23;
__int64 v24;
int v25;
unsigned int v26;
INT64 v27;
INT64 v28;
v1 = *(_QWORD *)(a1 + 24);
v2 = 0;
v4 = *(void(__fastcall **)(_QWORD, _QWORD, _QWORD, _QWORD))(a1 + 64);
v5 = *(unsigned int *)(a1 + 60);
v6 = *(void **)(a1 + 88);
v7 = *(_QWORD *)(v1 + 504);
v8 = *(__int64 **)(a1 + 48);
v9 = *(_DWORD *)(a1 + 56);
v10 = *(_QWORD *)(a1 + 80);
v11 = *(_BYTE *)(a1 + 96);
v28 = v7;
v24 = v1;
v25 = v5;
v20 = v4;
if( *(_BYTE *)(a1 + 98) )
v12 = *(_QWORD *)(v1 + 552);
else
v12 = 0i64;
*(_DWORD *)v10 = 0;
v27 = v12;
*(_QWORD *)(v10 + 8) = a1;
if( v8 )
{
v13 = 0i64;
while( v9 )
{
v14 = 3 * v13;
v15 = v9;
v22 = v14;
if( *((_DWORD *)v8 + 10) - (int)v5 <= v9 )
v15 = *((_DWORD *)v8 + 10) - v5;
v16 = v9 - v15;
v23 = v15;
v26 = v16;
v21 = ((_WORD)v5 + (unsigned __int16)*((_DWORD *)v8 + 11)) & 0xFFF;
v17 = ((unsigned __int64)v15 + v21 + 4095) >> 12;
if( !*(_BYTE *)(a1 + 98) )
{
v18 = HalpDomainLaAllocate(
v7,
(PDUMPWRITER_FILL_HEADERS *)(unsigned int)((_DWORD)v17 << 12),
v5,
0i64,
0i64,
(INT64)&v27);
v12 = v27;
v2 = v18;
if( v18 < 0 )
goto LABEL_24;
LODWORD(v5) = v25;
v7 = v28;
}
v2 = HalpIommuDomainMapLogical(
*(_QWORD *)(v7 + 40),
v16,
(INT64)&v8[((unsigned __int64)(unsigned int)(v5 + *((_DWORD *)v8 + 11)) >> 12) + 6],
(unsigned int)v17,
v12);
if( v2 < 0 )
goto LABEL_24;
v5 = 0i64;
v25 = 0;
*(_QWORD *)(v10 + 8 * v22 + 32) = 0i64;
*(_QWORD *)(v10 + 8 * v22 + 16) = v12 + v21;
*(_DWORD *)(v10 + 8 * v22 + 24) = v23;
v8 = (__int64 *)*v8;
v13 = (unsigned int)(*(_DWORD *)v10 + 1);
*(_DWORD *)v10 = v13;
if( *(_BYTE *)(a1 + 98) )
{
v12 += (unsigned __int64)(unsigned int)v17 << 12;
v27 = v12;
}
if( !v8 )
break;
v9 = v26;
v7 = v28;
}
v4 = v20;
}
if( v6 )
{
_m_prefetchw(v6);
if( (_InterlockedOr((volatile signed __int32 *)v6, 1u) & 2) != 0 )
v2 = -1073741536;
}
v12 = 0i64;
if( v4 )
v4(*(_QWORD *)(a1 + 32), *(_QWORD *)(a1 + 40), v10, *(_QWORD *)(a1 + 72));
if( v2 < 0 )
{
LABEL_24:
if( *(_DWORD *)v10 )
HalpPutScatterGatherListThin(*(_QWORD *)(a1 + 24), (_DWORD *)v10);
if( !*(_BYTE *)(a1 + 98) )
{
if( v12 )
HalpDomainLaDelete(v28, v12);
*(_BYTE *)(a1 + 98) = 1;
if( HalpDmaUseEmergencyLogicalAddressResources(v24, (_QWORD *)a1, v11 == 0) )
return HalpConstructScatterGatherListThin(a1);
else
return v11 != 0 ? v2 : 0;
}
}
return v2;
}Referenced by:
HalpBuildScatterGatherListThin
HalpConstructScatterGatherListThin
HalpDmaReturnEmergencyLogicalAddressResources