diff options
| author | TSR Berry <20988865+TSRBerry@users.noreply.github.com> | 2023-04-08 01:22:00 +0200 |
|---|---|---|
| committer | Mary <thog@protonmail.com> | 2023-04-27 23:51:14 +0200 |
| commit | cee712105850ac3385cd0091a923438167433f9f (patch) | |
| tree | 4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /Ryujinx.HLE/HOS/Services/Nifm/StaticService | |
| parent | cd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff) | |
Move solution and projects to src
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Nifm/StaticService')
14 files changed, 0 insertions, 566 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/GeneralServiceManager.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/GeneralServiceManager.cs deleted file mode 100644 index bbb218bb..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/GeneralServiceManager.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.GeneralService -{ - static class GeneralServiceManager - { - private static List<GeneralServiceDetail> _generalServices = new List<GeneralServiceDetail>(); - - public static int Count - { - get => _generalServices.Count; - } - - public static void Add(GeneralServiceDetail generalServiceDetail) - { - _generalServices.Add(generalServiceDetail); - } - - public static void Remove(int index) - { - _generalServices.RemoveAt(index); - } - - public static GeneralServiceDetail Get(int clientId) - { - return _generalServices.First(item => item.ClientId == clientId); - } - } -}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/Types/GeneralServiceDetail.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/Types/GeneralServiceDetail.cs deleted file mode 100644 index 3cf55345..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/GeneralService/Types/GeneralServiceDetail.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.GeneralService -{ - class GeneralServiceDetail - { - public int ClientId; - public bool IsAnyInternetRequestAccepted; - } -}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs deleted file mode 100644 index e9712e92..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs +++ /dev/null @@ -1,203 +0,0 @@ -using Ryujinx.Common; -using Ryujinx.Common.Logging; -using Ryujinx.Common.Utilities; -using Ryujinx.HLE.HOS.Services.Nifm.StaticService.GeneralService; -using Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types; -using System; -using System.Net.NetworkInformation; -using System.Runtime.CompilerServices; - -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService -{ - class IGeneralService : DisposableIpcService - { - private GeneralServiceDetail _generalServiceDetail; - - private IPInterfaceProperties _targetPropertiesCache = null; - private UnicastIPAddressInformation _targetAddressInfoCache = null; - private string _cacheChosenInterface = null; - - public IGeneralService() - { - _generalServiceDetail = new GeneralServiceDetail - { - ClientId = GeneralServiceManager.Count, - IsAnyInternetRequestAccepted = true // NOTE: Why not accept any internet request? - }; - - NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(LocalInterfaceCacheHandler); - - GeneralServiceManager.Add(_generalServiceDetail); - } - - [CommandCmif(1)] - // GetClientId() -> buffer<nn::nifm::ClientId, 0x1a, 4> - public ResultCode GetClientId(ServiceCtx context) - { - ulong position = context.Request.RecvListBuff[0].Position; - - context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(sizeof(int)); - - context.Memory.Write(position, _generalServiceDetail.ClientId); - - return ResultCode.Success; - } - - [CommandCmif(4)] - // CreateRequest(u32 version) -> object<nn::nifm::detail::IRequest> - public ResultCode CreateRequest(ServiceCtx context) - { - uint version = context.RequestData.ReadUInt32(); - - MakeObject(context, new IRequest(context.Device.System, version)); - - // Doesn't occur in our case. - // return ResultCode.ObjectIsNull; - - Logger.Stub?.PrintStub(LogClass.ServiceNifm, new { version }); - - return ResultCode.Success; - } - - [CommandCmif(5)] - // GetCurrentNetworkProfile() -> buffer<nn::nifm::detail::sf::NetworkProfileData, 0x1a, 0x17c> - public ResultCode GetCurrentNetworkProfile(ServiceCtx context) - { - ulong networkProfileDataPosition = context.Request.RecvListBuff[0].Position; - - (IPInterfaceProperties interfaceProperties, UnicastIPAddressInformation unicastAddress) = GetLocalInterface(context); - - if (interfaceProperties == null || unicastAddress == null) - { - return ResultCode.NoInternetConnection; - } - - Logger.Info?.Print(LogClass.ServiceNifm, $"Console's local IP is \"{unicastAddress.Address}\"."); - - context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize((uint)Unsafe.SizeOf<NetworkProfileData>()); - - NetworkProfileData networkProfile = new NetworkProfileData - { - Uuid = UInt128Utils.CreateRandom() - }; - - networkProfile.IpSettingData.IpAddressSetting = new IpAddressSetting(interfaceProperties, unicastAddress); - networkProfile.IpSettingData.DnsSetting = new DnsSetting(interfaceProperties); - - "RyujinxNetwork"u8.CopyTo(networkProfile.Name.AsSpan()); - - context.Memory.Write(networkProfileDataPosition, networkProfile); - - return ResultCode.Success; - } - - [CommandCmif(12)] - // GetCurrentIpAddress() -> nn::nifm::IpV4Address - public ResultCode GetCurrentIpAddress(ServiceCtx context) - { - (_, UnicastIPAddressInformation unicastAddress) = GetLocalInterface(context); - - if (unicastAddress == null) - { - return ResultCode.NoInternetConnection; - } - - context.ResponseData.WriteStruct(new IpV4Address(unicastAddress.Address)); - - Logger.Info?.Print(LogClass.ServiceNifm, $"Console's local IP is \"{unicastAddress.Address}\"."); - - return ResultCode.Success; - } - - [CommandCmif(15)] - // GetCurrentIpConfigInfo() -> (nn::nifm::IpAddressSetting, nn::nifm::DnsSetting) - public ResultCode GetCurrentIpConfigInfo(ServiceCtx context) - { - (IPInterfaceProperties interfaceProperties, UnicastIPAddressInformation unicastAddress) = GetLocalInterface(context); - - if (interfaceProperties == null || unicastAddress == null) - { - return ResultCode.NoInternetConnection; - } - - Logger.Info?.Print(LogClass.ServiceNifm, $"Console's local IP is \"{unicastAddress.Address}\"."); - - context.ResponseData.WriteStruct(new IpAddressSetting(interfaceProperties, unicastAddress)); - context.ResponseData.WriteStruct(new DnsSetting(interfaceProperties)); - - return ResultCode.Success; - } - - [CommandCmif(18)] - // GetInternetConnectionStatus() -> nn::nifm::detail::sf::InternetConnectionStatus - public ResultCode GetInternetConnectionStatus(ServiceCtx context) - { - if (!NetworkInterface.GetIsNetworkAvailable()) - { - return ResultCode.NoInternetConnection; - } - - InternetConnectionStatus internetConnectionStatus = new InternetConnectionStatus - { - Type = InternetConnectionType.WiFi, - WifiStrength = 3, - State = InternetConnectionState.Connected, - }; - - context.ResponseData.WriteStruct(internetConnectionStatus); - - return ResultCode.Success; - } - - [CommandCmif(21)] - // IsAnyInternetRequestAccepted(buffer<nn::nifm::ClientId, 0x19, 4>) -> bool - public ResultCode IsAnyInternetRequestAccepted(ServiceCtx context) - { - ulong position = context.Request.PtrBuff[0].Position; - ulong size = context.Request.PtrBuff[0].Size; - - int clientId = context.Memory.Read<int>(position); - - context.ResponseData.Write(GeneralServiceManager.Get(clientId).IsAnyInternetRequestAccepted); - - return ResultCode.Success; - } - - private (IPInterfaceProperties, UnicastIPAddressInformation) GetLocalInterface(ServiceCtx context) - { - if (!NetworkInterface.GetIsNetworkAvailable()) - { - return (null, null); - } - - string chosenInterface = context.Device.Configuration.MultiplayerLanInterfaceId; - - if (_targetPropertiesCache == null || _targetAddressInfoCache == null || _cacheChosenInterface != chosenInterface) - { - _cacheChosenInterface = chosenInterface; - - (_targetPropertiesCache, _targetAddressInfoCache) = NetworkHelpers.GetLocalInterface(chosenInterface); - } - - return (_targetPropertiesCache, _targetAddressInfoCache); - } - - private void LocalInterfaceCacheHandler(object sender, EventArgs e) - { - Logger.Info?.Print(LogClass.ServiceNifm, $"NetworkAddress changed, invalidating cached data."); - - _targetPropertiesCache = null; - _targetAddressInfoCache = null; - } - - protected override void Dispose(bool isDisposing) - { - if (isDisposing) - { - NetworkChange.NetworkAddressChanged -= LocalInterfaceCacheHandler; - - GeneralServiceManager.Remove(_generalServiceDetail.ClientId); - } - } - } -}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IRequest.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IRequest.cs deleted file mode 100644 index 87aad30b..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IRequest.cs +++ /dev/null @@ -1,142 +0,0 @@ -using Ryujinx.Common.Logging; -using Ryujinx.HLE.HOS.Ipc; -using Ryujinx.HLE.HOS.Kernel.Threading; -using Ryujinx.Horizon.Common; -using System; - -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService -{ - class IRequest : IpcService - { - private enum RequestState - { - Error = 1, - OnHold = 2, - Available = 3 - } - - private KEvent _event0; - private KEvent _event1; - - private int _event0Handle; - private int _event1Handle; - - private uint _version; - - public IRequest(Horizon system, uint version) - { - _event0 = new KEvent(system.KernelContext); - _event1 = new KEvent(system.KernelContext); - - _version = version; - } - - [CommandCmif(0)] - // GetRequestState() -> u32 - public ResultCode GetRequestState(ServiceCtx context) - { - RequestState requestState = context.Device.Configuration.EnableInternetAccess - ? RequestState.Available - : RequestState.Error; - - context.ResponseData.Write((int)requestState); - - Logger.Stub?.PrintStub(LogClass.ServiceNifm); - - return ResultCode.Success; - } - - [CommandCmif(1)] - // GetResult() - public ResultCode GetResult(ServiceCtx context) - { - Logger.Stub?.PrintStub(LogClass.ServiceNifm); - - return GetResultImpl(); - } - - private ResultCode GetResultImpl() - { - return ResultCode.Success; - } - - [CommandCmif(2)] - // GetSystemEventReadableHandles() -> (handle<copy>, handle<copy>) - public ResultCode GetSystemEventReadableHandles(ServiceCtx context) - { - if (_event0Handle == 0) - { - if (context.Process.HandleTable.GenerateHandle(_event0.ReadableEvent, out _event0Handle) != Result.Success) - { - throw new InvalidOperationException("Out of handles!"); - } - } - - if (_event1Handle == 0) - { - if (context.Process.HandleTable.GenerateHandle(_event1.ReadableEvent, out _event1Handle) != Result.Success) - { - throw new InvalidOperationException("Out of handles!"); - } - } - - context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_event0Handle, _event1Handle); - - return ResultCode.Success; - } - - [CommandCmif(3)] - // Cancel() - public ResultCode Cancel(ServiceCtx context) - { - Logger.Stub?.PrintStub(LogClass.ServiceNifm); - - return ResultCode.Success; - } - - [CommandCmif(4)] - // Submit() - public ResultCode Submit(ServiceCtx context) - { - Logger.Stub?.PrintStub(LogClass.ServiceNifm); - - return ResultCode.Success; - } - - [CommandCmif(11)] - // SetConnectionConfirmationOption(i8) - public ResultCode SetConnectionConfirmationOption(ServiceCtx context) - { - Logger.Stub?.PrintStub(LogClass.ServiceNifm); - - return ResultCode.Success; - } - - [CommandCmif(21)] - // GetAppletInfo(u32) -> (u32, u32, u32, buffer<bytes, 6>) - public ResultCode GetAppletInfo(ServiceCtx context) - { - uint themeColor = context.RequestData.ReadUInt32(); - - Logger.Stub?.PrintStub(LogClass.ServiceNifm); - - ResultCode result = GetResultImpl(); - - if (result == ResultCode.Success || (ResultCode)((int)result & 0x3fffff) == ResultCode.Unknown112) - { - return ResultCode.Unknown180; - } - - // Returns appletId, libraryAppletMode, outSize and a buffer. - // Returned applet ids- (0x19, 0xf, 0xe) - // libraryAppletMode seems to be 0 for all applets supported. - - // TODO: check order - context.ResponseData.Write(0xe); // Use error applet as default for now - context.ResponseData.Write(0); // libraryAppletMode - context.ResponseData.Write(0); // outSize - - return ResultCode.Success; - } - } -}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/DnsSetting.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/DnsSetting.cs deleted file mode 100644 index 374558ea..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/DnsSetting.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Net.NetworkInformation; -using System.Runtime.InteropServices; - -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types -{ - [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 9)] - struct DnsSetting - { - [MarshalAs(UnmanagedType.U1)] - public bool IsDynamicDnsEnabled; - public IpV4Address PrimaryDns; - public IpV4Address SecondaryDns; - - public DnsSetting(IPInterfaceProperties interfaceProperties) - { - IsDynamicDnsEnabled = OperatingSystem.IsWindows() && interfaceProperties.IsDynamicDnsEnabled; - - if (interfaceProperties.DnsAddresses.Count == 0) - { - PrimaryDns = new IpV4Address(); - SecondaryDns = new IpV4Address(); - } - else - { - PrimaryDns = new IpV4Address(interfaceProperties.DnsAddresses[0]); - SecondaryDns = new IpV4Address(interfaceProperties.DnsAddresses[interfaceProperties.DnsAddresses.Count > 1 ? 1 : 0]); - } - } - } -}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionState.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionState.cs deleted file mode 100644 index dfb8f76c..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionState.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types -{ - enum InternetConnectionState : byte - { - ConnectingType0 = 0, - ConnectingType1 = 1, - ConnectingType2 = 2, - ConnectingType3 = 3, - Connected = 4, - } -} diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionStatus.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionStatus.cs deleted file mode 100644 index ff944eca..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionStatus.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Runtime.InteropServices; - -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types -{ - [StructLayout(LayoutKind.Sequential)] - struct InternetConnectionStatus - { - public InternetConnectionType Type; - public byte WifiStrength; - public InternetConnectionState State; - } -} diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionType.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionType.cs deleted file mode 100644 index af2bcfa1..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/InternetConnectionType.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types -{ - enum InternetConnectionType : byte - { - Invalid = 0, - WiFi = 1, - Ethernet = 2, - } -} diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpAddressSetting.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpAddressSetting.cs deleted file mode 100644 index 59c1f6a7..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpAddressSetting.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Net.NetworkInformation; -using System.Runtime.InteropServices; - -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types -{ - [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0xd)] - struct IpAddressSetting - { - [MarshalAs(UnmanagedType.U1)] - public bool IsDhcpEnabled; - public IpV4Address Address; - public IpV4Address IPv4Mask; - public IpV4Address GatewayAddress; - - public IpAddressSetting(IPInterfaceProperties interfaceProperties, UnicastIPAddressInformation unicastIPAddressInformation) - { - IsDhcpEnabled = OperatingSystem.IsMacOS() || interfaceProperties.DhcpServerAddresses.Count != 0; - Address = new IpV4Address(unicastIPAddressInformation.Address); - IPv4Mask = new IpV4Address(unicastIPAddressInformation.IPv4Mask); - GatewayAddress = (interfaceProperties.GatewayAddresses.Count == 0) ? new IpV4Address() : new IpV4Address(interfaceProperties.GatewayAddresses[0].Address); - } - } -}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpSettingData.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpSettingData.cs deleted file mode 100644 index 8ffe824c..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpSettingData.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Runtime.InteropServices; - -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types -{ - [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0xc2)] - struct IpSettingData - { - public IpAddressSetting IpAddressSetting; - public DnsSetting DnsSetting; - public ProxySetting ProxySetting; - public short Mtu; - } -}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpV4Address.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpV4Address.cs deleted file mode 100644 index e5c2f39a..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/IpV4Address.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Net; -using System.Runtime.InteropServices; - -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types -{ - [StructLayout(LayoutKind.Sequential)] - struct IpV4Address - { - public uint Address; - - public IpV4Address(IPAddress address) - { - if (address == null) - { - Address = 0; - } - else - { - Address = BitConverter.ToUInt32(address.GetAddressBytes()); - } - } - } -} diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/NetworkProfileData.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/NetworkProfileData.cs deleted file mode 100644 index e270c10a..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/NetworkProfileData.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Ryujinx.Common.Memory; -using System; -using System.Runtime.InteropServices; - -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types -{ - [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x17C)] - struct NetworkProfileData - { - public IpSettingData IpSettingData; - public UInt128 Uuid; - public Array64<byte> Name; - public Array4<byte> Unknown; - public WirelessSettingData WirelessSettingData; - public byte Padding; - } -}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/ProxySetting.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/ProxySetting.cs deleted file mode 100644 index 6e534fe1..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/ProxySetting.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Ryujinx.Common.Memory; -using Ryujinx.Common.Utilities; -using System; -using System.Runtime.InteropServices; - -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types -{ - [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0xaa)] - public struct ProxySetting - { - [MarshalAs(UnmanagedType.I1)] - public bool Enabled; - private byte _padding; - public short Port; - private NameStruct _name; - [MarshalAs(UnmanagedType.I1)] - public bool AutoAuthEnabled; - public Array32<byte> User; - public Array32<byte> Pass; - private byte _padding2; - - [StructLayout(LayoutKind.Sequential, Size = 0x64)] - private struct NameStruct { } - - public Span<byte> Name => SpanHelpers.AsSpan<NameStruct, byte>(ref _name); - } -}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/WirelessSettingData.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/WirelessSettingData.cs deleted file mode 100644 index 8aa122c7..00000000 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/WirelessSettingData.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Ryujinx.Common.Memory; -using System.Runtime.InteropServices; - -namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types -{ - [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x65)] - struct WirelessSettingData - { - public byte SsidLength; - public Array32<byte> Ssid; - public Array3<byte> Unknown; - public Array64<byte> Passphrase1; - public byte Passphrase2; - } -}
\ No newline at end of file |
