loaders: Fix possible parsing errors of informations on some NSO (#1724)
This fix possible parsing errors of informations on some NSO where the "zero" field don't exist introduced by #1661 leading to crashes at start. References: https://github.com/Atmosphere-NX/Atmosphere/blob/master/stratosphere/creport/source/creport_modules.cpp#L202 https://github.com/Thog/oss-rtld/blob/master/source/main.cpp#L14
This commit is contained in:
parent
9435d62206
commit
7c3b559830
1 changed files with 18 additions and 10 deletions
|
@ -72,16 +72,21 @@ namespace Ryujinx.HLE.Loaders.Executables
|
||||||
string rawTextBuffer = Encoding.ASCII.GetString(roBuffer, 0, RoSize);
|
string rawTextBuffer = Encoding.ASCII.GetString(roBuffer, 0, RoSize);
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
int zero = BitConverter.ToInt32(roBuffer, 0);
|
||||||
|
|
||||||
|
if (zero == 0)
|
||||||
|
{
|
||||||
int length = BitConverter.ToInt32(roBuffer, 4);
|
int length = BitConverter.ToInt32(roBuffer, 4);
|
||||||
string moduleName = Encoding.UTF8.GetString(roBuffer, 8, length);
|
string modulePath = Encoding.UTF8.GetString(roBuffer, 8, length);
|
||||||
|
|
||||||
MatchCollection moduleMatches = Regex.Matches(rawTextBuffer, @"[a-z]:[\\/][ -~]{5,}\.nss", RegexOptions.IgnoreCase);
|
MatchCollection moduleMatches = Regex.Matches(rawTextBuffer, @"[a-z]:[\\/][ -~]{5,}\.nss", RegexOptions.IgnoreCase);
|
||||||
if (moduleMatches.Count > 0)
|
if (moduleMatches.Count > 0)
|
||||||
{
|
{
|
||||||
moduleName = moduleMatches.First().Value;
|
modulePath = moduleMatches.First().Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
stringBuilder.AppendLine($" Module: {moduleName}");
|
stringBuilder.AppendLine($" Module: {modulePath}");
|
||||||
|
}
|
||||||
|
|
||||||
MatchCollection fsSdkMatches = Regex.Matches(rawTextBuffer, @"sdk_version: ([0-9.]*)");
|
MatchCollection fsSdkMatches = Regex.Matches(rawTextBuffer, @"sdk_version: ([0-9.]*)");
|
||||||
if (fsSdkMatches.Count != 0)
|
if (fsSdkMatches.Count != 0)
|
||||||
|
@ -98,7 +103,10 @@ namespace Ryujinx.HLE.Loaders.Executables
|
||||||
stringBuilder.AppendLine($"{libHeader}{libContent}");
|
stringBuilder.AppendLine($"{libHeader}{libContent}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stringBuilder.Length > 0)
|
||||||
|
{
|
||||||
Logger.Info?.Print(LogClass.Loader, $"{Name}:\n{stringBuilder.ToString().TrimEnd('\r', '\n')}");
|
Logger.Info?.Print(LogClass.Loader, $"{Name}:\n{stringBuilder.ToString().TrimEnd('\r', '\n')}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue