UEFIDump 0.1.0 for Windows

- Linux and OSX will be done in next commit
This commit is contained in:
Nikolaj Schlej 2016-07-09 08:31:08 +02:00
parent 9045fc6cc0
commit 7bae8e040c
7 changed files with 135 additions and 112 deletions

View file

@ -53,9 +53,10 @@ typedef uint8_t USTATUS;
#define U_UNKNOWN_RELOCATION_TYPE 32
#define U_DIR_ALREADY_EXIST 33
#define U_DIR_CREATE 34
#define U_TRUNCATED_IMAGE 35
#define U_INVALID_CAPSULE 36
#define U_STORES_NOT_FOUND 37
#define U_DIR_CHANGE 35
#define U_TRUNCATED_IMAGE 36
#define U_INVALID_CAPSULE 37
#define U_STORES_NOT_FOUND 38
#define U_NOT_IMPLEMENTED 0xFF
// UDK porting definitions

View file

@ -44,6 +44,54 @@ UByteArray parsingDataToUByteArray(const PARSING_DATA & pdata)
return UByteArray((const char*)&pdata, sizeof(PARSING_DATA));
}
// Returns unique name string based for tree item
UString uniqueItemName(const UModelIndex & index)
{
// Sanity check
if (!index.isValid())
return UString("Invalid index");
// Get model from index
const TreeModel* model = index.model();
// Get data from parsing data
PARSING_DATA pdata = parsingDataFromUModelIndex(index);
// Construct the name
UString itemName = model->name(index);
UString itemText = model->text(index);
// Default name
UString name = itemName;
switch (model->type(index)) {
case Types::Volume:
if (pdata.volume.hasExtendedHeader) name = guidToUString(pdata.volume.extendedHeaderGuid);
break;
case Types::NvarEntry:
case Types::VssEntry:
case Types::FsysEntry:
case Types::EvsaEntry:
case Types::FlashMapEntry:
case Types::File:
name = itemText.isEmpty() ? itemName : itemText;
break;
case Types::Section: {
// Get parent file name
UModelIndex fileIndex = model->findParentOfType(index, Types::File);
UString fileText = model->text(fileIndex);
name = fileText.isEmpty() ? model->name(fileIndex) : fileText;
// Append section subtype name
name += '_' + itemName;
} break;
}
name.findreplace(' ', '_');
name.findreplace('/', '_');
name.findreplace('-', '_');
return name;
}
// Returns text representation of error code
UString errorCodeToUString(UINT8 errorCode)
{
@ -88,6 +136,7 @@ UString errorCodeToUString(UINT8 errorCode)
case U_COMPLEX_BLOCK_MAP: return UString("Block map structure too complex for correct analysis");
case U_DIR_ALREADY_EXIST: return UString("Directory already exists");
case U_DIR_CREATE: return UString("Directory can't be created");
case U_DIR_CHANGE: return UString("Change directory failed");
//case U_UNKNOWN_PATCH_TYPE: return UString("Unknown patch type");
//case U_PATCH_OFFSET_OUT_OF_BOUNDS: return UString("Patch offset out of bounds");
//case U_INVALID_SYMBOL: return UString("Invalid symbol");

View file

@ -25,22 +25,25 @@ PARSING_DATA parsingDataFromUModelIndex(const UModelIndex & index);
// Converts parsing data to byte array
UByteArray parsingDataToUByteArray(const PARSING_DATA & pdata);
// Returns unique name string based for tree item
UString uniqueItemName(const UModelIndex & index);
// Converts error code to UString
extern UString errorCodeToUString(UINT8 errorCode);
UString errorCodeToUString(UINT8 errorCode);
// Decompression routine
extern USTATUS decompress(const UByteArray & compressed, UINT8 & algorithm, UByteArray & decompressed, UByteArray & efiDecompressed);
USTATUS decompress(const UByteArray & compressed, UINT8 & algorithm, UByteArray & decompressed, UByteArray & efiDecompressed);
// Compression routine
//USTATUS compress(const UByteArray & decompressed, UByteArray & compressed, const UINT8 & algorithm);
// CRC32 calculation routine
extern UINT32 crc32(UINT32 initial, const UINT8* buffer, const UINT32 length);
UINT32 crc32(UINT32 initial, const UINT8* buffer, const UINT32 length);
// 8bit checksum calculation routine
extern UINT8 calculateChecksum8(const UINT8* buffer, UINT32 bufferSize);
UINT8 calculateChecksum8(const UINT8* buffer, UINT32 bufferSize);
// 16bit checksum calculation routine
extern UINT16 calculateChecksum16(const UINT16* buffer, UINT32 bufferSize);
UINT16 calculateChecksum16(const UINT16* buffer, UINT32 bufferSize);
#endif // UTILITY_H