1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-05 02:42:01 +00:00
Ryujinx/Ryujinx.HLE/Loaders/Executables/KernelInitialProcess.cs

147 lines
4.3 KiB
C#
Raw Normal View History

using Ryujinx.HLE.Loaders.Compression;
using System.IO;
namespace Ryujinx.HLE.Loaders.Executables
{
class KernelInitialProcess : IExecutable
{
public string Name { get; private set; }
Added GUI to Ryujinx (#695) * Added GUI to Ryujinx * Updated to use Glade Also added scrollbar and default dark theme * Added support for loading icon from .nro files and cleaned up the code a bit * Added General Settings Menu (read-only for now) and moved some functionality from MainMenu.cs to ApplicationLibrary.cs * Added custom GUI theme support and changed the defualt theme to one I just wrote * Added GTK to process path, fixed a bug and minor edits * some more edits and a bug fix * general settings menu is now fully functional. also fixed the bug where ryujinx crashes when it trys to load an invalid gamedir * big rewrite * aesthetic changes to General Settings menu * Added Control Settings one day done feature :P * minor changes * 1st wave of changes * 2nd wave of changes * 3rd wave of changes * Cleanup settings ui * minor edits * new about window added, still needs styling * added spin button for new option and tooltips to settings * Game icons and names are now shown in the games list * add nuget package which contains gtk dependencies * requested changes have been changed * put CreateGameWindow on a new thread and stopped destroying the main menu when a game loads * fixed bug that allowed a user to attempt to load multiple games at a time which causes a crash * Added LastPlayed and TimePlayed columns to the game list * Did some testing and fixed some bugs Im not happy with one of the fixes so i will do it properly an upcoming commit * did some more bug testing and fixed another 2 bugs * caught an exception when ryujinx tries to load non-homebrew as homebrew * Large changes Rewrote ApplicationLibrary.cs (added comments too) so any devs reading it wont get eye cancer, also its probably more efficient now. Added 2 new columns (Developer name and application version) to the game list and wrote the logic for it. Ryujinx now loads NRO's TitleName and TitleID from the NACP file instead of the default NPDM. I also killed a lot of bugs * Moved Files moved ApplicationLibrary.cs to Ryujinx.HLE as that is a better place for it. Moved contents of GUI folder to Ui folder and changed the namespaces of the gui files from Ryujinx to Ryujinx.Ui * Added 'Open Ryujinx Folder' button to the file menu and did some small fixes * New features * updated nuget package with missing dlls and changed emmauss' requested changes * fixed some minor issues * all requested changes marked as resolved have been changed * gdkchan's requested changes * fixed an issue with settings window getting chopped on small res * fixed 2 problems caused by rebase * changed the default theme * applied Thog's patch to fix issue on linux * fixed issue caused by rebase * added update check button that runs ryujinx-updater * reads version info from installer and displays it in about menu * changes completed * requested changes changed * fixed issue with default theme * fixed a bug and completed requested changes * added more tooltips and changed some text
2019-09-02 17:03:57 +01:00
public ulong TitleId { get; private set; }
public int ProcessCategory { get; private set; }
public byte MainThreadPriority { get; private set; }
public byte DefaultProcessorId { get; private set; }
public bool Is64Bits { get; private set; }
public bool Addr39Bits { get; private set; }
public bool IsService { get; private set; }
public byte[] Text { get; private set; }
public byte[] Ro { get; private set; }
public byte[] Data { get; private set; }
public int TextOffset { get; private set; }
public int RoOffset { get; private set; }
public int DataOffset { get; private set; }
public int BssOffset { get; private set; }
public int BssSize { get; private set; }
public int MainThreadStackSize { get; private set; }
public int[] Capabilities { get; private set; }
private struct SegmentHeader
{
public int Offset { get; private set; }
public int DecompressedSize { get; private set; }
public int CompressedSize { get; private set; }
public int Attribute { get; private set; }
public SegmentHeader(
int offset,
int decompressedSize,
int compressedSize,
int attribute)
{
Offset = offset;
DecompressedSize = decompressedSize;
CompressedSize = compressedSize;
Attribute = attribute;
}
}
public KernelInitialProcess(Stream input)
{
BinaryReader reader = new BinaryReader(input);
string magic = ReadString(reader, 4);
if (magic != "KIP1")
{
}
Name = ReadString(reader, 12);
Added GUI to Ryujinx (#695) * Added GUI to Ryujinx * Updated to use Glade Also added scrollbar and default dark theme * Added support for loading icon from .nro files and cleaned up the code a bit * Added General Settings Menu (read-only for now) and moved some functionality from MainMenu.cs to ApplicationLibrary.cs * Added custom GUI theme support and changed the defualt theme to one I just wrote * Added GTK to process path, fixed a bug and minor edits * some more edits and a bug fix * general settings menu is now fully functional. also fixed the bug where ryujinx crashes when it trys to load an invalid gamedir * big rewrite * aesthetic changes to General Settings menu * Added Control Settings one day done feature :P * minor changes * 1st wave of changes * 2nd wave of changes * 3rd wave of changes * Cleanup settings ui * minor edits * new about window added, still needs styling * added spin button for new option and tooltips to settings * Game icons and names are now shown in the games list * add nuget package which contains gtk dependencies * requested changes have been changed * put CreateGameWindow on a new thread and stopped destroying the main menu when a game loads * fixed bug that allowed a user to attempt to load multiple games at a time which causes a crash * Added LastPlayed and TimePlayed columns to the game list * Did some testing and fixed some bugs Im not happy with one of the fixes so i will do it properly an upcoming commit * did some more bug testing and fixed another 2 bugs * caught an exception when ryujinx tries to load non-homebrew as homebrew * Large changes Rewrote ApplicationLibrary.cs (added comments too) so any devs reading it wont get eye cancer, also its probably more efficient now. Added 2 new columns (Developer name and application version) to the game list and wrote the logic for it. Ryujinx now loads NRO's TitleName and TitleID from the NACP file instead of the default NPDM. I also killed a lot of bugs * Moved Files moved ApplicationLibrary.cs to Ryujinx.HLE as that is a better place for it. Moved contents of GUI folder to Ui folder and changed the namespaces of the gui files from Ryujinx to Ryujinx.Ui * Added 'Open Ryujinx Folder' button to the file menu and did some small fixes * New features * updated nuget package with missing dlls and changed emmauss' requested changes * fixed some minor issues * all requested changes marked as resolved have been changed * gdkchan's requested changes * fixed an issue with settings window getting chopped on small res * fixed 2 problems caused by rebase * changed the default theme * applied Thog's patch to fix issue on linux * fixed issue caused by rebase * added update check button that runs ryujinx-updater * reads version info from installer and displays it in about menu * changes completed * requested changes changed * fixed issue with default theme * fixed a bug and completed requested changes * added more tooltips and changed some text
2019-09-02 17:03:57 +01:00
TitleId = reader.ReadUInt64();
ProcessCategory = reader.ReadInt32();
MainThreadPriority = reader.ReadByte();
DefaultProcessorId = reader.ReadByte();
byte reserved = reader.ReadByte();
byte flags = reader.ReadByte();
Is64Bits = (flags & 0x08) != 0;
Addr39Bits = (flags & 0x10) != 0;
IsService = (flags & 0x20) != 0;
SegmentHeader[] segments = new SegmentHeader[6];
for (int index = 0; index < segments.Length; index++)
{
segments[index] = new SegmentHeader(
reader.ReadInt32(),
reader.ReadInt32(),
reader.ReadInt32(),
reader.ReadInt32());
}
TextOffset = segments[0].Offset;
RoOffset = segments[1].Offset;
DataOffset = segments[2].Offset;
BssOffset = segments[3].Offset;
BssSize = segments[3].DecompressedSize;
MainThreadStackSize = segments[1].Attribute;
Capabilities = new int[32];
for (int index = 0; index < Capabilities.Length; index++)
{
Capabilities[index] = reader.ReadInt32();
}
input.Seek(0x100, SeekOrigin.Begin);
Text = ReadSegment(segments[0], input);
Ro = ReadSegment(segments[1], input);
Data = ReadSegment(segments[2], input);
}
private byte[] ReadSegment(SegmentHeader header, Stream input)
{
byte[] data = new byte[header.DecompressedSize];
input.Read(data, 0, header.CompressedSize);
BackwardsLz.DecompressInPlace(data, header.CompressedSize);
return data;
}
private static string ReadString(BinaryReader reader, int maxSize)
{
string value = string.Empty;
for (int index = 0; index < maxSize; index++)
{
char chr = (char)reader.ReadByte();
if (chr == '\0')
{
reader.BaseStream.Seek(maxSize - index - 1, SeekOrigin.Current);
break;
}
value += chr;
}
return value;
}
}
}