diff options
| author | Ac_K <Acoustik666@gmail.com> | 2018-02-22 01:51:17 +0100 |
|---|---|---|
| committer | gdkchan <gab.dark.100@gmail.com> | 2018-02-21 21:51:17 -0300 |
| commit | 224211367f52cf514f0608d69056e84a3ef37ff5 (patch) | |
| tree | 9c8658f1dd3224dc7d004075514a8cd566f69e34 | |
| parent | b2f733da7839ff8ba7a70a529cb9eb3eea9f0af6 (diff) | |
Initiale hbmenu.nro support (#32)
* Initiale hbmenu.nro support
Implement missing SetScreenShotPermission object.
Implement missing IsCurrentProcessBeingDebugged in SVC.
Add a Extension variable to Executable.
Add basic support of hbmenu.nro.
* Homebrew.cs correction
| -rw-r--r-- | Ryujinx.Core/Loaders/Executable.cs | 3 | ||||
| -rw-r--r-- | Ryujinx.Core/Loaders/Executables/IExecutable.cs | 8 | ||||
| -rw-r--r-- | Ryujinx.Core/Loaders/Executables/Nro.cs | 4 | ||||
| -rw-r--r-- | Ryujinx.Core/Loaders/Executables/Nso.cs | 4 | ||||
| -rw-r--r-- | Ryujinx.Core/OsHle/Homebrew.cs | 34 | ||||
| -rw-r--r-- | Ryujinx.Core/OsHle/Objects/Am/ISelfController.cs | 8 | ||||
| -rw-r--r-- | Ryujinx.Core/OsHle/Process.cs | 7 | ||||
| -rw-r--r-- | Ryujinx.Core/OsHle/Svc/SvcSystem.cs | 64 |
8 files changed, 103 insertions, 29 deletions
diff --git a/Ryujinx.Core/Loaders/Executable.cs b/Ryujinx.Core/Loaders/Executable.cs index e2660838..25a62136 100644 --- a/Ryujinx.Core/Loaders/Executable.cs +++ b/Ryujinx.Core/Loaders/Executable.cs @@ -13,6 +13,7 @@ namespace Ryujinx.Core.Loaders public long ImageBase { get; private set; } public long ImageEnd { get; private set; } + public Extensions Extension { get; private set; } public Executable(IExecutable Exe, AMemory Memory, long ImageBase) { @@ -46,6 +47,8 @@ namespace Ryujinx.Core.Loaders long EhHdrEndOffset = Memory.ReadInt32(Mod0Offset + 0x14) + Mod0Offset; long ModObjOffset = Memory.ReadInt32(Mod0Offset + 0x18) + Mod0Offset; + Extension = Exe.Extension; + MapBss(BssStartOffset, BssEndOffset - BssStartOffset); ImageEnd = BssEndOffset; diff --git a/Ryujinx.Core/Loaders/Executables/IExecutable.cs b/Ryujinx.Core/Loaders/Executables/IExecutable.cs index 73787b1d..f6aa31ac 100644 --- a/Ryujinx.Core/Loaders/Executables/IExecutable.cs +++ b/Ryujinx.Core/Loaders/Executables/IExecutable.cs @@ -2,6 +2,12 @@ using System.Collections.ObjectModel; namespace Ryujinx.Core.Loaders.Executables { + public enum Extensions + { + NRO, + NSO + } + public interface IExecutable { ReadOnlyCollection<byte> Text { get; } @@ -13,5 +19,7 @@ namespace Ryujinx.Core.Loaders.Executables int ROOffset { get; } int DataOffset { get; } int BssSize { get; } + + Extensions Extension { get; } } }
\ No newline at end of file diff --git a/Ryujinx.Core/Loaders/Executables/Nro.cs b/Ryujinx.Core/Loaders/Executables/Nro.cs index 3cbc4c5d..7f492cc2 100644 --- a/Ryujinx.Core/Loaders/Executables/Nro.cs +++ b/Ryujinx.Core/Loaders/Executables/Nro.cs @@ -20,6 +20,8 @@ namespace Ryujinx.Core.Loaders.Executables public int DataOffset { get; private set; } public int BssSize { get; private set; } + public Extensions Extension { get; private set; } + public Nro(Stream Input) { BinaryReader Reader = new BinaryReader(Input); @@ -47,6 +49,8 @@ namespace Ryujinx.Core.Loaders.Executables this.DataOffset = DataOffset; this.BssSize = BssSize; + this.Extension = Extensions.NRO; + byte[] Read(long Position, int Size) { Input.Seek(Position, SeekOrigin.Begin); diff --git a/Ryujinx.Core/Loaders/Executables/Nso.cs b/Ryujinx.Core/Loaders/Executables/Nso.cs index 7b8bf253..63ae08ae 100644 --- a/Ryujinx.Core/Loaders/Executables/Nso.cs +++ b/Ryujinx.Core/Loaders/Executables/Nso.cs @@ -21,6 +21,8 @@ namespace Ryujinx.Core.Loaders.Executables public int DataOffset { get; private set; } public int BssSize { get; private set; } + public Extensions Extension { get; private set; } + [Flags] private enum NsoFlags { @@ -79,6 +81,8 @@ namespace Ryujinx.Core.Loaders.Executables this.DataOffset = DataMemOffset; this.BssSize = BssSize; + this.Extension = Extensions.NSO; + //Text segment Input.Seek(TextOffset, SeekOrigin.Begin); diff --git a/Ryujinx.Core/OsHle/Homebrew.cs b/Ryujinx.Core/OsHle/Homebrew.cs new file mode 100644 index 00000000..b69b31c9 --- /dev/null +++ b/Ryujinx.Core/OsHle/Homebrew.cs @@ -0,0 +1,34 @@ +using ChocolArm64.Memory; + +namespace Ryujinx.Core.OsHle +{ + public class Homebrew + { + //http://switchbrew.org/index.php?title=Homebrew_ABI + public Homebrew(AMemory Memory, long Position, long MainThreadHandle) + { + //(NbrKeys * LoaderConfigEntrySize) + 2 buffers for Key2 + long Size = (4 * 0x18) + 0x1000; + Memory.Manager.MapPhys(Position, Size, (int)MemoryType.Normal, AMemoryPerm.RW); + + //MainThreadHandle + WriteConfigEntry(Memory, ref Position, 1, 0, MainThreadHandle); + //NextLoadPath + WriteConfigEntry(Memory, ref Position, 2, 0, Position + Size, Position + Size + 0x200); + //AppletType + WriteConfigEntry(Memory, ref Position, 7); + //EndOfList + WriteConfigEntry(Memory, ref Position, 0); + } + + private void WriteConfigEntry(AMemory Memory, ref long Position, int Key, int Flags = 0, long Value0 = 0L, long Value1 = 0L) + { + Memory.WriteInt32(Position + 0x00, Key); + Memory.WriteInt32(Position + 0x04, Flags); + Memory.WriteInt64(Position + 0x08, Value0); + Memory.WriteInt64(Position + 0x10, Value1); + + Position += 0x18; + } + } +} diff --git a/Ryujinx.Core/OsHle/Objects/Am/ISelfController.cs b/Ryujinx.Core/OsHle/Objects/Am/ISelfController.cs index 691bb202..712874e8 100644 --- a/Ryujinx.Core/OsHle/Objects/Am/ISelfController.cs +++ b/Ryujinx.Core/OsHle/Objects/Am/ISelfController.cs @@ -13,6 +13,7 @@ namespace Ryujinx.Core.OsHle.Objects.Am { m_Commands = new Dictionary<int, ServiceProcessRequest>() { + { 10, SetScreenShotPermission }, { 11, SetOperationModeChangedNotification }, { 12, SetPerformanceModeChangedNotification }, { 13, SetFocusHandlingMode }, @@ -20,6 +21,13 @@ namespace Ryujinx.Core.OsHle.Objects.Am }; } + public long SetScreenShotPermission(ServiceCtx Context) + { + bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; + + return 0; + } + public long SetOperationModeChangedNotification(ServiceCtx Context) { bool Enable = Context.RequestData.ReadByte() != 0 ? true : false; diff --git a/Ryujinx.Core/OsHle/Process.cs b/Ryujinx.Core/OsHle/Process.cs index 84267885..022dc0f9 100644 --- a/Ryujinx.Core/OsHle/Process.cs +++ b/Ryujinx.Core/OsHle/Process.cs @@ -186,6 +186,13 @@ namespace Ryujinx.Core.OsHle Thread.ThreadState.X1 = (ulong)Handle; Thread.ThreadState.X31 = (ulong)StackTop; + if (Executables[0].Extension == Extensions.NRO) + { + Homebrew Homebrew_ABI = new Homebrew(Memory, Executables[0].ImageEnd, (long)Handle); + Thread.ThreadState.X0 = (ulong)Executables[0].ImageEnd; + Thread.ThreadState.X1 = 0xFFFFFFFFFFFFFFFF; + } + Thread.WorkFinished += ThreadFinished; ThreadsByTpidr.TryAdd(Thread.ThreadState.Tpidr, ThreadHnd); diff --git a/Ryujinx.Core/OsHle/Svc/SvcSystem.cs b/Ryujinx.Core/OsHle/Svc/SvcSystem.cs index 40369b99..f33d2ac8 100644 --- a/Ryujinx.Core/OsHle/Svc/SvcSystem.cs +++ b/Ryujinx.Core/OsHle/Svc/SvcSystem.cs @@ -161,17 +161,18 @@ namespace Ryujinx.Core.OsHle.Svc switch (InfoType) { - case 2: ThreadState.X1 = GetMapRegionBaseAddr(); break; - case 3: ThreadState.X1 = GetMapRegionSize(); break; - case 4: ThreadState.X1 = GetHeapRegionBaseAddr(); break; - case 5: ThreadState.X1 = GetHeapRegionSize(); break; - case 6: ThreadState.X1 = GetTotalMem(); break; - case 7: ThreadState.X1 = GetUsedMem(); break; - case 11: ThreadState.X1 = GetRnd64(); break; - case 12: ThreadState.X1 = GetAddrSpaceBaseAddr(); break; - case 13: ThreadState.X1 = GetAddrSpaceSize(); break; - case 14: ThreadState.X1 = GetMapRegionBaseAddr(); break; - case 15: ThreadState.X1 = GetMapRegionSize(); break; + case 2: ThreadState.X1 = GetMapRegionBaseAddr(); break; + case 3: ThreadState.X1 = GetMapRegionSize(); break; + case 4: ThreadState.X1 = GetHeapRegionBaseAddr(); break; + case 5: ThreadState.X1 = GetHeapRegionSize(); break; + case 6: ThreadState.X1 = GetTotalMem(); break; + case 7: ThreadState.X1 = GetUsedMem(); break; + case 8: ThreadState.X1 = IsCurrentProcessBeingDebugged(); break; + case 11: ThreadState.X1 = GetRnd64(); break; + case 12: ThreadState.X1 = GetAddrSpaceBaseAddr(); break; + case 13: ThreadState.X1 = GetAddrSpaceSize(); break; + case 14: ThreadState.X1 = GetMapRegionBaseAddr(); break; + case 15: ThreadState.X1 = GetMapRegionSize(); break; default: throw new NotImplementedException($"SvcGetInfo: {InfoType} {Handle} {InfoId}"); } @@ -179,49 +180,54 @@ namespace Ryujinx.Core.OsHle.Svc ThreadState.X0 = (int)SvcResult.Success; } - private ulong GetTotalMem() + private ulong GetMapRegionBaseAddr() { - return (ulong)Memory.Manager.GetTotalMemorySize(); + return 0x80000000; } - private ulong GetUsedMem() + private ulong GetMapRegionSize() { - return (ulong)Memory.Manager.GetUsedMemorySize(); + return 0x40000000; } - private ulong GetRnd64() + private ulong GetHeapRegionBaseAddr() { - return (ulong)Rng.Next() + ((ulong)Rng.Next() << 32); + return GetMapRegionBaseAddr() + GetMapRegionSize(); } - private ulong GetAddrSpaceBaseAddr() + private ulong GetHeapRegionSize() { - return 0x08000000; + return 0x40000000; } - private ulong GetAddrSpaceSize() + private ulong GetTotalMem() { - return AMemoryMgr.AddrSize - GetAddrSpaceBaseAddr(); + return (ulong)Memory.Manager.GetTotalMemorySize(); } - private ulong GetMapRegionBaseAddr() + private ulong GetUsedMem() { - return 0x80000000; + return (ulong)Memory.Manager.GetUsedMemorySize(); } - private ulong GetMapRegionSize() + private ulong IsCurrentProcessBeingDebugged() { - return 0x40000000; + return (ulong)0; } - private ulong GetHeapRegionBaseAddr() + private ulong GetRnd64() { - return GetMapRegionBaseAddr() + GetMapRegionSize(); + return (ulong)Rng.Next() + ((ulong)Rng.Next() << 32); } - private ulong GetHeapRegionSize() + private ulong GetAddrSpaceBaseAddr() { - return 0x40000000; + return 0x08000000; + } + + private ulong GetAddrSpaceSize() + { + return AMemoryMgr.AddrSize - GetAddrSpaceBaseAddr(); } } }
\ No newline at end of file |
