From dad85b87c391f5521bedb14f216da436f12c951c Mon Sep 17 00:00:00 2001 From: ParantezTech Date: Sun, 21 Jun 2026 23:19:16 +0300 Subject: [PATCH] [video] Add game title to window --- src/SharpEmu.Core/Loader/SelfImage.cs | 14 +++++++++- src/SharpEmu.Core/Loader/SelfLoader.cs | 28 +++++++++++++------- src/SharpEmu.Core/Runtime/SharpEmuRuntime.cs | 1 + 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/SharpEmu.Core/Loader/SelfImage.cs b/src/SharpEmu.Core/Loader/SelfImage.cs index 5123e84..2f86c53 100644 --- a/src/SharpEmu.Core/Loader/SelfImage.cs +++ b/src/SharpEmu.Core/Loader/SelfImage.cs @@ -21,7 +21,10 @@ public sealed class SelfImage IReadOnlyList? initializerFunctions = null, ulong initFunctionEntryPoint = 0, ulong imageBase = 0, - ulong procParamAddress = 0) + ulong procParamAddress = 0, + string? title = null, + string? titleId = null, + string? version = null) { ArgumentNullException.ThrowIfNull(programHeaders); ArgumentNullException.ThrowIfNull(mappedRegions); @@ -38,6 +41,9 @@ public sealed class SelfImage InitFunctionEntryPoint = initFunctionEntryPoint; _imageBase = imageBase; ProcParamAddress = procParamAddress; + Title = title; + TitleId = titleId; + Version = version; } public bool IsSelf { get; } @@ -63,4 +69,10 @@ public sealed class SelfImage public ulong EntryPoint => ElfHeader.EntryPoint + _imageBase; public ulong ProcParamAddress { get; } + + public string? Title { get; } + + public string? TitleId { get; } + + public string? Version { get; } } diff --git a/src/SharpEmu.Core/Loader/SelfLoader.cs b/src/SharpEmu.Core/Loader/SelfLoader.cs index 822ee1c..76dc042 100644 --- a/src/SharpEmu.Core/Loader/SelfLoader.cs +++ b/src/SharpEmu.Core/Loader/SelfLoader.cs @@ -144,10 +144,9 @@ public sealed class SelfLoader : ISelfLoader throw new InvalidDataException("Input image is empty."); } - if (readParamJson) - { - TryLoadParamJson(fs, mountRoot); - } + var applicationInfo = readParamJson + ? TryLoadParamJson(fs, mountRoot) + : default; if (clearVirtualMemory) { @@ -270,15 +269,20 @@ public sealed class SelfLoader : ISelfLoader initializerFunctions, initFunctionEntryPoint, imageBase, - procParamAddress); + procParamAddress, + applicationInfo.Title, + applicationInfo.TitleId, + applicationInfo.Version); } - private static void TryLoadParamJson(IFileSystem? fs, string? mountRoot) + private static (string? Title, string? TitleId, string? Version) TryLoadParamJson( + IFileSystem? fs, + string? mountRoot) { if (fs == null) { Console.WriteLine("[LOADER] param.json not found (no filesystem provided)."); - return; + return default; } string[] possiblePaths = string.IsNullOrEmpty(mountRoot) @@ -298,12 +302,16 @@ public sealed class SelfLoader : ISelfLoader if (foundPath == null) { Console.WriteLine("[LOADER] param.json not found (no root path / unknown layout)."); - return; + return default; } - var (title, titleId, ver) = Ps5ParamJsonReader.TryReadPs5Param(fs, foundPath); + var applicationInfo = Ps5ParamJsonReader.TryReadPs5Param(fs, foundPath); Console.WriteLine($"[LOADER] Loading param.json at {foundPath}"); - Console.WriteLine($"[LOADER] Title: {title ?? "(unknown)"}, TitleId: {titleId ?? "(unknown)"}, Version: {ver ?? "(unknown)"}"); + Console.WriteLine( + $"[LOADER] Title: {applicationInfo.Title ?? "(unknown)"}, " + + $"TitleId: {applicationInfo.TitleId ?? "(unknown)"}, " + + $"Version: {applicationInfo.Version ?? "(unknown)"}"); + return applicationInfo; } private static LoadContext ParseLayout(ReadOnlySpan imageData) diff --git a/src/SharpEmu.Core/Runtime/SharpEmuRuntime.cs b/src/SharpEmu.Core/Runtime/SharpEmuRuntime.cs index f2f556b..72374db 100644 --- a/src/SharpEmu.Core/Runtime/SharpEmuRuntime.cs +++ b/src/SharpEmu.Core/Runtime/SharpEmuRuntime.cs @@ -135,6 +135,7 @@ public sealed class SharpEmuRuntime : ISharpEmuRuntime LastMilestoneLog = null; KernelModuleRegistry.Reset(); var image = LoadImage(normalizedEbootPath); + VideoOutExports.ConfigureApplicationInfo(image.Title, image.TitleId, image.Version); RegisterLoadedModule(normalizedEbootPath, image, isMain: true, isSystemModule: false); KernelRuntimeCompatExports.ConfigureProcessProcParamAddress(image.ProcParamAddress); Console.Error.WriteLine($"[RUNTIME] Entry: 0x{image.EntryPoint:X16}");