Exemplo n.º 1
0
        // nn::friends::GetPlayHistoryRegistrationKey(b8 unknown, nn::account::Uid) -> buffer<nn::friends::PlayHistoryRegistrationKey, 0x1a>
        public ResultCode GetPlayHistoryRegistrationKey(ServiceCtx context)
        {
            bool   unknownBool = context.RequestData.ReadBoolean();
            UserId userId      = context.RequestData.ReadStruct <UserId>();

            context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(0x40UL);

            ulong bufferPosition = context.Request.RecvListBuff[0].Position;

            if (userId.IsNull)
            {
                return(ResultCode.InvalidArgument);
            }

            // NOTE: Calls nn::friends::detail::service::core::PlayHistoryManager::GetInstance and stores the instance.

            byte[] randomBytes = new byte[8];
            Random random      = new Random();

            random.NextBytes(randomBytes);

            // NOTE: Calls nn::friends::detail::service::core::UuidManager::GetInstance and stores the instance.
            //       Then call nn::friends::detail::service::core::AccountStorageManager::GetInstance and store the instance.
            //       Then it checks if an Uuid is already stored for the UserId, if not it generates a random Uuid.
            //       And store it in the savedata 8000000000000080 in the friends:/uid.bin file.

            Array16 <byte> randomGuid = new Array16 <byte>();

            Guid.NewGuid().ToByteArray().AsSpan().CopyTo(randomGuid.ToSpan());

            PlayHistoryRegistrationKey playHistoryRegistrationKey = new PlayHistoryRegistrationKey
            {
                Type        = 0x101,
                KeyIndex    = (byte)(randomBytes[0] & 7),
                UserIdBool  = 0,                           // TODO: Find it.
                UnknownBool = (byte)(unknownBool ? 1 : 0), // TODO: Find it.
                Reserved    = new Array11 <byte>(),
                Uuid        = randomGuid
            };

            ReadOnlySpan <byte> playHistoryRegistrationKeyBuffer = SpanHelpers.AsByteSpan(ref playHistoryRegistrationKey);

            /*
             *
             * NOTE: The service uses the KeyIndex to get a random key from a keys buffer (since the key index is stored in the returned buffer).
             *    We currently don't support play history and online services so we can use a blank key for now.
             *    Code for reference:
             *
             * byte[] hmacKey = new byte[0x20];
             *
             * HMACSHA256 hmacSha256 = new HMACSHA256(hmacKey);
             * byte[]     hmacHash   = hmacSha256.ComputeHash(playHistoryRegistrationKeyBuffer);
             *
             */

            context.Memory.Write(bufferPosition, playHistoryRegistrationKeyBuffer);
            context.Memory.Write(bufferPosition + 0x20, new byte[0x20]); // HmacHash

            return(ResultCode.Success);
        }
Exemplo n.º 2
0
        public bool Equals(ref PipelineUid other)
        {
            if (!Unsafe.As <ulong, Vector256 <byte> >(ref Id0).Equals(Unsafe.As <ulong, Vector256 <byte> >(ref other.Id0)) ||
                !Unsafe.As <ulong, Vector256 <byte> >(ref Id4).Equals(Unsafe.As <ulong, Vector256 <byte> >(ref other.Id4)) ||
                !Unsafe.As <ulong, Vector256 <byte> >(ref Id8).Equals(Unsafe.As <ulong, Vector256 <byte> >(ref other.Id8)))
            {
                return(false);
            }

            if (!SequenceEqual <VertexInputAttributeDescription>(VertexAttributeDescriptions.ToSpan(), other.VertexAttributeDescriptions.ToSpan(), VertexAttributeDescriptionsCount))
            {
                return(false);
            }

            if (!SequenceEqual <VertexInputBindingDescription>(VertexBindingDescriptions.ToSpan(), other.VertexBindingDescriptions.ToSpan(), VertexBindingDescriptionsCount))
            {
                return(false);
            }

            if (!VulkanConfiguration.UseDynamicState)
            {
                if (!SequenceEqual <Viewport>(Viewports.ToSpan(), other.Viewports.ToSpan(), ViewportsCount))
                {
                    return(false);
                }

                if (!SequenceEqual <Rect2D>(Scissors.ToSpan(), other.Scissors.ToSpan(), ScissorsCount))
                {
                    return(false);
                }
            }

            if (!SequenceEqual <PipelineColorBlendAttachmentState>(ColorBlendAttachmentState.ToSpan(), other.ColorBlendAttachmentState.ToSpan(), ColorBlendAttachmentStateCount))
            {
                return(false);
            }

            if (!SequenceEqual <Format>(AttachmentFormats.ToSpan(), other.AttachmentFormats.ToSpan(), ColorBlendAttachmentStateCount + (HasDepthStencil ? 1u : 0u)))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
 private void RecordViewport(Vk api, CommandBuffer commandBuffer)
 {
     api.CmdSetViewport(commandBuffer, 0, (uint)ViewportsCount, _viewports.ToSpan());
 }
Exemplo n.º 4
0
 private void RecordScissor(Vk api, CommandBuffer commandBuffer)
 {
     api.CmdSetScissor(commandBuffer, 0, (uint)ScissorsCount, _scissors.ToSpan());
 }