예제 #1
0
        // LoadTimeZoneRule(nn::time::LocationName locationName) -> buffer<nn::time::TimeZoneRule, 0x16>
        public ResultCode LoadTimeZoneRule(ServiceCtx context)
        {
            ulong bufferPosition = context.Request.ReceiveBuff[0].Position;
            ulong bufferSize     = context.Request.ReceiveBuff[0].Size;

            if (bufferSize != 0x4000)
            {
                // TODO: find error code here
                Logger.Error?.Print(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{bufferSize:x} (expected 0x4000)");

                throw new InvalidOperationException();
            }

            string locationName = StringUtils.ReadInlinedAsciiString(context.RequestData, 0x24);

            using (WritableRegion region = context.Memory.GetWritableRegion(bufferPosition, Unsafe.SizeOf <TimeZoneRule>()))
            {
                ref TimeZoneRule rules = ref MemoryMarshal.Cast <byte, TimeZoneRule>(region.Memory.Span)[0];

                return(_timeZoneContentManager.LoadTimeZoneRule(ref rules, locationName));
            }