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

View file

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

View file

@ -18,13 +18,13 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <stdlib.h>
UINT64
EFIAPI
LShiftU64 (
UINT64 Operand,
UINT32 Count
)
EFIAPI
LShiftU64(
UINT64 Operand,
UINT32 Count
)
{
return Operand << Count;
return Operand << Count;
}
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.
*/
UINT64
GetDecodedSizeOfBuf(
UINT8 *EncodedData
)
GetDecodedSizeOfBuf(
UINT8 *EncodedData
)
{
UINT64 DecodedSize;
INT32 Index;
UINT64 DecodedSize;
INT32 Index;
// Parse header
DecodedSize = 0;
for (Index = LZMA_PROPS_SIZE + 7; Index >= LZMA_PROPS_SIZE; Index--)
DecodedSize = LShiftU64(DecodedSize, 8) + EncodedData[Index];
// Parse header
DecodedSize = 0;
for (Index = LZMA_PROPS_SIZE + 7; Index >= LZMA_PROPS_SIZE; Index--)
DecodedSize = LShiftU64(DecodedSize, 8) + EncodedData[Index];
return DecodedSize;
return DecodedSize;
}
//
@ -59,15 +59,15 @@ UINT64
//
/*
Given a Lzma compressed source buffer, this function retrieves the size of
the uncompressed buffer and the size of the scratch buffer required
Given a Lzma compressed source buffer, this function retrieves the size of
the uncompressed buffer and the size of the scratch buffer required
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.
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.
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"
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.
@ -80,35 +80,35 @@ If SourceSize is less than LZMA_HEADER_SIZE, then ASSERT().
that will be generated when the compressed buffer specified
by Source and SourceSize is decompressed.
@retval EFI_SUCCESS The size of the uncompressed data was returned
DestinationSize and the size of the scratch
@retval EFI_SUCCESS The size of the uncompressed data was returned
DestinationSize and the size of the scratch
buffer was returned ScratchSize.
*/
INT32
EFIAPI
LzmaGetInfo (
CONST VOID *Source,
UINT32 SourceSize,
UINT32 *DestinationSize
)
EFIAPI
LzmaGetInfo(
CONST VOID *Source,
UINT32 SourceSize,
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;
return ERR_SUCCESS;
*DestinationSize = (UINT32)DecodedSize;
return ERR_SUCCESS;
}
/*
Decompresses a Lzma compressed source buffer.
Extracts decompressed data to its original form.
If the compressed source data specified by Source is successfully decompressed
into Destination, then RETURN_SUCCESS is returned. If the compressed source data
If the compressed source data specified by Source is successfully decompressed
into Destination, then RETURN_SUCCESS is returned. If the compressed source data
specified by Source is not a valid compressed data format,
then RETURN_INVALID_PARAMETER is returned.
@ -116,44 +116,44 @@ then RETURN_INVALID_PARAMETER is returned.
@param SourceSize The size of source buffer.
@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.
@retval EFI_INVALID_PARAMETER
The source buffer specified by Source is corrupted
@retval EFI_INVALID_PARAMETER
The source buffer specified by Source is corrupted
(not a valid compressed format).
*/
INT32
EFIAPI
LzmaDecompress (
CONST VOID *Source,
UINT32 SourceSize,
VOID *Destination
)
EFIAPI
LzmaDecompress(
CONST VOID *Source,
UINT32 SourceSize,
VOID *Destination
)
{
SRes LzmaResult;
ELzmaStatus Status;
SizeT DecodedBufSize;
SizeT EncodedDataSize;
SRes LzmaResult;
ELzmaStatus Status;
SizeT DecodedBufSize;
SizeT EncodedDataSize;
DecodedBufSize = (SizeT)GetDecodedSizeOfBuf((UINT8*)Source);
EncodedDataSize = (SizeT) (SourceSize - LZMA_HEADER_SIZE);
DecodedBufSize = (SizeT)GetDecodedSizeOfBuf((UINT8*)Source);
EncodedDataSize = (SizeT)(SourceSize - LZMA_HEADER_SIZE);
LzmaResult = LzmaDecode(
(Byte*) Destination,
&DecodedBufSize,
(Byte*)((UINT8*)Source + LZMA_HEADER_SIZE),
&EncodedDataSize,
(CONST Byte*) Source,
LZMA_PROPS_SIZE,
LZMA_FINISH_END,
&Status,
&SzAllocForLzma
);
if (LzmaResult == SZ_OK) {
return ERR_SUCCESS;
} else {
return ERR_INVALID_PARAMETER;
}
}
LzmaResult = LzmaDecode(
(Byte*)Destination,
&DecodedBufSize,
(Byte*)((UINT8*)Source + LZMA_HEADER_SIZE),
&EncodedDataSize,
(CONST Byte*) Source,
LZMA_PROPS_SIZE,
LZMA_FINISH_END,
&Status,
&SzAllocForLzma
);
if (LzmaResult == SZ_OK) {
return ERR_SUCCESS;
}
else {
return ERR_INVALID_PARAMETER;
}
}

View file

@ -9,7 +9,7 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
*/
#ifndef __LZMADECOMPRESS_H__
#define __LZMADECOMPRESS_H__
@ -23,77 +23,76 @@ extern "C" {
#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)
UINT64
EFIAPI
LShiftU64 (
UINT64 Operand,
UINT32 Count
);
UINT64
EFIAPI
LShiftU64(
UINT64 Operand,
UINT32 Count
);
/*
Given a Lzma compressed source buffer, this function retrieves the size of
the uncompressed buffer and the size of the scratch buffer required
to decompress the compressed source buffer.
/*
Given a Lzma compressed source buffer, this function retrieves the size of
the uncompressed buffer and the size of the scratch buffer required
to decompress the compressed source buffer.
Retrieves the size of the uncompressed buffer and the temporary scratch buffer
required to decompress the buffer specified by Source and SourceSize.
The size of the uncompressed buffer is returned DestinationSize,
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
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.
And ScratchSize is specific to the decompression implementation.
Retrieves the size of the uncompressed buffer and the temporary scratch buffer
required to decompress the buffer specified by Source and SourceSize.
The size of the uncompressed buffer is returned DestinationSize,
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
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.
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 SourceSize The size, bytes, of the source buffer.
@param DestinationSize A pointer to the size, bytes, of the uncompressed buffer
that will be generated when the compressed buffer specified
by Source and SourceSize is decompressed.
@param Source The source buffer containing the compressed data.
@param SourceSize The size, bytes, of the source buffer.
@param DestinationSize A pointer to the size, bytes, of the uncompressed buffer
that will be generated when the compressed buffer specified
by Source and SourceSize is decompressed.
@retval EFI_SUCCESS The size of the uncompressed data was returned
DestinationSize and the size of the scratch
buffer was returned ScratchSize.
@retval EFI_SUCCESS The size of the uncompressed data was returned
DestinationSize and the size of the scratch
buffer was returned ScratchSize.
*/
INT32
EFIAPI
LzmaGetInfo (
const VOID *Source,
UINT32 SourceSize,
UINT32 *DestinationSize
);
*/
INT32
EFIAPI
LzmaGetInfo(
const VOID *Source,
UINT32 SourceSize,
UINT32 *DestinationSize
);
/*
Decompresses a Lzma compressed source buffer.
/*
Decompresses a Lzma compressed source buffer.
Extracts decompressed data to its original form.
If the compressed source data specified by Source is successfully decompressed
into Destination, then RETURN_SUCCESS is returned. If the compressed source data
specified by Source is not a valid compressed data format,
then RETURN_INVALID_PARAMETER is returned.
Extracts decompressed data to its original form.
If the compressed source data specified by Source is successfully decompressed
into Destination, then RETURN_SUCCESS is returned. If the compressed source data
specified by Source is not a valid compressed data format,
then RETURN_INVALID_PARAMETER is returned.
@param Source The source buffer containing the compressed data.
@param SourceSize The size of source buffer.
@param Destination The destination buffer to store the decompressed data
@retval EFI_SUCCESS Decompression completed successfully, and
the uncompressed buffer is returned Destination.
@retval EFI_INVALID_PARAMETER
The source buffer specified by Source is corrupted
(not a valid compressed format).
*/
INT32
EFIAPI
LzmaDecompress (
const VOID *Source,
UINT32 SourceSize,
VOID *Destination
);
@param Source The source buffer containing the compressed data.
@param SourceSize The size of source buffer.
@param Destination The destination buffer to store the decompressed data
@retval EFI_SUCCESS Decompression completed successfully, and
the uncompressed buffer is returned Destination.
@retval EFI_INVALID_PARAMETER
The source buffer specified by Source is corrupted
(not a valid compressed format).
*/
INT32
EFIAPI
LzmaDecompress(
const VOID *Source,
UINT32 SourceSize,
VOID *Destination
);
#ifdef __cplusplus
}
#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'
//
mNext[LoopVar4] = mPos;
}
/**
@ -914,7 +913,6 @@ IN UINT32 x
mSubBitBuf |= x << (mBitCount -= LoopVar8);
}
else {
Temp = (UINT8)(mSubBitBuf | (x >> (LoopVar8 -= mBitCount)));
if (mDst < mDstUpperLimit) {
*mDst++ = Temp;
@ -925,7 +923,6 @@ IN UINT32 x
mSubBitBuf = x << (mBitCount = UINT8_BIT - LoopVar8);
}
else {
Temp = (UINT8)(x >> (LoopVar8 - UINT8_BIT));
if (mDst < mDstUpperLimit) {
*mDst++ = Temp;
@ -1031,7 +1028,7 @@ VOID
}
}
else {
ASSERT((LoopVar3 + 2)<(2 * NT - 1));
ASSERT((LoopVar3 + 2) < (2 * NT - 1));
mTFreq[LoopVar3 + 2]++;
}
}
@ -1135,7 +1132,7 @@ VOID
}
}
else {
ASSERT((LoopVar3 + 2)<NPT);
ASSERT((LoopVar3 + 2) < NPT);
PutBits(mPTLen[LoopVar3 + 2], mPTCode[LoopVar3 + 2]);
}
}
@ -1456,7 +1453,6 @@ IN OUT UINT64 *DstSize
*DstSize = mCompSize + 1 + 8;
return EFI_SUCCESS;
}
}
UINT8 EfiCompress(CONST VOID* SrcBuffer, CONST UINT64 SrcSize, VOID* DstBuffer, UINT64* DstSize)

View file

@ -2,22 +2,22 @@
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.<BR>
Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
TianoCompress.h
TianoCompress.h
Abstract:
Header file for compression routine.
Header file for compression routine.
*/
#ifndef _EFITIANOCOMPRESS_H_
@ -32,69 +32,69 @@ Abstract:
extern "C" {
#endif
/*++
/*++
Routine Description:
Routine Description:
Tiano compression routine.
Tiano compression routine.
Arguments:
Arguments:
SrcBuffer - The buffer storing the source data
SrcSize - The size of source data
DstBuffer - The buffer to store the compressed data
DstSize - On input, the size of DstBuffer; On output,
the size of the actual compressed data.
SrcBuffer - The buffer storing the source data
SrcSize - The size of source data
DstBuffer - The buffer to store the compressed data
DstSize - On input, the size of DstBuffer; On output,
the size of the actual compressed data.
Returns:
Returns:
EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. this case,
DstSize contains the size needed.
EFI_SUCCESS - Compression is successful.
EFI_OUT_OF_RESOURCES - No resource to complete function.
EFI_INVALID_PARAMETER - Parameter supplied is wrong.
EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. this case,
DstSize contains the size needed.
EFI_SUCCESS - Compression is successful.
EFI_OUT_OF_RESOURCES - No resource to complete function.
EFI_INVALID_PARAMETER - Parameter supplied is wrong.
--*/
UINT8
TianoCompress (
CONST VOID *SrcBuffer,
CONST UINT64 SrcSize,
VOID *DstBuffer,
UINT64 *DstSize
)
;
--*/
UINT8
TianoCompress(
CONST VOID *SrcBuffer,
CONST UINT64 SrcSize,
VOID *DstBuffer,
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
SrcSize - The size of source data
DstBuffer - The buffer to store the compressed data
DstSize - On input, the size of DstBuffer; On output,
the size of the actual compressed data.
SrcBuffer - The buffer storing the source data
SrcSize - The size of source data
DstBuffer - The buffer to store the compressed data
DstSize - On input, the size of DstBuffer; On output,
the size of the actual compressed data.
Returns:
Returns:
EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. this case,
DstSize contains the size needed.
EFI_SUCCESS - Compression is successful.
EFI_OUT_OF_RESOURCES - No resource to complete function.
EFI_INVALID_PARAMETER - Parameter supplied is wrong.
EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. this case,
DstSize contains the size needed.
EFI_SUCCESS - Compression is successful.
EFI_OUT_OF_RESOURCES - No resource to complete function.
EFI_INVALID_PARAMETER - Parameter supplied is wrong.
--*/
UINT8
EfiCompress (
CONST VOID *SrcBuffer,
CONST UINT64 SrcSize,
VOID *DstBuffer,
UINT64 *DstSize
)
;
--*/
UINT8
EfiCompress(
CONST VOID *SrcBuffer,
CONST UINT64 SrcSize,
VOID *DstBuffer,
UINT64 *DstSize
)
;
#ifdef __cplusplus
}

View file

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

View file

@ -2,22 +2,22 @@
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.<BR>
Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Decompress.h
Decompress.h
Abstract:
Header file for decompression routine.
Providing both EFI and Tiano decompress algorithms.
Header file for decompression routine.
Providing both EFI and Tiano decompress algorithms.
--*/
@ -32,108 +32,108 @@ Abstract:
extern "C" {
#endif
typedef struct {
UINT32 CompSize;
UINT32 OrigSize;
} EFI_TIANO_HEADER;
typedef struct {
UINT32 CompSize;
UINT32 OrigSize;
} EFI_TIANO_HEADER;
EFI_STATUS
EFIAPI
EfiTianoGetInfo (
VOID *Source,
UINT32 SrcSize,
UINT32 *DstSize,
UINT32 *ScratchSize
)
/*++
EFI_STATUS
EFIAPI
EfiTianoGetInfo(
VOID *Source,
UINT32 SrcSize,
UINT32 *DstSize,
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
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
DstSize - The size of destination buffer.
ScratchSize - The size of scratch buffer.
This - The protocol instance pointer
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
DstSize - The size of destination 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_INVALID_PARAMETER - The source data is corrupted
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_STATUS
EFIAPI
EfiDecompress (
VOID *Source,
UINT32 SrcSize,
VOID *Destination,
UINT32 DstSize,
VOID *Scratch,
UINT32 ScratchSize
)
/*++
EFI_STATUS
EFIAPI
EfiDecompress(
VOID *Source,
UINT32 SrcSize,
VOID *Destination,
UINT32 DstSize,
VOID *Scratch,
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
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
Destination - The destination buffer to store the decompressed data
DstSize - The size of destination buffer.
Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
ScratchSize - The size of scratch buffer.
This - The protocol instance pointer
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
Destination - The destination buffer to store the decompressed data
DstSize - The size of destination buffer.
Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
ScratchSize - The size of scratch buffer.
Returns:
Returns:
EFI_SUCCESS - Decompression is successful
EFI_INVALID_PARAMETER - The source data is corrupted
EFI_SUCCESS - Decompression is successful
EFI_INVALID_PARAMETER - The source data is corrupted
--*/
;
--*/
;
EFI_STATUS
EFIAPI
TianoDecompress (
VOID *Source,
UINT32 SrcSize,
VOID *Destination,
UINT32 DstSize,
VOID *Scratch,
UINT32 ScratchSize
)
/*++
EFI_STATUS
EFIAPI
TianoDecompress(
VOID *Source,
UINT32 SrcSize,
VOID *Destination,
UINT32 DstSize,
VOID *Scratch,
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
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
Destination - The destination buffer to store the decompressed data
DstSize - The size of destination buffer.
Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
ScratchSize - The size of scratch buffer.
This - The protocol instance pointer
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
Destination - The destination buffer to store the decompressed data
DstSize - The size of destination buffer.
Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
ScratchSize - The size of scratch buffer.
Returns:
Returns:
EFI_SUCCESS - Decompression is successful
EFI_INVALID_PARAMETER - The source data is corrupted
EFI_SUCCESS - Decompression is successful
EFI_INVALID_PARAMETER - The source data is corrupted
--*/
;
--*/
;
#ifdef __cplusplus
}

View file

@ -41,7 +41,7 @@ int main(int argc, char *argv[])
}
else {
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;
}

View file

@ -41,10 +41,6 @@ typedef uint16_t CHAR16;
#define FALSE ((BOOLEAN)(0==1))
#endif
#ifndef NULL
#define NULL ((VOID *) 0)
#endif
#define ERR_SUCCESS 0
#define ERR_INVALID_PARAMETER 1
#define ERR_BUFFER_TOO_SMALL 2
@ -83,7 +79,7 @@ typedef uint16_t CHAR16;
#define ERR_COMPLEX_BLOCK_MAP 35
#define ERR_DIR_ALREADY_EXIST 36
#define ERR_DIR_CREATE 37
#define ERR_UNKNOWN_PATCH_TYPE 38
#define ERR_UNKNOWN_PATCH_TYPE 38
#define ERR_PATCH_OFFSET_OUT_OF_BOUNDS 39
#define ERR_INVALID_SYMBOL 40
#define ERR_NOTHING_TO_PATCH 41
@ -95,7 +91,7 @@ typedef uint16_t CHAR16;
#define EFIAPI
#define EFI_STATUS UINT8
#define EFI_SUCCESS ERR_SUCCESS
#define EFI_INVALID_PARAMETER ERR_INVALID_PARAMETER
#define EFI_INVALID_PARAMETER ERR_INVALID_PARAMETER
#define EFI_OUT_OF_RESOURCES ERR_OUT_OF_RESOURCES
#define EFI_BUFFER_TOO_SMALL ERR_BUFFER_TOO_SMALL
#define EFI_ERROR(X) X

View file

@ -38,4 +38,4 @@ UINT32 calculateRegionSize(const UINT16 base, const UINT16 limit)
if (limit)
return (limit + 1 - base) * 0x1000;
return 0;
}
}

View file

@ -51,21 +51,20 @@ typedef struct {
UINT16 ReservedZero; // Still unknown, zeros in all descriptors I have seen
} FLASH_DESCRIPTOR_MAP;
// Component section
// Flash parameters DWORD structure
// Flash parameters DWORD structure
typedef struct {
UINT8 FirstChipDensity : 3;
UINT8 SecondChipDensity : 3;
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 ReservedZero2 : 4; // Still unknown, zeros in all descriptors I have seen
UINT8 FastReadEnabled : 1;
UINT8 FastReadFreqency : 3;
UINT8 FlashReadStatusFrequency : 3;
UINT8 FlashWriteFrequency : 3;
UINT8 FirstChipDensity : 3;
UINT8 SecondChipDensity : 3;
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 ReservedZero2 : 4; // Still unknown, zeros in all descriptors I have seen
UINT8 FastReadEnabled : 1;
UINT8 FastReadFreqency : 3;
UINT8 FlashReadStatusFrequency : 3;
UINT8 FlashWriteFrequency : 3;
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 densities

80
ffs.cpp
View file

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

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);
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);
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
("\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)
: QObject(parent)
: QObject(parent)
{
model = new TreeModel();
oldPeiCoreEntryPoint = 0;
@ -190,7 +190,7 @@ TreeModel* FfsEngine::treeModel() const
void FfsEngine::msg(const QString & message, const QModelIndex & index)
{
#ifndef _CONSOLE
#ifndef _CONSOLE
messageItems.enqueue(MessageListItem(message, NULL, 0, index));
#else
std::cout << message.toLatin1().constData() << std::endl;
@ -357,7 +357,7 @@ UINT8 FfsEngine::parseIntelImage(const QByteArray & intelImage, QModelIndex & in
if (regionSection->BiosLimit) {
biosBegin = calculateRegionOffset(regionSection->BiosBase);
biosEnd = calculateRegionSize(regionSection->BiosBase, regionSection->BiosLimit);
// Check for Gigabyte specific descriptor map
if (biosEnd - biosBegin == intelImage.size()) {
if (!meEnd) {
@ -366,7 +366,7 @@ UINT8 FfsEngine::parseIntelImage(const QByteArray & intelImage, QModelIndex & in
}
biosBegin = meEnd;
}
bios = intelImage.mid(biosBegin, biosEnd);
biosEnd += biosBegin;
}
@ -416,7 +416,7 @@ UINT8 FfsEngine::parseIntelImage(const QByteArray & intelImage, QModelIndex & in
msg(tr("parseIntelImage: descriptor parsing failed, BIOS region has intersection with PDR region"));
return ERR_INVALID_FLASH_DESCRIPTOR;
}
// Region map is consistent
QByteArray body;
QString name;
@ -492,7 +492,7 @@ UINT8 FfsEngine::parseIntelImage(const QByteArray & intelImage, QModelIndex & in
// Add descriptor tree item
model->addItem(Types::Region, Subtypes::DescriptorRegion, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), body, QByteArray(), index);
// Sort regions in ascending order
qSort(offsets);
@ -589,7 +589,7 @@ UINT8 FfsEngine::parseMeRegion(const QByteArray & me, QModelIndex & index, const
if (!versionFound)
msg(tr("parseRegion: ME region version is unknown, it can be damaged"), index);
return ERR_SUCCESS;
}
@ -606,6 +606,11 @@ UINT8 FfsEngine::parsePdrRegion(const QByteArray & pdr, QModelIndex & index, con
// Add tree item
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;
}
@ -737,7 +742,6 @@ UINT8 FfsEngine::parseBios(const QByteArray & bios, const QModelIndex & parent)
}
break;
}
}
return ERR_SUCCESS;
@ -800,9 +804,9 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co
EFI_FIRMWARE_VOLUME_EXT_HEADER* extendedHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER*)(volume.constData() + volumeHeader->ExtHeaderOffset);
headerSize = volumeHeader->ExtHeaderOffset + extendedHeader->ExtHeaderSize;
}
else
else
headerSize = volumeHeader->HeaderLength;
// Sanity check after some new crazy MSI images
headerSize = ALIGN8(headerSize);
@ -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) {
// 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
else if (QByteArray((const char*)&volumeHeader->FileSystemGuid, sizeof(EFI_GUID)) == EFI_FIRMWARE_FILE_SYSTEM2_GUID) {
// 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());
tempFileHeader->IntegrityCheck.Checksum.Header = 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)
{
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;
switch (sectionHeader->Type) {
// Encapsulated sections
// Encapsulated sections
case EFI_SECTION_COMPRESSION:
{
bool parseCurrentSection = true;
@ -1181,7 +1189,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
result = decompress(body, compressedSectionHeader->CompressionType, decompressed, &algorithm);
if (result)
parseCurrentSection = false;
// Get info
info = tr("Type: %1\nSize: %2\nCompression type: %3\nDecompressed size: %4")
.arg(sectionHeader->Type, 2, 16, QChar('0'))
@ -1193,7 +1201,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
index = model->addItem(Types::Section, sectionHeader->Type, algorithm, name, "", info, header, body, QByteArray(), parent, mode);
// Show message
if (!parseCurrentSection)
if (!parseCurrentSection)
msg(tr("parseSection: Decompression failed with error %1").arg(result), index);
else { // Parse decompressed data
result = parseSections(decompressed, index);
@ -1201,7 +1209,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
return result;
}
}
break;
break;
case EFI_SECTION_GUID_DEFINED:
{
bool parseCurrentSection = true;
@ -1242,7 +1250,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
info += tr("\nCompression type: LZMA");
result = decompress(body, EFI_CUSTOMIZED_COMPRESSION, decompressed, &algorithm);
if (result)
if (result)
parseCurrentSection = false;
}
// Unknown GUIDed section
@ -1260,7 +1268,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
// Calculate CRC32 of section data
UINT32 crc = crc32(0, NULL, 0);
crc = crc32(crc, (const UINT8*)body.constData(), body.size());
// Check stored CRC32
// Check stored CRC32
if (crc == *(UINT32*)(header.constData() + sizeof(EFI_GUID_DEFINED_SECTION))) {
info += tr("\nChecksum: valid");
}
@ -1269,7 +1277,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
msgInvalidCrc = true;
}
}
else
else
msgUnknownAuth = true;
}
@ -1293,7 +1301,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
return result;
}
}
break;
break;
case EFI_SECTION_DISPOSABLE:
{
header = section.left(sizeof(EFI_DISPOSABLE_SECTION));
@ -1312,8 +1320,8 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
if (result)
return result;
}
break;
// Leaf sections
break;
// Leaf sections
case EFI_SECTION_PE32:
case EFI_SECTION_TE:
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);
}
}
break;
break;
case EFI_SECTION_FREEFORM_SUBTYPE_GUID: {
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));
@ -1355,7 +1363,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
// Add tree item
index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
}
break;
break;
case EFI_SECTION_VERSION: {
header = section.left(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
index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
}
break;
break;
case EFI_SECTION_USER_INTERFACE: {
header = section.left(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
model->setTextString(model->findParentOfType(parent, Types::File), text);
}
break;
break;
case EFI_SECTION_FIRMWARE_VOLUME_IMAGE: {
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));
@ -1504,12 +1512,12 @@ UINT8 FfsEngine::create(const QModelIndex & index, const UINT8 type, const QByte
// Correct file size
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
fileHeader->IntegrityCheck.Checksum.Header = 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
if (fileHeader->Attributes & FFS_ATTRIB_CHECKSUM)
@ -1760,7 +1768,6 @@ UINT8 FfsEngine::replace(const QModelIndex & index, const QByteArray & object, c
return ERR_SUCCESS;
}
UINT8 FfsEngine::extract(const QModelIndex & index, QByteArray & extracted, const UINT8 mode)
{
if (!index.isValid())
@ -1986,7 +1993,7 @@ UINT8 FfsEngine::decompress(const QByteArray & compressedData, const UINT8 compr
UINT8 FfsEngine::compress(const QByteArray & data, const UINT8 algorithm, QByteArray & compressedData)
{
UINT8* compressed;
switch (algorithm) {
case COMPRESSION_ALGORITHM_NONE:
{
@ -2085,7 +2092,7 @@ UINT8 FfsEngine::constructPadFile(const QByteArray &guid, const UINT32 size, con
// Calculate header checksum
header->IntegrityCheck.Checksum.Header = 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
if (revision == 1)
@ -2136,7 +2143,7 @@ UINT8 FfsEngine::reconstructIntelImage(const QModelIndex& index, QByteArray& rec
UINT32 offset = descriptor.size();
// 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++) {
QByteArray 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) {
//!TODO: add check for weak aligned volume
//!TODO: better return codes
QByteArray header = model->header(index);
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
if (file.left(sizeof(EFI_GUID)) == EFI_FFS_VOLUME_TOP_FILE_GUID) {
baseFound = true;
volumeBase = (UINT32) (0x100000000 - volumeSize);
volumeBase = (UINT32)(0x100000000 - volumeSize);
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
for (QModelIndex parentIndex = index.parent(); model->type(parentIndex) != Types::Root; parentIndex = parentIndex.parent())
if (model->compression(parentIndex) != COMPRESSION_ALGORITHM_NONE) {
// No rebase needed for compressed PEI files
baseFound = true;
volumeBase = 0;
break;
// No rebase needed for compressed PEI files
baseFound = true;
volumeBase = 0;
break;
}
}
@ -2631,7 +2637,7 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
}
// 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
QByteArray section;
@ -2654,13 +2660,12 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
// Correct file size
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
fileHeader->IntegrityCheck.Checksum.Header = 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
else
@ -2789,7 +2794,7 @@ UINT8 FfsEngine::reconstructSection(const QModelIndex& index, const UINT32 base,
// Calculate CRC32 of section data
UINT32 crc = crc32(0, NULL, 0);
crc = crc32(crc, (const UINT8*)compressed.constData(), compressed.size());
// Store new CRC32
// Store new CRC32
*(UINT32*)(header.data() + sizeof(EFI_GUID_DEFINED_SECTION)) = crc;
}
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_PEIM ||
model->subtype(index.parent()) == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER)) {
if (base) {
result = rebase(reconstructed, base + header.size());
if (result) {
@ -2929,7 +2933,6 @@ UINT8 FfsEngine::growVolume(QByteArray & header, const UINT32 size, UINT32 & new
return ERR_INVALID_VOLUME;
// Case of complex blockMap
//!TODO: implement this case
if (blockMapCount > 2)
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(model->nameString(index))
.arg(mode == SEARCH_MODE_BODY ? tr("body") : tr("header"))
.arg(offset/2, 8, 16, QChar('0')),
.arg(offset / 2, 8, 16, QChar('0')),
index);
}
offset = regexp.indexIn(hexBody, offset + 1);
@ -3042,7 +3045,7 @@ UINT8 FfsEngine::findGuidPattern(const QModelIndex & index, const QByteArray & g
QList<QByteArray> list = guidPattern.split('-');
if (list.count() != 5)
return ERR_INVALID_PARAMETER;
QByteArray hexPattern;
// Reverse first GUID block
hexPattern.append(list.at(0).mid(6, 2));
@ -3413,7 +3416,7 @@ UINT8 FfsEngine::dump(const QModelIndex & index, const QString path)
{
if (!index.isValid())
return ERR_INVALID_PARAMETER;
QDir dir;
if (dir.cd(path))
return ERR_DIR_ALREADY_EXIST;
@ -3429,7 +3432,7 @@ UINT8 FfsEngine::dump(const QModelIndex & index, const QString path)
file.write(model->header(index));
file.close();
}
if (!model->body(index).isEmpty()) {
file.setFileName(tr("%1/body.bin").arg(path));
if (!file.open(QFile::WriteOnly))
@ -3471,7 +3474,7 @@ UINT8 FfsEngine::patch(const QModelIndex & index, const QVector<PatchData> & pat
return ERR_NOTHING_TO_PATCH;
UINT8 result;
// Apply patches to item's body
QByteArray body = model->body(index);
PatchData current;
@ -3487,7 +3490,7 @@ UINT8 FfsEngine::patch(const QModelIndex & index, const QVector<PatchData> & pat
if (result)
return result;
}
else
else
return ERR_UNKNOWN_PATCH_TYPE;
}
@ -3496,18 +3499,18 @@ UINT8 FfsEngine::patch(const QModelIndex & index, const QVector<PatchData> & pat
patched.append(body);
return replace(index, patched, REPLACE_MODE_AS_IS);
}
return ERR_NOTHING_TO_PATCH;
}
UINT8 FfsEngine::patchViaOffset(QByteArray & data, const UINT32 offset, const QByteArray & hexReplacePattern)
{
QByteArray body = data;
// Skip patterns with odd length
if (hexReplacePattern.length() % 2 > 0)
if (hexReplacePattern.length() % 2 > 0)
return ERR_INVALID_PARAMETER;
// Check offset bounds
if (offset > (UINT32)(body.length() - hexReplacePattern.length() / 2))
return ERR_PATCH_OFFSET_OUT_OF_BOUNDS;
@ -3519,7 +3522,7 @@ UINT8 FfsEngine::patchViaOffset(QByteArray & data, const UINT32 offset, const QB
QByteArray hex = hexReplacePattern.mid(2 * i, 2);
UINT8 value = 0;
if (!hex.contains('.')) { // Normal byte pattern
if (!hex.contains('.')) { // Normal byte pattern
value = (UINT8)hex.toUShort(&converted, 16);
if (!converted)
return ERR_INVALID_SYMBOL;
@ -3530,7 +3533,7 @@ UINT8 FfsEngine::patchViaOffset(QByteArray & data, const UINT32 offset, const QB
}
else if (hex[0] == '.') {// Upper byte part placeholder
hex[0] = '0';
value = (UINT8)(body.at(offset + i) & 0xF0);
value = (UINT8)(body.at(offset + i) & 0xF0);
value += (UINT8)hex.toUShort(&converted, 16);
if (!converted)
return ERR_INVALID_SYMBOL;
@ -3574,7 +3577,7 @@ UINT8 FfsEngine::patchViaPattern(QByteArray & data, const QByteArray & hexFindPa
INT32 offset = regexp.indexIn(hexBody);
while (offset >= 0) {
if (offset % 2 == 0) {
UINT8 result = patchViaOffset(body, offset/2, hexReplacePattern);
UINT8 result = patchViaOffset(body, offset / 2, hexReplacePattern);
if (result)
return result;
}

View file

@ -137,7 +137,7 @@ private:
#endif
// Message helper
void msg(const QString & message, const QModelIndex &index = QModelIndex());
// Internal operations
bool hasIntersection(const UINT32 begin1, const UINT32 end1, const UINT32 begin2, const UINT32 end2);
UINT32 crc32(UINT32 initial, const UINT8* buffer, UINT32 length);

4
gbe.h
View file

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

View file

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

View file

@ -9,7 +9,7 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
*/
#ifndef __MESSAGELISTITEM_H__
#define __MESSAGELISTITEM_H__
@ -26,7 +26,7 @@ public:
MessageListItem(const QString & text, QListWidget * parent = 0, int type = Type, const QModelIndex & index = QModelIndex());
MessageListItem(const QIcon & icon, const QString & text, QListWidget * parent = 0, int type = Type, const QModelIndex & index = QModelIndex());
~MessageListItem();
QModelIndex index() const;
void setIndex(QModelIndex & index);

View file

@ -3,13 +3,13 @@
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
@ -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_SAL_RUNTIME_DRIVER 13
//
// PE32+ Machine type for EFI images
//
@ -424,9 +423,9 @@ typedef struct {
#define EFI_IMAGE_REL_I386_SECREL 0x000B
#define EFI_IMAGE_REL_I386_REL32 0x0014 // PC-relative 32-bit reference to the symbols virtual address
//
//
// x64 processor relocation types.
//
//
#define IMAGE_REL_AMD64_ABSOLUTE 0x0000
#define IMAGE_REL_AMD64_ADDR64 0x0001
#define IMAGE_REL_AMD64_ADDR32 0x0002
@ -517,7 +516,6 @@ typedef struct {
//
#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
//
// DLL Support
//
@ -573,7 +571,6 @@ typedef struct {
EFI_IMAGE_THUNK_DATA *FirstThunk;
} EFI_IMAGE_IMPORT_DESCRIPTOR;
//
// Debug Directory Format
//
@ -620,7 +617,6 @@ typedef struct {
//
} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;
//
// Debug Data Structure defined by Apple Mach-O to COFF utility.
//
@ -654,16 +650,16 @@ typedef struct {
typedef struct {
union {
struct {
UINT32 NameOffset:31;
UINT32 NameIsString:1;
UINT32 NameOffset : 31;
UINT32 NameIsString : 1;
} s;
UINT32 Id;
} u1;
union {
UINT32 OffsetToData;
struct {
UINT32 OffsetToDirectory:31;
UINT32 DataIsDirectory:1;
UINT32 OffsetToDirectory : 31;
UINT32 DataIsDirectory : 1;
} s;
} u2;
} EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY;

View file

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

View file

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

View file

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

View file

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

View file

@ -25,9 +25,9 @@ class TreeItem
{
public:
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 QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(),
TreeItem *parent = 0);
const QString &name = QString(), const QString &text = QString(), const QString &info = QString(),
const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(),
TreeItem *parent = 0);
~TreeItem();
// 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,
int role) const
int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch(section)
switch (section)
{
case 0:
return tr("Name");
@ -132,7 +132,7 @@ int TreeModel::rowCount(const QModelIndex &parent) const
UINT8 TreeModel::type(const QModelIndex &index) const
{
if(!index.isValid())
if (!index.isValid())
return 0;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->type();
@ -140,7 +140,7 @@ UINT8 TreeModel::type(const QModelIndex &index) const
UINT8 TreeModel::subtype(const QModelIndex &index) const
{
if(!index.isValid())
if (!index.isValid())
return 0;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->subtype();
@ -148,7 +148,7 @@ UINT8 TreeModel::subtype(const QModelIndex &index) const
QByteArray TreeModel::header(const QModelIndex &index) const
{
if(!index.isValid())
if (!index.isValid())
return QByteArray();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->header();
@ -156,7 +156,7 @@ QByteArray TreeModel::header(const QModelIndex &index) const
bool TreeModel::hasEmptyHeader(const QModelIndex &index) const
{
if(!index.isValid())
if (!index.isValid())
return true;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->hasEmptyHeader();
@ -164,7 +164,7 @@ bool TreeModel::hasEmptyHeader(const QModelIndex &index) const
QByteArray TreeModel::body(const QModelIndex &index) const
{
if(!index.isValid())
if (!index.isValid())
return QByteArray();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->body();
@ -172,7 +172,7 @@ QByteArray TreeModel::body(const QModelIndex &index) const
bool TreeModel::hasEmptyBody(const QModelIndex &index) const
{
if(!index.isValid())
if (!index.isValid())
return true;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->hasEmptyBody();
@ -180,7 +180,7 @@ bool TreeModel::hasEmptyBody(const QModelIndex &index) const
QByteArray TreeModel::tail(const QModelIndex &index) const
{
if(!index.isValid())
if (!index.isValid())
return QByteArray();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->tail();
@ -188,7 +188,7 @@ QByteArray TreeModel::tail(const QModelIndex &index) const
bool TreeModel::hasEmptyTail(const QModelIndex &index) const
{
if(!index.isValid())
if (!index.isValid())
return true;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->hasEmptyTail();
@ -196,7 +196,7 @@ bool TreeModel::hasEmptyTail(const QModelIndex &index) const
QString TreeModel::info(const QModelIndex &index) const
{
if(!index.isValid())
if (!index.isValid())
return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->info();
@ -204,7 +204,7 @@ QString TreeModel::info(const QModelIndex &index) const
UINT8 TreeModel::action(const QModelIndex &index) const
{
if(!index.isValid())
if (!index.isValid())
return Actions::NoAction;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->action();
@ -212,7 +212,7 @@ UINT8 TreeModel::action(const QModelIndex &index) const
UINT8 TreeModel::compression(const QModelIndex &index) const
{
if(!index.isValid())
if (!index.isValid())
return COMPRESSION_ALGORITHM_UNKNOWN;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->compression();
@ -220,7 +220,7 @@ UINT8 TreeModel::compression(const QModelIndex &index) const
void TreeModel::setSubtype(const QModelIndex & index, UINT8 subtype)
{
if(!index.isValid())
if (!index.isValid())
return;
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)
{
if(!index.isValid())
if (!index.isValid())
return;
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)
{
if(!index.isValid())
if (!index.isValid())
return;
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)
{
if(!index.isValid())
if (!index.isValid())
return;
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)
{
if(!index.isValid())
if (!index.isValid())
return;
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
{
if(!index.isValid())
if (!index.isValid())
return QString();
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
{
if(!index.isValid())
if (!index.isValid())
return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->data(1).toString();}
return item->data(1).toString();
}
QString TreeModel::typeString(const QModelIndex &index) const
{
if(!index.isValid())
if (!index.isValid())
return QString();
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
{
if(!index.isValid())
if (!index.isValid())
return QString();
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
{
if(!index.isValid())
if (!index.isValid())
return QString();
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
return item->data(4).toString();
}
void TreeModel::setAction(const QModelIndex &index, const UINT8 action)
{
if(!index.isValid())
if (!index.isValid())
return;
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
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,
const QString & name, const QString & text, const QString & info,
const QByteArray & header, const QByteArray & body, const QByteArray & tail,
const QModelIndex & parent, const UINT8 mode)
const QString & name, const QString & text, const QString & info,
const QByteArray & header, const QByteArray & body, const QByteArray & tail,
const QModelIndex & parent, const UINT8 mode)
{
TreeItem *item = 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
{
if(!index.isValid())
if (!index.isValid())
return QModelIndex();
TreeItem *item;
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 = static_cast<TreeItem*>(parent.internalPointer()))
parent = parent.parent();
@ -390,4 +390,4 @@ QModelIndex TreeModel::findParentOfType(const QModelIndex& index, UINT8 type) co
return parent;
return QModelIndex();
}
}

View file

@ -35,9 +35,9 @@ public:
QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const;
const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
@ -69,9 +69,9 @@ public:
UINT8 compression(const QModelIndex &index) const;
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 QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(),
const QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND);
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 QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND);
QModelIndex findParentOfType(const QModelIndex & index, UINT8 type) const;

View file

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

View file

@ -9,14 +9,14 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
*/
#include "uefitool.h"
#include "ui_uefitool.h"
UEFITool::UEFITool(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::UEFITool)
QMainWindow(parent),
ui(new Ui::UEFITool)
{
clipboard = QApplication::clipboard();
@ -48,6 +48,9 @@ UEFITool::UEFITool(QWidget *parent) :
// Enable Drag-and-Drop actions
this->setAcceptDrops(true);
// Set current directory
currentDir = ".";
// Initialize non-persistent data
init();
@ -86,7 +89,7 @@ void UEFITool::init()
// Connect
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(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyAction(QListWidgetItem*)));
}
@ -98,7 +101,7 @@ void UEFITool::populateUi(const QModelIndex &current)
TreeModel* model = ffsEngine->treeModel();
UINT8 type = model->type(current);
UINT8 subtype = model->subtype(current);
UINT8 subtype = model->subtype(current);
// Set info text
ui->infoEdit->setPlainText(model->info(current));
@ -152,6 +155,7 @@ void UEFITool::search()
}
else if (index == 1) { // GUID
searchDialog->ui->guidEdit->setFocus();
searchDialog->ui->guidEdit->setCursorPosition(0);
QByteArray pattern = searchDialog->ui->guidEdit->text().toLatin1();
if (pattern.isEmpty())
return;
@ -171,7 +175,7 @@ void UEFITool::search()
if (pattern.isEmpty())
return;
ffsEngine->findTextPattern(rootIndex, pattern, searchDialog->ui->textUnicodeCheckBox->isChecked(),
(Qt::CaseSensitivity) searchDialog->ui->textCaseSensitiveCheckBox->isChecked());
(Qt::CaseSensitivity) searchDialog->ui->textCaseSensitiveCheckBox->isChecked());
showMessages();
}
}
@ -217,11 +221,11 @@ void UEFITool::insert(const UINT8 mode)
QString path;
switch (type) {
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;
case Types::File:
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;
default:
return;
@ -229,7 +233,7 @@ void UEFITool::insert(const UINT8 mode)
if (path.trimmed().isEmpty())
return;
QFileInfo fileInfo = QFileInfo(path);
if (!fileInfo.exists()) {
ui->statusBar->showMessage(tr("Please select existing file"));
@ -290,39 +294,39 @@ void UEFITool::replace(const UINT8 mode)
QString path;
if (model->type(index) == Types::Region) {
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
return;
}
else if (model->type(index) == Types::File) {
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) {
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
return;
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
return;
}
else if (model->type(index) == Types::Section) {
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) {
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)
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)
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
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
return;
@ -381,59 +385,59 @@ void UEFITool::extract(const UINT8 mode)
if (mode == EXTRACT_MODE_AS_IS) {
switch (type) {
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;
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;
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;
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;
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;
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;
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;
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) {
switch (type) {
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;
case Types::File: {
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
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;
case Types::Section: {
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)
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)
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
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;
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
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())
return;
@ -459,13 +463,13 @@ void UEFITool::extract(const UINT8 mode)
void UEFITool::about()
{
QMessageBox::about(this, tr("About UEFITool"), tr(
"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 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>"
"<b>THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS, "
"WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, "
"EITHER EXPRESS OR IMPLIED.</b>"));
"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 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>"
"<b>THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS, "
"WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, "
"EITHER EXPRESS OR IMPLIED.</b>"));
}
void UEFITool::aboutQt()
@ -480,8 +484,8 @@ void UEFITool::exit()
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())
return;
@ -510,7 +514,7 @@ void UEFITool::saveImageFile()
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);
}
@ -518,9 +522,9 @@ void UEFITool::openImageFile(QString path)
{
if (path.trimmed().isEmpty())
return;
QFileInfo fileInfo = QFileInfo(path);
if (!fileInfo.exists()) {
ui->statusBar->showMessage(tr("Please select existing file"));
return;
@ -547,6 +551,9 @@ void UEFITool::openImageFile(QString path)
// Enable search
ui->actionSearch->setEnabled(true);
// Set current directory
currentDir = fileInfo.absolutePath();
}
void UEFITool::copyMessage()
@ -610,16 +617,16 @@ void UEFITool::contextMenuEvent(QContextMenuEvent* event)
return;
}
if(!ui->structureTreeView->underMouse())
if (!ui->structureTreeView->underMouse())
return;
QPoint pt = event->pos();
QModelIndex index = ui->structureTreeView->indexAt(ui->structureTreeView->viewport()->mapFrom(this, pt));
if(!index.isValid())
if (!index.isValid())
return;
TreeModel* model = ffsEngine->treeModel();
switch(model->type(index))
switch (model->type(index))
{
case Types::Capsule:
ui->menuCapsuleActions->exec(event->globalPos());
@ -676,4 +683,4 @@ void UEFITool::writeSettings()
settings.setValue("tree/columnWidth1", ui->structureTreeView->columnWidth(1));
settings.setValue("tree/columnWidth2", ui->structureTreeView->columnWidth(2));
settings.setValue("tree/columnWidth3", ui->structureTreeView->columnWidth(3));
}
}

View file

@ -9,7 +9,7 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
*/
#ifndef __UEFITOOL_H__
#define __UEFITOOL_H__
@ -39,20 +39,20 @@
#include "searchdialog.h"
namespace Ui {
class UEFITool;
class UEFITool;
}
class UEFITool : public QMainWindow
{
Q_OBJECT
public:
explicit UEFITool(QWidget *parent = 0);
~UEFITool();
void openImageFile(QString path);
private slots:
private slots:
void init();
void populateUi(const QModelIndex &current);
void scrollTreeView(QListWidgetItem* item);
@ -64,24 +64,24 @@ private slots:
void extract(const UINT8 mode);
void extractAsIs();
void extractBody();
void insert(const UINT8 mode);
void insertInto();
void insertBefore();
void insertAfter();
void replace(const UINT8 mode);
void replaceAsIs();
void replaceBody();
void rebuild();
void remove();
void copyMessage();
void enableMessagesCopyAction(QListWidgetItem* item);
void clearMessages();
void about();
void aboutQt();
@ -93,10 +93,11 @@ private:
FfsEngine* ffsEngine;
SearchDialog* searchDialog;
QClipboard* clipboard;
QString currentDir;
QQueue<MessageListItem> messageItems;
void showMessages();
void dragEnterEvent(QDragEnterEvent* event);
void dropEvent(QDropEvent* event);
void contextMenuEvent(QContextMenuEvent* event);

View file

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

View file

@ -9,7 +9,7 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
*/
#include <QApplication>
#include <QString>
@ -26,6 +26,6 @@ int main(int argc, char *argv[])
if (a.arguments().length() > 1)
w.openImageFile(a.arguments().at(1));
w.show();
return a.exec();
}
}