Skip to content
This repository has been archived by the owner on Jan 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #8 from unexpected-eof/hotfix/0.3
Browse files Browse the repository at this point in the history
Hotfix/0.3
  • Loading branch information
tuxuser committed Feb 19, 2016
2 parents 16daaa0 + f78f3c0 commit 941c136
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 50 deletions.
6 changes: 3 additions & 3 deletions OZMTool/ozmtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ UINT8 OZMTool::OZMCreate(QString inputfile, QString outputfile, QString inputFFS
}

printf("Injecting FFS into BIOS...\n");
QDirIterator diFFS(inputFFSdir);
QDirIterator diFFS(inputFFSdir, (QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks | QDir::Readable), QDirIterator::NoIteratorFlags);
QFileInfo currFFS;

while (diFFS.hasNext()) {
Expand All @@ -479,7 +479,7 @@ UINT8 OZMTool::OZMCreate(QString inputfile, QString outputfile, QString inputFFS
}

if(insertKexts) {
QDirIterator diKext(inputKextdir);
QDirIterator diKext(inputKextdir, (QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks | QDir::Readable), QDirIterator::NoIteratorFlags);
QFileInfo currKext;

printf("Converting Kext & injecting into BIOS...\n");
Expand Down Expand Up @@ -546,7 +546,7 @@ UINT8 OZMTool::OZMCreate(QString inputfile, QString outputfile, QString inputFFS
}

if (insertEfi) {
QDirIterator diEfi(inputEFIdir);
QDirIterator diEfi(inputEFIdir, (QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks | QDir::Readable), QDirIterator::NoIteratorFlags);
QFileInfo currEfi;

printf("Injecting bare (EFI) files...\n");
Expand Down
75 changes: 38 additions & 37 deletions OZMTool/ozmtool_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,89 +26,90 @@ void usageDsdt2Bios()
{
printf("dsdt2bios command\n"
" usage:\n"
"\t%s --dsdt2bios -i AmiBoardInfo.bin -d DSDT.aml -o patchedAmiBoardInfo.bin\n\n"
"\t%s --dsdt2bios -i AmiBoardInfo.bin -d DSDT.aml -o patchedAmiBoardInfo.bin\n"
" parameters:\n" \
"\t-i, --input [file]\t\tInput file (AmiBoardInfo)\n"
"\t-d, --dsdt [file]\t\tDSDT.aml file\n"
"\t-o, --out [file]\t\tOutput file (patched AmiBoardInfo)\n"
"\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
"\t-i, --input [file]\tInput file (AmiBoardInfo)\n"
"\t-d, --dsdt [file]\tDSDT.aml file\n"
"\t-o, --out [file]\tOutput file (patched AmiBoardInfo)\n"
"\t-h, --help\t\tPrint this\n\n", qPrintable(appname));
}

void usageKext2Ffs()
{
printf("kext2ffs command\n"
" usage:\n"
"\t%s --kext2ffs -o outputdir -i kextsdir\n\n"
"\t%s --kext2ffs -o outputdir -i kextsdir\n"
" parameters:\n"
"\t-i, --input [dir]\t\tInput kexts directory\n"
"\t-i, --input [dir]\tInput kexts directory\n"
"\t-o, --out [dir]\t\tOutput ffs directory\n"
"\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
"\t-h, --help\t\tPrint this\n\n", qPrintable(appname));
}

void usageOzmUpdate()
{
printf("ozmupdate command\n" \
" usage:\n"
"\t%s --ozmupdate -a 1 -o BIOS_RECENT.OZM -i BIOS.OZM -r BIOS.CLEAN\n\n"
"\t%s --ozmupdate -a 1 -cr -o BIOS_RECENT.OZM -i BIOS.OZM -r BIOS.CLEAN\n"
" parameters:\n"
"\t-i, --input [file]\t\tInput \"old\" Ozmosis BIOSFile\n"
"\t-r, --recent [file]\t\tInput \"recent\" clean BIOSFile\n"
"\t-a, --aggressivity\t\tAggressivity level (see README)\n"
"\t-cr, --compressdxe\t\tCompress CORE_DXE\n"
"\t-o, --out [file]\t\tOutput BIOSFile\n"
"\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
"\t-i, --input [file]\tInput \"old\" Ozmosis BIOSFile\n"
"\t-r, --recent [file]\tInput \"recent\" clean BIOSFile\n"
"\t-a, --aggressivity\tAggressivity level (see README)\n"
"\t-cr, --compressdxe\tCompress CORE_DXE\n"
"\t-o, --out [file]\tOutput BIOSFile\n"
"\t-h, --help\t\tPrint this\n\n", qPrintable(appname));
}

void usageOzmCreate()
{
// ./OZMTool --ozmcreate -a 1 -cr -ck -f extractDir -k kextDir -o OZM1699-F3.rom -i oz5a_10.rom
printf("ozmcreate command\n" \
" usage:\n"
"\t%s --ozmcreate -a 1 -cr -ck -k kextdir -f ffsdir -d DSDT.aml -o outputfile -i BIOS.ROM\n\n"
"\t%s --ozmcreate -a 1 -cr -ck -k kextdir -f ffsdir -d DSDT.aml -o outputfile -i BIOS.ROM\n"
" parameters:\n"
"\t-f, --ffs [dir]\t\tFFS directory (extracted OZM files)\n"
"\t-d, --dsdt [file]\t\t (optional) DSDT.aml file\n"
"\t-k, --kext [dir]\t\t (optional) KEXT directory\n"
"\t-e, --efi [dir]\t\t (optional) EFI directory\n"
"\t-i, --input [file]\t\tInput CLEAN Bios\n"
"\t-a, --aggressivity\t\t (optional) Aggressivity level (see README)\n"
"\t-cr,--compressdxe\t\t (optional) Compress CORE_DXE\n"
"\t-ck,--compresskexts\t\t (optional) Compress converted Kexts\n"
"\t-o, --out [file]\t\tOutput OZM Bios\n"
"\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
"\t-d, --dsdt [file]\t(optional) DSDT.aml file\n"
"\t-k, --kext [dir]\t(optional) KEXT directory\n"
"\t-e, --efi [dir]\t\t(optional) EFI directory\n"
"\t-i, --input [file]\tInput CLEAN Bios\n"
"\t-a, --aggressivity\t(optional) Aggressivity level (see README)\n"
"\t-cr,--compressdxe\t(optional) Compress CORE_DXE\n"
"\t-ck,--compresskexts\t(optional) Compress converted Kexts\n"
"\t-o, --out [file]\tOutput OZM Bios\n"
"\t-h, --help\t\tPrint this\n\n", qPrintable(appname));
}

void usageOzmExtract()
{
printf("ozmextract command\n"
" usage:\n"
"\t%s --ozmextract -o outputdir -i OZM.ROM\n\n"
"\t%s --ozmextract -o outputdir -i OZM.ROM\n"
" parameters:\n"
"\t-i, --input [file]\t\tInput stock OZM Bios\n"
"\t-i, --input [file]\tInput stock OZM Bios\n"
"\t-o, --out [dir]\t\tOutput directory\n"
"\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
"\t-h, --help\t\tPrint this\n\n", qPrintable(appname));
}

void usageDSDTExtract()
{
printf("dsdtextract command\n"
" usage:\n"
"\t%s --dsdtextract -o outputdir -i OZMBIOS_or_BIOS.ROM\n\n"
"\t%s --dsdtextract -o outputdir -i OZMBIOS_or_BIOS.ROM\n"
" parameters:\n"
"\t-i, --input [file]\t\tBIOS file\n"
"\t-i, --input [file]\tBIOS file\n"
"\t-o, --out [dir]\t\tOutput directory\n"
"\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
"\t-h, --help\t\tPrint this\n\n", qPrintable(appname));
}

void usageDSDTInject()
{
printf("dsdtinject command\n"
" usage:\n"
"\t%s --dsdtinject -i BIOS.ROM -d DSDT.aml -o outputfile\n\n"
"\t%s --dsdtinject -i BIOS.ROM -d DSDT.aml -o outputfile\n"
" parameters:\n"
"\t-i, --input [file]\t\tBIOS file\n"
"\n-d, --dsdt [file]\t\tDSDT.aml\n"
"\t-i, --input [file]\tBIOS file\n"
"\t-d, --dsdt [file]\t\tDSDT.aml\n"
"\t-o, --out [dir]\t\tOutput directory\n"
"\t-h, --help\t\tPrint this\n\n",qPrintable(appname));
"\t-h, --help\t\tPrint this\n\n", qPrintable(appname));
}

void usageGeneral()
Expand All @@ -123,12 +124,12 @@ void usageGeneral()
"\t--ozmcreate\t\tPatches Original BIOS with Ozmosis\n"
"\t--kext2ffs\t\tConverts kext-directories to FFS\n"
"\t--dsdt2bios\t\tInjects (bigger) DSDT into AmiBoardInfo\n"
"\t--help, -h\t\tPrint this\n\n",qPrintable(appname));
"\t--help, -h\t\tPrint this\n\n", qPrintable(appname));
}

void versionInfo()
{
printf("%s - %s\n",qPrintable(appname), GIT_VERSION);
printf("%s - %s\n", qPrintable(appname), GIT_VERSION);
}

void usageAll()
Expand Down
23 changes: 13 additions & 10 deletions OZMTool/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,15 @@ UINT8 sectionCreate(QByteArray body, UINT8 sectionType, QByteArray & sectionOut)
switch (sectionType) {
case EFI_SECTION_COMPRESSION:
fe->compress(body, COMPRESSION_ALGORITHM_TIANO, fileBody);
alignment = fileBody.size() % 4;
if (alignment) {
fileBody.append(QByteArray(4 - alignment, '\x00'));
}

compressedSection->CompressionType = COMPRESSION_ALGORITHM_TIANO;
compressedSection->Type = EFI_SECTION_COMPRESSION;
compressedSection->UncompressedLength = fileBody.size();
uint32ToUint24(sizeof(EFI_COMPRESSION_SECTION) + body.size(), compressedSection->Size);
compressedSection->UncompressedLength = body.size(); //fileBody ???
uint32ToUint24(sizeof(EFI_COMPRESSION_SECTION) + fileBody.size(), compressedSection->Size); //body.size ???

header.append((const char *) compressedSection, sizeof(EFI_COMPRESSION_SECTION));
break;
Expand All @@ -395,23 +399,22 @@ UINT8 sectionCreate(QByteArray body, UINT8 sectionType, QByteArray & sectionOut)
case EFI_SECTION_COMPATIBILITY16:
case EFI_SECTION_USER_INTERFACE:
case EFI_SECTION_RAW:
fileBody.append(body);
alignment = fileBody.size() % 4;
if (alignment) {
fileBody.append(QByteArray(4 - alignment, '\x00'));
}

sectionHeader->Type = sectionType;
uint32ToUint24(sizeof(EFI_COMMON_SECTION_HEADER) + body.size(), sectionHeader->Size);
uint32ToUint24(sizeof(EFI_COMMON_SECTION_HEADER) + fileBody.size(), sectionHeader->Size);

header.append((const char *) sectionHeader, sizeof(EFI_COMMON_SECTION_HEADER));
fileBody.append(body);
break;
default:
printf("ERROR: Invalid sectionType supplied!\n");
return ERR_ERROR;
}

alignment = fileBody.size() % 4;
if (alignment) {
alignment = 4 - alignment;
fileBody.append(QByteArray(alignment, '\x00'));
}

sectionOut.append(header);
sectionOut.append(fileBody);

Expand Down

0 comments on commit 941c136

Please sign in to comment.