Only use this + 4 slot if there is no slot 4

This commit is contained in:
Charlie Birks
2019-10-09 17:47:33 +01:00
committed by Baldur Karlsson
parent 3fc89b3717
commit e303b8372e
+12 -13
View File
@@ -215,7 +215,8 @@ bool InjectLibraries(const std::string &deviceID, Network::Socket *sock)
{
std::vector<VariableSlot> slots = conn.GetLocalVariables(vulkanLoaderClass, vulkanLoaderMethod);
int32_t slotIdx = -1;
int32_t slotIdx = -1, thisSlotIdx = -1;
bool slot4Exists = false;
for(const VariableSlot &s : slots)
{
@@ -224,20 +225,18 @@ bool InjectLibraries(const std::string &deviceID, Network::Socket *sock)
slotIdx = s.slot;
break;
}
else if(s.name == "this")
{
thisSlotIdx = s.slot;
}
if(s.slot == 4)
slot4Exists = true;
}
// Android 9 doesn't return names and changed how slots are indexed, try an offset from this
if(slotIdx == -1)
{
for(const VariableSlot &s : slots)
{
if(s.name == "this")
{
slotIdx = s.slot + 4;
break;
}
}
}
// on some newer devices slots are not 0-based, try an offset from this if there is no slot 4
if(slotIdx == -1 && thisSlotIdx != -1 && !slot4Exists)
slotIdx = thisSlotIdx + 4;
// as a default, use the 4th slot as it's the 4th argument argument (0 is this), if symbols
// weren't available we can't identify the variable by name