IopSetupArbiterAndTranslators
NTSTATUS __stdcall IopSetupArbiterAndTranslators(_REQ_DESC *ReqDesc){
INT64 v2;
char v3;
char v4;
__int64 v5;
__int64 v6;
UINT8 v7;
_REQ_DESC v8;
char v9;
_DEVICE_NODE *LegacyBusDeviceNode;
_DEVICE_OBJECT *PhysicalDeviceObject;
UINT8 v12;
__int64 v13;
UINT8 v14;
INT64 v15;
_PI_RESOURCE_TRANSLATOR_ENTRY *v16;
_DEVICE_NODE *v17;
NTSTATUS result;
__int16 v19;
int v20;
__int16 v21;
int v22;
VOID **v23;
VOID **v24;
_QWORD *v25;
_QWORD *v26;
_LIST_ENTRY *v27;
_REQ_DESC *v28;
UINT8 v29;
char v30;
VOID *v31;
unsigned __int64 PoolWithTag;
_LIST_ENTRY *Blink;
VOID *v34;
INT64 v35;
INT64 v36;
VOID *v37;
_REQ_DESC *TranslatedReqDesc;
INT64 v39;
INT64 v40;
INT64 v41;
_BYTE savedregs[64];
char v43;
char v44;
VOID *Interface;
VOID *HandlerEntry;
v2 = *((_QWORD *)ReqDesc + 9);
v3 = 0;
HandlerEntry = 0i64;
v4 = 0;
v39 = v2;
v5 = *((_QWORD *)ReqDesc + 4);
TranslatedReqDesc = 0i64;
v44 = 1;
v37 = 0i64;
v6 = *(_QWORD *)(v5 + 64);
Interface = 0i64;
v7 = *(_BYTE *)(v6 + 1);
v8 = ReqDesc[20];
if( v7 == 7 )
v7 = 3;
if( v8 != 1 || (v9 = 1, *ReqDesc) )
v9 = 0;
v43 = v9;
if( !v2 || v8 == 1 )
LegacyBusDeviceNode = (_DEVICE_NODE *)*(&PnpReplaceEvent + 831);
else
LegacyBusDeviceNode = *(_DEVICE_NODE **)(*(_QWORD *)(v2 + 312) + 40i64);
if( !LegacyBusDeviceNode )
return -1073741686;
while( 1 )
{
if( LegacyBusDeviceNode != (_DEVICE_NODE *)*(&PnpReplaceEvent + 831) || v4 || v9 )
{
if( v3 )
goto LABEL_17;
PhysicalDeviceObject = LegacyBusDeviceNode->PhysicalDeviceObject;
if( PhysicalDeviceObject == (_DEVICE_OBJECT *)v2 )
goto LABEL_17;
if( IopFindResourceHandlerInfo(ResourceArbiter, LegacyBusDeviceNode, v7, &HandlerEntry) )
goto LABEL_13;
if( v7 > 0xFu )
v21 = 0;
else
v21 = 1 << v7;
IopQueryResourceHandlerInterface(ResourceArbiter, PhysicalDeviceObject, v12, &Interface);
LegacyBusDeviceNode->QueryArbiterMask |= v21;
if( v22 >= 0 )
{
v34 = Interface;
}
else
{
LegacyBusDeviceNode->NoArbiterMask |= v21;
if( v7 <= 0xFu )
{
LABEL_13:
v13 = (__int64)HandlerEntry;
LABEL_14:
if( v13 )
{
v3 = 1;
if( (*(_DWORD *)(*(_QWORD *)(v13 + 24) + 40i64) & 1) != 0
&& IopCallArbiter((_PI_RESOURCE_ARBITER_ENTRY *)v13, ArbiterActionQueryArbitrate, *((VOID **)ReqDesc + 4)) < 0 )
{
v3 = 0;
}
else
{
*((_QWORD *)ReqDesc + 36) = v13;
*(_WORD *)(v13 + 104) = 0;
}
}
LABEL_17:
if( !v44 )
{
LABEL_24:
LegacyBusDeviceNode = LegacyBusDeviceNode->Parent;
v9 = v43;
goto LABEL_25;
}
if( IopFindResourceHandlerInfo(ResourceTranslator, LegacyBusDeviceNode, v7, &v37) )
goto LABEL_19;
if( v7 > 0xFu )
v19 = 0;
else
v19 = 1 << v7;
IopQueryResourceHandlerInterface(
ResourceTranslator,
LegacyBusDeviceNode->PhysicalDeviceObject,
v14,
&Interface);
LegacyBusDeviceNode->QueryTranslatorMask |= v19;
if( v20 >= 0 )
{
v31 = Interface;
}
else
{
LegacyBusDeviceNode->NoTranslatorMask |= v19;
if( v7 <= 0xFu )
{
LABEL_19:
v16 = (_PI_RESOURCE_TRANSLATOR_ENTRY *)v37;
LABEL_20:
if( v16 )
v4 = 1;
if( !v3 && v16 )
{
IopTranslateAndAdjustReqDesc(
*((_REQ_DESC **)ReqDesc + 4),
v16,
&TranslatedReqDesc,
v15,
v35,
v36,
(INT64)v37,
(INT64)TranslatedReqDesc,
v39,
v40,
v41,
*(INT64 *)savedregs,
*(INT64 *)&savedregs[8],
*(UINT64 *)&savedregs[16]);
if( result < 0 )
return result;
v28 = TranslatedReqDesc;
v29 = *(_BYTE *)(*((_QWORD *)TranslatedReqDesc + 8) + 1i64);
*((_QWORD *)TranslatedReqDesc + 4) = *((_QWORD *)ReqDesc + 4);
v7 = v29;
if( v29 == 7 )
v7 = 3;
v30 = v44;
*((_QWORD *)ReqDesc + 4) = v28;
if( result == 288 )
v30 = 0;
v44 = v30;
}
goto LABEL_24;
}
v31 = 0i64;
Interface = 0i64;
}
PoolWithTag = (unsigned __int64)ExAllocatePoolWithTag(1ui64, 0x28ui64, 538996816i64);
if( !PoolWithTag )
return -1073741670;
*(_BYTE *)(PoolWithTag + 16) = v7;
*(_QWORD *)(PoolWithTag + 8) = PoolWithTag;
*(_QWORD *)PoolWithTag = PoolWithTag;
*(_QWORD *)(PoolWithTag + 24) = v31;
*(_QWORD *)(PoolWithTag + 32) = LegacyBusDeviceNode;
Blink = LegacyBusDeviceNode->DeviceTranslatorList.Blink;
if( Blink->Flink != &LegacyBusDeviceNode->DeviceTranslatorList )
goto LABEL_68;
*(_QWORD *)(PoolWithTag + 8) = Blink;
*(_QWORD *)PoolWithTag = &LegacyBusDeviceNode->DeviceTranslatorList;
Blink->Flink = (_LIST_ENTRY *)PoolWithTag;
v16 = (_PI_RESOURCE_TRANSLATOR_ENTRY *)(PoolWithTag & -(__int64)(v31 != 0i64));
LegacyBusDeviceNode->DeviceTranslatorList.Blink = (_LIST_ENTRY *)PoolWithTag;
v37 = v16;
goto LABEL_20;
}
v34 = 0i64;
Interface = 0i64;
}
v23 = ExAllocatePoolWithTag(1ui64, 0x70ui64, 538996816i64);
v24 = v23;
if( !v23 )
return -1073741670;
*((_WORD *)v23 + 52) = 0;
v23[12] = v23 + 11;
v23[11] = v23 + 11;
v23[10] = v23 + 9;
v23[9] = v23 + 9;
v25 = v23 + 5;
v23[6] = v23 + 5;
v26 = v23 + 7;
*v25 = v25;
v26[1] = v26;
*v26 = v26;
v24[1] = v24;
*v24 = v24;
*((_BYTE *)v24 + 16) = v7;
v24[4] = LegacyBusDeviceNode;
v27 = LegacyBusDeviceNode->DeviceArbiterList.Blink;
if( v27->Flink != &LegacyBusDeviceNode->DeviceArbiterList )
LABEL_68:
__fastfail(3u);
*v24 = &LegacyBusDeviceNode->DeviceArbiterList;
v24[1] = v27;
v27->Flink = (_LIST_ENTRY *)v24;
LegacyBusDeviceNode->DeviceArbiterList.Blink = (_LIST_ENTRY *)v24;
v24[3] = v34;
v13 = (unsigned __int64)v24 & -(__int64)(v34 != 0i64);
HandlerEntry = (VOID *)v13;
goto LABEL_14;
}
v43 = 1;
LegacyBusDeviceNode = IopFindLegacyBusDeviceNode((_INTERFACE_TYPE)*ReqDesc, (unsigned int)ReqDesc[1]);
if( LegacyBusDeviceNode == v17 && !**(_DWORD **)(*((_QWORD *)ReqDesc + 2) + 8i64) )
LegacyBusDeviceNode = IopFindLegacyBusDeviceNode(Isa, 0i64);
LABEL_25:
if( !LegacyBusDeviceNode )
break;
v2 = v39;
}
if( !v3 )
return -1073741686;
return 0;
}Referenced by:
IopResourceRequirementsListToReqList