mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-27 02:01:22 -08:00
fb1d9493a3
* Rename enum fields
* Naming conventions
* Remove unneeded ".this"
* Remove unneeded semicolons
* Remove unused Usings
* Don't use var
* Remove unneeded enum underlying types
* Explicitly label class visibility
* Remove unneeded @ prefixes
* Remove unneeded commas
* Remove unneeded if expressions
* Method doesn't use unsafe code
* Remove unneeded casts
* Initialized objects don't need an empty constructor
* Remove settings from DotSettings
* Revert "Explicitly label class visibility"
This reverts commit ad5eb5787c
.
* Small changes
* Revert external enum renaming
* Changes from feedback
* Apply previous refactorings to the merged code
78 lines
2.2 KiB
C#
78 lines
2.2 KiB
C#
using ChocolArm64.Memory;
|
|
using System.Text;
|
|
|
|
namespace Ryujinx.HLE.HOS
|
|
{
|
|
static class Homebrew
|
|
{
|
|
public const string TemporaryNroSuffix = ".ryu_tmp.nro";
|
|
|
|
//http://switchbrew.org/index.php?title=Homebrew_ABI
|
|
public static void WriteHbAbiData(MemoryManager memory, long position, int mainThreadHandle, string switchPath)
|
|
{
|
|
//MainThreadHandle.
|
|
WriteConfigEntry(memory, ref position, 1, 0, mainThreadHandle);
|
|
|
|
//NextLoadPath.
|
|
WriteConfigEntry(memory, ref position, 2, 0, position + 0x200, position + 0x400);
|
|
|
|
//Argv.
|
|
long argvPosition = position + 0xC00;
|
|
|
|
memory.WriteBytes(argvPosition, Encoding.ASCII.GetBytes(switchPath + "\0"));
|
|
|
|
WriteConfigEntry(memory, ref position, 5, 0, 0, argvPosition);
|
|
|
|
//AppletType.
|
|
WriteConfigEntry(memory, ref position, 7);
|
|
|
|
//EndOfList.
|
|
WriteConfigEntry(memory, ref position, 0);
|
|
}
|
|
|
|
private static void WriteConfigEntry(
|
|
MemoryManager memory,
|
|
ref long position,
|
|
int key,
|
|
int flags = 0,
|
|
long value0 = 0,
|
|
long value1 = 0)
|
|
{
|
|
memory.WriteInt32(position + 0x00, key);
|
|
memory.WriteInt32(position + 0x04, flags);
|
|
memory.WriteInt64(position + 0x08, value0);
|
|
memory.WriteInt64(position + 0x10, value1);
|
|
|
|
position += 0x18;
|
|
}
|
|
|
|
public static string ReadHbAbiNextLoadPath(MemoryManager memory, long position)
|
|
{
|
|
string fileName = null;
|
|
|
|
while (true)
|
|
{
|
|
long key = memory.ReadInt64(position);
|
|
|
|
if (key == 2)
|
|
{
|
|
long value0 = memory.ReadInt64(position + 0x08);
|
|
long value1 = memory.ReadInt64(position + 0x10);
|
|
|
|
fileName = MemoryHelper.ReadAsciiString(memory, value0, value1 - value0);
|
|
|
|
break;
|
|
}
|
|
else if (key == 0)
|
|
{
|
|
break;
|
|
}
|
|
|
|
position += 0x18;
|
|
}
|
|
|
|
return fileName;
|
|
}
|
|
}
|
|
}
|