From 322f28668dc93ff0ad348bd75ddaa25edc232921 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Fri, 9 Feb 2018 21:14:55 -0300 Subject: Ipc refactor (#9) * Start refactoring IPC objects (started with IFile and IFileSystem) * End refactoring IPC objects (#8) * End refactoring IPC objects * End refactoring IPC objects corrections --- Ryujinx/OsHle/Ipc/IpcHandler.cs | 132 +----------- Ryujinx/OsHle/Ipc/ServiceProcessRequest.cs | 4 + .../OsHle/Objects/Acc/IManagerForApplication.cs | 33 +++ Ryujinx/OsHle/Objects/Acc/IProfile.cs | 33 +++ Ryujinx/OsHle/Objects/AccIManagerForApplication.cs | 17 -- Ryujinx/OsHle/Objects/AccIProfile.cs | 18 -- Ryujinx/OsHle/Objects/Am/IApplicationFunctions.cs | 80 ++++++++ Ryujinx/OsHle/Objects/Am/IApplicationProxy.cs | 86 ++++++++ Ryujinx/OsHle/Objects/Am/IAudioController.cs | 20 ++ Ryujinx/OsHle/Objects/Am/ICommonStateGetter.cs | 74 +++++++ Ryujinx/OsHle/Objects/Am/IDebugFunctions.cs | 20 ++ Ryujinx/OsHle/Objects/Am/IDisplayController.cs | 20 ++ Ryujinx/OsHle/Objects/Am/ILibraryAppletCreator.cs | 20 ++ .../OsHle/Objects/Am/IParentalControlService.cs | 20 ++ Ryujinx/OsHle/Objects/Am/ISelfController.cs | 53 +++++ Ryujinx/OsHle/Objects/Am/IStorage.cs | 35 ++++ Ryujinx/OsHle/Objects/Am/IStorageAccessor.cs | 68 +++++++ Ryujinx/OsHle/Objects/Am/IWindowController.cs | 33 +++ Ryujinx/OsHle/Objects/AmIApplicationFunctions.cs | 63 ------ Ryujinx/OsHle/Objects/AmIApplicationProxy.cs | 63 ------ Ryujinx/OsHle/Objects/AmIAudioController.cs | 7 - Ryujinx/OsHle/Objects/AmICommonStateGetter.cs | 55 ----- Ryujinx/OsHle/Objects/AmIDebugFunctions.cs | 7 - Ryujinx/OsHle/Objects/AmIDisplayController.cs | 7 - Ryujinx/OsHle/Objects/AmILibraryAppletCreator.cs | 7 - Ryujinx/OsHle/Objects/AmIParentalControlService.cs | 7 - Ryujinx/OsHle/Objects/AmISelfController.cs | 35 ---- Ryujinx/OsHle/Objects/AmIStorage.cs | 23 --- Ryujinx/OsHle/Objects/AmIStorageAccessor.cs | 56 ------ Ryujinx/OsHle/Objects/AmIWindowController.cs | 17 -- Ryujinx/OsHle/Objects/Apm/ISession.cs | 28 +++ Ryujinx/OsHle/Objects/ApmISession.cs | 13 -- Ryujinx/OsHle/Objects/Aud/IAudioOut.cs | 179 +++++++++++++++++ Ryujinx/OsHle/Objects/Aud/IAudioRenderer.cs | 66 ++++++ Ryujinx/OsHle/Objects/AudIAudioOut.cs | 159 --------------- Ryujinx/OsHle/Objects/AudIAudioRenderer.cs | 50 ----- Ryujinx/OsHle/Objects/Friend/IFriendService.cs | 20 ++ Ryujinx/OsHle/Objects/FriendIFriendService.cs | 7 - Ryujinx/OsHle/Objects/FspSrv/IFile.cs | 79 ++++++++ Ryujinx/OsHle/Objects/FspSrv/IFileSystem.cs | 79 ++++++++ Ryujinx/OsHle/Objects/FspSrv/IStorage.cs | 54 +++++ Ryujinx/OsHle/Objects/FspSrvIFile.cs | 72 ------- Ryujinx/OsHle/Objects/FspSrvIFileSystem.cs | 70 ------- Ryujinx/OsHle/Objects/FspSrvIStorage.cs | 44 ---- Ryujinx/OsHle/Objects/Hid/IAppletResource.cs | 32 +++ Ryujinx/OsHle/Objects/HidIAppletResource.cs | 22 -- Ryujinx/OsHle/Objects/IIpcInterface.cs | 10 + Ryujinx/OsHle/Objects/Time/ISteadyClock.cs | 20 ++ Ryujinx/OsHle/Objects/Time/ISystemClock.cs | 30 +++ Ryujinx/OsHle/Objects/Time/ITimeZoneService.cs | 20 ++ Ryujinx/OsHle/Objects/TimeISteadyClock.cs | 7 - Ryujinx/OsHle/Objects/TimeISystemClock.cs | 16 -- Ryujinx/OsHle/Objects/TimeITimeZoneService.cs | 7 - .../OsHle/Objects/Vi/IApplicationDisplayService.cs | 176 ++++++++++++++++ Ryujinx/OsHle/Objects/Vi/IHOSBinderDriver.cs | 221 +++++++++++++++++++++ Ryujinx/OsHle/Objects/Vi/IManagerDisplayService.cs | 33 +++ Ryujinx/OsHle/Objects/Vi/ISystemDisplayService.cs | 25 +++ .../OsHle/Objects/ViIApplicationDisplayService.cs | 155 --------------- Ryujinx/OsHle/Objects/ViIHOSBinderDriver.cs | 210 -------------------- Ryujinx/OsHle/Objects/ViIManagerDisplayService.cs | 17 -- Ryujinx/OsHle/Objects/ViISystemDisplayService.cs | 10 - Ryujinx/OsHle/Services/ServiceAcc.cs | 6 +- Ryujinx/OsHle/Services/ServiceApm.cs | 4 +- Ryujinx/OsHle/Services/ServiceAppletOE.cs | 2 +- Ryujinx/OsHle/Services/ServiceAud.cs | 6 +- Ryujinx/OsHle/Services/ServiceFriend.cs | 4 +- Ryujinx/OsHle/Services/ServiceFspSrv.cs | 10 +- Ryujinx/OsHle/Services/ServiceHid.cs | 4 +- Ryujinx/OsHle/Services/ServicePctl.cs | 4 +- Ryujinx/OsHle/Services/ServiceTime.cs | 10 +- Ryujinx/OsHle/Services/ServiceVi.cs | 4 +- 71 files changed, 1707 insertions(+), 1391 deletions(-) create mode 100644 Ryujinx/OsHle/Ipc/ServiceProcessRequest.cs create mode 100644 Ryujinx/OsHle/Objects/Acc/IManagerForApplication.cs create mode 100644 Ryujinx/OsHle/Objects/Acc/IProfile.cs delete mode 100644 Ryujinx/OsHle/Objects/AccIManagerForApplication.cs delete mode 100644 Ryujinx/OsHle/Objects/AccIProfile.cs create mode 100644 Ryujinx/OsHle/Objects/Am/IApplicationFunctions.cs create mode 100644 Ryujinx/OsHle/Objects/Am/IApplicationProxy.cs create mode 100644 Ryujinx/OsHle/Objects/Am/IAudioController.cs create mode 100644 Ryujinx/OsHle/Objects/Am/ICommonStateGetter.cs create mode 100644 Ryujinx/OsHle/Objects/Am/IDebugFunctions.cs create mode 100644 Ryujinx/OsHle/Objects/Am/IDisplayController.cs create mode 100644 Ryujinx/OsHle/Objects/Am/ILibraryAppletCreator.cs create mode 100644 Ryujinx/OsHle/Objects/Am/IParentalControlService.cs create mode 100644 Ryujinx/OsHle/Objects/Am/ISelfController.cs create mode 100644 Ryujinx/OsHle/Objects/Am/IStorage.cs create mode 100644 Ryujinx/OsHle/Objects/Am/IStorageAccessor.cs create mode 100644 Ryujinx/OsHle/Objects/Am/IWindowController.cs delete mode 100644 Ryujinx/OsHle/Objects/AmIApplicationFunctions.cs delete mode 100644 Ryujinx/OsHle/Objects/AmIApplicationProxy.cs delete mode 100644 Ryujinx/OsHle/Objects/AmIAudioController.cs delete mode 100644 Ryujinx/OsHle/Objects/AmICommonStateGetter.cs delete mode 100644 Ryujinx/OsHle/Objects/AmIDebugFunctions.cs delete mode 100644 Ryujinx/OsHle/Objects/AmIDisplayController.cs delete mode 100644 Ryujinx/OsHle/Objects/AmILibraryAppletCreator.cs delete mode 100644 Ryujinx/OsHle/Objects/AmIParentalControlService.cs delete mode 100644 Ryujinx/OsHle/Objects/AmISelfController.cs delete mode 100644 Ryujinx/OsHle/Objects/AmIStorage.cs delete mode 100644 Ryujinx/OsHle/Objects/AmIStorageAccessor.cs delete mode 100644 Ryujinx/OsHle/Objects/AmIWindowController.cs create mode 100644 Ryujinx/OsHle/Objects/Apm/ISession.cs delete mode 100644 Ryujinx/OsHle/Objects/ApmISession.cs create mode 100644 Ryujinx/OsHle/Objects/Aud/IAudioOut.cs create mode 100644 Ryujinx/OsHle/Objects/Aud/IAudioRenderer.cs delete mode 100644 Ryujinx/OsHle/Objects/AudIAudioOut.cs delete mode 100644 Ryujinx/OsHle/Objects/AudIAudioRenderer.cs create mode 100644 Ryujinx/OsHle/Objects/Friend/IFriendService.cs delete mode 100644 Ryujinx/OsHle/Objects/FriendIFriendService.cs create mode 100644 Ryujinx/OsHle/Objects/FspSrv/IFile.cs create mode 100644 Ryujinx/OsHle/Objects/FspSrv/IFileSystem.cs create mode 100644 Ryujinx/OsHle/Objects/FspSrv/IStorage.cs delete mode 100644 Ryujinx/OsHle/Objects/FspSrvIFile.cs delete mode 100644 Ryujinx/OsHle/Objects/FspSrvIFileSystem.cs delete mode 100644 Ryujinx/OsHle/Objects/FspSrvIStorage.cs create mode 100644 Ryujinx/OsHle/Objects/Hid/IAppletResource.cs delete mode 100644 Ryujinx/OsHle/Objects/HidIAppletResource.cs create mode 100644 Ryujinx/OsHle/Objects/IIpcInterface.cs create mode 100644 Ryujinx/OsHle/Objects/Time/ISteadyClock.cs create mode 100644 Ryujinx/OsHle/Objects/Time/ISystemClock.cs create mode 100644 Ryujinx/OsHle/Objects/Time/ITimeZoneService.cs delete mode 100644 Ryujinx/OsHle/Objects/TimeISteadyClock.cs delete mode 100644 Ryujinx/OsHle/Objects/TimeISystemClock.cs delete mode 100644 Ryujinx/OsHle/Objects/TimeITimeZoneService.cs create mode 100644 Ryujinx/OsHle/Objects/Vi/IApplicationDisplayService.cs create mode 100644 Ryujinx/OsHle/Objects/Vi/IHOSBinderDriver.cs create mode 100644 Ryujinx/OsHle/Objects/Vi/IManagerDisplayService.cs create mode 100644 Ryujinx/OsHle/Objects/Vi/ISystemDisplayService.cs delete mode 100644 Ryujinx/OsHle/Objects/ViIApplicationDisplayService.cs delete mode 100644 Ryujinx/OsHle/Objects/ViIHOSBinderDriver.cs delete mode 100644 Ryujinx/OsHle/Objects/ViIManagerDisplayService.cs delete mode 100644 Ryujinx/OsHle/Objects/ViISystemDisplayService.cs diff --git a/Ryujinx/OsHle/Ipc/IpcHandler.cs b/Ryujinx/OsHle/Ipc/IpcHandler.cs index c8b26dba..ff90d873 100644 --- a/Ryujinx/OsHle/Ipc/IpcHandler.cs +++ b/Ryujinx/OsHle/Ipc/IpcHandler.cs @@ -10,8 +10,6 @@ namespace Ryujinx.OsHle.Ipc { static class IpcHandler { - private delegate long ServiceProcessRequest(ServiceCtx Context); - private static Dictionary<(string, int), ServiceProcessRequest> ServiceCmds = new Dictionary<(string, int), ServiceProcessRequest>() { @@ -71,122 +69,10 @@ namespace Ryujinx.OsHle.Ipc { ( "vi:m", 2), Service.ViGetDisplayService }, }; - private static Dictionary<(Type, int), ServiceProcessRequest> ObjectCmds = - new Dictionary<(Type, int), ServiceProcessRequest>() - { - //IManagerForApplication - { (typeof(AccIManagerForApplication), 0), AccIManagerForApplication.CheckAvailability }, - { (typeof(AccIManagerForApplication), 1), AccIManagerForApplication.GetAccountId }, - - //IProfile - { (typeof(AccIProfile), 1), AccIProfile.GetBase }, - - //IApplicationFunctions - { (typeof(AmIApplicationFunctions), 1), AmIApplicationFunctions.PopLaunchParameter }, - { (typeof(AmIApplicationFunctions), 20), AmIApplicationFunctions.EnsureSaveData }, - { (typeof(AmIApplicationFunctions), 21), AmIApplicationFunctions.GetDesiredLanguage }, - { (typeof(AmIApplicationFunctions), 40), AmIApplicationFunctions.NotifyRunning }, - - //IApplicationProxy - { (typeof(AmIApplicationProxy), 0), AmIApplicationProxy.GetCommonStateGetter }, - { (typeof(AmIApplicationProxy), 1), AmIApplicationProxy.GetSelfController }, - { (typeof(AmIApplicationProxy), 2), AmIApplicationProxy.GetWindowController }, - { (typeof(AmIApplicationProxy), 3), AmIApplicationProxy.GetAudioController }, - { (typeof(AmIApplicationProxy), 4), AmIApplicationProxy.GetDisplayController }, - { (typeof(AmIApplicationProxy), 11), AmIApplicationProxy.GetLibraryAppletCreator }, - { (typeof(AmIApplicationProxy), 20), AmIApplicationProxy.GetApplicationFunctions }, - { (typeof(AmIApplicationProxy), 1000), AmIApplicationProxy.GetDebugFunctions }, - - //ICommonStateGetter - { (typeof(AmICommonStateGetter), 0), AmICommonStateGetter.GetEventHandle }, - { (typeof(AmICommonStateGetter), 1), AmICommonStateGetter.ReceiveMessage }, - { (typeof(AmICommonStateGetter), 5), AmICommonStateGetter.GetOperationMode }, - { (typeof(AmICommonStateGetter), 6), AmICommonStateGetter.GetPerformanceMode }, - { (typeof(AmICommonStateGetter), 9), AmICommonStateGetter.GetCurrentFocusState }, - - //ISelfController - { (typeof(AmISelfController), 11), AmISelfController.SetOperationModeChangedNotification }, - { (typeof(AmISelfController), 12), AmISelfController.SetPerformanceModeChangedNotification }, - { (typeof(AmISelfController), 13), AmISelfController.SetFocusHandlingMode }, - { (typeof(AmISelfController), 16), AmISelfController.SetOutOfFocusSuspendingEnabled }, - - //IStorage - { (typeof(AmIStorage), 0), AmIStorage.Open }, - - //IStorageAccessor - { (typeof(AmIStorageAccessor), 0), AmIStorageAccessor.GetSize }, - { (typeof(AmIStorageAccessor), 11), AmIStorageAccessor.Read }, - - //IWindowController - { (typeof(AmIWindowController), 1), AmIWindowController.GetAppletResourceUserId }, - { (typeof(AmIWindowController), 10), AmIWindowController.AcquireForegroundRights }, - - //ISession - { (typeof(ApmISession), 0), ApmISession.SetPerformanceConfiguration }, - - //IAudioRenderer - { (typeof(AudIAudioRenderer), 4), AudIAudioRenderer.RequestUpdateAudioRenderer }, - { (typeof(AudIAudioRenderer), 5), AudIAudioRenderer.StartAudioRenderer }, - { (typeof(AudIAudioRenderer), 6), AudIAudioRenderer.StopAudioRenderer }, - { (typeof(AudIAudioRenderer), 7), AudIAudioRenderer.QuerySystemEvent }, - - //IAudioOut - { (typeof(AudIAudioOut), 0), AudIAudioOut.GetAudioOutState }, - { (typeof(AudIAudioOut), 1), AudIAudioOut.StartAudioOut }, - { (typeof(AudIAudioOut), 2), AudIAudioOut.StopAudioOut }, - { (typeof(AudIAudioOut), 3), AudIAudioOut.AppendAudioOutBuffer }, - { (typeof(AudIAudioOut), 4), AudIAudioOut.RegisterBufferEvent }, - { (typeof(AudIAudioOut), 5), AudIAudioOut.GetReleasedAudioOutBuffer }, - { (typeof(AudIAudioOut), 6), AudIAudioOut.ContainsAudioOutBuffer }, - { (typeof(AudIAudioOut), 7), AudIAudioOut.AppendAudioOutBuffer_ex }, - { (typeof(AudIAudioOut), 8), AudIAudioOut.GetReleasedAudioOutBuffer_ex }, - - //IFile - { (typeof(FspSrvIFile), 0), FspSrvIFile.Read }, - { (typeof(FspSrvIFile), 1), FspSrvIFile.Write }, - - //IFileSystem - { (typeof(FspSrvIFileSystem), 7), FspSrvIFileSystem.GetEntryType }, - { (typeof(FspSrvIFileSystem), 8), FspSrvIFileSystem.OpenFile }, - { (typeof(FspSrvIFileSystem), 10), FspSrvIFileSystem.Commit }, - - //IStorage - { (typeof(FspSrvIStorage), 0), FspSrvIStorage.Read }, - - //IAppletResource - { (typeof(HidIAppletResource), 0), HidIAppletResource.GetSharedMemoryHandle }, - - //ISystemClock - { (typeof(TimeISystemClock), 0), TimeISystemClock.GetCurrentTime }, - - //IApplicationDisplayService - { (typeof(ViIApplicationDisplayService), 100), ViIApplicationDisplayService.GetRelayService }, - { (typeof(ViIApplicationDisplayService), 101), ViIApplicationDisplayService.GetSystemDisplayService }, - { (typeof(ViIApplicationDisplayService), 102), ViIApplicationDisplayService.GetManagerDisplayService }, - { (typeof(ViIApplicationDisplayService), 103), ViIApplicationDisplayService.GetIndirectDisplayTransactionService }, - { (typeof(ViIApplicationDisplayService), 1010), ViIApplicationDisplayService.OpenDisplay }, - { (typeof(ViIApplicationDisplayService), 2020), ViIApplicationDisplayService.OpenLayer }, - { (typeof(ViIApplicationDisplayService), 2030), ViIApplicationDisplayService.CreateStrayLayer }, - { (typeof(ViIApplicationDisplayService), 2101), ViIApplicationDisplayService.SetLayerScalingMode }, - { (typeof(ViIApplicationDisplayService), 5202), ViIApplicationDisplayService.GetDisplayVSyncEvent }, - - //IHOSBinderDriver - { (typeof(ViIHOSBinderDriver), 0), ViIHOSBinderDriver.TransactParcel }, - { (typeof(ViIHOSBinderDriver), 1), ViIHOSBinderDriver.AdjustRefcount }, - { (typeof(ViIHOSBinderDriver), 2), ViIHOSBinderDriver.GetNativeHandle }, - - //IManagerDisplayService - { (typeof(ViIManagerDisplayService), 2010), ViIManagerDisplayService.CreateManagedLayer }, - { (typeof(ViIManagerDisplayService), 6000), ViIManagerDisplayService.AddToLayerStack }, - - //ISystemDisplayService - { (typeof(ViISystemDisplayService), 2205), ViISystemDisplayService.SetLayerZ }, - }; - private const long SfciMagic = 'S' << 0 | 'F' << 8 | 'C' << 16 | 'I' << 24; private const long SfcoMagic = 'S' << 0 | 'F' << 8 | 'C' << 16 | 'O' << 24; - public static void ProcessRequest( + public static void IpcCall( Switch Ns, AMemory Memory, HSession Session, @@ -221,15 +107,15 @@ namespace Ryujinx.OsHle.Ipc if (Obj is HDomain) { - DbgServiceName = $"{ServiceName} {CmdId}"; - ServiceCmds.TryGetValue((ServiceName, CmdId), out ProcReq); + + DbgServiceName = $"{ServiceName} {ProcReq?.Method.Name ?? CmdId.ToString()}"; } else if (Obj != null) { - DbgServiceName = $"{ServiceName} {Obj.GetType().Name} {CmdId}"; + ((IIpcInterface)Obj).Commands.TryGetValue(CmdId, out ProcReq); - ObjectCmds.TryGetValue((Obj.GetType(), CmdId), out ProcReq); + DbgServiceName = $"{ServiceName} {Obj.GetType().Name} {ProcReq?.Method.Name ?? CmdId.ToString()}"; } } else if (Request.DomCmd == IpcDomCmd.DeleteObj) @@ -250,15 +136,15 @@ namespace Ryujinx.OsHle.Ipc { object Obj = ((HSessionObj)Session).Obj; - DbgServiceName = $"{ServiceName} {Obj.GetType().Name} {CmdId}"; + ((IIpcInterface)Obj).Commands.TryGetValue(CmdId, out ProcReq); - ObjectCmds.TryGetValue((Obj.GetType(), CmdId), out ProcReq); + DbgServiceName = $"{ServiceName} {Obj.GetType().Name} {ProcReq?.Method.Name ?? CmdId.ToString()}"; } else { - DbgServiceName = $"{ServiceName} {CmdId}"; - ServiceCmds.TryGetValue((ServiceName, CmdId), out ProcReq); + + DbgServiceName = $"{ServiceName} {ProcReq?.Method.Name ?? CmdId.ToString()}"; } } diff --git a/Ryujinx/OsHle/Ipc/ServiceProcessRequest.cs b/Ryujinx/OsHle/Ipc/ServiceProcessRequest.cs new file mode 100644 index 00000000..838a6aea --- /dev/null +++ b/Ryujinx/OsHle/Ipc/ServiceProcessRequest.cs @@ -0,0 +1,4 @@ +namespace Ryujinx.OsHle.Ipc +{ + delegate long ServiceProcessRequest(ServiceCtx Context); +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Acc/IManagerForApplication.cs b/Ryujinx/OsHle/Objects/Acc/IManagerForApplication.cs new file mode 100644 index 00000000..404ee7da --- /dev/null +++ b/Ryujinx/OsHle/Objects/Acc/IManagerForApplication.cs @@ -0,0 +1,33 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Acc +{ + class IManagerForApplication : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IManagerForApplication() + { + m_Commands = new Dictionary() + { + { 0, CheckAvailability }, + { 1, GetAccountId } + }; + } + + public long CheckAvailability(ServiceCtx Context) + { + return 0; + } + + public long GetAccountId(ServiceCtx Context) + { + Context.ResponseData.Write(0xcafeL); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Acc/IProfile.cs b/Ryujinx/OsHle/Objects/Acc/IProfile.cs new file mode 100644 index 00000000..c84c7ae2 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Acc/IProfile.cs @@ -0,0 +1,33 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Acc +{ + class IProfile : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IProfile() + { + m_Commands = new Dictionary() + { + { 1, GetBase } + }; + } + + public long GetBase(ServiceCtx Context) + { + Context.ResponseData.Write(0L); + Context.ResponseData.Write(0L); + Context.ResponseData.Write(0L); + Context.ResponseData.Write(0L); + Context.ResponseData.Write(0L); + Context.ResponseData.Write(0L); + Context.ResponseData.Write(0L); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AccIManagerForApplication.cs b/Ryujinx/OsHle/Objects/AccIManagerForApplication.cs deleted file mode 100644 index 8e2a002b..00000000 --- a/Ryujinx/OsHle/Objects/AccIManagerForApplication.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AccIManagerForApplication - { - public static long CheckAvailability(ServiceCtx Context) - { - return 0; - } - - public static long GetAccountId(ServiceCtx Context) - { - Context.ResponseData.Write(0xcafeL); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AccIProfile.cs b/Ryujinx/OsHle/Objects/AccIProfile.cs deleted file mode 100644 index 2dbe189d..00000000 --- a/Ryujinx/OsHle/Objects/AccIProfile.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AccIProfile - { - public static long GetBase(ServiceCtx Context) - { - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); - Context.ResponseData.Write(0L); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IApplicationFunctions.cs b/Ryujinx/OsHle/Objects/Am/IApplicationFunctions.cs new file mode 100644 index 00000000..138d9084 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IApplicationFunctions.cs @@ -0,0 +1,80 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; +using System.IO; + +using static Ryujinx.OsHle.Objects.ObjHelper; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IApplicationFunctions : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IApplicationFunctions() + { + m_Commands = new Dictionary() + { + { 1, PopLaunchParameter }, + { 20, EnsureSaveData }, + { 21, GetDesiredLanguage }, + { 40, NotifyRunning } + }; + } + + private const uint LaunchParamsMagic = 0xc79497ca; + + public long PopLaunchParameter(ServiceCtx Context) + { + //Only the first 0x18 bytes of the Data seems to be actually used. + MakeObject(Context, new IStorage(MakeLaunchParams())); + + return 0; + } + + public long EnsureSaveData(ServiceCtx Context) + { + long UIdLow = Context.RequestData.ReadInt64(); + long UIdHigh = Context.RequestData.ReadInt64(); + + Context.ResponseData.Write(0L); + + return 0; + } + + public long GetDesiredLanguage(ServiceCtx Context) + { + //This is an enumerator where each number is a differnet language. + //0 is Japanese and 1 is English, need to figure out the other codes. + Context.ResponseData.Write(1L); + + return 0; + } + + public long NotifyRunning(ServiceCtx Context) + { + Context.ResponseData.Write(1); + + return 0; + } + + private byte[] MakeLaunchParams() + { + //Size needs to be at least 0x88 bytes otherwise application errors. + using (MemoryStream MS = new MemoryStream()) + { + BinaryWriter Writer = new BinaryWriter(MS); + + MS.SetLength(0x88); + + Writer.Write(LaunchParamsMagic); + Writer.Write(1); //IsAccountSelected? Only lower 8 bits actually used. + Writer.Write(1L); //User Id Low (note: User Id needs to be != 0) + Writer.Write(0L); //User Id High + + return MS.ToArray(); + } + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IApplicationProxy.cs b/Ryujinx/OsHle/Objects/Am/IApplicationProxy.cs new file mode 100644 index 00000000..15940f67 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IApplicationProxy.cs @@ -0,0 +1,86 @@ +using Ryujinx.OsHle.Ipc; +using Ryujinx.OsHle.Objects.Am; +using System.Collections.Generic; + +using static Ryujinx.OsHle.Objects.ObjHelper; + +namespace Ryujinx.OsHle.Objects +{ + class IApplicationProxy : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IApplicationProxy() + { + m_Commands = new Dictionary() + { + { 0, GetCommonStateGetter }, + { 1, GetSelfController }, + { 2, GetWindowController }, + { 3, GetAudioController }, + { 4, GetDisplayController }, + { 11, GetLibraryAppletCreator }, + { 20, GetApplicationFunctions }, + { 1000, GetDebugFunctions } + }; + } + + public long GetCommonStateGetter(ServiceCtx Context) + { + MakeObject(Context, new ICommonStateGetter()); + + return 0; + } + + public long GetSelfController(ServiceCtx Context) + { + MakeObject(Context, new ISelfController()); + + return 0; + } + + public long GetWindowController(ServiceCtx Context) + { + MakeObject(Context, new IWindowController()); + + return 0; + } + + public long GetAudioController(ServiceCtx Context) + { + MakeObject(Context, new IAudioController()); + + return 0; + } + + public long GetDisplayController(ServiceCtx Context) + { + MakeObject(Context, new IDisplayController()); + + return 0; + } + + public long GetLibraryAppletCreator(ServiceCtx Context) + { + MakeObject(Context, new ILibraryAppletCreator()); + + return 0; + } + + public long GetApplicationFunctions(ServiceCtx Context) + { + MakeObject(Context, new IApplicationFunctions()); + + return 0; + } + + public long GetDebugFunctions(ServiceCtx Context) + { + MakeObject(Context, new IDebugFunctions()); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IAudioController.cs b/Ryujinx/OsHle/Objects/Am/IAudioController.cs new file mode 100644 index 00000000..0ca49f89 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IAudioController.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IAudioController : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IAudioController() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/ICommonStateGetter.cs b/Ryujinx/OsHle/Objects/Am/ICommonStateGetter.cs new file mode 100644 index 00000000..5a3af8e1 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/ICommonStateGetter.cs @@ -0,0 +1,74 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class ICommonStateGetter : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ICommonStateGetter() + { + m_Commands = new Dictionary() + { + { 0, GetEventHandle }, + { 1, ReceiveMessage }, + { 5, GetOperationMode }, + { 6, GetPerformanceMode }, + { 9, GetCurrentFocusState }, + }; + } + + private enum FocusState + { + InFocus = 1, + OutOfFocus = 2 + } + + private enum OperationMode + { + Handheld = 0, + Docked = 1 + } + + public long GetEventHandle(ServiceCtx Context) + { + Context.ResponseData.Write(0L); + + return 0; + } + + public long ReceiveMessage(ServiceCtx Context) + { + //Program expects 0xF at 0x17ae70 on puyo sdk, + //otherwise runs on a infinite loop until it reads said value. + //What it means is still unknown. + Context.ResponseData.Write(0xfL); + + return 0; //0x680; + } + + public long GetOperationMode(ServiceCtx Context) + { + Context.ResponseData.Write((byte)OperationMode.Handheld); + + return 0; + } + + public long GetPerformanceMode(ServiceCtx Context) + { + Context.ResponseData.Write((byte)0); + + return 0; + } + + public long GetCurrentFocusState(ServiceCtx Context) + { + Context.ResponseData.Write((byte)FocusState.InFocus); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IDebugFunctions.cs b/Ryujinx/OsHle/Objects/Am/IDebugFunctions.cs new file mode 100644 index 00000000..dc57e8e6 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IDebugFunctions.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IDebugFunctions : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IDebugFunctions() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IDisplayController.cs b/Ryujinx/OsHle/Objects/Am/IDisplayController.cs new file mode 100644 index 00000000..88612086 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IDisplayController.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IDisplayController : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IDisplayController() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/ILibraryAppletCreator.cs b/Ryujinx/OsHle/Objects/Am/ILibraryAppletCreator.cs new file mode 100644 index 00000000..91fae3dd --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/ILibraryAppletCreator.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class ILibraryAppletCreator : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ILibraryAppletCreator() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IParentalControlService.cs b/Ryujinx/OsHle/Objects/Am/IParentalControlService.cs new file mode 100644 index 00000000..c462ff07 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IParentalControlService.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IParentalControlService : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IParentalControlService() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/ISelfController.cs b/Ryujinx/OsHle/Objects/Am/ISelfController.cs new file mode 100644 index 00000000..c46396c5 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/ISelfController.cs @@ -0,0 +1,53 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class ISelfController : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ISelfController() + { + m_Commands = new Dictionary() + { + { 11, SetOperationModeChangedNotification }, + { 12, SetPerformanceModeChangedNotification }, + { 13, SetFocusHandlingMode }, + { 16, SetOutOfFocusSuspendingEnabled } + }; + } + + public long SetOperationModeChangedNotification(ServiceCtx Context) + { + bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; + + return 0; + } + + public long SetPerformanceModeChangedNotification(ServiceCtx Context) + { + bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; + + return 0; + } + + public long SetFocusHandlingMode(ServiceCtx Context) + { + bool Flag1 = Context.RequestData.ReadByte() != 0 ? true : false; + bool Flag2 = Context.RequestData.ReadByte() != 0 ? true : false; + bool Flag3 = Context.RequestData.ReadByte() != 0 ? true : false; + + return 0; + } + + public long SetOutOfFocusSuspendingEnabled(ServiceCtx Context) + { + bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IStorage.cs b/Ryujinx/OsHle/Objects/Am/IStorage.cs new file mode 100644 index 00000000..53bb5cf1 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IStorage.cs @@ -0,0 +1,35 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +using static Ryujinx.OsHle.Objects.ObjHelper; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IStorage : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public byte[] Data { get; private set; } + + public IStorage(byte[] Data) + { + m_Commands = new Dictionary() + { + { 0, Open } + }; + + this.Data = Data; + } + + public long Open(ServiceCtx Context) + { + IStorage Storage = Context.GetObject(); + + MakeObject(Context, new IStorageAccessor(Storage)); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IStorageAccessor.cs b/Ryujinx/OsHle/Objects/Am/IStorageAccessor.cs new file mode 100644 index 00000000..fdd54744 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IStorageAccessor.cs @@ -0,0 +1,68 @@ +using ChocolArm64.Memory; +using Ryujinx.OsHle.Ipc; +using System; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IStorageAccessor : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IStorage Storage { get; private set; } + + public IStorageAccessor(IStorage Storage) + { + m_Commands = new Dictionary() + { + { 0, GetSize }, + { 11, Read } + }; + + this.Storage = Storage; + } + + public long GetSize(ServiceCtx Context) + { + IStorageAccessor Accessor = Context.GetObject(); + + Context.ResponseData.Write((long)Accessor.Storage.Data.Length); + + return 0; + } + + public long Read(ServiceCtx Context) + { + IStorageAccessor Accessor = Context.GetObject(); + + IStorage Storage = Accessor.Storage; + + long ReadPosition = Context.RequestData.ReadInt64(); + + if (Context.Request.RecvListBuff.Count > 0) + { + long Position = Context.Request.RecvListBuff[0].Position; + short Size = Context.Request.RecvListBuff[0].Size; + + byte[] Data; + + if (Storage.Data.Length > Size) + { + Data = new byte[Size]; + + Buffer.BlockCopy(Storage.Data, 0, Data, 0, Size); + } + else + { + Data = Storage.Data; + } + + AMemoryHelper.WriteBytes(Context.Memory, Position, Data); + } + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Am/IWindowController.cs b/Ryujinx/OsHle/Objects/Am/IWindowController.cs new file mode 100644 index 00000000..1796644e --- /dev/null +++ b/Ryujinx/OsHle/Objects/Am/IWindowController.cs @@ -0,0 +1,33 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Am +{ + class IWindowController : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IWindowController() + { + m_Commands = new Dictionary() + { + { 1, GetAppletResourceUserId }, + { 10, AcquireForegroundRights } + }; + } + + public long GetAppletResourceUserId(ServiceCtx Context) + { + Context.ResponseData.Write(0L); + + return 0; + } + + public long AcquireForegroundRights(ServiceCtx Context) + { + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIApplicationFunctions.cs b/Ryujinx/OsHle/Objects/AmIApplicationFunctions.cs deleted file mode 100644 index b5712484..00000000 --- a/Ryujinx/OsHle/Objects/AmIApplicationFunctions.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.IO; - -using static Ryujinx.OsHle.Objects.ObjHelper; - -namespace Ryujinx.OsHle.Objects -{ - class AmIApplicationFunctions - { - private const uint LaunchParamsMagic = 0xc79497ca; - - public static long PopLaunchParameter(ServiceCtx Context) - { - //Only the first 0x18 bytes of the Data seems to be actually used. - MakeObject(Context, new AmIStorage(MakeLaunchParams())); - - return 0; - } - - public static long EnsureSaveData(ServiceCtx Context) - { - long UIdLow = Context.RequestData.ReadInt64(); - long UIdHigh = Context.RequestData.ReadInt64(); - - Context.ResponseData.Write(0L); - - return 0; - } - - public static long GetDesiredLanguage(ServiceCtx Context) - { - //This is an enumerator where each number is a differnet language. - //0 is Japanese and 1 is English, need to figure out the other codes. - Context.ResponseData.Write(1L); - - return 0; - } - - public static long NotifyRunning(ServiceCtx Context) - { - Context.ResponseData.Write(1); - - return 0; - } - - private static byte[] MakeLaunchParams() - { - //Size needs to be at least 0x88 bytes otherwise application errors. - using (MemoryStream MS = new MemoryStream()) - { - BinaryWriter Writer = new BinaryWriter(MS); - - MS.SetLength(0x88); - - Writer.Write(LaunchParamsMagic); - Writer.Write(1); //IsAccountSelected? Only lower 8 bits actually used. - Writer.Write(1L); //User Id Low (note: User Id needs to be != 0) - Writer.Write(0L); //User Id High - - return MS.ToArray(); - } - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIApplicationProxy.cs b/Ryujinx/OsHle/Objects/AmIApplicationProxy.cs deleted file mode 100644 index 2b0bc346..00000000 --- a/Ryujinx/OsHle/Objects/AmIApplicationProxy.cs +++ /dev/null @@ -1,63 +0,0 @@ -using static Ryujinx.OsHle.Objects.ObjHelper; - -namespace Ryujinx.OsHle.Objects -{ - class AmIApplicationProxy - { - public static long GetCommonStateGetter(ServiceCtx Context) - { - MakeObject(Context, new AmICommonStateGetter()); - - return 0; - } - - public static long GetSelfController(ServiceCtx Context) - { - MakeObject(Context, new AmISelfController()); - - return 0; - } - - public static long GetWindowController(ServiceCtx Context) - { - MakeObject(Context, new AmIWindowController()); - - return 0; - } - - public static long GetAudioController(ServiceCtx Context) - { - MakeObject(Context, new AmIAudioController()); - - return 0; - } - - public static long GetDisplayController(ServiceCtx Context) - { - MakeObject(Context, new AmIDisplayController()); - - return 0; - } - - public static long GetLibraryAppletCreator(ServiceCtx Context) - { - MakeObject(Context, new AmILibraryAppletCreator()); - - return 0; - } - - public static long GetApplicationFunctions(ServiceCtx Context) - { - MakeObject(Context, new AmIApplicationFunctions()); - - return 0; - } - - public static long GetDebugFunctions(ServiceCtx Context) - { - MakeObject(Context, new AmIDebugFunctions()); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIAudioController.cs b/Ryujinx/OsHle/Objects/AmIAudioController.cs deleted file mode 100644 index 59d94bda..00000000 --- a/Ryujinx/OsHle/Objects/AmIAudioController.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmIAudioController - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmICommonStateGetter.cs b/Ryujinx/OsHle/Objects/AmICommonStateGetter.cs deleted file mode 100644 index 32f065c8..00000000 --- a/Ryujinx/OsHle/Objects/AmICommonStateGetter.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmICommonStateGetter - { - private enum FocusState - { - InFocus = 1, - OutOfFocus = 2 - } - - private enum OperationMode - { - Handheld = 0, - Docked = 1 - } - - public static long GetEventHandle(ServiceCtx Context) - { - Context.ResponseData.Write(0L); - - return 0; - } - - public static long ReceiveMessage(ServiceCtx Context) - { - //Program expects 0xF at 0x17ae70 on puyo sdk, - //otherwise runs on a infinite loop until it reads said value. - //What it means is still unknown. - Context.ResponseData.Write(0xfL); - - return 0; //0x680; - } - - public static long GetOperationMode(ServiceCtx Context) - { - Context.ResponseData.Write((byte)OperationMode.Handheld); - - return 0; - } - - public static long GetPerformanceMode(ServiceCtx Context) - { - Context.ResponseData.Write((byte)0); - - return 0; - } - - public static long GetCurrentFocusState(ServiceCtx Context) - { - Context.ResponseData.Write((byte)FocusState.InFocus); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIDebugFunctions.cs b/Ryujinx/OsHle/Objects/AmIDebugFunctions.cs deleted file mode 100644 index 9794c43f..00000000 --- a/Ryujinx/OsHle/Objects/AmIDebugFunctions.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmIDebugFunctions - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIDisplayController.cs b/Ryujinx/OsHle/Objects/AmIDisplayController.cs deleted file mode 100644 index be36ca0c..00000000 --- a/Ryujinx/OsHle/Objects/AmIDisplayController.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmIDisplayController - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmILibraryAppletCreator.cs b/Ryujinx/OsHle/Objects/AmILibraryAppletCreator.cs deleted file mode 100644 index 585df9e9..00000000 --- a/Ryujinx/OsHle/Objects/AmILibraryAppletCreator.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmILibraryAppletCreator - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIParentalControlService.cs b/Ryujinx/OsHle/Objects/AmIParentalControlService.cs deleted file mode 100644 index 12c3c2a9..00000000 --- a/Ryujinx/OsHle/Objects/AmIParentalControlService.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmIParentalControlService - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmISelfController.cs b/Ryujinx/OsHle/Objects/AmISelfController.cs deleted file mode 100644 index 8affb92b..00000000 --- a/Ryujinx/OsHle/Objects/AmISelfController.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmISelfController - { - public static long SetOperationModeChangedNotification(ServiceCtx Context) - { - bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; - - return 0; - } - - public static long SetPerformanceModeChangedNotification(ServiceCtx Context) - { - bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; - - return 0; - } - - public static long SetFocusHandlingMode(ServiceCtx Context) - { - bool Flag1 = Context.RequestData.ReadByte() != 0 ? true : false; - bool Flag2 = Context.RequestData.ReadByte() != 0 ? true : false; - bool Flag3 = Context.RequestData.ReadByte() != 0 ? true : false; - - return 0; - } - - public static long SetOutOfFocusSuspendingEnabled(ServiceCtx Context) - { - bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIStorage.cs b/Ryujinx/OsHle/Objects/AmIStorage.cs deleted file mode 100644 index 7e608ac8..00000000 --- a/Ryujinx/OsHle/Objects/AmIStorage.cs +++ /dev/null @@ -1,23 +0,0 @@ -using static Ryujinx.OsHle.Objects.ObjHelper; - -namespace Ryujinx.OsHle.Objects -{ - class AmIStorage - { - public byte[] Data { get; private set; } - - public AmIStorage(byte[] Data) - { - this.Data = Data; - } - - public static long Open(ServiceCtx Context) - { - AmIStorage Storage = Context.GetObject(); - - MakeObject(Context, new AmIStorageAccessor(Storage)); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIStorageAccessor.cs b/Ryujinx/OsHle/Objects/AmIStorageAccessor.cs deleted file mode 100644 index 62007ef8..00000000 --- a/Ryujinx/OsHle/Objects/AmIStorageAccessor.cs +++ /dev/null @@ -1,56 +0,0 @@ -using ChocolArm64.Memory; -using System; - -namespace Ryujinx.OsHle.Objects -{ - class AmIStorageAccessor - { - public AmIStorage Storage { get; private set; } - - public AmIStorageAccessor(AmIStorage Storage) - { - this.Storage = Storage; - } - - public static long GetSize(ServiceCtx Context) - { - AmIStorageAccessor Accessor = Context.GetObject(); - - Context.ResponseData.Write((long)Accessor.Storage.Data.Length); - - return 0; - } - - public static long Read(ServiceCtx Context) - { - AmIStorageAccessor Accessor = Context.GetObject(); - - AmIStorage Storage = Accessor.Storage; - - long ReadPosition = Context.RequestData.ReadInt64(); - - if (Context.Request.RecvListBuff.Count > 0) - { - long Position = Context.Request.RecvListBuff[0].Position; - short Size = Context.Request.RecvListBuff[0].Size; - - byte[] Data; - - if (Storage.Data.Length > Size) - { - Data = new byte[Size]; - - Buffer.BlockCopy(Storage.Data, 0, Data, 0, Size); - } - else - { - Data = Storage.Data; - } - - AMemoryHelper.WriteBytes(Context.Memory, Position, Data); - } - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AmIWindowController.cs b/Ryujinx/OsHle/Objects/AmIWindowController.cs deleted file mode 100644 index ea967ae8..00000000 --- a/Ryujinx/OsHle/Objects/AmIWindowController.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class AmIWindowController - { - public static long GetAppletResourceUserId(ServiceCtx Context) - { - Context.ResponseData.Write(0L); - - return 0; - } - - public static long AcquireForegroundRights(ServiceCtx Context) - { - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Apm/ISession.cs b/Ryujinx/OsHle/Objects/Apm/ISession.cs new file mode 100644 index 00000000..f3965b48 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Apm/ISession.cs @@ -0,0 +1,28 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Apm +{ + class ISession : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ISession() + { + m_Commands = new Dictionary() + { + { 0, SetPerformanceConfiguration } + }; + } + + public long SetPerformanceConfiguration(ServiceCtx Context) + { + int PerfMode = Context.RequestData.ReadInt32(); + int PerfConfig = Context.RequestData.ReadInt32(); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/ApmISession.cs b/Ryujinx/OsHle/Objects/ApmISession.cs deleted file mode 100644 index 2b2c0351..00000000 --- a/Ryujinx/OsHle/Objects/ApmISession.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class ApmISession - { - public static long SetPerformanceConfiguration(ServiceCtx Context) - { - int PerfMode = Context.RequestData.ReadInt32(); - int PerfConfig = Context.RequestData.ReadInt32(); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Aud/IAudioOut.cs b/Ryujinx/OsHle/Objects/Aud/IAudioOut.cs new file mode 100644 index 00000000..5feb67d8 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Aud/IAudioOut.cs @@ -0,0 +1,179 @@ +using ChocolArm64.Memory; +using Ryujinx.OsHle.Handles; +using Ryujinx.OsHle.Ipc; +using OpenTK.Audio; +using OpenTK.Audio.OpenAL; +using System; +using System.Collections.Generic; +using System.IO; + +namespace Ryujinx.OsHle.Objects.Aud +{ + class IAudioOut : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IAudioOut() + { + m_Commands = new Dictionary() + { + { 0, GetAudioOutState }, + { 1, StartAudioOut }, + { 2, StopAudioOut }, + { 3, AppendAudioOutBuffer }, + { 4, RegisterBufferEvent }, + { 5, GetReleasedAudioOutBuffer }, + { 6, ContainsAudioOutBuffer }, + { 7, AppendAudioOutBuffer_ex }, + { 8, GetReleasedAudioOutBuffer_ex } + }; + } + + enum AudioOutState + { + Started, + Stopped + }; + + //IAudioOut + private AudioOutState State = AudioOutState.Stopped; + private Queue KeysQueue = new Queue(); + + //OpenAL + private bool OpenALInstalled = true; + private AudioContext AudioCtx; + private int Source; + private int Buffer; + + //Return State of IAudioOut + public long GetAudioOutState(ServiceCtx Context) + { + Context.ResponseData.Write((int)State); + + return 0; + } + + public long StartAudioOut(ServiceCtx Context) + { + if (State == AudioOutState.Stopped) + { + State = AudioOutState.Started; + + try + { + AudioCtx = new AudioContext(); //Create the audio context + } + catch (Exception) + { + Logging.Warn("OpenAL Error! PS: Install OpenAL Core SDK!"); + OpenALInstalled = false; + } + + if (OpenALInstalled) AL.Listener(ALListenerf.Gain, (float)8.0); //Add more gain to it + } + + return 0; + } + + public long StopAudioOut(ServiceCtx Context) + { + if (State == AudioOutState.Started) + { + if (OpenALInstalled) + { + if (AudioCtx == null) //Needed to call the instance of AudioContext() + return 0; + + AL.SourceStop(Source); + AL.DeleteSource(Source); + } + State = AudioOutState.Stopped; + } + + return 0; + } + + public long AppendAudioOutBuffer(ServiceCtx Context) + { + long BufferId = Context.RequestData.ReadInt64(); + + KeysQueue.Enqueue(BufferId); + + byte[] AudioOutBuffer = AMemoryHelper.ReadBytes(Context.Memory, Context.Request.SendBuff[0].Position, 0x28); + using (MemoryStream MS = new MemoryStream(AudioOutBuffer)) + { + BinaryReader Reader = new BinaryReader(MS); + long PointerToSampleDataPointer = Reader.ReadInt64(); + long PointerToSampleData = Reader.ReadInt64(); + long CapacitySampleBuffer = Reader.ReadInt64(); + long SizeDataSampleBuffer = Reader.ReadInt64(); + long Unknown = Reader.ReadInt64(); + + byte[] AudioSampleBuffer = AMemoryHelper.ReadBytes(Context.Memory, PointerToSampleData, (int)SizeDataSampleBuffer); + + if (OpenALInstalled) + { + if (AudioCtx == null) //Needed to call the instance of AudioContext() + return 0; + + Buffer = AL.GenBuffer(); + AL.BufferData(Buffer, ALFormat.Stereo16, AudioSampleBuffer, AudioSampleBuffer.Length, 48000); + + Source = AL.GenSource(); + AL.SourceQueueBuffer(Source, Buffer); + } + } + + return 0; + } + + public long RegisterBufferEvent(ServiceCtx Context) + { + int Handle = Context.Ns.Os.Handles.GenerateId(new HEvent()); + + Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + + return 0; + } + + public long GetReleasedAudioOutBuffer(ServiceCtx Context) + { + long TempKey = 0; + + if (KeysQueue.Count > 0) TempKey = KeysQueue.Dequeue(); + + AMemoryHelper.WriteBytes(Context.Memory, Context.Request.ReceiveBuff[0].Position, BitConverter.GetBytes(TempKey)); + + Context.ResponseData.Write((int)TempKey); + + if (OpenALInstalled) + { + if (AudioCtx == null) //Needed to call the instance of AudioContext() + return 0; + + AL.SourcePlay(Source); + int[] FreeBuffers = AL.SourceUnqueueBuffers(Source, 1); + AL.DeleteBuffers(FreeBuffers); + } + + return 0; + } + + public long ContainsAudioOutBuffer(ServiceCtx Context) + { + return 0; + } + + public long AppendAudioOutBuffer_ex(ServiceCtx Context) + { + return 0; + } + + public long GetReleasedAudioOutBuffer_ex(ServiceCtx Context) + { + return 0; + } + } +} diff --git a/Ryujinx/OsHle/Objects/Aud/IAudioRenderer.cs b/Ryujinx/OsHle/Objects/Aud/IAudioRenderer.cs new file mode 100644 index 00000000..a953d82a --- /dev/null +++ b/Ryujinx/OsHle/Objects/Aud/IAudioRenderer.cs @@ -0,0 +1,66 @@ +using Ryujinx.OsHle.Handles; +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Aud +{ + class IAudioRenderer : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IAudioRenderer() + { + m_Commands = new Dictionary() + { + { 4, RequestUpdateAudioRenderer }, + { 5, StartAudioRenderer }, + { 6, StopAudioRenderer }, + { 7, QuerySystemEvent } + }; + } + + public long RequestUpdateAudioRenderer(ServiceCtx Context) + { + //(buffer) -> (buffer, buffer) + + long Position = Context.Request.ReceiveBuff[0].Position; + + //0x40 bytes header + Context.Memory.WriteInt32(Position + 0x4, 0xb0); //Behavior Out State Size? (note: this is the last section) + Context.Memory.WriteInt32(Position + 0x8, 0x18e0); //Memory Pool Out State Size? + Context.Memory.WriteInt32(Position + 0xc, 0x600); //Voice Out State Size? + Context.Memory.WriteInt32(Position + 0x14, 0xe0); //Effect Out State Size? + Context.Memory.WriteInt32(Position + 0x1c, 0x20); //Sink Out State Size? + Context.Memory.WriteInt32(Position + 0x20, 0x10); //Performance Out State Size? + Context.Memory.WriteInt32(Position + 0x3c, 0x20e0); //Total Size (including 0x40 bytes header) + + for (int Offset = 0x40; Offset < 0x40 + 0x18e0; Offset += 0x10) + { + Context.Memory.WriteInt32(Position + Offset, 5); + } + + return 0; + } + + public long StartAudioRenderer(ServiceCtx Context) + { + return 0; + } + + public long StopAudioRenderer(ServiceCtx Context) + { + return 0; + } + + public long QuerySystemEvent(ServiceCtx Context) + { + int Handle = Context.Ns.Os.Handles.GenerateId(new HEvent()); + + Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/AudIAudioOut.cs b/Ryujinx/OsHle/Objects/AudIAudioOut.cs deleted file mode 100644 index 029c058f..00000000 --- a/Ryujinx/OsHle/Objects/AudIAudioOut.cs +++ /dev/null @@ -1,159 +0,0 @@ -using ChocolArm64.Memory; -using OpenTK.Audio; -using OpenTK.Audio.OpenAL; -using Ryujinx.OsHle.Handles; -using Ryujinx.OsHle.Ipc; -using System; -using System.Collections.Generic; -using System.IO; - -namespace Ryujinx.OsHle.Objects -{ - class AudIAudioOut - { - enum AudioOutState - { - Started, - Stopped - }; - - //IAudioOut - private static AudioOutState State = AudioOutState.Stopped; - private static Queue KeysQueue = new Queue(); - - //OpenAL - private static bool OpenALInstalled = true; - private static AudioContext AudioCtx; - private static int Source; - private static int Buffer; - - //Return State of IAudioOut - public static long GetAudioOutState(ServiceCtx Context) - { - Context.ResponseData.Write((int)State); - - return 0; - } - - public static long StartAudioOut(ServiceCtx Context) - { - if (State == AudioOutState.Stopped) - { - State = AudioOutState.Started; - - try - { - AudioCtx = new AudioContext(); //Create the audio context - } - catch (Exception) - { - Logging.Warn("OpenAL Error! PS: Install OpenAL Core SDK!"); - OpenALInstalled = false; - } - - if (OpenALInstalled) AL.Listener(ALListenerf.Gain, (float)8.0); //Add more gain to it - } - - return 0; - } - - public static long StopAudioOut(ServiceCtx Context) - { - if (State == AudioOutState.Started) - { - if (OpenALInstalled) - { - if (AudioCtx == null) //Needed to call the instance of AudioContext() - return 0; - - AL.SourceStop(Source); - AL.DeleteSource(Source); - } - State = AudioOutState.Stopped; - } - - return 0; - } - - public static long AppendAudioOutBuffer(ServiceCtx Context) - { - long BufferId = Context.RequestData.ReadInt64(); - - KeysQueue.Enqueue(BufferId); - - byte[] AudioOutBuffer = AMemoryHelper.ReadBytes(Context.Memory, Context.Request.SendBuff[0].Position, 0x28); - using (MemoryStream MS = new MemoryStream(AudioOutBuffer)) - { - BinaryReader Reader = new BinaryReader(MS); - long PointerToSampleDataPointer = Reader.ReadInt64(); - long PointerToSampleData = Reader.ReadInt64(); - long CapacitySampleBuffer = Reader.ReadInt64(); - long SizeDataSampleBuffer = Reader.ReadInt64(); - long Unknown = Reader.ReadInt64(); - - byte[] AudioSampleBuffer = AMemoryHelper.ReadBytes(Context.Memory, PointerToSampleData, (int)SizeDataSampleBuffer); - - if (OpenALInstalled) - { - if (AudioCtx == null) //Needed to call the instance of AudioContext() - return 0; - - Buffer = AL.GenBuffer(); - AL.BufferData(Buffer, ALFormat.Stereo16, AudioSampleBuffer, AudioSampleBuffer.Length, 48000); - - Source = AL.GenSource(); - AL.SourceQueueBuffer(Source, Buffer); - } - } - - return 0; - } - - public static long RegisterBufferEvent(ServiceCtx Context) - { - int Handle = Context.Ns.Os.Handles.GenerateId(new HEvent()); - - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); - - return 0; - } - - public static long GetReleasedAudioOutBuffer(ServiceCtx Context) - { - long TempKey = 0; - - if (KeysQueue.Count > 0) TempKey = KeysQueue.Dequeue(); - - AMemoryHelper.WriteBytes(Context.Memory, Context.Request.ReceiveBuff[0].Position, BitConverter.GetBytes(TempKey)); - - Context.ResponseData.Write((int)TempKey); - - if (OpenALInstalled) - { - if (AudioCtx == null) //Needed to call the instance of AudioContext() - return 0; - - AL.SourcePlay(Source); - int[] FreeBuffers = AL.SourceUnqueueBuffers(Source, 1); - AL.DeleteBuffers(FreeBuffers); - } - - return 0; - } - - public static long ContainsAudioOutBuffer(ServiceCtx Context) - { - return 0; - } - - public static long AppendAudioOutBuffer_ex(ServiceCtx Context) - { - return 0; - } - - public static long GetReleasedAudioOutBuffer_ex(ServiceCtx Context) - { - return 0; - } - } -} diff --git a/Ryujinx/OsHle/Objects/AudIAudioRenderer.cs b/Ryujinx/OsHle/Objects/AudIAudioRenderer.cs deleted file mode 100644 index 35a5b82d..00000000 --- a/Ryujinx/OsHle/Objects/AudIAudioRenderer.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Ryujinx.OsHle.Handles; -using Ryujinx.OsHle.Ipc; - -namespace Ryujinx.OsHle.Objects -{ - class AudIAudioRenderer - { - public static long RequestUpdateAudioRenderer(ServiceCtx Context) - { - //buffer < unknown, 5, 0 >) -> (buffer < unknown, 6, 0 >, buffer < unknown, 6, 0 > - - long Position = Context.Request.ReceiveBuff[0].Position; - - //0x40 bytes header - Context.Memory.WriteInt32(Position + 0x4, 0xb0); //Behavior Out State Size? (note: this is the last section) - Context.Memory.WriteInt32(Position + 0x8, 0x18e0); //Memory Pool Out State Size? - Context.Memory.WriteInt32(Position + 0xc, 0x600); //Voice Out State Size? - Context.Memory.WriteInt32(Position + 0x14, 0xe0); //Effect Out State Size? - Context.Memory.WriteInt32(Position + 0x1c, 0x20); //Sink Out State Size? - Context.Memory.WriteInt32(Position + 0x20, 0x10); //Performance Out State Size? - Context.Memory.WriteInt32(Position + 0x3c, 0x20e0); //Total Size (including 0x40 bytes header) - - for (int Offset = 0x40; Offset < 0x40 + 0x18e0; Offset += 0x10) - { - Context.Memory.WriteInt32(Position + Offset, 5); - } - - return 0; - } - - public static long StartAudioRenderer(ServiceCtx Context) - { - return 0; - } - - public static long StopAudioRenderer(ServiceCtx Context) - { - return 0; - } - - public static long QuerySystemEvent(ServiceCtx Context) - { - int Handle = Context.Ns.Os.Handles.GenerateId(new HEvent()); - - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Friend/IFriendService.cs b/Ryujinx/OsHle/Objects/Friend/IFriendService.cs new file mode 100644 index 00000000..41084f8d --- /dev/null +++ b/Ryujinx/OsHle/Objects/Friend/IFriendService.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Friend +{ + class IFriendService : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IFriendService() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/FriendIFriendService.cs b/Ryujinx/OsHle/Objects/FriendIFriendService.cs deleted file mode 100644 index 9a39380a..00000000 --- a/Ryujinx/OsHle/Objects/FriendIFriendService.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class FriendIFriendService - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/FspSrv/IFile.cs b/Ryujinx/OsHle/Objects/FspSrv/IFile.cs new file mode 100644 index 00000000..1c6cc2e2 --- /dev/null +++ b/Ryujinx/OsHle/Objects/FspSrv/IFile.cs @@ -0,0 +1,79 @@ +using ChocolArm64.Memory; +using Ryujinx.OsHle.Ipc; +using System; +using System.Collections.Generic; +using System.IO; + +namespace Ryujinx.OsHle.Objects.FspSrv +{ + class IFile : IIpcInterface, IDisposable + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + private Stream BaseStream; + + public IFile(Stream BaseStream) + { + m_Commands = new Dictionary() + { + { 0, Read }, + { 1, Write } + }; + + this.BaseStream = BaseStream; + } + + public long Read(ServiceCtx Context) + { + long Position = Context.Request.ReceiveBuff[0].Position; + + long Zero = Context.RequestData.ReadInt64(); + long Offset = Context.RequestData.ReadInt64(); + long Size = Context.RequestData.ReadInt64(); + + byte[] Data = new byte[Size]; + + int ReadSize = BaseStream.Read(Data, 0, (int)Size); + + AMemoryHelper.WriteBytes(Context.Memory, Position, Data); + + //TODO: Use ReadSize, we need to return the size that was REALLY read from the file. + //This is a workaround because we are doing something wrong and the game expects to read + //data from a file that doesn't yet exists -- and breaks if it can't read anything. + Context.ResponseData.Write((long)Size); + + return 0; + } + + public long Write(ServiceCtx Context) + { + long Position = Context.Request.SendBuff[0].Position; + + long Zero = Context.RequestData.ReadInt64(); + long Offset = Context.RequestData.ReadInt64(); + long Size = Context.RequestData.ReadInt64(); + + byte[] Data = AMemoryHelper.ReadBytes(Context.Memory, Position, (int)Size); + + BaseStream.Seek(Offset, SeekOrigin.Begin); + BaseStream.Write(Data, 0, (int)Size); + + return 0; + } + + public void Dispose() + { + Dispose(true); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing && BaseStream != null) + { + BaseStream.Dispose(); + } + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/FspSrv/IFileSystem.cs b/Ryujinx/OsHle/Objects/FspSrv/IFileSystem.cs new file mode 100644 index 00000000..bf501594 --- /dev/null +++ b/Ryujinx/OsHle/Objects/FspSrv/IFileSystem.cs @@ -0,0 +1,79 @@ +using ChocolArm64.Memory; +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; +using System.IO; + +using static Ryujinx.OsHle.Objects.ObjHelper; + +namespace Ryujinx.OsHle.Objects.FspSrv +{ + class IFileSystem : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + private string Path; + + public IFileSystem(string Path) + { + m_Commands = new Dictionary() + { + { 7, GetEntryType }, + { 8, OpenFile }, + { 10, Commit } + }; + + this.Path = Path; + } + + public long GetEntryType(ServiceCtx Context) + { + long Position = Context.Request.PtrBuff[0].Position; + + string Name = AMemoryHelper.ReadAsciiString(Context.Memory, Position); + + string FileName = Context.Ns.VFs.GetFullPath(Path, Name); + + if (FileName == null) + { + //TODO: Correct error code. + return -1; + } + + bool IsFile = File.Exists(FileName); + + Context.ResponseData.Write(IsFile ? 1 : 0); + + return 0; + } + + public long OpenFile(ServiceCtx Context) + { + long Position = Context.Request.PtrBuff[0].Position; + + int FilterFlags = Context.RequestData.ReadInt32(); + + string Name = AMemoryHelper.ReadAsciiString(Context.Memory, Position); + + string FileName = Context.Ns.VFs.GetFullPath(Path, Name); + + if (FileName == null) + { + //TODO: Correct error code. + return -1; + } + + FileStream Stream = new FileStream(FileName, FileMode.OpenOrCreate); + + MakeObject(Context, new IFile(Stream)); + + return 0; + } + + public long Commit(ServiceCtx Context) + { + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/FspSrv/IStorage.cs b/Ryujinx/OsHle/Objects/FspSrv/IStorage.cs new file mode 100644 index 00000000..2068a2cb --- /dev/null +++ b/Ryujinx/OsHle/Objects/FspSrv/IStorage.cs @@ -0,0 +1,54 @@ +using ChocolArm64.Memory; +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; +using System.IO; + +namespace Ryujinx.OsHle.Objects.FspSrv +{ + class IStorage : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public Stream BaseStream { get; private set; } + + public IStorage(Stream BaseStream) + { + m_Commands = new Dictionary() + { + { 0, Read } + }; + + this.BaseStream = BaseStream; + } + + public static long Read(ServiceCtx Context) + { + IStorage Storage = Context.GetObject(); + + long Offset = Context.RequestData.ReadInt64(); + long Size = Context.RequestData.ReadInt64(); + + if (Context.Request.ReceiveBuff.Count > 0) + { + IpcBuffDesc BuffDesc = Context.Request.ReceiveBuff[0]; + + //Use smaller length to avoid overflows. + if (Size > BuffDesc.Size) + { + Size = BuffDesc.Size; + } + + byte[] Data = new byte[Size]; + + Storage.BaseStream.Seek(Offset, SeekOrigin.Begin); + Storage.BaseStream.Read(Data, 0, Data.Length); + + AMemoryHelper.WriteBytes(Context.Memory, BuffDesc.Position, Data); + } + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/FspSrvIFile.cs b/Ryujinx/OsHle/Objects/FspSrvIFile.cs deleted file mode 100644 index 4b9f8c37..00000000 --- a/Ryujinx/OsHle/Objects/FspSrvIFile.cs +++ /dev/null @@ -1,72 +0,0 @@ -using ChocolArm64.Memory; -using System; - -using System.IO; - -namespace Ryujinx.OsHle.Objects -{ - class FspSrvIFile : IDisposable - { - public Stream BaseStream { get; private set; } - - public FspSrvIFile(Stream BaseStream) - { - this.BaseStream = BaseStream; - } - - public static long Read(ServiceCtx Context) - { - FspSrvIFile File = Context.GetObject(); - - long Position = Context.Request.ReceiveBuff[0].Position; - - long Zero = Context.RequestData.ReadInt64(); - long Offset = Context.RequestData.ReadInt64(); - long Size = Context.RequestData.ReadInt64(); - - byte[] Data = new byte[Size]; - - int ReadSize = File.BaseStream.Read(Data, 0, (int)Size); - - AMemoryHelper.WriteBytes(Context.Memory, Position, Data); - - //TODO: Use ReadSize, we need to return the size that was REALLY read from the file. - //This is a workaround because we are doing something wrong and the game expects to read - //data from a file that doesn't yet exists -- and breaks if it can't read anything. - Context.ResponseData.Write((long)Size); - - return 0; - } - - public static long Write(ServiceCtx Context) - { - FspSrvIFile File = Context.GetObject(); - - long Position = Context.Request.SendBuff[0].Position; - - long Zero = Context.RequestData.ReadInt64(); - long Offset = Context.RequestData.ReadInt64(); - long Size = Context.RequestData.ReadInt64(); - - byte[] Data = AMemoryHelper.ReadBytes(Context.Memory, Position, (int)Size); - - File.BaseStream.Seek(Offset, SeekOrigin.Begin); - File.BaseStream.Write(Data, 0, (int)Size); - - return 0; - } - - public void Dispose() - { - Dispose(true); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing && BaseStream != null) - { - BaseStream.Dispose(); - } - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/FspSrvIFileSystem.cs b/Ryujinx/OsHle/Objects/FspSrvIFileSystem.cs deleted file mode 100644 index fed1c55a..00000000 --- a/Ryujinx/OsHle/Objects/FspSrvIFileSystem.cs +++ /dev/null @@ -1,70 +0,0 @@ -using ChocolArm64.Memory; -using System.IO; - -using static Ryujinx.OsHle.Objects.ObjHelper; - -namespace Ryujinx.OsHle.Objects -{ - class FspSrvIFileSystem - { - public string FilePath { get; private set; } - - public FspSrvIFileSystem(string Path) - { - this.FilePath = Path; - } - - public static long GetEntryType(ServiceCtx Context) - { - FspSrvIFileSystem FileSystem = Context.GetObject(); - - long Position = Context.Request.PtrBuff[0].Position; - - string Name = AMemoryHelper.ReadAsciiString(Context.Memory, Position); - - string FileName = Context.Ns.VFs.GetFullPath(FileSystem.FilePath, Name); - - if (FileName == null) - { - //TODO: Correct error code. - return -1; - } - - bool IsFile = File.Exists(FileName); - - Context.ResponseData.Write(IsFile ? 1 : 0); - - return 0; - } - - public static long OpenFile(ServiceCtx Context) - { - FspSrvIFileSystem FileSystem = Context.GetObject(); - - long Position = Context.Request.PtrBuff[0].Position; - - int FilterFlags = Context.RequestData.ReadInt32(); - - string Name = AMemoryHelper.ReadAsciiString(Context.Memory, Position); - - string FileName = Context.Ns.VFs.GetFullPath(FileSystem.FilePath, Name); - - if (FileName == null) - { - //TODO: Correct error code. - return -1; - } - - FileStream Stream = new FileStream(FileName, FileMode.OpenOrCreate); - - MakeObject(Context, new FspSrvIFile(Stream)); - - return 0; - } - - public static long Commit(ServiceCtx Context) - { - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/FspSrvIStorage.cs b/Ryujinx/OsHle/Objects/FspSrvIStorage.cs deleted file mode 100644 index 76ad8917..00000000 --- a/Ryujinx/OsHle/Objects/FspSrvIStorage.cs +++ /dev/null @@ -1,44 +0,0 @@ -using ChocolArm64.Memory; -using Ryujinx.OsHle.Ipc; -using System.IO; - -namespace Ryujinx.OsHle.Objects -{ - class FspSrvIStorage - { - public Stream BaseStream { get; private set; } - - public FspSrvIStorage(Stream BaseStream) - { - this.BaseStream = BaseStream; - } - - public static long Read(ServiceCtx Context) - { - FspSrvIStorage Storage = Context.GetObject(); - - long Offset = Context.RequestData.ReadInt64(); - long Size = Context.RequestData.ReadInt64(); - - if (Context.Request.ReceiveBuff.Count > 0) - { - IpcBuffDesc BuffDesc = Context.Request.ReceiveBuff[0]; - - //Use smaller length to avoid overflows. - if (Size > BuffDesc.Size) - { - Size = BuffDesc.Size; - } - - byte[] Data = new byte[Size]; - - Storage.BaseStream.Seek(Offset, SeekOrigin.Begin); - Storage.BaseStream.Read(Data, 0, Data.Length); - - AMemoryHelper.WriteBytes(Context.Memory, BuffDesc.Position, Data); - } - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Hid/IAppletResource.cs b/Ryujinx/OsHle/Objects/Hid/IAppletResource.cs new file mode 100644 index 00000000..ac7ccf56 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Hid/IAppletResource.cs @@ -0,0 +1,32 @@ +using Ryujinx.OsHle.Handles; +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Hid +{ + class IAppletResource : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public HSharedMem Handle; + + public IAppletResource(HSharedMem Handle) + { + m_Commands = new Dictionary() + { + { 0, GetSharedMemoryHandle } + }; + + this.Handle = Handle; + } + + public static long GetSharedMemoryHandle(ServiceCtx Context) + { + Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Context.Ns.Os.HidHandle); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/HidIAppletResource.cs b/Ryujinx/OsHle/Objects/HidIAppletResource.cs deleted file mode 100644 index 73b948df..00000000 --- a/Ryujinx/OsHle/Objects/HidIAppletResource.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Ryujinx.OsHle.Handles; -using Ryujinx.OsHle.Ipc; - -namespace Ryujinx.OsHle.Objects -{ - class HidIAppletResource - { - public HSharedMem Handle; - - public HidIAppletResource(HSharedMem Handle) - { - this.Handle = Handle; - } - - public static long GetSharedMemoryHandle(ServiceCtx Context) - { - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Context.Ns.Os.HidHandle); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/IIpcInterface.cs b/Ryujinx/OsHle/Objects/IIpcInterface.cs new file mode 100644 index 00000000..af0594cc --- /dev/null +++ b/Ryujinx/OsHle/Objects/IIpcInterface.cs @@ -0,0 +1,10 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects +{ + interface IIpcInterface + { + IReadOnlyDictionary Commands { get; } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Time/ISteadyClock.cs b/Ryujinx/OsHle/Objects/Time/ISteadyClock.cs new file mode 100644 index 00000000..a5139bab --- /dev/null +++ b/Ryujinx/OsHle/Objects/Time/ISteadyClock.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Time +{ + class ISteadyClock : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ISteadyClock() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Time/ISystemClock.cs b/Ryujinx/OsHle/Objects/Time/ISystemClock.cs new file mode 100644 index 00000000..2c5b898b --- /dev/null +++ b/Ryujinx/OsHle/Objects/Time/ISystemClock.cs @@ -0,0 +1,30 @@ +using Ryujinx.OsHle.Ipc; +using System; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Time +{ + class ISystemClock : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + private static DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + + public ISystemClock() + { + m_Commands = new Dictionary() + { + { 0, GetCurrentTime } + }; + } + + public long GetCurrentTime(ServiceCtx Context) + { + Context.ResponseData.Write((long)(DateTime.Now - Epoch).TotalSeconds); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Time/ITimeZoneService.cs b/Ryujinx/OsHle/Objects/Time/ITimeZoneService.cs new file mode 100644 index 00000000..29e7ec92 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Time/ITimeZoneService.cs @@ -0,0 +1,20 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Time +{ + class ITimeZoneService : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ITimeZoneService() + { + m_Commands = new Dictionary() + { + //... + }; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/TimeISteadyClock.cs b/Ryujinx/OsHle/Objects/TimeISteadyClock.cs deleted file mode 100644 index ead8c41a..00000000 --- a/Ryujinx/OsHle/Objects/TimeISteadyClock.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class TimeISteadyClock - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/TimeISystemClock.cs b/Ryujinx/OsHle/Objects/TimeISystemClock.cs deleted file mode 100644 index d9a3a073..00000000 --- a/Ryujinx/OsHle/Objects/TimeISystemClock.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace Ryujinx.OsHle.Objects -{ - class TimeISystemClock - { - private static DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - - public static long GetCurrentTime(ServiceCtx Context) - { - Context.ResponseData.Write((long)(DateTime.Now - Epoch).TotalSeconds); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/TimeITimeZoneService.cs b/Ryujinx/OsHle/Objects/TimeITimeZoneService.cs deleted file mode 100644 index af5490a6..00000000 --- a/Ryujinx/OsHle/Objects/TimeITimeZoneService.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class TimeITimeZoneService - { - - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Vi/IApplicationDisplayService.cs b/Ryujinx/OsHle/Objects/Vi/IApplicationDisplayService.cs new file mode 100644 index 00000000..4fa35928 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Vi/IApplicationDisplayService.cs @@ -0,0 +1,176 @@ +using ChocolArm64.Memory; +using Ryujinx.OsHle.Handles; +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; +using System.IO; + +using static Ryujinx.OsHle.Objects.Android.Parcel; +using static Ryujinx.OsHle.Objects.ObjHelper; + +namespace Ryujinx.OsHle.Objects.Vi +{ + class IApplicationDisplayService : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IApplicationDisplayService() + { + m_Commands = new Dictionary() + { + { 100, GetRelayService }, + { 101, GetSystemDisplayService }, + { 102, GetManagerDisplayService }, + { 103, GetIndirectDisplayTransactionService }, + { 1010, OpenDisplay }, + { 2020, OpenLayer }, + { 2030, CreateStrayLayer }, + { 2101, SetLayerScalingMode }, + { 5202, GetDisplayVSyncEvent } + }; + } + + public long GetRelayService(ServiceCtx Context) + { + MakeObject(Context, new IHOSBinderDriver()); + + return 0; + } + + public long GetSystemDisplayService(ServiceCtx Context) + { + MakeObject(Context, new ISystemDisplayService()); + + return 0; + } + + public long GetManagerDisplayService(ServiceCtx Context) + { + MakeObject(Context, new IManagerDisplayService()); + + return 0; + } + + public long GetIndirectDisplayTransactionService(ServiceCtx Context) + { + MakeObject(Context, new IHOSBinderDriver()); + + return 0; + } + + public long OpenDisplay(ServiceCtx Context) + { + string Name = GetDisplayName(Context); + + long DisplayId = Context.Ns.Os.Displays.GenerateId(new Display(Name)); + + Context.ResponseData.Write(DisplayId); + + return 0; + } + + public long OpenLayer(ServiceCtx Context) + { + long LayerId = Context.RequestData.ReadInt64(); + long UserId = Context.RequestData.ReadInt64(); + + long ParcelPtr = Context.Request.ReceiveBuff[0].Position; + + byte[] Parcel = MakeIGraphicsBufferProducer(ParcelPtr); + + AMemoryHelper.WriteBytes(Context.Memory, ParcelPtr, Parcel); + + Context.ResponseData.Write((long)Parcel.Length); + + return 0; + } + + public long CreateStrayLayer(ServiceCtx Context) + { + long LayerFlags = Context.RequestData.ReadInt64(); + long DisplayId = Context.RequestData.ReadInt64(); + + long ParcelPtr = Context.Request.ReceiveBuff[0].Position; + + Display Disp = Context.Ns.Os.Displays.GetData((int)DisplayId); + + byte[] Parcel = MakeIGraphicsBufferProducer(ParcelPtr); + + AMemoryHelper.WriteBytes(Context.Memory, ParcelPtr, Parcel); + + Context.ResponseData.Write(0L); + Context.ResponseData.Write((long)Parcel.Length); + + return 0; + } + + public long SetLayerScalingMode(ServiceCtx Context) + { + int ScalingMode = Context.RequestData.ReadInt32(); + long Unknown = Context.RequestData.ReadInt64(); + + return 0; + } + + public long GetDisplayVSyncEvent(ServiceCtx Context) + { + string Name = GetDisplayName(Context); + + int Handle = Context.Ns.Os.Handles.GenerateId(new HEvent()); + + Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); + + return 0; + } + + private byte[] MakeIGraphicsBufferProducer(long BasePtr) + { + long Id = 0x20; + long CookiePtr = 0L; + + using (MemoryStream MS = new MemoryStream()) + { + BinaryWriter Writer = new BinaryWriter(MS); + + //flat_binder_object (size is 0x28) + Writer.Write(2); //Type (BINDER_TYPE_WEAK_BINDER) + Writer.Write(0); //Flags + Writer.Write((int)(Id >> 0)); + Writer.Write((int)(Id >> 32)); + Writer.Write((int)(CookiePtr >> 0)); + Writer.Write((int)(CookiePtr >> 32)); + Writer.Write((byte)'d'); + Writer.Write((byte)'i'); + Writer.Write((byte)'s'); + Writer.Write((byte)'p'); + Writer.Write((byte)'d'); + Writer.Write((byte)'r'); + Writer.Write((byte)'v'); + Writer.Write((byte)'\0'); + Writer.Write(0L); //Pad + + return MakeParcel(MS.ToArray(), new byte[] { 0, 0, 0, 0 }); + } + } + + private string GetDisplayName(ServiceCtx Context) + { + string Name = string.Empty; + + for (int Index = 0; Index < 8 && + Context.RequestData.BaseStream.Position < + Context.RequestData.BaseStream.Length; Index++) + { + byte Chr = Context.RequestData.ReadByte(); + + if (Chr >= 0x20 && Chr < 0x7f) + { + Name += (char)Chr; + } + } + + return Name; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Vi/IHOSBinderDriver.cs b/Ryujinx/OsHle/Objects/Vi/IHOSBinderDriver.cs new file mode 100644 index 00000000..3c3211c7 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Vi/IHOSBinderDriver.cs @@ -0,0 +1,221 @@ +using ChocolArm64.Memory; +using Ryujinx.OsHle.Handles; +using Ryujinx.OsHle.Ipc; +using Ryujinx.OsHle.Utilities; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +using static Ryujinx.OsHle.Objects.Android.Parcel; + +namespace Ryujinx.OsHle.Objects.Vi +{ + class IHOSBinderDriver : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + private delegate long ServiceProcessRequest2(ServiceCtx Context, byte[] ParcelData); + + private Dictionary<(string, int), ServiceProcessRequest2> InterfaceMthd = + new Dictionary<(string, int), ServiceProcessRequest2>() + { + { ("android.gui.IGraphicBufferProducer", 0x1), GraphicBufferProducerRequestBuffer }, + { ("android.gui.IGraphicBufferProducer", 0x3), GraphicBufferProducerDequeueBuffer }, + { ("android.gui.IGraphicBufferProducer", 0x7), GraphicBufferProducerQueueBuffer }, + //{ ("android.gui.IGraphicBufferProducer", 0x8), GraphicBufferProducerCancelBuffer }, + { ("android.gui.IGraphicBufferProducer", 0x9), GraphicBufferProducerQuery }, + { ("android.gui.IGraphicBufferProducer", 0xa), GraphicBufferProducerConnect }, + { ("android.gui.IGraphicBufferProducer", 0xe), GraphicBufferPreallocateBuffer }, + }; + + private class BufferObj + { + + } + + public IdPoolWithObj BufferSlots { get; private set; } + + public byte[] Gbfr; + + public IHOSBinderDriver() + { + m_Commands = new Dictionary() + { + { 0, TransactParcel }, + { 1, AdjustRefcount }, + { 2, GetNativeHandle } + }; + + BufferSlots = new IdPoolWithObj(); + } + + public long TransactParcel(ServiceCtx Context) + { + int Id = Context.RequestData.ReadInt32(); + int Code = Context.RequestData.ReadInt32(); + + long DataPos = Context.Request.SendBuff[0].Position; + long DataSize = Context.Request.SendBuff[0].Size; + + byte[] Data = AMemoryHelper.ReadBytes(Context.Memory, DataPos, (int)DataSize); + + Data = GetParcelData(Data); + + using (MemoryStream MS = new MemoryStream(Data)) + { + BinaryReader Reader = new BinaryReader(MS); + + MS.Seek(4, SeekOrigin.Current); + + int StrSize = Reader.ReadInt32(); + + string InterfaceName = Encoding.Unicode.GetString(Data, 8, StrSize * 2); + + if (InterfaceMthd.TryGetValue((InterfaceName, Code), out ServiceProcessRequest2 ProcReq)) + { + return ProcReq(Context, Data); + } + else + { + throw new NotImplementedException($"{InterfaceName} {Code}"); + } + } + } + + private static long GraphicBufferProducerRequestBuffer(ServiceCtx Context, byte[] ParcelData) + { + IHOSBinderDriver BinderDriver = Context.GetObject(); + + int GbfrSize = BinderDriver.Gbfr?.Length ?? 0; + + byte[] Data = new byte[GbfrSize + 4]; + + if (BinderDriver.Gbfr != null) + { + Buffer.BlockCopy(BinderDriver.Gbfr, 0, Data, 0, GbfrSize); + } + + return MakeReplyParcel(Context, Data); + } + + private static long GraphicBufferProducerDequeueBuffer(ServiceCtx Context, byte[] ParcelData) + { + IHOSBinderDriver BinderDriver = Context.GetObject(); + + //Note: It seems that the maximum number of slots is 64, because if we return + //a Slot number > 63, it seems to cause a buffer overrun and it reads garbage. + //Note 2: The size of each object associated with the slot is 0x30. + int Slot = BinderDriver.BufferSlots.GenerateId(new BufferObj()); + + return MakeReplyParcel(Context, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + + private static long GraphicBufferProducerQueueBuffer(ServiceCtx Context, byte[] ParcelData) + { + return MakeReplyParcel(Context, 1280, 720, 0, 0, 0); + } + + private static long GraphicBufferProducerCancelBuffer(ServiceCtx Context, byte[] ParcelData) + { + IHOSBinderDriver BinderDriver = Context.GetObject(); + + using (MemoryStream MS = new MemoryStream(ParcelData)) + { + BinaryReader Reader = new BinaryReader(MS); + + MS.Seek(0x50, SeekOrigin.Begin); + + int Slot = Reader.ReadInt32(); + + BinderDriver.BufferSlots.Delete(Slot); + + return MakeReplyParcel(Context, 0); + } + } + + private static long GraphicBufferProducerQuery(ServiceCtx Context, byte[] ParcelData) + { + return MakeReplyParcel(Context, 0, 0); + } + + private static long GraphicBufferProducerConnect(ServiceCtx Context, byte[] ParcelData) + { + return MakeReplyParcel(Context, 1280, 720, 0, 0, 0); + } + + private static long GraphicBufferPreallocateBuffer(ServiceCtx Context, byte[] ParcelData) + { + IHOSBinderDriver BinderDriver = Context.GetObject(); + + int GbfrSize = ParcelData.Length - 0x54; + + BinderDriver.Gbfr = new byte[GbfrSize]; + + Buffer.BlockCopy(ParcelData, 0x54, BinderDriver.Gbfr, 0, GbfrSize); + + using (MemoryStream MS = new MemoryStream(ParcelData)) + { + BinaryReader Reader = new BinaryReader(MS); + + MS.Seek(0xd4, SeekOrigin.Begin); + + int Handle = Reader.ReadInt32(); + + HNvMap NvMap = Context.Ns.Os.Handles.GetData(Handle); + + Context.Ns.Gpu.Renderer.FrameBufferPtr = NvMap.Address; + } + + return MakeReplyParcel(Context, 0); + } + + private static long MakeReplyParcel(ServiceCtx Context, params int[] Ints) + { + using (MemoryStream MS = new MemoryStream()) + { + BinaryWriter Writer = new BinaryWriter(MS); + + foreach (int Int in Ints) + { + Writer.Write(Int); + } + + return MakeReplyParcel(Context, MS.ToArray()); + } + } + + private static long MakeReplyParcel(ServiceCtx Context, byte[] Data) + { + long ReplyPos = Context.Request.ReceiveBuff[0].Position; + long ReplySize = Context.Request.ReceiveBuff[0].Position; + + byte[] Reply = MakeParcel(Data, new byte[0]); + + AMemoryHelper.WriteBytes(Context.Memory, ReplyPos, Reply); + + return 0; + } + + public long AdjustRefcount(ServiceCtx Context) + { + int Id = Context.RequestData.ReadInt32(); + int AddVal = Context.RequestData.ReadInt32(); + int Type = Context.RequestData.ReadInt32(); + + return 0; + } + + public long GetNativeHandle(ServiceCtx Context) + { + int Id = Context.RequestData.ReadInt32(); + uint Unk = Context.RequestData.ReadUInt32(); + + Context.Response.HandleDesc = IpcHandleDesc.MakeMove(0xbadcafe); + + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Vi/IManagerDisplayService.cs b/Ryujinx/OsHle/Objects/Vi/IManagerDisplayService.cs new file mode 100644 index 00000000..c2bbf43b --- /dev/null +++ b/Ryujinx/OsHle/Objects/Vi/IManagerDisplayService.cs @@ -0,0 +1,33 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Vi +{ + class IManagerDisplayService : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public IManagerDisplayService() + { + m_Commands = new Dictionary() + { + { 2010, CreateManagedLayer }, + { 6000, AddToLayerStack } + }; + } + + public static long CreateManagedLayer(ServiceCtx Context) + { + Context.ResponseData.Write(0L); //LayerId + + return 0; + } + + public static long AddToLayerStack(ServiceCtx Context) + { + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/Vi/ISystemDisplayService.cs b/Ryujinx/OsHle/Objects/Vi/ISystemDisplayService.cs new file mode 100644 index 00000000..39d19786 --- /dev/null +++ b/Ryujinx/OsHle/Objects/Vi/ISystemDisplayService.cs @@ -0,0 +1,25 @@ +using Ryujinx.OsHle.Ipc; +using System.Collections.Generic; + +namespace Ryujinx.OsHle.Objects.Vi +{ + class ISystemDisplayService : IIpcInterface + { + private Dictionary m_Commands; + + public IReadOnlyDictionary Commands => m_Commands; + + public ISystemDisplayService() + { + m_Commands = new Dictionary() + { + { 2205, SetLayerZ } + }; + } + + public static long SetLayerZ(ServiceCtx Context) + { + return 0; + } + } +} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/ViIApplicationDisplayService.cs b/Ryujinx/OsHle/Objects/ViIApplicationDisplayService.cs deleted file mode 100644 index 174c97b4..00000000 --- a/Ryujinx/OsHle/Objects/ViIApplicationDisplayService.cs +++ /dev/null @@ -1,155 +0,0 @@ -using ChocolArm64.Memory; -using Ryujinx.OsHle.Handles; -using Ryujinx.OsHle.Ipc; -using System.IO; - -using static Ryujinx.OsHle.Objects.Android.Parcel; -using static Ryujinx.OsHle.Objects.ObjHelper; - -namespace Ryujinx.OsHle.Objects -{ - class ViIApplicationDisplayService - { - public static long GetRelayService(ServiceCtx Context) - { - MakeObject(Context, new ViIHOSBinderDriver()); - - return 0; - } - - public static long GetSystemDisplayService(ServiceCtx Context) - { - MakeObject(Context, new ViISystemDisplayService()); - - return 0; - } - - public static long GetManagerDisplayService(ServiceCtx Context) - { - MakeObject(Context, new ViIManagerDisplayService()); - - return 0; - } - - public static long GetIndirectDisplayTransactionService(ServiceCtx Context) - { - MakeObject(Context, new ViIHOSBinderDriver()); - - return 0; - } - - public static long OpenDisplay(ServiceCtx Context) - { - string Name = GetDisplayName(Context); - - long DisplayId = Context.Ns.Os.Displays.GenerateId(new Display(Name)); - - Context.ResponseData.Write(DisplayId); - - return 0; - } - - public static long OpenLayer(ServiceCtx Context) - { - long LayerId = Context.RequestData.ReadInt64(); - long UserId = Context.RequestData.ReadInt64(); - - long ParcelPtr = Context.Request.ReceiveBuff[0].Position; - - byte[] Parcel = MakeIGraphicsBufferProducer(ParcelPtr); - - AMemoryHelper.WriteBytes(Context.Memory, ParcelPtr, Parcel); - - Context.ResponseData.Write((long)Parcel.Length); - - return 0; - } - - public static long CreateStrayLayer(ServiceCtx Context) - { - long LayerFlags = Context.RequestData.ReadInt64(); - long DisplayId = Context.RequestData.ReadInt64(); - - long ParcelPtr = Context.Request.ReceiveBuff[0].Position; - - Display Disp = Context.Ns.Os.Displays.GetData((int)DisplayId); - - byte[] Parcel = MakeIGraphicsBufferProducer(ParcelPtr); - - AMemoryHelper.WriteBytes(Context.Memory, ParcelPtr, Parcel); - - Context.ResponseData.Write(0L); - Context.ResponseData.Write((long)Parcel.Length); - - return 0; - } - - public static long SetLayerScalingMode(ServiceCtx Context) - { - int ScalingMode = Context.RequestData.ReadInt32(); - long Unknown = Context.RequestData.ReadInt64(); - - return 0; - } - - public static long GetDisplayVSyncEvent(ServiceCtx Context) - { - string Name = GetDisplayName(Context); - - int Handle = Context.Ns.Os.Handles.GenerateId(new HEvent()); - - Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle); - - return 0; - } - - private static byte[] MakeIGraphicsBufferProducer(long BasePtr) - { - long Id = 0x20; - long CookiePtr = 0L; - - using (MemoryStream MS = new MemoryStream()) - { - BinaryWriter Writer = new BinaryWriter(MS); - - //flat_binder_object (size is 0x28) - Writer.Write(2); //Type (BINDER_TYPE_WEAK_BINDER) - Writer.Write(0); //Flags - Writer.Write((int)(Id >> 0)); - Writer.Write((int)(Id >> 32)); - Writer.Write((int)(CookiePtr >> 0)); - Writer.Write((int)(CookiePtr >> 32)); - Writer.Write((byte)'d'); - Writer.Write((byte)'i'); - Writer.Write((byte)'s'); - Writer.Write((byte)'p'); - Writer.Write((byte)'d'); - Writer.Write((byte)'r'); - Writer.Write((byte)'v'); - Writer.Write((byte)'\0'); - Writer.Write(0L); //Pad - - return MakeParcel(MS.ToArray(), new byte[] { 0, 0, 0, 0 }); - } - } - - private static string GetDisplayName(ServiceCtx Context) - { - string Name = string.Empty; - - for (int Index = 0; Index < 8 && - Context.RequestData.BaseStream.Position < - Context.RequestData.BaseStream.Length; Index++) - { - byte Chr = Context.RequestData.ReadByte(); - - if (Chr >= 0x20 && Chr < 0x7f) - { - Name += (char)Chr; - } - } - - return Name; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/ViIHOSBinderDriver.cs b/Ryujinx/OsHle/Objects/ViIHOSBinderDriver.cs deleted file mode 100644 index 13393eaf..00000000 --- a/Ryujinx/OsHle/Objects/ViIHOSBinderDriver.cs +++ /dev/null @@ -1,210 +0,0 @@ -using ChocolArm64.Memory; -using Ryujinx.OsHle.Handles; -using Ryujinx.OsHle.Ipc; -using Ryujinx.OsHle.Utilities; -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -using static Ryujinx.OsHle.Objects.Android.Parcel; - -namespace Ryujinx.OsHle.Objects -{ - class ViIHOSBinderDriver - { - private delegate long ServiceProcessRequest(ServiceCtx Context, byte[] ParcelData); - - private static Dictionary<(string, int), ServiceProcessRequest> InterfaceMthd = - new Dictionary<(string, int), ServiceProcessRequest>() - { - { ("android.gui.IGraphicBufferProducer", 0x1), GraphicBufferProducerRequestBuffer }, - { ("android.gui.IGraphicBufferProducer", 0x3), GraphicBufferProducerDequeueBuffer }, - { ("android.gui.IGraphicBufferProducer", 0x7), GraphicBufferProducerQueueBuffer }, - //{ ("android.gui.IGraphicBufferProducer", 0x8), GraphicBufferProducerCancelBuffer }, - { ("android.gui.IGraphicBufferProducer", 0x9), GraphicBufferProducerQuery }, - { ("android.gui.IGraphicBufferProducer", 0xa), GraphicBufferProducerConnect }, - { ("android.gui.IGraphicBufferProducer", 0xe), GraphicBufferPreallocateBuffer }, - }; - - private class BufferObj - { - - } - - public IdPoolWithObj BufferSlots { get; private set; } - - public byte[] Gbfr; - - public ViIHOSBinderDriver() - { - BufferSlots = new IdPoolWithObj(); - } - - public static long TransactParcel(ServiceCtx Context) - { - int Id = Context.RequestData.ReadInt32(); - int Code = Context.RequestData.ReadInt32(); - - long DataPos = Context.Request.SendBuff[0].Position; - long DataSize = Context.Request.SendBuff[0].Size; - - byte[] Data = AMemoryHelper.ReadBytes(Context.Memory, DataPos, (int)DataSize); - - Data = GetParcelData(Data); - - using (MemoryStream MS = new MemoryStream(Data)) - { - BinaryReader Reader = new BinaryReader(MS); - - MS.Seek(4, SeekOrigin.Current); - - int StrSize = Reader.ReadInt32(); - - string InterfaceName = Encoding.Unicode.GetString(Data, 8, StrSize * 2); - - if (InterfaceMthd.TryGetValue((InterfaceName, Code), out ServiceProcessRequest ProcReq)) - { - return ProcReq(Context, Data); - } - else - { - throw new NotImplementedException($"{InterfaceName} {Code}"); - } - } - } - - private static long GraphicBufferProducerRequestBuffer(ServiceCtx Context, byte[] ParcelData) - { - ViIHOSBinderDriver BinderDriver = Context.GetObject(); - - int GbfrSize = BinderDriver.Gbfr?.Length ?? 0; - - byte[] Data = new byte[GbfrSize + 4]; - - if (BinderDriver.Gbfr != null) - { - Buffer.BlockCopy(BinderDriver.Gbfr, 0, Data, 0, GbfrSize); - } - - return MakeReplyParcel(Context, Data); - } - - private static long GraphicBufferProducerDequeueBuffer(ServiceCtx Context, byte[] ParcelData) - { - ViIHOSBinderDriver BinderDriver = Context.GetObject(); - - //Note: It seems that the maximum number of slots is 64, because if we return - //a Slot number > 63, it seems to cause a buffer overrun and it reads garbage. - //Note 2: The size of each object associated with the slot is 0x30. - int Slot = BinderDriver.BufferSlots.GenerateId(new BufferObj()); - - return MakeReplyParcel(Context, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - } - - private static long GraphicBufferProducerQueueBuffer(ServiceCtx Context, byte[] ParcelData) - { - return MakeReplyParcel(Context, 1280, 720, 0, 0, 0); - } - - private static long GraphicBufferProducerCancelBuffer(ServiceCtx Context, byte[] ParcelData) - { - ViIHOSBinderDriver BinderDriver = Context.GetObject(); - - using (MemoryStream MS = new MemoryStream(ParcelData)) - { - BinaryReader Reader = new BinaryReader(MS); - - MS.Seek(0x50, SeekOrigin.Begin); - - int Slot = Reader.ReadInt32(); - - BinderDriver.BufferSlots.Delete(Slot); - - return MakeReplyParcel(Context, 0); - } - } - - private static long GraphicBufferProducerQuery(ServiceCtx Context, byte[] ParcelData) - { - return MakeReplyParcel(Context, 0, 0); - } - - private static long GraphicBufferProducerConnect(ServiceCtx Context, byte[] ParcelData) - { - return MakeReplyParcel(Context, 1280, 720, 0, 0, 0); - } - - private static long GraphicBufferPreallocateBuffer(ServiceCtx Context, byte[] ParcelData) - { - ViIHOSBinderDriver BinderDriver = Context.GetObject(); - - int GbfrSize = ParcelData.Length - 0x54; - - BinderDriver.Gbfr = new byte[GbfrSize]; - - Buffer.BlockCopy(ParcelData, 0x54, BinderDriver.Gbfr, 0, GbfrSize); - - using (MemoryStream MS = new MemoryStream(ParcelData)) - { - BinaryReader Reader = new BinaryReader(MS); - - MS.Seek(0xd4, SeekOrigin.Begin); - - int Handle = Reader.ReadInt32(); - - HNvMap NvMap = Context.Ns.Os.Handles.GetData(Handle); - - Context.Ns.Gpu.Renderer.FrameBufferPtr = NvMap.Address; - } - - return MakeReplyParcel(Context, 0); - } - - private static long MakeReplyParcel(ServiceCtx Context, params int[] Ints) - { - using (MemoryStream MS = new MemoryStream()) - { - BinaryWriter Writer = new BinaryWriter(MS); - - foreach (int Int in Ints) - { - Writer.Write(Int); - } - - return MakeReplyParcel(Context, MS.ToArray()); - } - } - - private static long MakeReplyParcel(ServiceCtx Context, byte[] Data) - { - long ReplyPos = Context.Request.ReceiveBuff[0].Position; - long ReplySize = Context.Request.ReceiveBuff[0].Position; - - byte[] Reply = MakeParcel(Data, new byte[0]); - - AMemoryHelper.WriteBytes(Context.Memory, ReplyPos, Reply); - - return 0; - } - - public static long AdjustRefcount(ServiceCtx Context) - { - int Id = Context.RequestData.ReadInt32(); - int AddVal = Context.RequestData.ReadInt32(); - int Type = Context.RequestData.ReadInt32(); - - return 0; - } - - public static long GetNativeHandle(ServiceCtx Context) - { - int Id = Context.RequestData.ReadInt32(); - uint Unk = Context.RequestData.ReadUInt32(); - - Context.Response.HandleDesc = IpcHandleDesc.MakeMove(0xbadcafe); - - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/ViIManagerDisplayService.cs b/Ryujinx/OsHle/Objects/ViIManagerDisplayService.cs deleted file mode 100644 index 0fdca3ba..00000000 --- a/Ryujinx/OsHle/Objects/ViIManagerDisplayService.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class ViIManagerDisplayService - { - public static long CreateManagedLayer(ServiceCtx Context) - { - Context.ResponseData.Write(0L); //LayerId - - return 0; - } - - public static long AddToLayerStack(ServiceCtx Context) - { - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Objects/ViISystemDisplayService.cs b/Ryujinx/OsHle/Objects/ViISystemDisplayService.cs deleted file mode 100644 index 8d3a51f4..00000000 --- a/Ryujinx/OsHle/Objects/ViISystemDisplayService.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Ryujinx.OsHle.Objects -{ - class ViISystemDisplayService - { - public static long SetLayerZ(ServiceCtx Context) - { - return 0; - } - } -} \ No newline at end of file diff --git a/Ryujinx/OsHle/Services/ServiceAcc.cs b/Ryujinx/OsHle/Services/ServiceAcc.cs index 14a3e83e..632fb41c 100644 --- a/Ryujinx/OsHle/Services/ServiceAcc.cs +++ b/Ryujinx/OsHle/Services/ServiceAcc.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Acc; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -13,7 +13,7 @@ namespace Ryujinx.OsHle.Services public static long AccU0GetProfile(ServiceCtx Context) { - MakeObject(Context, new AccIProfile()); + MakeObject(Context, new IProfile()); return 0; } @@ -25,7 +25,7 @@ namespace Ryujinx.OsHle.Services public static long AccU0GetBaasAccountManagerForApplication(ServiceCtx Context) { - MakeObject(Context, new AccIManagerForApplication()); + MakeObject(Context, new IManagerForApplication()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceApm.cs b/Ryujinx/OsHle/Services/ServiceApm.cs index f0df462b..81e68680 100644 --- a/Ryujinx/OsHle/Services/ServiceApm.cs +++ b/Ryujinx/OsHle/Services/ServiceApm.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Apm; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -8,7 +8,7 @@ namespace Ryujinx.OsHle.Services { public static long ApmOpenSession(ServiceCtx Context) { - MakeObject(Context, new ApmISession()); + MakeObject(Context, new ISession()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceAppletOE.cs b/Ryujinx/OsHle/Services/ServiceAppletOE.cs index 2f98a201..cd0ed92b 100644 --- a/Ryujinx/OsHle/Services/ServiceAppletOE.cs +++ b/Ryujinx/OsHle/Services/ServiceAppletOE.cs @@ -8,7 +8,7 @@ namespace Ryujinx.OsHle.Services { public static long AppletOpenApplicationProxy(ServiceCtx Context) { - MakeObject(Context, new AmIApplicationProxy()); + MakeObject(Context, new IApplicationProxy()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceAud.cs b/Ryujinx/OsHle/Services/ServiceAud.cs index 18401ae9..6d1367cf 100644 --- a/Ryujinx/OsHle/Services/ServiceAud.cs +++ b/Ryujinx/OsHle/Services/ServiceAud.cs @@ -1,5 +1,5 @@ using ChocolArm64.Memory; -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Aud; using System.Text; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -21,7 +21,7 @@ namespace Ryujinx.OsHle.Services public static long AudOutOpenAudioOut(ServiceCtx Context) { - MakeObject(Context, new AudIAudioOut()); + MakeObject(Context, new IAudioOut()); Context.ResponseData.Write(48000); //Sample Rate Context.ResponseData.Write(2); //Channel Count @@ -42,7 +42,7 @@ namespace Ryujinx.OsHle.Services public static long AudRenOpenAudioRenderer(ServiceCtx Context) { - MakeObject(Context, new AudIAudioRenderer()); + MakeObject(Context, new IAudioRenderer()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceFriend.cs b/Ryujinx/OsHle/Services/ServiceFriend.cs index 980d4219..10c23aae 100644 --- a/Ryujinx/OsHle/Services/ServiceFriend.cs +++ b/Ryujinx/OsHle/Services/ServiceFriend.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Friend; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -8,7 +8,7 @@ namespace Ryujinx.OsHle.Services { public static long FriendCreateFriendService(ServiceCtx Context) { - MakeObject(Context, new FriendIFriendService()); + MakeObject(Context, new IFriendService()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceFspSrv.cs b/Ryujinx/OsHle/Services/ServiceFspSrv.cs index 7f431f26..17aa3bda 100644 --- a/Ryujinx/OsHle/Services/ServiceFspSrv.cs +++ b/Ryujinx/OsHle/Services/ServiceFspSrv.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.FspSrv; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -13,28 +13,28 @@ namespace Ryujinx.OsHle.Services public static long FspSrvMountSdCard(ServiceCtx Context) { - MakeObject(Context, new FspSrvIFileSystem(Context.Ns.VFs.GetSdCardPath())); + MakeObject(Context, new IFileSystem(Context.Ns.VFs.GetSdCardPath())); return 0; } public static long FspSrvMountSaveData(ServiceCtx Context) { - MakeObject(Context, new FspSrvIFileSystem(Context.Ns.VFs.GetGameSavesPath())); + MakeObject(Context, new IFileSystem(Context.Ns.VFs.GetGameSavesPath())); return 0; } public static long FspSrvOpenDataStorageByCurrentProcess(ServiceCtx Context) { - MakeObject(Context, new FspSrvIStorage(Context.Ns.VFs.RomFs)); + MakeObject(Context, new IStorage(Context.Ns.VFs.RomFs)); return 0; } public static long FspSrvOpenRomStorage(ServiceCtx Context) { - MakeObject(Context, new FspSrvIStorage(Context.Ns.VFs.RomFs)); + MakeObject(Context, new IStorage(Context.Ns.VFs.RomFs)); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceHid.cs b/Ryujinx/OsHle/Services/ServiceHid.cs index 30093f49..176c7842 100644 --- a/Ryujinx/OsHle/Services/ServiceHid.cs +++ b/Ryujinx/OsHle/Services/ServiceHid.cs @@ -1,5 +1,5 @@ using Ryujinx.OsHle.Handles; -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Hid; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -11,7 +11,7 @@ namespace Ryujinx.OsHle.Services { HSharedMem HidHndData = Context.Ns.Os.Handles.GetData(Context.Ns.Os.HidHandle); - MakeObject(Context, new HidIAppletResource(HidHndData)); + MakeObject(Context, new IAppletResource(HidHndData)); return 0; } diff --git a/Ryujinx/OsHle/Services/ServicePctl.cs b/Ryujinx/OsHle/Services/ServicePctl.cs index 62537f28..a0a5aaf3 100644 --- a/Ryujinx/OsHle/Services/ServicePctl.cs +++ b/Ryujinx/OsHle/Services/ServicePctl.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Am; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -8,7 +8,7 @@ namespace Ryujinx.OsHle.Services { public static long PctlCreateService(ServiceCtx Context) { - MakeObject(Context, new AmIParentalControlService()); + MakeObject(Context, new IParentalControlService()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceTime.cs b/Ryujinx/OsHle/Services/ServiceTime.cs index 2b93e3db..4f8e34e9 100644 --- a/Ryujinx/OsHle/Services/ServiceTime.cs +++ b/Ryujinx/OsHle/Services/ServiceTime.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Time; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -8,28 +8,28 @@ namespace Ryujinx.OsHle.Services { public static long TimeGetStandardUserSystemClock(ServiceCtx Context) { - MakeObject(Context, new TimeISystemClock()); + MakeObject(Context, new ISystemClock()); return 0; } public static long TimeGetStandardNetworkSystemClock(ServiceCtx Context) { - MakeObject(Context, new TimeISystemClock()); + MakeObject(Context, new ISystemClock()); return 0; } public static long TimeGetStandardSteadyClock(ServiceCtx Context) { - MakeObject(Context, new TimeISteadyClock()); + MakeObject(Context, new ISteadyClock()); return 0; } public static long TimeGetTimeZoneService(ServiceCtx Context) { - MakeObject(Context, new TimeITimeZoneService()); + MakeObject(Context, new ITimeZoneService()); return 0; } diff --git a/Ryujinx/OsHle/Services/ServiceVi.cs b/Ryujinx/OsHle/Services/ServiceVi.cs index d5c86bfc..096bc18f 100644 --- a/Ryujinx/OsHle/Services/ServiceVi.cs +++ b/Ryujinx/OsHle/Services/ServiceVi.cs @@ -1,4 +1,4 @@ -using Ryujinx.OsHle.Objects; +using Ryujinx.OsHle.Objects.Vi; using static Ryujinx.OsHle.Objects.ObjHelper; @@ -10,7 +10,7 @@ namespace Ryujinx.OsHle.Services { int Unknown = Context.RequestData.ReadInt32(); - MakeObject(Context, new ViIApplicationDisplayService()); + MakeObject(Context, new IApplicationDisplayService()); return 0; } -- cgit v1.2.3