diff options
author | Ac_K <Acoustik666@gmail.com> | 2023-01-08 13:13:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-08 12:13:39 +0000 |
commit | 550747eac6c0f6da14070c8b6d208bde6f1d1eb9 (patch) | |
tree | 1be203777156dae17a4221589c852c638b273d94 /Ryujinx.Horizon/Sdk/Sf/HipcCommandProcessor.cs | |
parent | 3ffceab1fb220c13f5982de599d788f2e3e7cc47 (diff) |
Horizon: Impl Prepo, Fixes bugs, Clean things (#4220)1.1.519
* Horizon: Impl Prepo, Fixes bugs, Clean things
* remove ToArray()
* resultCode > status
* Remove old services
* Addresses gdkchan's comments and more cleanup
* Addresses Gdkchan's feedback 2
* Reorganize services, make sure service are loaded before guest
Co-Authored-By: gdkchan <5624669+gdkchan@users.noreply.github.com>
* Create interfaces for lm and sm
Co-authored-by: gdkchan <5624669+gdkchan@users.noreply.github.com>
Diffstat (limited to 'Ryujinx.Horizon/Sdk/Sf/HipcCommandProcessor.cs')
-rw-r--r-- | Ryujinx.Horizon/Sdk/Sf/HipcCommandProcessor.cs | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/Ryujinx.Horizon/Sdk/Sf/HipcCommandProcessor.cs b/Ryujinx.Horizon/Sdk/Sf/HipcCommandProcessor.cs index 53202ede..6bba49ae 100644 --- a/Ryujinx.Horizon/Sdk/Sf/HipcCommandProcessor.cs +++ b/Ryujinx.Horizon/Sdk/Sf/HipcCommandProcessor.cs @@ -136,9 +136,9 @@ namespace Ryujinx.Horizon.Sdk.Sf ulong pointerBufferTail = context.PointerBuffer.Address; ulong pointerBufferHead = pointerBufferTail + context.PointerBuffer.Size; - int sendMapAliasIndex = 0; - int recvMapAliasIndex = 0; - int sendPointerIndex = 0; + int sendMapAliasIndex = 0; + int recvMapAliasIndex = 0; + int sendPointerIndex = 0; int unfixedRecvPointerIndex = 0; for (int i = 0; i < _args.Length; i++) @@ -188,8 +188,9 @@ namespace Ryujinx.Horizon.Sdk.Sf if (flags.HasFlag(HipcBufferFlags.In)) { var descriptor = context.Request.Data.SendStatics[sendPointerIndex++]; - ulong address = descriptor.Address; - ulong size = descriptor.Size; + ulong address = descriptor.Address; + ulong size = descriptor.Size; + _bufferRanges[i] = new PointerAndSize(address, size); if (size != 0) @@ -207,13 +208,14 @@ namespace Ryujinx.Horizon.Sdk.Sf } else { - var data = MemoryMarshal.Cast<uint, byte>(context.Request.Data.DataWords); - var recvPointerSizes = MemoryMarshal.Cast<byte, ushort>(data.Slice(runtimeMetadata.UnfixedOutPointerSizeOffset)); + var data = MemoryMarshal.Cast<uint, byte>(context.Request.Data.DataWords); + var recvPointerSizes = MemoryMarshal.Cast<byte, ushort>(data[runtimeMetadata.UnfixedOutPointerSizeOffset..]); + size = recvPointerSizes[unfixedRecvPointerIndex++]; } pointerBufferHead = BitUtils.AlignDown(pointerBufferHead - size, 0x10UL); - _bufferRanges[i] = new PointerAndSize(pointerBufferHead, size); + _bufferRanges[i] = new PointerAndSize(pointerBufferHead, size); } } } @@ -304,16 +306,17 @@ namespace Ryujinx.Horizon.Sdk.Sf { ref var meta = ref context.Request.Meta; bool requestValid = true; - requestValid &= meta.SendPid == _hasInProcessIdHolder; - requestValid &= meta.SendStaticsCount == _inPointerBuffersCount; - requestValid &= meta.SendBuffersCount == _inMapAliasBuffersCount; - requestValid &= meta.ReceiveBuffersCount == _outMapAliasBuffersCount; + requestValid &= meta.SendPid == _hasInProcessIdHolder; + requestValid &= meta.SendStaticsCount == _inPointerBuffersCount; + requestValid &= meta.SendBuffersCount == _inMapAliasBuffersCount; + requestValid &= meta.ReceiveBuffersCount == _outMapAliasBuffersCount; requestValid &= meta.ExchangeBuffersCount == 0; - requestValid &= meta.CopyHandlesCount == _inCopyHandlesCount; - requestValid &= meta.MoveHandlesCount == _inMoveHandlesCount; + requestValid &= meta.CopyHandlesCount == _inCopyHandlesCount; + requestValid &= meta.MoveHandlesCount == _inMoveHandlesCount; int rawSizeInBytes = meta.DataWordsCount * sizeof(uint); int commandRawSize = BitUtils.AlignUp(runtimeMetadata.UnfixedOutPointerSizeOffset + (OutUnfixedSizePointerBuffersCount * sizeof(ushort)), sizeof(uint)); + requestValid &= rawSizeInBytes >= commandRawSize; return requestValid ? Result.Success : HipcResult.InvalidCmifRequest; @@ -340,7 +343,7 @@ namespace Ryujinx.Horizon.Sdk.Sf { if (_args[i].Type == CommandArgType.InObject) { - int index = inObjectIndex++; + int index = inObjectIndex++; var inObject = inObjects[index]; objects[index] = inObject?.ServiceObject; @@ -365,6 +368,7 @@ namespace Ryujinx.Horizon.Sdk.Sf _outCopyHandlesCount, _outMoveHandlesCount + runtimeMetadata.OutObjectsCount); outRawData = MemoryMarshal.Cast<uint, byte>(response.DataWords); + return response; } @@ -377,6 +381,7 @@ namespace Ryujinx.Horizon.Sdk.Sf (BitUtils.AlignUp(rawDataSize, 4) + 0x10) / sizeof(uint), 0, 0); + outRawData = MemoryMarshal.Cast<uint, byte>(response.DataWords); } @@ -410,6 +415,7 @@ namespace Ryujinx.Horizon.Sdk.Sf if (obj == null) { response.MoveHandles[index] = 0; + return; } @@ -418,4 +424,4 @@ namespace Ryujinx.Horizon.Sdk.Sf response.MoveHandles[index] = clientHandle; } } -} +}
\ No newline at end of file |