HalpInterruptRegisterLine
NTSTATUS __stdcall HalpInterruptRegisterLine(_INTERRUPT_LINE_DESCRIPTION *Lines){
NTSTATUS v1;
int MinLine;
int MaxLine;
_INTERRUPT_LINE_TYPE Type;
unsigned int ControllerIdentifier;
_REGISTERED_INTERRUPT_CONTROLLER *v7;
_REGISTERED_INTERRUPT_CONTROLLER *v8;
int v9;
int v10;
unsigned int MsiAddress;
unsigned int v12;
unsigned int v13;
PSTR MemoryInternal;
PSTR v15;
int v16;
_INTERRUPT_LINE_TYPE v17;
int v18;
int v19;
char *v20;
int v21;
int v22;
_LIST_ENTRY *p_OutputLinesHead;
PSTR *Blink;
unsigned int v26;
_LIST_ENTRY *Flink;
_LIST_ENTRY *v28;
v1 = 0;
if( !HalpInterruptRegistrationAllowed || KeGetPcr()->Prcb.Number )
return -1073741431;
MinLine = Lines->MinLine;
MaxLine = Lines->MaxLine;
if( MinLine >= MaxLine )
return -1073741811;
Type = Lines->Type;
if( Type == InterruptLineInvalidType )
return -1073741811;
ControllerIdentifier = Lines->ControllerIdentifier;
v7 = HalpInterruptLookupController(Lines->ControllerIdentifier);
v8 = v7;
if( !v7 )
return -1073741275;
if( Type != InterruptLineOutputPin )
{
v9 = v7->MinLine;
v10 = v7->MaxLine;
if( v9 != v10 && MaxLine > v9 && MinLine < v10 )
{
Flink = v8->LinesHead.Flink;
while( Flink != &v8->LinesHead )
{
v28 = Flink;
Flink = Flink->Flink;
if( MinLine < SLODWORD(v28[1].Blink) && MaxLine > SHIDWORD(v28[1].Flink) )
return -1073741182;
}
}
}
MsiAddress = Lines->MsiAddress;
if( MsiAddress != -1 && HalpInterruptFindLinesForGsiRange(MsiAddress, MaxLine + MsiAddress - MinLine) )
return -1073741182;
v12 = MaxLine - MinLine;
if( v8->KnownType == InterruptControllerApic && MsiAddress != -1 )
{
v26 = 0;
if( *(&CmpDummyThreadEvent + 1771) )
{
while( *(_DWORD *)(*(&CmpDummyThreadEvent + 884) + 16i64 * v26) != ControllerIdentifier
|| v12 <= *(_DWORD *)(*(&CmpDummyThreadEvent + 884) + 16i64 * v26 + 12) )
{
if( ++v26 >= *(&CmpDummyThreadEvent + 1771) )
goto LABEL_12;
}
v12 = *(_DWORD *)(*(&CmpDummyThreadEvent + 884) + 16i64 * v26 + 12);
}
}
LABEL_12:
if( Type == InterruptLineMsi )
v13 = (((v12 + 31) >> 3) + 7) & 0xFFFFFFF8;
else
v13 = 0;
MemoryInternal = HalpMmAllocateMemoryInternal(v13 + 8 * (v12 + 8 * v12 + 11), MmCached);
v15 = MemoryInternal;
if( !MemoryInternal )
return -1073741670;
memset(MemoryInternal, 0i64, v13 + 8 * (v12 + 8 * v12 + 11));
if( v13 )
{
*((_DWORD *)v15 + 18) = v12;
*((_QWORD *)v15 + 10) = v15 + 88;
}
v16 = Lines->MinLine;
v17 = Lines->Type;
v18 = Lines->MsiAddress;
*((_DWORD *)v15 + 5) = v16;
*((_DWORD *)v15 + 7) = v18;
v19 = v16 + v12;
*((_DWORD *)v15 + 6) = v16 + v12;
*((_DWORD *)v15 + 8) = v17;
if( v17 == InterruptLineMsi )
{
*((_QWORD *)v15 + 7) = *(_QWORD *)&Lines->MsiData;
*((_DWORD *)v15 + 16) = Lines[1].ControllerIdentifier;
*((_DWORD *)v15 + 9) = Lines->OutputUnitId;
}
v20 = &v15[v13 + 88];
*((_QWORD *)v15 + 5) = v20;
*((_QWORD *)v15 + 6) = &v20[56 * v12];
if( v17 == InterruptLineOutputPin )
{
p_OutputLinesHead = &v8->OutputLinesHead;
*((_DWORD *)v15 + 4) = Lines->GsiBase;
}
else
{
*((_DWORD *)v15 + 4) = v8->UnitId;
v21 = v8->MinLine;
v22 = v8->MaxLine;
if( v21 == v22 )
{
v8->MinLine = v16;
v8->MaxLine = *((_DWORD *)v15 + 6);
}
else if( v16 >= v21 )
{
if( v19 > v22 )
v8->MaxLine = v19;
}
else
{
v8->MinLine = v16;
}
p_OutputLinesHead = &v8->LinesHead;
}
Blink = (PSTR *)p_OutputLinesHead->Blink;
if( *Blink != (PSTR)p_OutputLinesHead )
__fastfail(3u);
*(_QWORD *)v15 = p_OutputLinesHead;
*((_QWORD *)v15 + 1) = Blink;
*Blink = v15;
p_OutputLinesHead->Blink = (_LIST_ENTRY *)v15;
return v1;
}Referenced by:
HalpApicDescribeLines
HalpApicDescribeLocalLines
HalpPicDiscover