Homebrew.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. using ChocolArm64.Memory;
  2. namespace Ryujinx.Core.OsHle
  3. {
  4. public class Homebrew
  5. {
  6. //http://switchbrew.org/index.php?title=Homebrew_ABI
  7. public Homebrew(AMemory Memory, long Position, long MainThreadHandle)
  8. {
  9. //(NbrKeys * LoaderConfigEntrySize) + 2 buffers for Key2
  10. long Size = (4 * 0x18) + 0x1000;
  11. Memory.Manager.MapPhys(Position, Size, (int)MemoryType.Normal, AMemoryPerm.RW);
  12. //MainThreadHandle
  13. WriteConfigEntry(Memory, ref Position, 1, 0, MainThreadHandle);
  14. //NextLoadPath
  15. WriteConfigEntry(Memory, ref Position, 2, 0, Position + Size, Position + Size + 0x200);
  16. //AppletType
  17. WriteConfigEntry(Memory, ref Position, 7);
  18. //EndOfList
  19. WriteConfigEntry(Memory, ref Position, 0);
  20. }
  21. private void WriteConfigEntry(AMemory Memory, ref long Position, int Key, int Flags = 0, long Value0 = 0L, long Value1 = 0L)
  22. {
  23. Memory.WriteInt32(Position + 0x00, Key);
  24. Memory.WriteInt32(Position + 0x04, Flags);
  25. Memory.WriteInt64(Position + 0x08, Value0);
  26. Memory.WriteInt64(Position + 0x10, Value1);
  27. Position += 0x18;
  28. }
  29. }
  30. }