public bool Run(bool NeedsHbAbi = false) { if (Disposed) { throw new ObjectDisposedException(nameof(Process)); } this.NeedsHbAbi = NeedsHbAbi; if (Executables.Count == 0) { return(false); } MakeSymbolTable(); MapRWMemRegion( MemoryRegions.MainStackAddress, MemoryRegions.MainStackSize, MemoryType.Normal); long StackTop = MemoryRegions.MainStackAddress + MemoryRegions.MainStackSize; int Handle = MakeThread(Executables[0].ImageBase, StackTop, 0, 44, 0); if (Handle == -1) { return(false); } MainThread = HandleTable.GetData <KThread>(Handle); if (NeedsHbAbi) { HbAbiDataPosition = AMemoryHelper.PageRoundUp(Executables[0].ImageEnd); string SwitchPath = Ns.VFs.SystemPathToSwitchPath(Executables[0].FilePath); Homebrew.WriteHbAbiData(Memory, HbAbiDataPosition, Handle, SwitchPath); MainThread.Thread.ThreadState.X0 = (ulong)HbAbiDataPosition; MainThread.Thread.ThreadState.X1 = ulong.MaxValue; } Scheduler.StartThread(MainThread); return(true); }
public bool Run(bool NeedsHbAbi = false) { if (Disposed) { throw new ObjectDisposedException(nameof(Process)); } this.NeedsHbAbi = NeedsHbAbi; if (Executables.Count == 0) { return(false); } MakeSymbolTable(); long MainStackTop = MemoryManager.CodeRegionEnd - KMemoryManager.PageSize; long MainStackSize = 1 * 1024 * 1024; long MainStackBottom = MainStackTop - MainStackSize; MemoryManager.HleMapCustom( MainStackBottom, MainStackSize, MemoryState.MappedMemory, MemoryPermission.ReadAndWrite); int Handle = MakeThread(Executables[0].ImageBase, MainStackTop, 0, 44, 0); if (Handle == -1) { return(false); } KThread MainThread = HandleTable.GetData <KThread>(Handle); if (NeedsHbAbi) { HbAbiDataPosition = IntUtils.AlignUp(Executables[0].ImageEnd, KMemoryManager.PageSize); const long HbAbiDataSize = KMemoryManager.PageSize; MemoryManager.HleMapCustom( HbAbiDataPosition, HbAbiDataSize, MemoryState.MappedMemory, MemoryPermission.ReadAndWrite); string SwitchPath = Device.FileSystem.SystemPathToSwitchPath(Executables[0].FilePath); Homebrew.WriteHbAbiData(Memory, HbAbiDataPosition, Handle, SwitchPath); MainThread.Thread.ThreadState.X0 = (ulong)HbAbiDataPosition; MainThread.Thread.ThreadState.X1 = ulong.MaxValue; } MainThread.TimeUp(); return(true); }