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

@ -101,10 +101,8 @@ INT32
if (LzmaResult == SZ_OK) { if (LzmaResult == SZ_OK) {
return ERR_SUCCESS; return ERR_SUCCESS;
} else { }
else {
return ERR_INVALID_PARAMETER; return ERR_INVALID_PARAMETER;
} }
} }

View File

@ -152,8 +152,8 @@ INT32
if (LzmaResult == SZ_OK) { if (LzmaResult == SZ_OK) {
return ERR_SUCCESS; return ERR_SUCCESS;
} else { }
else {
return ERR_INVALID_PARAMETER; return ERR_INVALID_PARAMETER;
} }
} }

View File

@ -96,4 +96,3 @@ LzmaDecompress (
} }
#endif #endif
#endif #endif

View File

@ -516,7 +516,6 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
p->hash[hash2Value] = p->hash[hash2Value] =
p->hash[kFix3HashSize + hashValue] = p->pos; p->hash[kFix3HashSize + hashValue] = p->pos;
maxLen = 2; maxLen = 2;
offset = 0; offset = 0;
if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
@ -653,8 +652,7 @@ static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
curMatch = p->hash[hashValue]; curMatch = p->hash[hashValue];
p->hash[hashValue] = p->pos; p->hash[hashValue] = p->pos;
SKIP_FOOTER SKIP_FOOTER
} } while (--num != 0);
while (--num != 0);
} }
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
@ -666,8 +664,7 @@ void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
curMatch = p->hash[hashValue]; curMatch = p->hash[hashValue];
p->hash[hashValue] = p->pos; p->hash[hashValue] = p->pos;
SKIP_FOOTER SKIP_FOOTER
} } while (--num != 0);
while (--num != 0);
} }
static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
@ -681,8 +678,7 @@ static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
p->hash[hash2Value] = p->hash[hash2Value] =
p->hash[kFix3HashSize + hashValue] = p->pos; p->hash[kFix3HashSize + hashValue] = p->pos;
SKIP_FOOTER SKIP_FOOTER
} } while (--num != 0);
while (--num != 0);
} }
static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
@ -697,8 +693,7 @@ static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
p->hash[kFix3HashSize + hash3Value] = p->pos; p->hash[kFix3HashSize + hash3Value] = p->pos;
p->hash[kFix4HashSize + hashValue] = p->pos; p->hash[kFix4HashSize + hashValue] = p->pos;
SKIP_FOOTER SKIP_FOOTER
} } while (--num != 0);
while (--num != 0);
} }
static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
@ -714,8 +709,7 @@ static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
p->hash[kFix4HashSize + hashValue] = p->pos; p->hash[kFix4HashSize + hashValue] = p->pos;
p->son[p->cyclicBufferPos] = curMatch; p->son[p->cyclicBufferPos] = curMatch;
MOVE_POS MOVE_POS
} } while (--num != 0);
while (--num != 0);
} }
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
@ -728,8 +722,7 @@ void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
p->hash[hashValue] = p->pos; p->hash[hashValue] = p->pos;
p->son[p->cyclicBufferPos] = curMatch; p->son[p->cyclicBufferPos] = curMatch;
MOVE_POS MOVE_POS
} } while (--num != 0);
while (--num != 0);
} }
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable) void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)

View File

@ -56,7 +56,6 @@
#define TREE_DECODE_CHECK(probs, limit, i) \ #define TREE_DECODE_CHECK(probs, limit, i) \
{ i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }
#define kNumPosBitsMax 4 #define kNumPosBitsMax 4
#define kNumPosStatesMax (1 << kNumPosBitsMax) #define kNumPosStatesMax (1 << kNumPosBitsMax)
@ -74,7 +73,6 @@
#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) #define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
#define kNumLenProbs (LenHigh + kLenNumHighSymbols) #define kNumLenProbs (LenHigh + kLenNumHighSymbols)
#define kNumStates 12 #define kNumStates 12
#define kNumLitStates 7 #define kNumLitStates 7
@ -187,8 +185,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
bit = (matchByte & offs); bit = (matchByte & offs);
probLit = prob + offs + bit + symbol; probLit = prob + offs + bit + symbol;
GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit)
} } while (symbol < 0x100);
while (symbol < 0x100);
} }
dic[dicPos++] = (Byte)symbol; dic[dicPos++] = (Byte)symbol;
processedPos++; processedPos++;
@ -313,8 +310,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
{ {
GET_BIT2(prob + i, i, ;, distance |= mask); GET_BIT2(prob + i, i, ;, distance |= mask);
mask <<= 1; mask <<= 1;
} } while (--numDirectBits != 0);
while (--numDirectBits != 0);
} }
} }
else else
@ -340,8 +336,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
distance |= 1; distance |= 1;
} }
*/ */
} } while (--numDirectBits != 0);
while (--numDirectBits != 0);
prob = probs + Align; prob = probs + Align;
distance <<= kNumAlignBits; distance <<= kNumAlignBits;
{ {
@ -402,13 +397,11 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
dic[dicPos++] = dic[pos]; dic[dicPos++] = dic[pos];
if (++pos == dicBufSize) if (++pos == dicBufSize)
pos = 0; pos = 0;
} } while (--curLen != 0);
while (--curLen != 0);
} }
} }
} }
} } while (dicPos < limit && buf < bufLimit);
while (dicPos < limit && buf < bufLimit);
NORMALIZE; NORMALIZE;
p->buf = buf; p->buf = buf;
p->range = range; p->range = range;
@ -466,8 +459,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte
if (p->processedPos >= p->prop.dicSize) if (p->processedPos >= p->prop.dicSize)
p->checkDicSize = p->prop.dicSize; p->checkDicSize = p->prop.dicSize;
LzmaDec_WriteRem(p, limit); LzmaDec_WriteRem(p, limit);
} } while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);
while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);
if (p->remainLen > kMatchSpecLenStart) if (p->remainLen > kMatchSpecLenStart)
{ {
@ -531,8 +523,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
bit = (matchByte & offs); bit = (matchByte & offs);
probLit = prob + offs + bit + symbol; probLit = prob + offs + bit + symbol;
GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit)
} } while (symbol < 0x100);
while (symbol < 0x100);
} }
res = DUMMY_LIT; res = DUMMY_LIT;
} }
@ -653,8 +644,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
range >>= 1; range >>= 1;
code -= range & (((code - range) >> 31) - 1); code -= range & (((code - range) >> 31) - 1);
/* if (code >= range) code -= range; */ /* if (code >= range) code -= range; */
} } while (--numDirectBits != 0);
while (--numDirectBits != 0);
prob = probs + Align; prob = probs + Align;
numDirectBits = kNumAlignBits; numDirectBits = kNumAlignBits;
} }
@ -663,8 +653,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
do do
{ {
GET_BIT_CHECK(prob + i, i); GET_BIT_CHECK(prob + i, i);
} } while (--numDirectBits != 0);
while (--numDirectBits != 0);
} }
} }
} }
@ -674,7 +663,6 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
return res; return res;
} }
static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data) static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data)
{ {
p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]); p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]);

View File

@ -83,7 +83,6 @@ UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
/* #define LZMA_LOG_BSR */ /* #define LZMA_LOG_BSR */
/* Define it for Intel's CPU */ /* Define it for Intel's CPU */
#ifdef LZMA_LOG_BSR #ifdef LZMA_LOG_BSR
#define kDicLogSizeMaxCompress 30 #define kDicLogSizeMaxCompress 30
@ -134,7 +133,6 @@ void LzmaEnc_FastPosInit(Byte *g_FastPos)
#endif #endif
#define LZMA_NUM_REPS 4 #define LZMA_NUM_REPS 4
typedef unsigned CState; typedef unsigned CState;
@ -163,7 +161,6 @@ typedef struct
#define kDicLogSizeMax 32 #define kDicLogSizeMax 32
#define kDistTableSizeMax (kDicLogSizeMax * 2) #define kDistTableSizeMax (kDicLogSizeMax * 2)
#define kNumAlignBits 4 #define kNumAlignBits 4
#define kAlignTableSize (1 << kNumAlignBits) #define kAlignTableSize (1 << kNumAlignBits)
#define kAlignMask (kAlignTableSize - 1) #define kAlignMask (kAlignTableSize - 1)
@ -186,7 +183,6 @@ typedef struct
#define LZMA_NUM_PB_STATES_MAX (1 << LZMA_PB_MAX) #define LZMA_NUM_PB_STATES_MAX (1 << LZMA_PB_MAX)
#define kLenNumLowBits 3 #define kLenNumLowBits 3
#define kLenNumLowSymbols (1 << kLenNumLowBits) #define kLenNumLowSymbols (1 << kLenNumLowBits)
#define kLenNumMidBits 3 #define kLenNumMidBits 3
@ -519,8 +515,7 @@ static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p)
if (buf == p->bufLim) if (buf == p->bufLim)
RangeEnc_FlushStream(p); RangeEnc_FlushStream(p);
temp = 0xFF; temp = 0xFF;
} } while (--p->cacheSize != 0);
while (--p->cacheSize != 0);
p->cache = (Byte)((UInt32)p->low >> 24); p->cache = (Byte)((UInt32)p->low >> 24);
} }
p->cacheSize++; p->cacheSize++;
@ -545,8 +540,7 @@ static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, int numBits)
p->range <<= 8; p->range <<= 8;
RangeEnc_ShiftLow(p); RangeEnc_ShiftLow(p);
} }
} } while (numBits != 0);
while (numBits != 0);
} }
static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, UInt32 symbol) static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, UInt32 symbol)
@ -579,8 +573,7 @@ static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol)
{ {
RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & 1); RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & 1);
symbol <<= 1; symbol <<= 1;
} } while (symbol < 0x10000);
while (symbol < 0x10000);
} }
static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol, UInt32 matchByte) static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol, UInt32 matchByte)
@ -593,8 +586,7 @@ static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol,
RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1); RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1);
symbol <<= 1; symbol <<= 1;
offs &= ~(matchByte ^ symbol); offs &= ~(matchByte ^ symbol);
} } while (symbol < 0x10000);
while (symbol < 0x10000);
} }
void LzmaEnc_InitPriceTables(UInt32 *ProbPrices) void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
@ -620,7 +612,6 @@ void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
} }
} }
#define GET_PRICE(prob, symbol) \ #define GET_PRICE(prob, symbol) \
p->ProbPrices[((prob) ^ (((-(int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits]; p->ProbPrices[((prob) ^ (((-(int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];
@ -641,8 +632,7 @@ static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, UInt32 *Pro
{ {
price += GET_PRICEa(probs[symbol >> 8], (symbol >> 7) & 1); price += GET_PRICEa(probs[symbol >> 8], (symbol >> 7) & 1);
symbol <<= 1; symbol <<= 1;
} } while (symbol < 0x10000);
while (symbol < 0x10000);
return price; return price;
} }
@ -657,12 +647,10 @@ static UInt32 LitEnc_GetPriceMatched(const CLzmaProb *probs, UInt32 symbol, UInt
price += GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)], (symbol >> 7) & 1); price += GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)], (symbol >> 7) & 1);
symbol <<= 1; symbol <<= 1;
offs &= ~(matchByte ^ symbol); offs &= ~(matchByte ^ symbol);
} } while (symbol < 0x10000);
while (symbol < 0x10000);
return price; return price;
} }
static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol) static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol)
{ {
UInt32 m = 1; UInt32 m = 1;
@ -717,7 +705,6 @@ static UInt32 RcTree_ReverseGetPrice(const CLzmaProb *probs, int numBitLevels, U
return price; return price;
} }
static void LenEnc_Init(CLenEnc *p) static void LenEnc_Init(CLenEnc *p)
{ {
unsigned i; unsigned i;
@ -797,9 +784,6 @@ static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32
LenPriceEnc_UpdateTable(p, posState, ProbPrices); LenPriceEnc_UpdateTable(p, posState, ProbPrices);
} }
static void MovePos(CLzmaEnc *p, UInt32 num) static void MovePos(CLzmaEnc *p, UInt32 num)
{ {
#ifdef SHOW_STAT #ifdef SHOW_STAT
@ -848,7 +832,6 @@ static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)
return lenRes; return lenRes;
} }
#define MakeAsChar(p) (p)->backPrev = (UInt32)(-1); (p)->prev1IsChar = False; #define MakeAsChar(p) (p)->backPrev = (UInt32)(-1); (p)->prev1IsChar = False;
#define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = False; #define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = False;
#define IsShortRep(p) ((p)->backPrev == 0) #define IsShortRep(p) ((p)->backPrev == 0)
@ -917,8 +900,7 @@ static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)
p->opt[posPrev].posPrev = cur; p->opt[posPrev].posPrev = cur;
cur = posPrev; cur = posPrev;
} }
} } while (cur != 0);
while (cur != 0);
*backRes = p->opt[0].backPrev; *backRes = p->opt[0].backPrev;
p->optimumCurrentIndex = p->opt[0].posPrev; p->optimumCurrentIndex = p->opt[0].posPrev;
return p->optimumCurrentIndex; return p->optimumCurrentIndex;
@ -1065,8 +1047,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
opt->backPrev = i; opt->backPrev = i;
opt->prev1IsChar = False; opt->prev1IsChar = False;
} }
} } while (--repLen >= 2);
while (--repLen >= 2);
} }
normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]); normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]);
@ -1331,8 +1312,7 @@ static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)
opt->backPrev = repIndex; opt->backPrev = repIndex;
opt->prev1IsChar = False; opt->prev1IsChar = False;
} }
} } while (--lenTest >= 2);
while (--lenTest >= 2);
lenTest = lenTestTemp; lenTest = lenTestTemp;
if (repIndex == 0) if (repIndex == 0)
@ -1953,7 +1933,6 @@ void LzmaEnc_Init(CLzmaEnc *p)
RangeEnc_Init(&p->rc); RangeEnc_Init(&p->rc);
for (i = 0; i < kNumStates; i++) for (i = 0; i < kNumStates; i++)
{ {
UInt32 j; UInt32 j;
@ -2104,7 +2083,6 @@ static size_t MyWrite(void *pp, const void *data, size_t size)
return size; return size;
} }
UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
{ {
const CLzmaEnc *p = (CLzmaEnc *)pp; const CLzmaEnc *p = (CLzmaEnc *)pp;

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;
@ -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

@ -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

@ -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,7 +51,6 @@ 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 {

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

@ -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
@ -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())
@ -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();
@ -2660,7 +2666,6 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
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;

View File

@ -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

@ -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.
// //

View File

@ -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

@ -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,9 +15,6 @@ 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,

View File

@ -283,7 +283,8 @@ QString TreeModel::actionString(const QModelIndex &index) const
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
{ {
@ -312,7 +313,6 @@ QString TreeModel::textString(const QModelIndex &index) const
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())

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

@ -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();
@ -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;
@ -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;
@ -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()

View File

@ -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">