UEFITool 0.18.4 / UEFIExtract 0.2.2

- added new FFS GUID found new in Apple EFI images
- added PDR region parsing as BIOS space (Apple feature again)
- changed default directory for saving to the directory containing opened file
- focus and cursor position are now set properly for GUID tab in search dialog
- search dialog resized to fit the whole GUID
- codebase cleaned form unnecessary spaces
This commit is contained in:
Nikolaj Schlej 2014-07-24 16:59:51 -07:00
parent 6e1f226aa0
commit 534f01fcd5
35 changed files with 3589 additions and 3656 deletions

View File

@ -25,86 +25,84 @@ static ISzAlloc SzAllocForLzma = { &AllocForLzma, &FreeForLzma };
SRes OnProgress(void *p, UInt64 inSize, UInt64 outSize) SRes OnProgress(void *p, UInt64 inSize, UInt64 outSize)
{ {
return SZ_OK; return SZ_OK;
} }
static ICompressProgress g_ProgressCallback = { &OnProgress }; static ICompressProgress g_ProgressCallback = { &OnProgress };
STATIC STATIC
UINT64 UINT64
EFIAPI EFIAPI
RShiftU64 ( RShiftU64(
UINT64 Operand, UINT64 Operand,
UINT32 Count UINT32 Count
) )
{ {
return Operand >> Count; return Operand >> Count;
} }
VOID VOID
SetEncodedSizeOfBuf( SetEncodedSizeOfBuf(
UINT64 EncodedSize, UINT64 EncodedSize,
UINT8 *EncodedData UINT8 *EncodedData
) )
{ {
INT32 Index; INT32 Index;
EncodedData[LZMA_PROPS_SIZE] = EncodedSize & 0xFF; EncodedData[LZMA_PROPS_SIZE] = EncodedSize & 0xFF;
for (Index = LZMA_PROPS_SIZE+1; Index <= LZMA_PROPS_SIZE + 7; Index++) for (Index = LZMA_PROPS_SIZE + 1; Index <= LZMA_PROPS_SIZE + 7; Index++)
{ {
EncodedSize = RShiftU64(EncodedSize, 8); EncodedSize = RShiftU64(EncodedSize, 8);
EncodedData[Index] = EncodedSize & 0xFF; EncodedData[Index] = EncodedSize & 0xFF;
} }
} }
INT32 INT32
EFIAPI EFIAPI
LzmaCompress ( LzmaCompress(
CONST UINT8 *Source, CONST UINT8 *Source,
UINT32 SourceSize, UINT32 SourceSize,
UINT8 *Destination, UINT8 *Destination,
UINT32 *DestinationSize UINT32 *DestinationSize
) )
{ {
SRes LzmaResult; SRes LzmaResult;
CLzmaEncProps props; CLzmaEncProps props;
SizeT propsSize = LZMA_PROPS_SIZE; SizeT propsSize = LZMA_PROPS_SIZE;
SizeT destLen = SourceSize + SourceSize / 3 + 128; SizeT destLen = SourceSize + SourceSize / 3 + 128;
if (*DestinationSize < destLen) if (*DestinationSize < destLen)
{ {
*DestinationSize = destLen; *DestinationSize = destLen;
return ERR_BUFFER_TOO_SMALL; return ERR_BUFFER_TOO_SMALL;
} }
LzmaEncProps_Init(&props); LzmaEncProps_Init(&props);
props.dictSize = LZMA_DICTIONARY_SIZE; props.dictSize = LZMA_DICTIONARY_SIZE;
props.level = 9; props.level = 9;
props.fb = 273; props.fb = 273;
LzmaResult = LzmaEncode( LzmaResult = LzmaEncode(
(Byte*)((UINT8*)Destination + LZMA_HEADER_SIZE), (Byte*)((UINT8*)Destination + LZMA_HEADER_SIZE),
&destLen, &destLen,
Source, Source,
SourceSize, SourceSize,
&props, &props,
(UINT8*)Destination, (UINT8*)Destination,
&propsSize, &propsSize,
props.writeEndMark, props.writeEndMark,
&g_ProgressCallback, &g_ProgressCallback,
&SzAllocForLzma, &SzAllocForLzma,
&SzAllocForLzma); &SzAllocForLzma);
*DestinationSize = destLen + LZMA_HEADER_SIZE; *DestinationSize = destLen + LZMA_HEADER_SIZE;
SetEncodedSizeOfBuf((UINT64)SourceSize, Destination); SetEncodedSizeOfBuf((UINT64)SourceSize, Destination);
if (LzmaResult == SZ_OK) { if (LzmaResult == SZ_OK) {
return ERR_SUCCESS; return ERR_SUCCESS;
} else { }
return ERR_INVALID_PARAMETER; else {
} return ERR_INVALID_PARAMETER;
}
} }

View File

@ -9,7 +9,7 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/ */
#ifndef __LZMACOMPRESS_H__ #ifndef __LZMACOMPRESS_H__
#define __LZMACOMPRESS_H__ #define __LZMACOMPRESS_H__
@ -24,14 +24,14 @@ extern "C" {
#define LZMA_DICTIONARY_SIZE 0x800000 #define LZMA_DICTIONARY_SIZE 0x800000
#define _LZMA_SIZE_OPT #define _LZMA_SIZE_OPT
INT32 INT32
EFIAPI EFIAPI
LzmaCompress ( LzmaCompress(
const UINT8 *Source, const UINT8 *Source,
UINT32 SourceSize, UINT32 SourceSize,
UINT8 *Destination, UINT8 *Destination,
UINT32 *DestinationSize UINT32 *DestinationSize
); );
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -18,13 +18,13 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <stdlib.h> #include <stdlib.h>
UINT64 UINT64
EFIAPI EFIAPI
LShiftU64 ( LShiftU64(
UINT64 Operand, UINT64 Operand,
UINT32 Count UINT32 Count
) )
{ {
return Operand << Count; return Operand << Count;
} }
static void * AllocForLzma(void *p, size_t size) { return malloc(size); } static void * AllocForLzma(void *p, size_t size) { return malloc(size); }
@ -39,19 +39,19 @@ Get the size of the uncompressed buffer by parsing EncodeData header.
@return The size of the uncompressed buffer. @return The size of the uncompressed buffer.
*/ */
UINT64 UINT64
GetDecodedSizeOfBuf( GetDecodedSizeOfBuf(
UINT8 *EncodedData UINT8 *EncodedData
) )
{ {
UINT64 DecodedSize; UINT64 DecodedSize;
INT32 Index; INT32 Index;
// Parse header // Parse header
DecodedSize = 0; DecodedSize = 0;
for (Index = LZMA_PROPS_SIZE + 7; Index >= LZMA_PROPS_SIZE; Index--) for (Index = LZMA_PROPS_SIZE + 7; Index >= LZMA_PROPS_SIZE; Index--)
DecodedSize = LShiftU64(DecodedSize, 8) + EncodedData[Index]; DecodedSize = LShiftU64(DecodedSize, 8) + EncodedData[Index];
return DecodedSize; return DecodedSize;
} }
// //
@ -86,21 +86,21 @@ buffer was returned ScratchSize.
*/ */
INT32 INT32
EFIAPI EFIAPI
LzmaGetInfo ( LzmaGetInfo(
CONST VOID *Source, CONST VOID *Source,
UINT32 SourceSize, UINT32 SourceSize,
UINT32 *DestinationSize UINT32 *DestinationSize
) )
{ {
UInt64 DecodedSize; UInt64 DecodedSize;
ASSERT(SourceSize >= LZMA_HEADER_SIZE); ASSERT(SourceSize >= LZMA_HEADER_SIZE);
DecodedSize = GetDecodedSizeOfBuf((UINT8*)Source); DecodedSize = GetDecodedSizeOfBuf((UINT8*)Source);
*DestinationSize = (UINT32)DecodedSize; *DestinationSize = (UINT32)DecodedSize;
return ERR_SUCCESS; return ERR_SUCCESS;
} }
/* /*
@ -123,37 +123,37 @@ The source buffer specified by Source is corrupted
(not a valid compressed format). (not a valid compressed format).
*/ */
INT32 INT32
EFIAPI EFIAPI
LzmaDecompress ( LzmaDecompress(
CONST VOID *Source, CONST VOID *Source,
UINT32 SourceSize, UINT32 SourceSize,
VOID *Destination VOID *Destination
) )
{ {
SRes LzmaResult; SRes LzmaResult;
ELzmaStatus Status; ELzmaStatus Status;
SizeT DecodedBufSize; SizeT DecodedBufSize;
SizeT EncodedDataSize; SizeT EncodedDataSize;
DecodedBufSize = (SizeT)GetDecodedSizeOfBuf((UINT8*)Source); DecodedBufSize = (SizeT)GetDecodedSizeOfBuf((UINT8*)Source);
EncodedDataSize = (SizeT) (SourceSize - LZMA_HEADER_SIZE); EncodedDataSize = (SizeT)(SourceSize - LZMA_HEADER_SIZE);
LzmaResult = LzmaDecode( LzmaResult = LzmaDecode(
(Byte*) Destination, (Byte*)Destination,
&DecodedBufSize, &DecodedBufSize,
(Byte*)((UINT8*)Source + LZMA_HEADER_SIZE), (Byte*)((UINT8*)Source + LZMA_HEADER_SIZE),
&EncodedDataSize, &EncodedDataSize,
(CONST Byte*) Source, (CONST Byte*) Source,
LZMA_PROPS_SIZE, LZMA_PROPS_SIZE,
LZMA_FINISH_END, LZMA_FINISH_END,
&Status, &Status,
&SzAllocForLzma &SzAllocForLzma
); );
if (LzmaResult == SZ_OK) { if (LzmaResult == SZ_OK) {
return ERR_SUCCESS; return ERR_SUCCESS;
} else { }
return ERR_INVALID_PARAMETER; else {
} return ERR_INVALID_PARAMETER;
}
} }

View File

@ -9,7 +9,7 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/ */
#ifndef __LZMADECOMPRESS_H__ #ifndef __LZMADECOMPRESS_H__
#define __LZMADECOMPRESS_H__ #define __LZMADECOMPRESS_H__
@ -23,77 +23,76 @@ extern "C" {
#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8) #define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)
UINT64 UINT64
EFIAPI EFIAPI
LShiftU64 ( LShiftU64(
UINT64 Operand, UINT64 Operand,
UINT32 Count UINT32 Count
); );
/* /*
Given a Lzma compressed source buffer, this function retrieves the size of Given a Lzma compressed source buffer, this function retrieves the size of
the uncompressed buffer and the size of the scratch buffer required the uncompressed buffer and the size of the scratch buffer required
to decompress the compressed source buffer. to decompress the compressed source buffer.
Retrieves the size of the uncompressed buffer and the temporary scratch buffer Retrieves the size of the uncompressed buffer and the temporary scratch buffer
required to decompress the buffer specified by Source and SourceSize. required to decompress the buffer specified by Source and SourceSize.
The size of the uncompressed buffer is returned DestinationSize, The size of the uncompressed buffer is returned DestinationSize,
the size of the scratch buffer is returned ScratchSize, and RETURN_SUCCESS is returned. the size of the scratch buffer is returned ScratchSize, and RETURN_SUCCESS is returned.
This function does not have scratch buffer available to perform a thorough This function does not have scratch buffer available to perform a thorough
checking of the validity of the source data. It just retrieves the "Original Size" checking of the validity of the source data. It just retrieves the "Original Size"
field from the LZMA_HEADER_SIZE beginning bytes of the source data and output it as DestinationSize. field from the LZMA_HEADER_SIZE beginning bytes of the source data and output it as DestinationSize.
And ScratchSize is specific to the decompression implementation. And ScratchSize is specific to the decompression implementation.
If SourceSize is less than LZMA_HEADER_SIZE, then ASSERT(). If SourceSize is less than LZMA_HEADER_SIZE, then ASSERT().
@param Source The source buffer containing the compressed data. @param Source The source buffer containing the compressed data.
@param SourceSize The size, bytes, of the source buffer. @param SourceSize The size, bytes, of the source buffer.
@param DestinationSize A pointer to the size, bytes, of the uncompressed buffer @param DestinationSize A pointer to the size, bytes, of the uncompressed buffer
that will be generated when the compressed buffer specified that will be generated when the compressed buffer specified
by Source and SourceSize is decompressed. by Source and SourceSize is decompressed.
@retval EFI_SUCCESS The size of the uncompressed data was returned @retval EFI_SUCCESS The size of the uncompressed data was returned
DestinationSize and the size of the scratch DestinationSize and the size of the scratch
buffer was returned ScratchSize. buffer was returned ScratchSize.
*/ */
INT32 INT32
EFIAPI EFIAPI
LzmaGetInfo ( LzmaGetInfo(
const VOID *Source, const VOID *Source,
UINT32 SourceSize, UINT32 SourceSize,
UINT32 *DestinationSize UINT32 *DestinationSize
); );
/* /*
Decompresses a Lzma compressed source buffer. Decompresses a Lzma compressed source buffer.
Extracts decompressed data to its original form. Extracts decompressed data to its original form.
If the compressed source data specified by Source is successfully decompressed If the compressed source data specified by Source is successfully decompressed
into Destination, then RETURN_SUCCESS is returned. If the compressed source data into Destination, then RETURN_SUCCESS is returned. If the compressed source data
specified by Source is not a valid compressed data format, specified by Source is not a valid compressed data format,
then RETURN_INVALID_PARAMETER is returned. then RETURN_INVALID_PARAMETER is returned.
@param Source The source buffer containing the compressed data. @param Source The source buffer containing the compressed data.
@param SourceSize The size of source buffer. @param SourceSize The size of source buffer.
@param Destination The destination buffer to store the decompressed data @param Destination The destination buffer to store the decompressed data
@retval EFI_SUCCESS Decompression completed successfully, and @retval EFI_SUCCESS Decompression completed successfully, and
the uncompressed buffer is returned Destination. the uncompressed buffer is returned Destination.
@retval EFI_INVALID_PARAMETER @retval EFI_INVALID_PARAMETER
The source buffer specified by Source is corrupted The source buffer specified by Source is corrupted
(not a valid compressed format). (not a valid compressed format).
*/ */
INT32 INT32
EFIAPI EFIAPI
LzmaDecompress ( LzmaDecompress(
const VOID *Source, const VOID *Source,
UINT32 SourceSize, UINT32 SourceSize,
VOID *Destination VOID *Destination
); );
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -500,7 +500,6 @@ VOID
// Special usage of 'next' // Special usage of 'next'
// //
mNext[LoopVar4] = mPos; mNext[LoopVar4] = mPos;
} }
/** /**
@ -914,7 +913,6 @@ IN UINT32 x
mSubBitBuf |= x << (mBitCount -= LoopVar8); mSubBitBuf |= x << (mBitCount -= LoopVar8);
} }
else { else {
Temp = (UINT8)(mSubBitBuf | (x >> (LoopVar8 -= mBitCount))); Temp = (UINT8)(mSubBitBuf | (x >> (LoopVar8 -= mBitCount)));
if (mDst < mDstUpperLimit) { if (mDst < mDstUpperLimit) {
*mDst++ = Temp; *mDst++ = Temp;
@ -925,7 +923,6 @@ IN UINT32 x
mSubBitBuf = x << (mBitCount = UINT8_BIT - LoopVar8); mSubBitBuf = x << (mBitCount = UINT8_BIT - LoopVar8);
} }
else { else {
Temp = (UINT8)(x >> (LoopVar8 - UINT8_BIT)); Temp = (UINT8)(x >> (LoopVar8 - UINT8_BIT));
if (mDst < mDstUpperLimit) { if (mDst < mDstUpperLimit) {
*mDst++ = Temp; *mDst++ = Temp;
@ -1031,7 +1028,7 @@ VOID
} }
} }
else { else {
ASSERT((LoopVar3 + 2)<(2 * NT - 1)); ASSERT((LoopVar3 + 2) < (2 * NT - 1));
mTFreq[LoopVar3 + 2]++; mTFreq[LoopVar3 + 2]++;
} }
} }
@ -1135,7 +1132,7 @@ VOID
} }
} }
else { else {
ASSERT((LoopVar3 + 2)<NPT); ASSERT((LoopVar3 + 2) < NPT);
PutBits(mPTLen[LoopVar3 + 2], mPTCode[LoopVar3 + 2]); PutBits(mPTLen[LoopVar3 + 2], mPTCode[LoopVar3 + 2]);
} }
} }
@ -1456,7 +1453,6 @@ IN OUT UINT64 *DstSize
*DstSize = mCompSize + 1 + 8; *DstSize = mCompSize + 1 + 8;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
UINT8 EfiCompress(CONST VOID* SrcBuffer, CONST UINT64 SrcSize, VOID* DstBuffer, UINT64* DstSize) UINT8 EfiCompress(CONST VOID* SrcBuffer, CONST UINT64 SrcSize, VOID* DstBuffer, UINT64* DstSize)

View File

@ -12,11 +12,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name:
TianoCompress.h TianoCompress.h
Abstract: Abstract:
Header file for compression routine. Header file for compression routine.
*/ */
@ -32,69 +32,69 @@ Abstract:
extern "C" { extern "C" {
#endif #endif
/*++ /*++
Routine Description: Routine Description:
Tiano compression routine. Tiano compression routine.
Arguments: Arguments:
SrcBuffer - The buffer storing the source data SrcBuffer - The buffer storing the source data
SrcSize - The size of source data SrcSize - The size of source data
DstBuffer - The buffer to store the compressed data DstBuffer - The buffer to store the compressed data
DstSize - On input, the size of DstBuffer; On output, DstSize - On input, the size of DstBuffer; On output,
the size of the actual compressed data. the size of the actual compressed data.
Returns: Returns:
EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. this case, EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. this case,
DstSize contains the size needed. DstSize contains the size needed.
EFI_SUCCESS - Compression is successful. EFI_SUCCESS - Compression is successful.
EFI_OUT_OF_RESOURCES - No resource to complete function. EFI_OUT_OF_RESOURCES - No resource to complete function.
EFI_INVALID_PARAMETER - Parameter supplied is wrong. EFI_INVALID_PARAMETER - Parameter supplied is wrong.
--*/ --*/
UINT8 UINT8
TianoCompress ( TianoCompress(
CONST VOID *SrcBuffer, CONST VOID *SrcBuffer,
CONST UINT64 SrcSize, CONST UINT64 SrcSize,
VOID *DstBuffer, VOID *DstBuffer,
UINT64 *DstSize UINT64 *DstSize
) )
; ;
/*++ /*++
Routine Description: Routine Description:
EFI 1.1 compression routine. EFI 1.1 compression routine.
Arguments: Arguments:
SrcBuffer - The buffer storing the source data SrcBuffer - The buffer storing the source data
SrcSize - The size of source data SrcSize - The size of source data
DstBuffer - The buffer to store the compressed data DstBuffer - The buffer to store the compressed data
DstSize - On input, the size of DstBuffer; On output, DstSize - On input, the size of DstBuffer; On output,
the size of the actual compressed data. the size of the actual compressed data.
Returns: Returns:
EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. this case, EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. this case,
DstSize contains the size needed. DstSize contains the size needed.
EFI_SUCCESS - Compression is successful. EFI_SUCCESS - Compression is successful.
EFI_OUT_OF_RESOURCES - No resource to complete function. EFI_OUT_OF_RESOURCES - No resource to complete function.
EFI_INVALID_PARAMETER - Parameter supplied is wrong. EFI_INVALID_PARAMETER - Parameter supplied is wrong.
--*/ --*/
UINT8 UINT8
EfiCompress ( EfiCompress(
CONST VOID *SrcBuffer, CONST VOID *SrcBuffer,
CONST UINT64 SrcSize, CONST UINT64 SrcSize,
VOID *DstBuffer, VOID *DstBuffer,
UINT64 *DstSize UINT64 *DstSize
) )
; ;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -103,7 +103,6 @@ Returns: (VOID)
Sd->mBitBuf = (UINT32)(Sd->mBitBuf << NumOfBits); Sd->mBitBuf = (UINT32)(Sd->mBitBuf << NumOfBits);
while (NumOfBits > Sd->mBitCount) { while (NumOfBits > Sd->mBitCount) {
Sd->mBitBuf |= (UINT32)(Sd->mSubBitBuf << (NumOfBits = (UINT16)(NumOfBits - Sd->mBitCount))); Sd->mBitBuf |= (UINT32)(Sd->mSubBitBuf << (NumOfBits = (UINT16)(NumOfBits - Sd->mBitCount)));
if (Sd->mCompSize > 0) { if (Sd->mCompSize > 0) {
@ -114,7 +113,6 @@ Returns: (VOID)
Sd->mSubBitBuf = 0; Sd->mSubBitBuf = 0;
Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++]; Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++];
Sd->mBitCount = 8; Sd->mBitCount = 8;
} }
else { else {
// //
@ -122,7 +120,6 @@ Returns: (VOID)
// //
Sd->mSubBitBuf = 0; Sd->mSubBitBuf = 0;
Sd->mBitCount = 8; Sd->mBitCount = 8;
} }
} }
@ -270,7 +267,6 @@ BAD_TABLE - The table is corrupted.
Mask = (UINT16)(1U << (15 - TableBits)); Mask = (UINT16)(1U << (15 - TableBits));
for (Char = 0; Char < NumOfChar; Char++) { for (Char = 0; Char < NumOfChar; Char++) {
Len = BitLen[Char]; Len = BitLen[Char];
if (Len == 0 || Len >= 17) { if (Len == 0 || Len >= 17) {
continue; continue;
@ -279,17 +275,14 @@ BAD_TABLE - The table is corrupted.
NextCode = (UINT16)(Start[Len] + Weight[Len]); NextCode = (UINT16)(Start[Len] + Weight[Len]);
if (Len <= TableBits) { if (Len <= TableBits) {
for (Index = Start[Len]; Index < NextCode; Index++) { for (Index = Start[Len]; Index < NextCode; Index++) {
// Check to prevent possible heap corruption // Check to prevent possible heap corruption
if (Index >= (UINT16)(1U << TableBits)) if (Index >= (UINT16)(1U << TableBits))
return (UINT16)BAD_TABLE; return (UINT16)BAD_TABLE;
Table[Index] = Char; Table[Index] = Char;
} }
} }
else { else {
Index3 = Start[Len]; Index3 = Start[Len];
Pointer = &Table[Index3 >> JuBits]; Pointer = &Table[Index3 >> JuBits];
Index = (UINT16)(Len - TableBits); Index = (UINT16)(Len - TableBits);
@ -318,7 +311,6 @@ BAD_TABLE - The table is corrupted.
} }
*Pointer = Char; *Pointer = Char;
} }
Start[Len] = NextCode; Start[Len] = NextCode;
@ -360,7 +352,6 @@ The position value decoded.
Mask = 1U << (BITBUFSIZ - 1 - 8); Mask = 1U << (BITBUFSIZ - 1 - 8);
do { do {
if (Sd->mBitBuf & Mask) { if (Sd->mBitBuf & Mask) {
Val = Sd->mRight[Val]; Val = Sd->mRight[Val];
} }
@ -443,7 +434,6 @@ BAD_TABLE - Table is corrupted.
Index = 0; Index = 0;
while (Index < Number) { while (Index < Number) {
CharC = (UINT16)(Sd->mBitBuf >> (BITBUFSIZ - 3)); CharC = (UINT16)(Sd->mBitBuf >> (BITBUFSIZ - 3));
if (CharC == 7) { if (CharC == 7) {
@ -521,13 +511,11 @@ Returns: (VOID)
Index = 0; Index = 0;
while (Index < Number) { while (Index < Number) {
CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)]; CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
if (CharC >= NT) { if (CharC >= NT) {
Mask = 1U << (BITBUFSIZ - 1 - 8); Mask = 1U << (BITBUFSIZ - 1 - 8);
do { do {
if (Mask & Sd->mBitBuf) { if (Mask & Sd->mBitBuf) {
CharC = Sd->mRight[CharC]; CharC = Sd->mRight[CharC];
} }
@ -536,7 +524,6 @@ Returns: (VOID)
} }
Mask >>= 1; Mask >>= 1;
} while (CharC >= NT); } while (CharC >= NT);
} }
// //
@ -545,7 +532,6 @@ Returns: (VOID)
FillBuf(Sd, Sd->mPTLen[CharC]); FillBuf(Sd, Sd->mPTLen[CharC]);
if (CharC <= 2) { if (CharC <= 2) {
if (CharC == 0) { if (CharC == 0) {
CharC = 1; CharC = 1;
} }
@ -559,12 +545,9 @@ Returns: (VOID)
while ((INT16)(--CharC) >= 0) { while ((INT16)(--CharC) >= 0) {
Sd->mCLen[Index++] = 0; Sd->mCLen[Index++] = 0;
} }
} }
else { else {
Sd->mCLen[Index++] = (UINT8)(CharC - 2); Sd->mCLen[Index++] = (UINT8)(CharC - 2);
} }
} }
@ -687,7 +670,6 @@ Returns: (VOID)
else { else {
Sd->mDstBase[Sd->mOutBuf++] = (UINT8)CharC; Sd->mDstBase[Sd->mOutBuf++] = (UINT8)CharC;
} }
} }
else { else {
// //

View File

@ -12,12 +12,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name:
Decompress.h Decompress.h
Abstract: Abstract:
Header file for decompression routine. Header file for decompression routine.
Providing both EFI and Tiano decompress algorithms. Providing both EFI and Tiano decompress algorithms.
--*/ --*/
@ -32,108 +32,108 @@ Abstract:
extern "C" { extern "C" {
#endif #endif
typedef struct { typedef struct {
UINT32 CompSize; UINT32 CompSize;
UINT32 OrigSize; UINT32 OrigSize;
} EFI_TIANO_HEADER; } EFI_TIANO_HEADER;
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiTianoGetInfo ( EfiTianoGetInfo(
VOID *Source, VOID *Source,
UINT32 SrcSize, UINT32 SrcSize,
UINT32 *DstSize, UINT32 *DstSize,
UINT32 *ScratchSize UINT32 *ScratchSize
) )
/*++ /*++
Routine Description: Routine Description:
The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.GetInfo(). The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.GetInfo().
Arguments: Arguments:
This - The protocol instance pointer This - The protocol instance pointer
Source - The source buffer containing the compressed data. Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer SrcSize - The size of source buffer
DstSize - The size of destination buffer. DstSize - The size of destination buffer.
ScratchSize - The size of scratch buffer. ScratchSize - The size of scratch buffer.
Returns: Returns:
EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successfully retrieved. EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successfully retrieved.
EFI_INVALID_PARAMETER - The source data is corrupted EFI_INVALID_PARAMETER - The source data is corrupted
--*/ --*/
; ;
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
EfiDecompress ( EfiDecompress(
VOID *Source, VOID *Source,
UINT32 SrcSize, UINT32 SrcSize,
VOID *Destination, VOID *Destination,
UINT32 DstSize, UINT32 DstSize,
VOID *Scratch, VOID *Scratch,
UINT32 ScratchSize UINT32 ScratchSize
) )
/*++ /*++
Routine Description: Routine Description:
The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.Decompress(). The implementation is same as that of EFI_DECOMPRESS_PROTOCOL.Decompress().
Arguments: Arguments:
This - The protocol instance pointer This - The protocol instance pointer
Source - The source buffer containing the compressed data. Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer SrcSize - The size of source buffer
Destination - The destination buffer to store the decompressed data Destination - The destination buffer to store the decompressed data
DstSize - The size of destination buffer. DstSize - The size of destination buffer.
Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
ScratchSize - The size of scratch buffer. ScratchSize - The size of scratch buffer.
Returns: Returns:
EFI_SUCCESS - Decompression is successful EFI_SUCCESS - Decompression is successful
EFI_INVALID_PARAMETER - The source data is corrupted EFI_INVALID_PARAMETER - The source data is corrupted
--*/ --*/
; ;
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
TianoDecompress ( TianoDecompress(
VOID *Source, VOID *Source,
UINT32 SrcSize, UINT32 SrcSize,
VOID *Destination, VOID *Destination,
UINT32 DstSize, UINT32 DstSize,
VOID *Scratch, VOID *Scratch,
UINT32 ScratchSize UINT32 ScratchSize
) )
/*++ /*++
Routine Description: Routine Description:
The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress(). The implementation is same as that of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress().
Arguments: Arguments:
This - The protocol instance pointer This - The protocol instance pointer
Source - The source buffer containing the compressed data. Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer SrcSize - The size of source buffer
Destination - The destination buffer to store the decompressed data Destination - The destination buffer to store the decompressed data
DstSize - The size of destination buffer. DstSize - The size of destination buffer.
Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
ScratchSize - The size of scratch buffer. ScratchSize - The size of scratch buffer.
Returns: Returns:
EFI_SUCCESS - Decompression is successful EFI_SUCCESS - Decompression is successful
EFI_INVALID_PARAMETER - The source data is corrupted EFI_INVALID_PARAMETER - The source data is corrupted
--*/ --*/
; ;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -41,7 +41,7 @@ int main(int argc, char *argv[])
} }
else { else {
result = ERR_INVALID_PARAMETER; result = ERR_INVALID_PARAMETER;
std::cout << "UEFIExtract 0.2.1" << std::endl << std::endl << std::cout << "UEFIExtract 0.2.2" << std::endl << std::endl <<
"Usage: uefiextract imagefile\n" << std::endl; "Usage: uefiextract imagefile\n" << std::endl;
} }

View File

@ -41,10 +41,6 @@ typedef uint16_t CHAR16;
#define FALSE ((BOOLEAN)(0==1)) #define FALSE ((BOOLEAN)(0==1))
#endif #endif
#ifndef NULL
#define NULL ((VOID *) 0)
#endif
#define ERR_SUCCESS 0 #define ERR_SUCCESS 0
#define ERR_INVALID_PARAMETER 1 #define ERR_INVALID_PARAMETER 1
#define ERR_BUFFER_TOO_SMALL 2 #define ERR_BUFFER_TOO_SMALL 2

View File

@ -51,21 +51,20 @@ typedef struct {
UINT16 ReservedZero; // Still unknown, zeros in all descriptors I have seen UINT16 ReservedZero; // Still unknown, zeros in all descriptors I have seen
} FLASH_DESCRIPTOR_MAP; } FLASH_DESCRIPTOR_MAP;
// Component section // Component section
// Flash parameters DWORD structure // Flash parameters DWORD structure
typedef struct { typedef struct {
UINT8 FirstChipDensity : 3; UINT8 FirstChipDensity : 3;
UINT8 SecondChipDensity : 3; UINT8 SecondChipDensity : 3;
UINT8 ReservedZero0 : 2; // Still unknown, zeros in all descriptors I have seen UINT8 ReservedZero0 : 2; // Still unknown, zeros in all descriptors I have seen
UINT8 ReservedZero1 : 8; // Still unknown, zeros in all descriptors I have seen UINT8 ReservedZero1 : 8; // Still unknown, zeros in all descriptors I have seen
UINT8 ReservedZero2 : 4; // Still unknown, zeros in all descriptors I have seen UINT8 ReservedZero2 : 4; // Still unknown, zeros in all descriptors I have seen
UINT8 FastReadEnabled : 1; UINT8 FastReadEnabled : 1;
UINT8 FastReadFreqency : 3; UINT8 FastReadFreqency : 3;
UINT8 FlashReadStatusFrequency : 3; UINT8 FlashReadStatusFrequency : 3;
UINT8 FlashWriteFrequency : 3; UINT8 FlashWriteFrequency : 3;
UINT8 DualOutputFastReadSupported : 1; UINT8 DualOutputFastReadSupported : 1;
UINT8 ReservedZero3 : 1; // Still unknown, zero in all descriptors I have seen UINT8 ReservedZero3 : 1; // Still unknown, zero in all descriptors I have seen
} FLASH_PARAMETERS; } FLASH_PARAMETERS;
// Flash densities // Flash densities

72
ffs.cpp
View File

@ -14,24 +14,24 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "ffs.h" #include "ffs.h"
const UINT8 ffsAlignmentTable[] = const UINT8 ffsAlignmentTable[] =
{0, 4, 7, 9, 10, 12, 15, 16}; { 0, 4, 7, 9, 10, 12, 15, 16 };
UINT8 calculateChecksum8(UINT8* buffer, UINT32 bufferSize) UINT8 calculateChecksum8(UINT8* buffer, UINT32 bufferSize)
{ {
if(!buffer) if (!buffer)
return 0; return 0;
UINT8 counter = 0; UINT8 counter = 0;
while(bufferSize--) while (bufferSize--)
counter += buffer[bufferSize]; counter += buffer[bufferSize];
return (UINT8) 0x100 - counter; return (UINT8)0x100 - counter;
} }
UINT16 calculateChecksum16(UINT16* buffer, UINT32 bufferSize) UINT16 calculateChecksum16(UINT16* buffer, UINT32 bufferSize)
{ {
if(!buffer) if (!buffer)
return 0; return 0;
UINT16 counter = 0; UINT16 counter = 0;
@ -40,53 +40,53 @@ UINT16 calculateChecksum16(UINT16* buffer, UINT32 bufferSize)
bufferSize /= sizeof(UINT16); bufferSize /= sizeof(UINT16);
for (; index < bufferSize; index++) { for (; index < bufferSize; index++) {
counter = (UINT16) (counter + buffer[index]); counter = (UINT16)(counter + buffer[index]);
} }
return (UINT16) 0x10000 - counter; return (UINT16)0x10000 - counter;
} }
VOID uint32ToUint24(UINT32 size, UINT8* ffsSize) VOID uint32ToUint24(UINT32 size, UINT8* ffsSize)
{ {
ffsSize[2] = (UINT8) ((size) >> 16); ffsSize[2] = (UINT8)((size) >> 16);
ffsSize[1] = (UINT8) ((size) >> 8); ffsSize[1] = (UINT8)((size) >> 8);
ffsSize[0] = (UINT8) ((size) ); ffsSize[0] = (UINT8)((size));
} }
UINT32 uint24ToUint32(UINT8* ffsSize) UINT32 uint24ToUint32(UINT8* ffsSize)
{ {
return (ffsSize[2] << 16) + return (ffsSize[2] << 16) +
(ffsSize[1] << 8) + (ffsSize[1] << 8) +
ffsSize[0]; ffsSize[0];
} }
QString guidToQString(const EFI_GUID& guid) QString guidToQString(const EFI_GUID& guid)
{ {
QByteArray baGuid = QByteArray::fromRawData((const char*) guid.Data, sizeof(EFI_GUID)); QByteArray baGuid = QByteArray::fromRawData((const char*)guid.Data, sizeof(EFI_GUID));
UINT32 i32 = *(UINT32*)baGuid.left(4).constData(); UINT32 i32 = *(UINT32*)baGuid.left(4).constData();
UINT16 i16_0 = *(UINT16*)baGuid.mid(4, 2).constData(); UINT16 i16_0 = *(UINT16*)baGuid.mid(4, 2).constData();
UINT16 i16_1 = *(UINT16*)baGuid.mid(6, 2).constData(); UINT16 i16_1 = *(UINT16*)baGuid.mid(6, 2).constData();
UINT8 i8_0 = *(UINT8*)baGuid.mid(8, 1).constData(); UINT8 i8_0 = *(UINT8*)baGuid.mid(8, 1).constData();
UINT8 i8_1 = *(UINT8*)baGuid.mid(9, 1).constData(); UINT8 i8_1 = *(UINT8*)baGuid.mid(9, 1).constData();
UINT8 i8_2 = *(UINT8*)baGuid.mid(10, 1).constData(); UINT8 i8_2 = *(UINT8*)baGuid.mid(10, 1).constData();
UINT8 i8_3 = *(UINT8*)baGuid.mid(11, 1).constData(); UINT8 i8_3 = *(UINT8*)baGuid.mid(11, 1).constData();
UINT8 i8_4 = *(UINT8*)baGuid.mid(12, 1).constData(); UINT8 i8_4 = *(UINT8*)baGuid.mid(12, 1).constData();
UINT8 i8_5 = *(UINT8*)baGuid.mid(13, 1).constData(); UINT8 i8_5 = *(UINT8*)baGuid.mid(13, 1).constData();
UINT8 i8_6 = *(UINT8*)baGuid.mid(14, 1).constData(); UINT8 i8_6 = *(UINT8*)baGuid.mid(14, 1).constData();
UINT8 i8_7 = *(UINT8*)baGuid.mid(15, 1).constData(); UINT8 i8_7 = *(UINT8*)baGuid.mid(15, 1).constData();
return QString("%1-%2-%3-%4%5-%6%7%8%9%10%11") return QString("%1-%2-%3-%4%5-%6%7%8%9%10%11")
.arg(i32, 8, 16, QChar('0')) .arg(i32, 8, 16, QChar('0'))
.arg(i16_0, 4, 16, QChar('0')) .arg(i16_0, 4, 16, QChar('0'))
.arg(i16_1, 4, 16, QChar('0')) .arg(i16_1, 4, 16, QChar('0'))
.arg(i8_0, 2, 16, QChar('0')) .arg(i8_0, 2, 16, QChar('0'))
.arg(i8_1, 2, 16, QChar('0')) .arg(i8_1, 2, 16, QChar('0'))
.arg(i8_2, 2, 16, QChar('0')) .arg(i8_2, 2, 16, QChar('0'))
.arg(i8_3, 2, 16, QChar('0')) .arg(i8_3, 2, 16, QChar('0'))
.arg(i8_4, 2, 16, QChar('0')) .arg(i8_4, 2, 16, QChar('0'))
.arg(i8_5, 2, 16, QChar('0')) .arg(i8_5, 2, 16, QChar('0'))
.arg(i8_6, 2, 16, QChar('0')) .arg(i8_6, 2, 16, QChar('0'))
.arg(i8_7, 2, 16, QChar('0')).toUpper(); .arg(i8_7, 2, 16, QChar('0')).toUpper();
} }
QString fileTypeToQString(const UINT8 type) QString fileTypeToQString(const UINT8 type)
@ -177,7 +177,7 @@ UINT32 sizeOfSectionHeader(EFI_COMMON_SECTION_HEADER* header)
case EFI_SECTION_GUID_DEFINED: { case EFI_SECTION_GUID_DEFINED: {
EFI_GUID_DEFINED_SECTION* gdsHeader = (EFI_GUID_DEFINED_SECTION*)header; EFI_GUID_DEFINED_SECTION* gdsHeader = (EFI_GUID_DEFINED_SECTION*)header;
return gdsHeader->DataOffset; return gdsHeader->DataOffset;
} }
case EFI_SECTION_DISPOSABLE: case EFI_SECTION_DISPOSABLE:
return sizeof(EFI_DISPOSABLE_SECTION); return sizeof(EFI_DISPOSABLE_SECTION);
case EFI_SECTION_PE32: case EFI_SECTION_PE32:

2
ffs.h
View File

@ -97,6 +97,8 @@ const QByteArray EFI_FIRMWARE_FILE_SYSTEM_GUID
("\xD9\x54\x93\x7A\x68\x04\x4A\x44\x81\xCE\x0B\xF6\x17\xD8\x90\xDF", 16); ("\xD9\x54\x93\x7A\x68\x04\x4A\x44\x81\xCE\x0B\xF6\x17\xD8\x90\xDF", 16);
const QByteArray EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM_GUID const QByteArray EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM_GUID
("\xAD\xEE\xAD\x04\xFF\x61\x31\x4D\xB6\xBA\x64\xF8\xBF\x90\x1F\x5A", 16); ("\xAD\xEE\xAD\x04\xFF\x61\x31\x4D\xB6\xBA\x64\xF8\xBF\x90\x1F\x5A", 16);
const QByteArray EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM2_GUID
("\x8C\x1B\x00\xBD\x71\x6A\x7B\x48\xA1\x4F\x0C\x2A\x2D\xCF\x7A\x5D", 16);
const QByteArray EFI_FIRMWARE_FILE_SYSTEM2_GUID const QByteArray EFI_FIRMWARE_FILE_SYSTEM2_GUID
("\x78\xE5\x8C\x8C\x3D\x8A\x1C\x4F\x99\x35\x89\x61\x85\xC3\x2D\xD3", 16); ("\x78\xE5\x8C\x8C\x3D\x8A\x1C\x4F\x99\x35\x89\x61\x85\xC3\x2D\xD3", 16);

View File

@ -171,7 +171,7 @@ QString errorMessage(UINT8 errorCode)
} }
FfsEngine::FfsEngine(QObject *parent) FfsEngine::FfsEngine(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
model = new TreeModel(); model = new TreeModel();
oldPeiCoreEntryPoint = 0; oldPeiCoreEntryPoint = 0;
@ -606,6 +606,11 @@ UINT8 FfsEngine::parsePdrRegion(const QByteArray & pdr, QModelIndex & index, con
// Add tree item // Add tree item
index = model->addItem(Types::Region, Subtypes::PdrRegion, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), pdr, QByteArray(), parent, mode); index = model->addItem(Types::Region, Subtypes::PdrRegion, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), pdr, QByteArray(), parent, mode);
// Parse PDR region as BIOS space
UINT8 result = parseBios(pdr, index);
if (result && result != ERR_VOLUMES_NOT_FOUND)
return result;
return ERR_SUCCESS; return ERR_SUCCESS;
} }
@ -737,7 +742,6 @@ UINT8 FfsEngine::parseBios(const QByteArray & bios, const QModelIndex & parent)
} }
break; break;
} }
} }
return ERR_SUCCESS; return ERR_SUCCESS;
@ -817,6 +821,10 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co
else if (QByteArray((const char*)&volumeHeader->FileSystemGuid, sizeof(EFI_GUID)) == EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM_GUID) { else if (QByteArray((const char*)&volumeHeader->FileSystemGuid, sizeof(EFI_GUID)) == EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM_GUID) {
// Code can be added here // Code can be added here
} }
// Apple Boot Volume FFS GUID
else if (QByteArray((const char*)&volumeHeader->FileSystemGuid, sizeof(EFI_GUID)) == EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM2_GUID) {
// Code can be added here
}
// FFS GUID v2 // FFS GUID v2
else if (QByteArray((const char*)&volumeHeader->FileSystemGuid, sizeof(EFI_GUID)) == EFI_FIRMWARE_FILE_SYSTEM2_GUID) { else if (QByteArray((const char*)&volumeHeader->FileSystemGuid, sizeof(EFI_GUID)) == EFI_FIRMWARE_FILE_SYSTEM2_GUID) {
// Code can be added here // Code can be added here
@ -976,7 +984,7 @@ UINT8 FfsEngine::parseFile(const QByteArray & file, QModelIndex & index, const U
EFI_FFS_FILE_HEADER* tempFileHeader = (EFI_FFS_FILE_HEADER*)(tempHeader.data()); EFI_FFS_FILE_HEADER* tempFileHeader = (EFI_FFS_FILE_HEADER*)(tempHeader.data());
tempFileHeader->IntegrityCheck.Checksum.Header = 0; tempFileHeader->IntegrityCheck.Checksum.Header = 0;
tempFileHeader->IntegrityCheck.Checksum.File = 0; tempFileHeader->IntegrityCheck.Checksum.File = 0;
UINT8 calculated = calculateChecksum8((UINT8*)tempFileHeader, sizeof(EFI_FFS_FILE_HEADER)-1); UINT8 calculated = calculateChecksum8((UINT8*)tempFileHeader, sizeof(EFI_FFS_FILE_HEADER) - 1);
if (fileHeader->IntegrityCheck.Checksum.Header != calculated) if (fileHeader->IntegrityCheck.Checksum.Header != calculated)
{ {
msg(tr("parseFile: %1, stored header checksum %2 differs from calculated %3") msg(tr("parseFile: %1, stored header checksum %2 differs from calculated %3")
@ -1167,7 +1175,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
UINT8 result; UINT8 result;
switch (sectionHeader->Type) { switch (sectionHeader->Type) {
// Encapsulated sections // Encapsulated sections
case EFI_SECTION_COMPRESSION: case EFI_SECTION_COMPRESSION:
{ {
bool parseCurrentSection = true; bool parseCurrentSection = true;
@ -1201,7 +1209,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
return result; return result;
} }
} }
break; break;
case EFI_SECTION_GUID_DEFINED: case EFI_SECTION_GUID_DEFINED:
{ {
bool parseCurrentSection = true; bool parseCurrentSection = true;
@ -1293,7 +1301,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
return result; return result;
} }
} }
break; break;
case EFI_SECTION_DISPOSABLE: case EFI_SECTION_DISPOSABLE:
{ {
header = section.left(sizeof(EFI_DISPOSABLE_SECTION)); header = section.left(sizeof(EFI_DISPOSABLE_SECTION));
@ -1312,8 +1320,8 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
if (result) if (result)
return result; return result;
} }
break; break;
// Leaf sections // Leaf sections
case EFI_SECTION_PE32: case EFI_SECTION_PE32:
case EFI_SECTION_TE: case EFI_SECTION_TE:
case EFI_SECTION_PIC: case EFI_SECTION_PIC:
@ -1340,7 +1348,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
msg(tr("parseSection: Can't get entry point of image file"), index); msg(tr("parseSection: Can't get entry point of image file"), index);
} }
} }
break; break;
case EFI_SECTION_FREEFORM_SUBTYPE_GUID: { case EFI_SECTION_FREEFORM_SUBTYPE_GUID: {
header = section.left(sizeof(EFI_FREEFORM_SUBTYPE_GUID_SECTION)); header = section.left(sizeof(EFI_FREEFORM_SUBTYPE_GUID_SECTION));
body = section.mid(sizeof(EFI_FREEFORM_SUBTYPE_GUID_SECTION), sectionSize - sizeof(EFI_FREEFORM_SUBTYPE_GUID_SECTION)); body = section.mid(sizeof(EFI_FREEFORM_SUBTYPE_GUID_SECTION), sectionSize - sizeof(EFI_FREEFORM_SUBTYPE_GUID_SECTION));
@ -1355,7 +1363,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
// Add tree item // Add tree item
index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode); index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
} }
break; break;
case EFI_SECTION_VERSION: { case EFI_SECTION_VERSION: {
header = section.left(sizeof(EFI_VERSION_SECTION)); header = section.left(sizeof(EFI_VERSION_SECTION));
body = section.mid(sizeof(EFI_VERSION_SECTION), sectionSize - sizeof(EFI_VERSION_SECTION)); body = section.mid(sizeof(EFI_VERSION_SECTION), sectionSize - sizeof(EFI_VERSION_SECTION));
@ -1372,7 +1380,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
// Add tree item // Add tree item
index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode); index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
} }
break; break;
case EFI_SECTION_USER_INTERFACE: { case EFI_SECTION_USER_INTERFACE: {
header = section.left(sizeof(EFI_USER_INTERFACE_SECTION)); header = section.left(sizeof(EFI_USER_INTERFACE_SECTION));
body = section.mid(sizeof(EFI_USER_INTERFACE_SECTION), sectionSize - sizeof(EFI_USER_INTERFACE_SECTION)); body = section.mid(sizeof(EFI_USER_INTERFACE_SECTION), sectionSize - sizeof(EFI_USER_INTERFACE_SECTION));
@ -1390,7 +1398,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
// Rename parent file // Rename parent file
model->setTextString(model->findParentOfType(parent, Types::File), text); model->setTextString(model->findParentOfType(parent, Types::File), text);
} }
break; break;
case EFI_SECTION_FIRMWARE_VOLUME_IMAGE: { case EFI_SECTION_FIRMWARE_VOLUME_IMAGE: {
header = section.left(sizeof(EFI_FIRMWARE_VOLUME_IMAGE_SECTION)); header = section.left(sizeof(EFI_FIRMWARE_VOLUME_IMAGE_SECTION));
body = section.mid(sizeof(EFI_FIRMWARE_VOLUME_IMAGE_SECTION), sectionSize - sizeof(EFI_FIRMWARE_VOLUME_IMAGE_SECTION)); body = section.mid(sizeof(EFI_FIRMWARE_VOLUME_IMAGE_SECTION), sectionSize - sizeof(EFI_FIRMWARE_VOLUME_IMAGE_SECTION));
@ -1504,12 +1512,12 @@ UINT8 FfsEngine::create(const QModelIndex & index, const UINT8 type, const QByte
// Correct file size // Correct file size
UINT8 tailSize = fileHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT ? sizeof(UINT16) : 0; UINT8 tailSize = fileHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT ? sizeof(UINT16) : 0;
uint32ToUint24(sizeof(EFI_FFS_FILE_HEADER)+body.size() + tailSize, fileHeader->Size); uint32ToUint24(sizeof(EFI_FFS_FILE_HEADER) + body.size() + tailSize, fileHeader->Size);
// Recalculate header checksum // Recalculate header checksum
fileHeader->IntegrityCheck.Checksum.Header = 0; fileHeader->IntegrityCheck.Checksum.Header = 0;
fileHeader->IntegrityCheck.Checksum.File = 0; fileHeader->IntegrityCheck.Checksum.File = 0;
fileHeader->IntegrityCheck.Checksum.Header = calculateChecksum8((UINT8*)fileHeader, sizeof(EFI_FFS_FILE_HEADER)-1); fileHeader->IntegrityCheck.Checksum.Header = calculateChecksum8((UINT8*)fileHeader, sizeof(EFI_FFS_FILE_HEADER) - 1);
// Recalculate data checksum, if needed // Recalculate data checksum, if needed
if (fileHeader->Attributes & FFS_ATTRIB_CHECKSUM) if (fileHeader->Attributes & FFS_ATTRIB_CHECKSUM)
@ -1760,7 +1768,6 @@ UINT8 FfsEngine::replace(const QModelIndex & index, const QByteArray & object, c
return ERR_SUCCESS; return ERR_SUCCESS;
} }
UINT8 FfsEngine::extract(const QModelIndex & index, QByteArray & extracted, const UINT8 mode) UINT8 FfsEngine::extract(const QModelIndex & index, QByteArray & extracted, const UINT8 mode)
{ {
if (!index.isValid()) if (!index.isValid())
@ -2085,7 +2092,7 @@ UINT8 FfsEngine::constructPadFile(const QByteArray &guid, const UINT32 size, con
// Calculate header checksum // Calculate header checksum
header->IntegrityCheck.Checksum.Header = 0; header->IntegrityCheck.Checksum.Header = 0;
header->IntegrityCheck.Checksum.File = 0; header->IntegrityCheck.Checksum.File = 0;
header->IntegrityCheck.Checksum.Header = calculateChecksum8((UINT8*)header, sizeof(EFI_FFS_FILE_HEADER)-1); header->IntegrityCheck.Checksum.Header = calculateChecksum8((UINT8*)header, sizeof(EFI_FFS_FILE_HEADER) - 1);
// Set data checksum // Set data checksum
if (revision == 1) if (revision == 1)
@ -2136,7 +2143,7 @@ UINT8 FfsEngine::reconstructIntelImage(const QModelIndex& index, QByteArray& rec
UINT32 offset = descriptor.size(); UINT32 offset = descriptor.size();
// Reconstruct other regions // Reconstruct other regions
char empty = '\xFF'; //!TODO: determine empty char using one of reserved descriptor fields char empty = '\xFF';
for (int i = 1; i < model->rowCount(index); i++) { for (int i = 1; i < model->rowCount(index); i++) {
QByteArray region; QByteArray region;
result = reconstructRegion(index.child(i, 0), region); result = reconstructRegion(index.child(i, 0), region);
@ -2280,7 +2287,6 @@ UINT8 FfsEngine::reconstructVolume(const QModelIndex & index, QByteArray & recon
} }
else if (model->action(index) == Actions::Rebuild) { else if (model->action(index) == Actions::Rebuild) {
//!TODO: add check for weak aligned volume //!TODO: add check for weak aligned volume
//!TODO: better return codes
QByteArray header = model->header(index); QByteArray header = model->header(index);
EFI_FIRMWARE_VOLUME_HEADER* volumeHeader = (EFI_FIRMWARE_VOLUME_HEADER*)header.data(); EFI_FIRMWARE_VOLUME_HEADER* volumeHeader = (EFI_FIRMWARE_VOLUME_HEADER*)header.data();
@ -2311,7 +2317,7 @@ UINT8 FfsEngine::reconstructVolume(const QModelIndex & index, QByteArray & recon
// VTF found // VTF found
if (file.left(sizeof(EFI_GUID)) == EFI_FFS_VOLUME_TOP_FILE_GUID) { if (file.left(sizeof(EFI_GUID)) == EFI_FFS_VOLUME_TOP_FILE_GUID) {
baseFound = true; baseFound = true;
volumeBase = (UINT32) (0x100000000 - volumeSize); volumeBase = (UINT32)(0x100000000 - volumeSize);
break; break;
} }
} }
@ -2321,10 +2327,10 @@ UINT8 FfsEngine::reconstructVolume(const QModelIndex & index, QByteArray & recon
// Iterate up to the root, checking for compression type to be other then none // Iterate up to the root, checking for compression type to be other then none
for (QModelIndex parentIndex = index.parent(); model->type(parentIndex) != Types::Root; parentIndex = parentIndex.parent()) for (QModelIndex parentIndex = index.parent(); model->type(parentIndex) != Types::Root; parentIndex = parentIndex.parent())
if (model->compression(parentIndex) != COMPRESSION_ALGORITHM_NONE) { if (model->compression(parentIndex) != COMPRESSION_ALGORITHM_NONE) {
// No rebase needed for compressed PEI files // No rebase needed for compressed PEI files
baseFound = true; baseFound = true;
volumeBase = 0; volumeBase = 0;
break; break;
} }
} }
@ -2631,7 +2637,7 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
} }
// Calculate section base // Calculate section base
UINT32 sectionBase = base ? base + sizeof(EFI_FFS_FILE_HEADER)+offset : 0; UINT32 sectionBase = base ? base + sizeof(EFI_FFS_FILE_HEADER) + offset : 0;
// Reconstruct section // Reconstruct section
QByteArray section; QByteArray section;
@ -2654,13 +2660,12 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
// Correct file size // Correct file size
UINT8 tailSize = (fileHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) ? sizeof(UINT16) : 0; UINT8 tailSize = (fileHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) ? sizeof(UINT16) : 0;
uint32ToUint24(sizeof(EFI_FFS_FILE_HEADER)+reconstructed.size() + tailSize, fileHeader->Size); uint32ToUint24(sizeof(EFI_FFS_FILE_HEADER) + reconstructed.size() + tailSize, fileHeader->Size);
// Recalculate header checksum // Recalculate header checksum
fileHeader->IntegrityCheck.Checksum.Header = 0; fileHeader->IntegrityCheck.Checksum.Header = 0;
fileHeader->IntegrityCheck.Checksum.File = 0; fileHeader->IntegrityCheck.Checksum.File = 0;
fileHeader->IntegrityCheck.Checksum.Header = calculateChecksum8((UINT8*)fileHeader, sizeof(EFI_FFS_FILE_HEADER)-1); fileHeader->IntegrityCheck.Checksum.Header = calculateChecksum8((UINT8*)fileHeader, sizeof(EFI_FFS_FILE_HEADER) - 1);
} }
// Use current file body // Use current file body
else else
@ -2818,7 +2823,6 @@ UINT8 FfsEngine::reconstructSection(const QModelIndex& index, const UINT32 base,
(model->subtype(index.parent()) == EFI_FV_FILETYPE_PEI_CORE || (model->subtype(index.parent()) == EFI_FV_FILETYPE_PEI_CORE ||
model->subtype(index.parent()) == EFI_FV_FILETYPE_PEIM || model->subtype(index.parent()) == EFI_FV_FILETYPE_PEIM ||
model->subtype(index.parent()) == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER)) { model->subtype(index.parent()) == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER)) {
if (base) { if (base) {
result = rebase(reconstructed, base + header.size()); result = rebase(reconstructed, base + header.size());
if (result) { if (result) {
@ -2929,7 +2933,6 @@ UINT8 FfsEngine::growVolume(QByteArray & header, const UINT32 size, UINT32 & new
return ERR_INVALID_VOLUME; return ERR_INVALID_VOLUME;
// Case of complex blockMap // Case of complex blockMap
//!TODO: implement this case
if (blockMapCount > 2) if (blockMapCount > 2)
return ERR_COMPLEX_BLOCK_MAP; return ERR_COMPLEX_BLOCK_MAP;
@ -3002,7 +3005,7 @@ UINT8 FfsEngine::findHexPattern(const QModelIndex & index, const QByteArray & he
.arg(hexBody.mid(offset, hexPattern.length())) .arg(hexBody.mid(offset, hexPattern.length()))
.arg(model->nameString(index)) .arg(model->nameString(index))
.arg(mode == SEARCH_MODE_BODY ? tr("body") : tr("header")) .arg(mode == SEARCH_MODE_BODY ? tr("body") : tr("header"))
.arg(offset/2, 8, 16, QChar('0')), .arg(offset / 2, 8, 16, QChar('0')),
index); index);
} }
offset = regexp.indexIn(hexBody, offset + 1); offset = regexp.indexIn(hexBody, offset + 1);
@ -3530,7 +3533,7 @@ UINT8 FfsEngine::patchViaOffset(QByteArray & data, const UINT32 offset, const QB
} }
else if (hex[0] == '.') {// Upper byte part placeholder else if (hex[0] == '.') {// Upper byte part placeholder
hex[0] = '0'; hex[0] = '0';
value = (UINT8)(body.at(offset + i) & 0xF0); value = (UINT8)(body.at(offset + i) & 0xF0);
value += (UINT8)hex.toUShort(&converted, 16); value += (UINT8)hex.toUShort(&converted, 16);
if (!converted) if (!converted)
return ERR_INVALID_SYMBOL; return ERR_INVALID_SYMBOL;
@ -3574,7 +3577,7 @@ UINT8 FfsEngine::patchViaPattern(QByteArray & data, const QByteArray & hexFindPa
INT32 offset = regexp.indexIn(hexBody); INT32 offset = regexp.indexIn(hexBody);
while (offset >= 0) { while (offset >= 0) {
if (offset % 2 == 0) { if (offset % 2 == 0) {
UINT8 result = patchViaOffset(body, offset/2, hexReplacePattern); UINT8 result = patchViaOffset(body, offset / 2, hexReplacePattern);
if (result) if (result)
return result; return result;
} }

4
gbe.h
View File

@ -26,8 +26,8 @@ typedef struct {
#define GBE_VERSION_OFFSET 10 #define GBE_VERSION_OFFSET 10
typedef struct { typedef struct {
UINT8 id: 4; UINT8 id : 4;
UINT8 minor: 4; UINT8 minor : 4;
UINT8 major; UINT8 major;
} GBE_VERSION; } GBE_VERSION;

View File

@ -9,7 +9,7 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/ */
#include "messagelistitem.h" #include "messagelistitem.h"
@ -33,7 +33,6 @@ MessageListItem::MessageListItem(const QIcon & icon, const QString & text, QList
MessageListItem::~MessageListItem() MessageListItem::~MessageListItem()
{ {
} }
QModelIndex MessageListItem::index() const QModelIndex MessageListItem::index() const

View File

@ -9,7 +9,7 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/ */
#ifndef __MESSAGELISTITEM_H__ #ifndef __MESSAGELISTITEM_H__
#define __MESSAGELISTITEM_H__ #define __MESSAGELISTITEM_H__

View File

@ -27,7 +27,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12 #define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER 13 #define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER 13
// //
// PE32+ Machine type for EFI images // PE32+ Machine type for EFI images
// //
@ -517,7 +516,6 @@ typedef struct {
// //
#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60 #define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
// //
// DLL Support // DLL Support
// //
@ -573,7 +571,6 @@ typedef struct {
EFI_IMAGE_THUNK_DATA *FirstThunk; EFI_IMAGE_THUNK_DATA *FirstThunk;
} EFI_IMAGE_IMPORT_DESCRIPTOR; } EFI_IMAGE_IMPORT_DESCRIPTOR;
// //
// Debug Directory Format // Debug Directory Format
// //
@ -620,7 +617,6 @@ typedef struct {
// //
} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY; } EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;
// //
// Debug Data Structure defined by Apple Mach-O to COFF utility. // Debug Data Structure defined by Apple Mach-O to COFF utility.
// //
@ -654,16 +650,16 @@ typedef struct {
typedef struct { typedef struct {
union { union {
struct { struct {
UINT32 NameOffset:31; UINT32 NameOffset : 31;
UINT32 NameIsString:1; UINT32 NameIsString : 1;
} s; } s;
UINT32 Id; UINT32 Id;
} u1; } u1;
union { union {
UINT32 OffsetToData; UINT32 OffsetToData;
struct { struct {
UINT32 OffsetToDirectory:31; UINT32 OffsetToDirectory : 31;
UINT32 DataIsDirectory:1; UINT32 DataIsDirectory : 1;
} s; } s;
} u2; } u2;
} EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY; } EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY;

View File

@ -9,15 +9,15 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/ */
#include "searchdialog.h" #include "searchdialog.h"
SearchDialog::SearchDialog(QWidget *parent) : SearchDialog::SearchDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::SearchDialog), ui(new Ui::SearchDialog),
hexValidator(QRegExp("([0-9a-fA-F\\.])*")), hexValidator(QRegExp("([0-9a-fA-F\\.])*")),
guidValidator(QRegExp("[0-9a-fA-F\\.]{8}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{12}")) guidValidator(QRegExp("[0-9a-fA-F\\.]{8}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{12}"))
{ {
// Create UI // Create UI
ui->setupUi(this); ui->setupUi(this);
@ -40,9 +40,10 @@ void SearchDialog::setEditFocus(int index)
{ {
if (index == 0) // Hex pattern if (index == 0) // Hex pattern
ui->hexEdit->setFocus(); ui->hexEdit->setFocus();
else if (index == 1) // GUID else if (index == 1) { // GUID
ui->guidEdit->setFocus(); ui->guidEdit->setFocus();
ui->guidEdit->setCursorPosition(0);
}
else if (index == 2) // Text else if (index == 2) // Text
ui->textEdit->setFocus(); ui->textEdit->setFocus();
} }

View File

@ -9,7 +9,7 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/ */
#ifndef SEARCHDIALOG_H #ifndef SEARCHDIALOG_H
#define SEARCHDIALOG_H #define SEARCHDIALOG_H

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>340</width> <width>400</width>
<height>214</height> <height>214</height>
</rect> </rect>
</property> </property>

View File

@ -15,13 +15,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "treeitem.h" #include "treeitem.h"
#include "types.h" #include "types.h"
TreeItem::TreeItem(const UINT8 type, const UINT8 subtype, const UINT8 compression, TreeItem::TreeItem(const UINT8 type, const UINT8 subtype, const UINT8 compression,
const QString & name, const QString & text, const QString & info, const QString & name, const QString & text, const QString & info,
const QByteArray & header, const QByteArray & body, const QByteArray & tail, const QByteArray & header, const QByteArray & body, const QByteArray & tail,
TreeItem *parent) TreeItem *parent)
{ {
itemAction = Actions::NoAction; itemAction = Actions::NoAction;
itemType = type; itemType = type;
@ -95,7 +92,7 @@ int TreeItem::columnCount() const
QVariant TreeItem::data(int column) const QVariant TreeItem::data(int column) const
{ {
switch(column) switch (column)
{ {
case 0: //Name case 0: //Name
return itemName; return itemName;
@ -206,7 +203,7 @@ void TreeItem::setAction(const UINT8 action)
// On insert action, set insert action for children // On insert action, set insert action for children
if (action == Actions::Insert) if (action == Actions::Insert)
for(int i = 0; i < childCount(); i++) for (int i = 0; i < childCount(); i++)
child(i)->setAction(Actions::Insert); child(i)->setAction(Actions::Insert);
// Set rebuild action for parent, if it has no action now // Set rebuild action for parent, if it has no action now

View File

@ -25,9 +25,9 @@ class TreeItem
{ {
public: public:
TreeItem(const UINT8 type, const UINT8 subtype = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE, TreeItem(const UINT8 type, const UINT8 subtype = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE,
const QString &name = QString(), const QString &text = QString(), const QString &info = QString(), const QString &name = QString(), const QString &text = QString(), const QString &info = QString(),
const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(), const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(),
TreeItem *parent = 0); TreeItem *parent = 0);
~TreeItem(); ~TreeItem();
// Operations with items // Operations with items

View File

@ -58,10 +58,10 @@ Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
} }
QVariant TreeModel::headerData(int section, Qt::Orientation orientation, QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
int role) const int role) const
{ {
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch(section) switch (section)
{ {
case 0: case 0:
return tr("Name"); return tr("Name");
@ -132,7 +132,7 @@ int TreeModel::rowCount(const QModelIndex &parent) const
UINT8 TreeModel::type(const QModelIndex &index) const UINT8 TreeModel::type(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return 0; return 0;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->type(); return item->type();
@ -140,7 +140,7 @@ UINT8 TreeModel::type(const QModelIndex &index) const
UINT8 TreeModel::subtype(const QModelIndex &index) const UINT8 TreeModel::subtype(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return 0; return 0;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->subtype(); return item->subtype();
@ -148,7 +148,7 @@ UINT8 TreeModel::subtype(const QModelIndex &index) const
QByteArray TreeModel::header(const QModelIndex &index) const QByteArray TreeModel::header(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return QByteArray(); return QByteArray();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->header(); return item->header();
@ -156,7 +156,7 @@ QByteArray TreeModel::header(const QModelIndex &index) const
bool TreeModel::hasEmptyHeader(const QModelIndex &index) const bool TreeModel::hasEmptyHeader(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return true; return true;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->hasEmptyHeader(); return item->hasEmptyHeader();
@ -164,7 +164,7 @@ bool TreeModel::hasEmptyHeader(const QModelIndex &index) const
QByteArray TreeModel::body(const QModelIndex &index) const QByteArray TreeModel::body(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return QByteArray(); return QByteArray();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->body(); return item->body();
@ -172,7 +172,7 @@ QByteArray TreeModel::body(const QModelIndex &index) const
bool TreeModel::hasEmptyBody(const QModelIndex &index) const bool TreeModel::hasEmptyBody(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return true; return true;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->hasEmptyBody(); return item->hasEmptyBody();
@ -180,7 +180,7 @@ bool TreeModel::hasEmptyBody(const QModelIndex &index) const
QByteArray TreeModel::tail(const QModelIndex &index) const QByteArray TreeModel::tail(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return QByteArray(); return QByteArray();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->tail(); return item->tail();
@ -188,7 +188,7 @@ QByteArray TreeModel::tail(const QModelIndex &index) const
bool TreeModel::hasEmptyTail(const QModelIndex &index) const bool TreeModel::hasEmptyTail(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return true; return true;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->hasEmptyTail(); return item->hasEmptyTail();
@ -196,7 +196,7 @@ bool TreeModel::hasEmptyTail(const QModelIndex &index) const
QString TreeModel::info(const QModelIndex &index) const QString TreeModel::info(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return QString(); return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->info(); return item->info();
@ -204,7 +204,7 @@ QString TreeModel::info(const QModelIndex &index) const
UINT8 TreeModel::action(const QModelIndex &index) const UINT8 TreeModel::action(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return Actions::NoAction; return Actions::NoAction;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->action(); return item->action();
@ -212,7 +212,7 @@ UINT8 TreeModel::action(const QModelIndex &index) const
UINT8 TreeModel::compression(const QModelIndex &index) const UINT8 TreeModel::compression(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return COMPRESSION_ALGORITHM_UNKNOWN; return COMPRESSION_ALGORITHM_UNKNOWN;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->compression(); return item->compression();
@ -220,7 +220,7 @@ UINT8 TreeModel::compression(const QModelIndex &index) const
void TreeModel::setSubtype(const QModelIndex & index, UINT8 subtype) void TreeModel::setSubtype(const QModelIndex & index, UINT8 subtype)
{ {
if(!index.isValid()) if (!index.isValid())
return; return;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
@ -230,7 +230,7 @@ void TreeModel::setSubtype(const QModelIndex & index, UINT8 subtype)
void TreeModel::setNameString(const QModelIndex &index, const QString &data) void TreeModel::setNameString(const QModelIndex &index, const QString &data)
{ {
if(!index.isValid()) if (!index.isValid())
return; return;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
@ -240,7 +240,7 @@ void TreeModel::setNameString(const QModelIndex &index, const QString &data)
void TreeModel::setTypeString(const QModelIndex &index, const QString &data) void TreeModel::setTypeString(const QModelIndex &index, const QString &data)
{ {
if(!index.isValid()) if (!index.isValid())
return; return;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
@ -250,7 +250,7 @@ void TreeModel::setTypeString(const QModelIndex &index, const QString &data)
void TreeModel::setSubtypeString(const QModelIndex &index, const QString &data) void TreeModel::setSubtypeString(const QModelIndex &index, const QString &data)
{ {
if(!index.isValid()) if (!index.isValid())
return; return;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
@ -260,7 +260,7 @@ void TreeModel::setSubtypeString(const QModelIndex &index, const QString &data)
void TreeModel::setTextString(const QModelIndex &index, const QString &data) void TreeModel::setTextString(const QModelIndex &index, const QString &data)
{ {
if(!index.isValid()) if (!index.isValid())
return; return;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
@ -270,7 +270,7 @@ void TreeModel::setTextString(const QModelIndex &index, const QString &data)
QString TreeModel::nameString(const QModelIndex &index) const QString TreeModel::nameString(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return QString(); return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
@ -279,15 +279,16 @@ QString TreeModel::nameString(const QModelIndex &index) const
QString TreeModel::actionString(const QModelIndex &index) const QString TreeModel::actionString(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return QString(); return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->data(1).toString();} return item->data(1).toString();
}
QString TreeModel::typeString(const QModelIndex &index) const QString TreeModel::typeString(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return QString(); return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
@ -296,7 +297,7 @@ QString TreeModel::typeString(const QModelIndex &index) const
QString TreeModel::subtypeString(const QModelIndex &index) const QString TreeModel::subtypeString(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return QString(); return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
@ -305,28 +306,27 @@ QString TreeModel::subtypeString(const QModelIndex &index) const
QString TreeModel::textString(const QModelIndex &index) const QString TreeModel::textString(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return QString(); return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->data(4).toString(); return item->data(4).toString();
} }
void TreeModel::setAction(const QModelIndex &index, const UINT8 action) void TreeModel::setAction(const QModelIndex &index, const UINT8 action)
{ {
if(!index.isValid()) if (!index.isValid())
return; return;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer()); TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
item->setAction(action); item->setAction(action);
emit dataChanged(this->index(0,0), index); emit dataChanged(this->index(0, 0), index);
} }
QModelIndex TreeModel::addItem(const UINT8 type, const UINT8 subtype, const UINT8 compression, QModelIndex TreeModel::addItem(const UINT8 type, const UINT8 subtype, const UINT8 compression,
const QString & name, const QString & text, const QString & info, const QString & name, const QString & text, const QString & info,
const QByteArray & header, const QByteArray & body, const QByteArray & tail, const QByteArray & header, const QByteArray & body, const QByteArray & tail,
const QModelIndex & parent, const UINT8 mode) const QModelIndex & parent, const UINT8 mode)
{ {
TreeItem *item = 0; TreeItem *item = 0;
TreeItem *parentItem = 0; TreeItem *parentItem = 0;
@ -376,13 +376,13 @@ QModelIndex TreeModel::addItem(const UINT8 type, const UINT8 subtype, const UINT
QModelIndex TreeModel::findParentOfType(const QModelIndex& index, UINT8 type) const QModelIndex TreeModel::findParentOfType(const QModelIndex& index, UINT8 type) const
{ {
if(!index.isValid()) if (!index.isValid())
return QModelIndex(); return QModelIndex();
TreeItem *item; TreeItem *item;
QModelIndex parent = index; QModelIndex parent = index;
for(item = static_cast<TreeItem*>(parent.internalPointer()); for (item = static_cast<TreeItem*>(parent.internalPointer());
item != NULL && item != rootItem && item->type() != type; item != NULL && item != rootItem && item->type() != type;
item = static_cast<TreeItem*>(parent.internalPointer())) item = static_cast<TreeItem*>(parent.internalPointer()))
parent = parent.parent(); parent = parent.parent();

View File

@ -35,9 +35,9 @@ public:
QVariant data(const QModelIndex &index, int role) const; QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const; Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const; int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column, QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const; const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const; QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const; int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const;
@ -69,9 +69,9 @@ public:
UINT8 compression(const QModelIndex &index) const; UINT8 compression(const QModelIndex &index) const;
QModelIndex addItem(const UINT8 type, const UINT8 subtype = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE, QModelIndex addItem(const UINT8 type, const UINT8 subtype = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE,
const QString & name = QString(), const QString & text = QString(), const QString & info = QString(), const QString & name = QString(), const QString & text = QString(), const QString & info = QString(),
const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(), const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(),
const QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND); const QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND);
QModelIndex findParentOfType(const QModelIndex & index, UINT8 type) const; QModelIndex findParentOfType(const QModelIndex & index, UINT8 type) const;

View File

@ -116,7 +116,6 @@ QString compressionTypeToQString(UINT8 algorithm)
} }
} }
QString actionTypeToQString(UINT8 action) QString actionTypeToQString(UINT8 action)
{ {
switch (action) { switch (action) {
@ -138,4 +137,3 @@ QString actionTypeToQString(UINT8 action)
return QObject::tr("Unknown"); return QObject::tr("Unknown");
} }
} }

View File

@ -9,14 +9,14 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/ */
#include "uefitool.h" #include "uefitool.h"
#include "ui_uefitool.h" #include "ui_uefitool.h"
UEFITool::UEFITool(QWidget *parent) : UEFITool::UEFITool(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::UEFITool) ui(new Ui::UEFITool)
{ {
clipboard = QApplication::clipboard(); clipboard = QApplication::clipboard();
@ -48,6 +48,9 @@ UEFITool::UEFITool(QWidget *parent) :
// Enable Drag-and-Drop actions // Enable Drag-and-Drop actions
this->setAcceptDrops(true); this->setAcceptDrops(true);
// Set current directory
currentDir = ".";
// Initialize non-persistent data // Initialize non-persistent data
init(); init();
@ -86,7 +89,7 @@ void UEFITool::init()
// Connect // Connect
connect(ui->structureTreeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), connect(ui->structureTreeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
this, SLOT(populateUi(const QModelIndex &))); this, SLOT(populateUi(const QModelIndex &)));
connect(ui->messageListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*))); connect(ui->messageListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*)));
connect(ui->messageListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyAction(QListWidgetItem*))); connect(ui->messageListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyAction(QListWidgetItem*)));
} }
@ -98,7 +101,7 @@ void UEFITool::populateUi(const QModelIndex &current)
TreeModel* model = ffsEngine->treeModel(); TreeModel* model = ffsEngine->treeModel();
UINT8 type = model->type(current); UINT8 type = model->type(current);
UINT8 subtype = model->subtype(current); UINT8 subtype = model->subtype(current);
// Set info text // Set info text
ui->infoEdit->setPlainText(model->info(current)); ui->infoEdit->setPlainText(model->info(current));
@ -152,6 +155,7 @@ void UEFITool::search()
} }
else if (index == 1) { // GUID else if (index == 1) { // GUID
searchDialog->ui->guidEdit->setFocus(); searchDialog->ui->guidEdit->setFocus();
searchDialog->ui->guidEdit->setCursorPosition(0);
QByteArray pattern = searchDialog->ui->guidEdit->text().toLatin1(); QByteArray pattern = searchDialog->ui->guidEdit->text().toLatin1();
if (pattern.isEmpty()) if (pattern.isEmpty())
return; return;
@ -171,7 +175,7 @@ void UEFITool::search()
if (pattern.isEmpty()) if (pattern.isEmpty())
return; return;
ffsEngine->findTextPattern(rootIndex, pattern, searchDialog->ui->textUnicodeCheckBox->isChecked(), ffsEngine->findTextPattern(rootIndex, pattern, searchDialog->ui->textUnicodeCheckBox->isChecked(),
(Qt::CaseSensitivity) searchDialog->ui->textCaseSensitiveCheckBox->isChecked()); (Qt::CaseSensitivity) searchDialog->ui->textCaseSensitiveCheckBox->isChecked());
showMessages(); showMessages();
} }
} }
@ -217,11 +221,11 @@ void UEFITool::insert(const UINT8 mode)
QString path; QString path;
switch (type) { switch (type) {
case Types::Volume: case Types::Volume:
path = QFileDialog::getOpenFileName(this, tr("Select FFS file to insert"),".","FFS files (*.ffs *.bin);;All files (*.*)"); path = QFileDialog::getOpenFileName(this, tr("Select FFS file to insert"), currentDir, "FFS files (*.ffs *.bin);;All files (*.*)");
break; break;
case Types::File: case Types::File:
case Types::Section: case Types::Section:
path = QFileDialog::getOpenFileName(this, tr("Select section file to insert"),".","Section files (*.sct *.bin);;All files (*.*)"); path = QFileDialog::getOpenFileName(this, tr("Select section file to insert"), currentDir, "Section files (*.sct *.bin);;All files (*.*)");
break; break;
default: default:
return; return;
@ -290,39 +294,39 @@ void UEFITool::replace(const UINT8 mode)
QString path; QString path;
if (model->type(index) == Types::Region) { if (model->type(index) == Types::Region) {
if (mode == REPLACE_MODE_AS_IS) { if (mode == REPLACE_MODE_AS_IS) {
path = QFileDialog::getOpenFileName(this, tr("Select region file to replace selected object"), ".", "Region files (*.rgn *.bin);;All files (*.*)"); path = QFileDialog::getOpenFileName(this, tr("Select region file to replace selected object"), currentDir, "Region files (*.rgn *.bin);;All files (*.*)");
} }
else else
return; return;
} }
else if (model->type(index) == Types::File) { else if (model->type(index) == Types::File) {
if (mode == REPLACE_MODE_AS_IS) { if (mode == REPLACE_MODE_AS_IS) {
path = QFileDialog::getOpenFileName(this, tr("Select FFS file to replace selected object"),".","FFS files (*.ffs *.bin);;All files (*.*)"); path = QFileDialog::getOpenFileName(this, tr("Select FFS file to replace selected object"), currentDir, "FFS files (*.ffs *.bin);;All files (*.*)");
} }
else if (mode == REPLACE_MODE_BODY) { else if (mode == REPLACE_MODE_BODY) {
if (model->subtype(index) == EFI_FV_FILETYPE_ALL || model->subtype(index) == EFI_FV_FILETYPE_RAW) if (model->subtype(index) == EFI_FV_FILETYPE_ALL || model->subtype(index) == EFI_FV_FILETYPE_RAW)
path = QFileDialog::getOpenFileName(this, tr("Select raw file to replace body"),".","Raw files (*.raw *.bin);;All files (*.*)"); path = QFileDialog::getOpenFileName(this, tr("Select raw file to replace body"), currentDir, "Raw files (*.raw *.bin);;All files (*.*)");
else if (model->subtype(index) == EFI_FV_FILETYPE_PAD) // Pad file body can't be replaced else if (model->subtype(index) == EFI_FV_FILETYPE_PAD) // Pad file body can't be replaced
return; return;
else else
path = QFileDialog::getOpenFileName(this, tr("Select FFS file body to replace body"),".","FFS file body files (*.fbd *.bin);;All files (*.*)"); path = QFileDialog::getOpenFileName(this, tr("Select FFS file body to replace body"), currentDir, "FFS file body files (*.fbd *.bin);;All files (*.*)");
} }
else else
return; return;
} }
else if (model->type(index) == Types::Section) { else if (model->type(index) == Types::Section) {
if (mode == REPLACE_MODE_AS_IS) { if (mode == REPLACE_MODE_AS_IS) {
path = QFileDialog::getOpenFileName(this, tr("Select section file to replace selected object"),".","Section files (*.sec *.bin);;All files (*.*)"); path = QFileDialog::getOpenFileName(this, tr("Select section file to replace selected object"), currentDir, "Section files (*.sec *.bin);;All files (*.*)");
} }
else if (mode == REPLACE_MODE_BODY) { else if (mode == REPLACE_MODE_BODY) {
if (model->subtype(index) == EFI_SECTION_COMPRESSION || model->subtype(index) == EFI_SECTION_GUID_DEFINED || model->subtype(index) == EFI_SECTION_DISPOSABLE) if (model->subtype(index) == EFI_SECTION_COMPRESSION || model->subtype(index) == EFI_SECTION_GUID_DEFINED || model->subtype(index) == EFI_SECTION_DISPOSABLE)
path = QFileDialog::getOpenFileName(this, tr("Select FFS file body file to replace body"),".","FFS file body files (*.fbd *.bin);;All files (*.*)"); path = QFileDialog::getOpenFileName(this, tr("Select FFS file body file to replace body"), currentDir, "FFS file body files (*.fbd *.bin);;All files (*.*)");
else if (model->subtype(index) == EFI_SECTION_FIRMWARE_VOLUME_IMAGE) else if (model->subtype(index) == EFI_SECTION_FIRMWARE_VOLUME_IMAGE)
path = QFileDialog::getOpenFileName(this, tr("Select volume file to replace body"),".","Volume files (*.vol *.bin);;All files (*.*)"); path = QFileDialog::getOpenFileName(this, tr("Select volume file to replace body"), currentDir, "Volume files (*.vol *.bin);;All files (*.*)");
else if (model->subtype(index) == EFI_SECTION_RAW) else if (model->subtype(index) == EFI_SECTION_RAW)
path = QFileDialog::getOpenFileName(this, tr("Select raw file to replace body"),".","Raw files (*.raw *.bin);;All files (*.*)"); path = QFileDialog::getOpenFileName(this, tr("Select raw file to replace body"), currentDir, "Raw files (*.raw *.bin);;All files (*.*)");
else else
path = QFileDialog::getOpenFileName(this, tr("Select file to replace body"),".","Binary files (*.bin);;All files (*.*)"); path = QFileDialog::getOpenFileName(this, tr("Select file to replace body"), currentDir, "Binary files (*.bin);;All files (*.*)");
} }
else else
return; return;
@ -381,59 +385,59 @@ void UEFITool::extract(const UINT8 mode)
if (mode == EXTRACT_MODE_AS_IS) { if (mode == EXTRACT_MODE_AS_IS) {
switch (type) { switch (type) {
case Types::Capsule: case Types::Capsule:
path = QFileDialog::getSaveFileName(this, tr("Save capsule to file"),".","Capsule files (*.cap *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save capsule to file"), currentDir, "Capsule files (*.cap *.bin);;All files (*.*)");
break; break;
case Types::Image: case Types::Image:
path = QFileDialog::getSaveFileName(this, tr("Save image to file"),".","Image files (*.rom *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save image to file"), currentDir, "Image files (*.rom *.bin);;All files (*.*)");
break; break;
case Types::Region: case Types::Region:
path = QFileDialog::getSaveFileName(this, tr("Save region to file"),".","Region files (*.rgn *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save region to file"), currentDir, "Region files (*.rgn *.bin);;All files (*.*)");
break; break;
case Types::Padding: case Types::Padding:
path = QFileDialog::getSaveFileName(this, tr("Save padding to file"),".","Padding files (*.pad *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save padding to file"), currentDir, "Padding files (*.pad *.bin);;All files (*.*)");
break; break;
case Types::Volume: case Types::Volume:
path = QFileDialog::getSaveFileName(this, tr("Save volume to file"),".","Volume files (*.vol *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save volume to file"), currentDir, "Volume files (*.vol *.bin);;All files (*.*)");
break; break;
case Types::File: case Types::File:
path = QFileDialog::getSaveFileName(this, tr("Save FFS file to file"),".","FFS files (*.ffs *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save FFS file to file"), currentDir, "FFS files (*.ffs *.bin);;All files (*.*)");
break; break;
case Types::Section: case Types::Section:
path = QFileDialog::getSaveFileName(this, tr("Save section file to file"),".","Section files (*.sct *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save section file to file"), currentDir, "Section files (*.sct *.bin);;All files (*.*)");
break; break;
default: default:
path = QFileDialog::getSaveFileName(this, tr("Save object to file"),".","Binary files (*.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save object to file"), currentDir, "Binary files (*.bin);;All files (*.*)");
} }
} }
else if (mode == EXTRACT_MODE_BODY) { else if (mode == EXTRACT_MODE_BODY) {
switch (type) { switch (type) {
case Types::Capsule: case Types::Capsule:
path = QFileDialog::getSaveFileName(this, tr("Save capsule body to image file"),".","Image files (*.rom *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save capsule body to image file"), currentDir, "Image files (*.rom *.bin);;All files (*.*)");
break; break;
case Types::File: { case Types::File: {
if (model->subtype(index) == EFI_FV_FILETYPE_ALL || model->subtype(index) == EFI_FV_FILETYPE_RAW) if (model->subtype(index) == EFI_FV_FILETYPE_ALL || model->subtype(index) == EFI_FV_FILETYPE_RAW)
path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to raw file"),".","Raw files (*.raw *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to raw file"), currentDir, "Raw files (*.raw *.bin);;All files (*.*)");
else else
path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to file"),".","FFS file body files (*.fbd *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to file"), currentDir, "FFS file body files (*.fbd *.bin);;All files (*.*)");
} }
break; break;
case Types::Section: { case Types::Section: {
if (model->subtype(index) == EFI_SECTION_COMPRESSION || model->subtype(index) == EFI_SECTION_GUID_DEFINED || model->subtype(index) == EFI_SECTION_DISPOSABLE) if (model->subtype(index) == EFI_SECTION_COMPRESSION || model->subtype(index) == EFI_SECTION_GUID_DEFINED || model->subtype(index) == EFI_SECTION_DISPOSABLE)
path = QFileDialog::getSaveFileName(this, tr("Save encapsulation section body to FFS body file"),".","FFS file body files (*.fbd *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save encapsulation section body to FFS body file"), currentDir, "FFS file body files (*.fbd *.bin);;All files (*.*)");
else if (model->subtype(index) == EFI_SECTION_FIRMWARE_VOLUME_IMAGE) else if (model->subtype(index) == EFI_SECTION_FIRMWARE_VOLUME_IMAGE)
path = QFileDialog::getSaveFileName(this, tr("Save section body to volume file"),".","Volume files (*.vol *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save section body to volume file"), currentDir, "Volume files (*.vol *.bin);;All files (*.*)");
else if (model->subtype(index) == EFI_SECTION_RAW) else if (model->subtype(index) == EFI_SECTION_RAW)
path = QFileDialog::getSaveFileName(this, tr("Save section body to raw file"),".","Raw files (*.raw *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save section body to raw file"), currentDir, "Raw files (*.raw *.bin);;All files (*.*)");
else else
path = QFileDialog::getSaveFileName(this, tr("Save section body to file"),".","Binary files (*.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save section body to file"), currentDir, "Binary files (*.bin);;All files (*.*)");
} }
break; break;
default: default:
path = QFileDialog::getSaveFileName(this, tr("Save object to file"),".","Binary files (*.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save object to file"), currentDir, "Binary files (*.bin);;All files (*.*)");
} }
} }
else else
path = QFileDialog::getSaveFileName(this, tr("Save object to file"),".","Binary files (*.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save object to file"), currentDir, "Binary files (*.bin);;All files (*.*)");
if (path.trimmed().isEmpty()) if (path.trimmed().isEmpty())
return; return;
@ -459,13 +463,13 @@ void UEFITool::extract(const UINT8 mode)
void UEFITool::about() void UEFITool::about()
{ {
QMessageBox::about(this, tr("About UEFITool"), tr( QMessageBox::about(this, tr("About UEFITool"), tr(
"Copyright (c) 2014, Nikolaj Schlej aka <b>CodeRush</b>.<br><br>" "Copyright (c) 2014, Nikolaj Schlej aka <b>CodeRush</b>.<br><br>"
"The program is dedicated to <b>RevoGirl</b>. Rest in peace, young genius.<br><br>" "The program is dedicated to <b>RevoGirl</b>. Rest in peace, young genius.<br><br>"
"The program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License.<br>" "The program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License.<br>"
"The full text of the license may be found at <a href=http://opensource.org/licenses/bsd-license.php>OpenSource.org</a>.<br><br>" "The full text of the license may be found at <a href=http://opensource.org/licenses/bsd-license.php>OpenSource.org</a>.<br><br>"
"<b>THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS, " "<b>THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS, "
"WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, " "WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, "
"EITHER EXPRESS OR IMPLIED.</b>")); "EITHER EXPRESS OR IMPLIED.</b>"));
} }
void UEFITool::aboutQt() void UEFITool::aboutQt()
@ -480,7 +484,7 @@ void UEFITool::exit()
void UEFITool::saveImageFile() void UEFITool::saveImageFile()
{ {
QString path = QFileDialog::getSaveFileName(this, tr("Save BIOS image file"),".","BIOS image files (*.rom *.bin *.cap *.bio *.fd *.wph *.efi);;All files (*.*)"); QString path = QFileDialog::getSaveFileName(this, tr("Save BIOS image file"), currentDir, "BIOS image files (*.rom *.bin *.cap *.bio *.fd *.wph *.efi);;All files (*.*)");
if (path.isEmpty()) if (path.isEmpty())
return; return;
@ -510,7 +514,7 @@ void UEFITool::saveImageFile()
void UEFITool::openImageFile() void UEFITool::openImageFile()
{ {
QString path = QFileDialog::getOpenFileName(this, tr("Open BIOS image file"),".","BIOS image files (*.rom *.bin *.cap *.bio *.fd *.wph *.efi);;All files (*.*)"); QString path = QFileDialog::getOpenFileName(this, tr("Open BIOS image file"), currentDir, "BIOS image files (*.rom *.bin *.cap *.bio *.fd *.wph *.efi);;All files (*.*)");
openImageFile(path); openImageFile(path);
} }
@ -547,6 +551,9 @@ void UEFITool::openImageFile(QString path)
// Enable search // Enable search
ui->actionSearch->setEnabled(true); ui->actionSearch->setEnabled(true);
// Set current directory
currentDir = fileInfo.absolutePath();
} }
void UEFITool::copyMessage() void UEFITool::copyMessage()
@ -610,16 +617,16 @@ void UEFITool::contextMenuEvent(QContextMenuEvent* event)
return; return;
} }
if(!ui->structureTreeView->underMouse()) if (!ui->structureTreeView->underMouse())
return; return;
QPoint pt = event->pos(); QPoint pt = event->pos();
QModelIndex index = ui->structureTreeView->indexAt(ui->structureTreeView->viewport()->mapFrom(this, pt)); QModelIndex index = ui->structureTreeView->indexAt(ui->structureTreeView->viewport()->mapFrom(this, pt));
if(!index.isValid()) if (!index.isValid())
return; return;
TreeModel* model = ffsEngine->treeModel(); TreeModel* model = ffsEngine->treeModel();
switch(model->type(index)) switch (model->type(index))
{ {
case Types::Capsule: case Types::Capsule:
ui->menuCapsuleActions->exec(event->globalPos()); ui->menuCapsuleActions->exec(event->globalPos());

View File

@ -9,7 +9,7 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/ */
#ifndef __UEFITOOL_H__ #ifndef __UEFITOOL_H__
#define __UEFITOOL_H__ #define __UEFITOOL_H__
@ -39,7 +39,7 @@
#include "searchdialog.h" #include "searchdialog.h"
namespace Ui { namespace Ui {
class UEFITool; class UEFITool;
} }
class UEFITool : public QMainWindow class UEFITool : public QMainWindow
@ -52,7 +52,7 @@ public:
void openImageFile(QString path); void openImageFile(QString path);
private slots: private slots:
void init(); void init();
void populateUi(const QModelIndex &current); void populateUi(const QModelIndex &current);
void scrollTreeView(QListWidgetItem* item); void scrollTreeView(QListWidgetItem* item);
@ -93,6 +93,7 @@ private:
FfsEngine* ffsEngine; FfsEngine* ffsEngine;
SearchDialog* searchDialog; SearchDialog* searchDialog;
QClipboard* clipboard; QClipboard* clipboard;
QString currentDir;
QQueue<MessageListItem> messageItems; QQueue<MessageListItem> messageItems;
void showMessages(); void showMessages();

View File

@ -20,7 +20,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>UEFITool 0.18.3</string> <string>UEFITool 0.18.4</string>
</property> </property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<property name="sizePolicy"> <property name="sizePolicy">

View File

@ -9,7 +9,7 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/ */
#include <QApplication> #include <QApplication>
#include <QString> #include <QString>