Added filesize check; fixed formatting

This commit is contained in:
Jake 2022-02-20 19:05:05 +00:00
commit 58c418362b
3 changed files with 9 additions and 3 deletions

View file

@ -72,7 +72,7 @@ namespace LBPUnion.UnionPatcher.Gui {
ElfFile eboot = new(this.filePicker.FilePath);
if(eboot.IsValid == false) {
this.CreateOkDialog("Eboot Error", $"{eboot.Name} is not a valid ELF file (magic number mismatch)").ShowModal();
this.CreateOkDialog("Eboot Error", $"{eboot.Name} is not a valid ELF file (magic number mismatch)\nThe EBOOT must be decrypted before using this tool").ShowModal();
return;
}

View file

@ -35,8 +35,13 @@ namespace LBPUnion.UnionPatcher {
public byte[] Contents { get; } = null;
public ElfFile(byte[] fileContents) {
if(fileContents.length < 52) {
IsValid = false;
return;
}
IsValid = fileContents[0x00..0x04].SequenceEqual(new byte[] {0x7F, (byte)'E', (byte)'L', (byte)'F'});
if(IsValid == false) return;
if(!IsValid) return;
byte identClassValue = fileContents[0x04];
byte identDataValue = fileContents[0x05];

View file

@ -24,8 +24,9 @@ namespace LBPUnion.UnionPatcher {
ElfFile eboot = new(new FileInfo(args[0]));
if(eboot.IsValid == false) {
if(!eboot.IsValid) {
Console.WriteLine($"{eboot.Name} is not a valid ELF file (magic number mismatch)");
Console.WriteLine("The EBOOT must be decrypted before using this tool");
return;
}