This commit is contained in:
vit9696 2018-10-10 23:41:53 +03:00
parent 021da9df4c
commit bc3193420c
3 changed files with 24 additions and 7 deletions

View File

@ -24,10 +24,13 @@ USTATUS FfsDumper::dump(const UModelIndex & root, const UString & path, const Du
return U_DIR_ALREADY_EXIST; return U_DIR_ALREADY_EXIST;
USTATUS result = recursiveDump(root, path, dumpMode, sectionType, guid); USTATUS result = recursiveDump(root, path, dumpMode, sectionType, guid);
if (result) if (result) {
return result; return result;
else if (!dumped) } else if (!dumped) {
removeDirectory(path);
return U_ITEM_NOT_FOUND; return U_ITEM_NOT_FOUND;
}
return U_SUCCESS; return U_SUCCESS;
} }
@ -61,6 +64,8 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
return U_FILE_OPEN; return U_FILE_OPEN;
const UByteArray &data = model->header(index); const UByteArray &data = model->header(index);
file.write(data.constData(), data.size()); file.write(data.constData(), data.size());
dumped = true;
} }
} }
@ -77,6 +82,8 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
return U_FILE_OPEN; return U_FILE_OPEN;
const UByteArray &data = model->body(index); const UByteArray &data = model->body(index);
file.write(data.constData(), data.size()); file.write(data.constData(), data.size());
dumped = true;
} }
} }
@ -99,6 +106,8 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
file.write(headerData.constData(), headerData.size()); file.write(headerData.constData(), headerData.size());
file.write(bodyData.constData(), bodyData.size()); file.write(bodyData.constData(), bodyData.size());
file.write(tailData.constData(), tailData.size()); file.write(tailData.constData(), tailData.size());
dumped = true;
} }
} }
@ -121,9 +130,9 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
if (!file) if (!file)
return U_FILE_OPEN; return U_FILE_OPEN;
file << info.toLocal8Bit(); file << info.toLocal8Bit();
}
dumped = true; dumped = true;
}
} }
USTATUS result; USTATUS result;

View File

@ -2516,7 +2516,7 @@ USTATUS FfsParser::parseGuidedSectionBody(const UModelIndex & index)
if (model->hasEmptyParsingData(index) == false) { if (model->hasEmptyParsingData(index) == false) {
UByteArray data = model->parsingData(index); UByteArray data = model->parsingData(index);
const GUIDED_SECTION_PARSING_DATA* pdata = (const GUIDED_SECTION_PARSING_DATA*)data.constData(); const GUIDED_SECTION_PARSING_DATA* pdata = (const GUIDED_SECTION_PARSING_DATA*)data.constData();
guid = pdata->guid; guid = readMisaligned(pdata).guid;
} }
// Check if section requires processing // Check if section requires processing
@ -3008,8 +3008,8 @@ USTATUS FfsParser::addMemoryAddressesRecursive(const UModelIndex & index)
if (model->hasEmptyParsingData(index) == false) { if (model->hasEmptyParsingData(index) == false) {
UByteArray data = model->parsingData(index); UByteArray data = model->parsingData(index);
const TE_IMAGE_SECTION_PARSING_DATA* pdata = (const TE_IMAGE_SECTION_PARSING_DATA*)data.constData(); const TE_IMAGE_SECTION_PARSING_DATA* pdata = (const TE_IMAGE_SECTION_PARSING_DATA*)data.constData();
originalImageBase = pdata->imageBase; originalImageBase = readMisaligned(pdata).imageBase;
adjustedImageBase = pdata->adjustedImageBase; adjustedImageBase = readMisaligned(pdata).adjustedImageBase;
} }
if (imageBase != 0) { if (imageBase != 0) {

View File

@ -36,6 +36,10 @@ static inline bool changeDirectory(const UString & dir) {
return (_chdir(dir.toLocal8Bit()) == 0); return (_chdir(dir.toLocal8Bit()) == 0);
} }
static inline void removeDirectory(const UString & dir) {
_rmdir(dir.toLocal8Bit());
}
static inline UString getAbsPath(const UString & path) { static inline UString getAbsPath(const UString & path) {
char abs[1024] = {}; char abs[1024] = {};
if (_fullpath(abs, path.toLocal8Bit(), sizeof(abs))) if (_fullpath(abs, path.toLocal8Bit(), sizeof(abs)))
@ -54,6 +58,10 @@ static inline bool makeDirectory(const UString & dir) {
return (mkdir(dir.toLocal8Bit(), ACCESSPERMS) == 0); return (mkdir(dir.toLocal8Bit(), ACCESSPERMS) == 0);
} }
static inline void removeDirectory(const UString & dir) {
rmdir(dir.toLocal8Bit());
}
static inline bool changeDirectory(const UString & dir) { static inline bool changeDirectory(const UString & dir) {
return (chdir(dir.toLocal8Bit()) == 0); return (chdir(dir.toLocal8Bit()) == 0);
} }