Fixup CancelBuffer fence handling

This commit is contained in:
Billy Laws 2022-10-30 16:28:52 +00:00
parent 7f24c7b857
commit ec139b3027
2 changed files with 15 additions and 8 deletions

View File

@ -660,7 +660,7 @@ namespace skyline::service::hosbinder {
} }
case TransactionCode::CancelBuffer: { case TransactionCode::CancelBuffer: {
CancelBuffer(in.Pop<i32>(), in.Pop<AndroidFence>()); CancelBuffer(in.Pop<i32>(), in.PopFlattenable<AndroidFence>());
break; break;
} }

View File

@ -49,20 +49,27 @@ namespace skyline::service::hosbinder {
return value; return value;
} }
/**
* @return A reference to an item from the top of data
*/
template<typename ValueType>
ValueType &PopFlattenable() {
auto size{Pop<u64>()};
if (size != sizeof(ValueType))
throw exception("Popping flattenable of size 0x{:X} with type size 0x{:X}", size, sizeof(ValueType));
return Pop<ValueType>();
}
/** /**
* @return A pointer to an optional flattenable from the top of data, nullptr will be returned if the object doesn't exist * @return A pointer to an optional flattenable from the top of data, nullptr will be returned if the object doesn't exist
*/ */
template<typename ValueType> template<typename ValueType>
ValueType *PopOptionalFlattenable() { ValueType *PopOptionalFlattenable() {
bool hasObject{Pop<u32>() != 0}; bool hasObject{Pop<u32>() != 0};
if (hasObject) { if (hasObject)
auto size{Pop<u64>()}; return &PopFlattenable<ValueType>();
if (size != sizeof(ValueType)) else
throw exception("Popping flattenable of size 0x{:X} with type size 0x{:X}", size, sizeof(ValueType));
return &Pop<ValueType>();
} else {
return nullptr; return nullptr;
}
} }
template<typename ValueType> template<typename ValueType>