Pad banner if it's too small and at end of file.

This commit is contained in:
JeffRuLz 2018-10-06 22:05:31 -05:00 committed by GitHub
parent e9d9444e43
commit 27c497e313
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 1 deletions

View File

@ -419,7 +419,18 @@ void install(Menu* m)
goto error;
}
iprintf("Done\n");
iprintf("Done\n");
}
//Pad out banner if it is the last part of the file
if (header->ndshdr.bannerOffset == fileSize - 0x1C00)
{
iprintf("Padding banner...");
if (padFile(appPath, 0x7C0) == false)
iprintf("Failed\n");
else
iprintf("Done\n");
}
//Write new patched header

View File

@ -233,6 +233,24 @@ int getFileSizePath(const char* path)
return size;
}
int padFile(const char* path, int size)
{
FILE* f = fopen(path, "ab");
if (!f)
return 0;
else
{
unsigned char zero = 0;
fwrite(&zero, sizeof(char), size, f);
}
fclose(f);
return 1;
}
//Directories
int dirExists(const char* path)
{

View File

@ -20,6 +20,7 @@ void clearProgressBar();
int copyFile(const char* in, char* out);
int getFileSize(FILE* f);
int getFileSizePath(const char* path);
int padFile(const char* path, int size);
//Directories
int dirExists(const char* path);