mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-27 09:12:46 +01:00
hle_ipc: Add GetReadBufferSize and check write buffer size.
This commit is contained in:
parent
516a95721c
commit
6fd19f05f1
2 changed files with 10 additions and 0 deletions
|
@ -229,6 +229,8 @@ std::vector<u8> HLERequestContext::ReadBuffer() const {
|
||||||
size_t HLERequestContext::WriteBuffer(const void* buffer, const size_t size) const {
|
size_t HLERequestContext::WriteBuffer(const void* buffer, const size_t size) const {
|
||||||
const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()};
|
const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()};
|
||||||
|
|
||||||
|
ASSERT_MSG(size <= GetWriteBufferSize(), "Size %d is too big", size);
|
||||||
|
|
||||||
if (is_buffer_b) {
|
if (is_buffer_b) {
|
||||||
Memory::WriteBlock(BufferDescriptorB()[0].Address(), buffer, size);
|
Memory::WriteBlock(BufferDescriptorB()[0].Address(), buffer, size);
|
||||||
} else {
|
} else {
|
||||||
|
@ -242,6 +244,11 @@ size_t HLERequestContext::WriteBuffer(const std::vector<u8>& buffer) const {
|
||||||
return WriteBuffer(buffer.data(), buffer.size());
|
return WriteBuffer(buffer.data(), buffer.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t HLERequestContext::GetReadBufferSize() const {
|
||||||
|
const bool is_buffer_a{BufferDescriptorA().size() && BufferDescriptorA()[0].Size()};
|
||||||
|
return is_buffer_a ? BufferDescriptorA()[0].Size() : BufferDescriptorX()[0].Size();
|
||||||
|
}
|
||||||
|
|
||||||
size_t HLERequestContext::GetWriteBufferSize() const {
|
size_t HLERequestContext::GetWriteBufferSize() const {
|
||||||
const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()};
|
const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()};
|
||||||
return is_buffer_b ? BufferDescriptorB()[0].Size() : BufferDescriptorC()[0].Size();
|
return is_buffer_b ? BufferDescriptorB()[0].Size() : BufferDescriptorC()[0].Size();
|
||||||
|
|
|
@ -152,6 +152,9 @@ public:
|
||||||
/// Helper function to write a buffer using the appropriate buffer descriptor
|
/// Helper function to write a buffer using the appropriate buffer descriptor
|
||||||
size_t WriteBuffer(const std::vector<u8>& buffer) const;
|
size_t WriteBuffer(const std::vector<u8>& buffer) const;
|
||||||
|
|
||||||
|
/// Helper function to get the size of the input buffer
|
||||||
|
size_t GetReadBufferSize() const;
|
||||||
|
|
||||||
/// Helper function to get the size of the output buffer
|
/// Helper function to get the size of the output buffer
|
||||||
size_t GetWriteBufferSize() const;
|
size_t GetWriteBufferSize() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue