This commit is contained in:
Alex Matrosov 2018-04-29 22:38:54 -07:00
parent 956a804dd5
commit a5ce9ab3d9
16 changed files with 3575 additions and 3514 deletions

View File

@ -25,8 +25,8 @@ static ISzAlloc SzAllocForLzma = { &AllocForLzma, &FreeForLzma };
SRes OnProgress(void *p, UInt64 inSize, UInt64 outSize)
{
(void)p; (void) inSize; (void) outSize;
return SZ_OK;
(void)p; (void)inSize; (void)outSize;
return SZ_OK;
}
static ICompressProgress g_ProgressCallback = { &OnProgress };
@ -34,76 +34,76 @@ static ICompressProgress g_ProgressCallback = { &OnProgress };
STATIC
UINT64
EFIAPI
RShiftU64(
UINT64 Operand,
UINT32 Count
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
CONST UINT8 *Source,
UINTN SourceSize,
UINT8 *Destination,
UINTN *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);
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;
*DestinationSize = destLen + LZMA_HEADER_SIZE;
SetEncodedSizeOfBuf((UINT64)SourceSize, Destination);
SetEncodedSizeOfBuf(SourceSize, Destination);
if (LzmaResult == SZ_OK) {
return ERR_SUCCESS;
}
else {
return ERR_INVALID_PARAMETER;
}
if (LzmaResult == SZ_OK) {
return ERR_SUCCESS;
}
else {
return ERR_INVALID_PARAMETER;
}
}

View File

@ -28,9 +28,9 @@ extern "C" {
EFIAPI
LzmaCompress(
const UINT8 *Source,
UINT32 SourceSize,
UINTN SourceSize,
UINT8 *Destination,
UINT32 *DestinationSize
UINTN *DestinationSize
);
#ifdef __cplusplus

View File

@ -20,11 +20,11 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
UINT64
EFIAPI
LShiftU64(
UINT64 Operand,
UINT32 Count
UINT64 Operand,
UINT32 Count
)
{
return Operand << Count;
return Operand << Count;
}
static void * AllocForLzma(void *p, size_t size) { (void)p; return malloc(size); }
@ -40,18 +40,18 @@ Get the size of the uncompressed buffer by parsing EncodeData header.
*/
UINT64
GetDecodedSizeOfBuf(
UINT8 *EncodedData
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;
}
//
@ -88,19 +88,15 @@ buffer was returned ScratchSize.
INT32
EFIAPI
LzmaGetInfo(
CONST VOID *Source,
UINT32 SourceSize,
UINT32 *DestinationSize
CONST VOID *Source,
UINTN SourceSize,
UINTN *DestinationSize
)
{
UInt64 DecodedSize;
ASSERT(SourceSize >= LZMA_HEADER_SIZE); (void)SourceSize;
ASSERT(SourceSize >= LZMA_HEADER_SIZE); (void)SourceSize;
DecodedSize = GetDecodedSizeOfBuf((UINT8*)Source);
*DestinationSize = (UINT32)DecodedSize;
return ERR_SUCCESS;
*DestinationSize = (UINTN)GetDecodedSizeOfBuf((UINT8*)Source);
return ERR_SUCCESS;
}
/*
@ -125,35 +121,35 @@ The source buffer specified by Source is corrupted
INT32
EFIAPI
LzmaDecompress(
CONST VOID *Source,
UINT32 SourceSize,
VOID *Destination
CONST VOID *Source,
UINTN 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
);
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;
}
if (LzmaResult == SZ_OK) {
return ERR_SUCCESS;
}
else {
return ERR_INVALID_PARAMETER;
}
}

View File

@ -61,8 +61,8 @@ extern "C" {
EFIAPI
LzmaGetInfo(
const VOID *Source,
UINT32 SourceSize,
UINT32 *DestinationSize
UINTN SourceSize,
UINTN *DestinationSize
);
/*
@ -88,8 +88,8 @@ extern "C" {
EFIAPI
LzmaDecompress(
const VOID *Source,
UINT32 SourceSize,
VOID *Destination
UINTN SourceSize,
VOID *Destination
);
#ifdef __cplusplus

File diff suppressed because it is too large Load Diff

View File

@ -32,85 +32,82 @@ Header file for compression routine.
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.
--*/
EFI_STATUS
TianoCompress(
CONST VOID *SrcBuffer,
UINT32 SrcSize,
VOID *DstBuffer,
UINT32 *DstSize
)
;
--*/
EFI_STATUS
TianoCompress(
IN CONST VOID *SrcBuffer,
IN UINT32 SrcSize,
IN VOID *DstBuffer,
IN OUT UINT32 *DstSize
);
EFI_STATUS
TianoCompressLegacy(
CONST VOID *SrcBuffer,
UINT32 SrcSize,
VOID *DstBuffer,
UINT32 *DstSize
)
;
/*++
EFI_STATUS
TianoCompressLegacy(
CONST VOID *SrcBuffer,
UINT32 SrcSize,
VOID *DstBuffer,
UINT32 *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.
--*/
EFI_STATUS
EfiCompress(
CONST VOID *SrcBuffer,
UINT32 SrcSize,
VOID *DstBuffer,
UINT32 *DstSize
)
;
EFI_STATUS
EfiCompressLegacy(
CONST VOID *SrcBuffer,
UINT32 SrcSize,
VOID *DstBuffer,
UINT32 *DstSize
)
;
--*/
EFI_STATUS
EfiCompress(
IN CONST VOID *SrcBuffer,
IN UINT32 SrcSize,
IN VOID *DstBuffer,
IN OUT UINT32 *DstSize
);
EFI_STATUS
EfiCompressLegacy(
CONST VOID *SrcBuffer,
UINT32 SrcSize,
VOID *DstBuffer,
UINT32 *DstSize
);
#ifdef __cplusplus
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -37,14 +37,13 @@ extern "C" {
UINT32 OrigSize;
} EFI_TIANO_HEADER;
EFI_STATUS
EFIAPI
EfiTianoGetInfo(
const VOID *Source,
UINT32 SrcSize,
UINT32 *DstSize,
UINT32 *ScratchSize
)
EFI_STATUS
EfiTianoGetInfo(
IN const VOID *Source,
IN UINT32 SrcSize,
OUT UINT32 *DstSize,
OUT UINT32 *ScratchSize
)
/*++
Routine Description:
@ -67,16 +66,16 @@ extern "C" {
--*/
;
EFI_STATUS
EFIAPI
EfiDecompress(
const VOID *Source,
UINT32 SrcSize,
VOID *Destination,
UINT32 DstSize,
VOID *Scratch,
UINT32 ScratchSize
)
EFI_STATUS
EFIAPI
EfiDecompress(
IN const VOID *Source,
IN UINT32 SrcSize,
IN OUT VOID *Destination,
IN UINT32 DstSize,
IN OUT VOID *Scratch,
IN UINT32 ScratchSize
)
/*++
Routine Description:
@ -101,16 +100,16 @@ extern "C" {
--*/
;
EFI_STATUS
EFIAPI
TianoDecompress(
const VOID *Source,
UINT32 SrcSize,
VOID *Destination,
UINT32 DstSize,
VOID *Scratch,
UINT32 ScratchSize
)
EFI_STATUS
EFIAPI
TianoDecompress(
IN const VOID *Source,
IN UINT32 SrcSize,
IN OUT VOID *Destination,
IN UINT32 DstSize,
IN OUT VOID *Scratch,
IN UINT32 ScratchSize
)
/*++
Routine Description:

View File

@ -52,8 +52,9 @@ F7731B4C-58A2-4DF4-8980-5645D39ECE58 10 P:0FBA6C24380F:0FBA7424380F
299D6F8B-2EC9-4E40-9EC6-DDAA7EBF5FD9 10 P:81E10080000033C1:9090909090909090
299D6F8B-2EC9-4E40-9EC6-DDAA7EBF5FD9 12 P:81E10080000033C1:9090909090909090
# PpmInitialize | Skylake-X
3FFCAE95-23CF-4967-94F5-16352F68E43B 10 P:742CB9E2000000:752CB9E2000000
# SiInit | Skylake-X
D71C8BA4-4AF2-4D0D-B1BA-F2409F0C20D3 10 P:81E10080000033C1:9090909090909090
D71C8BA4-4AF2-4D0D-B1BA-F2409F0C20D3 12 P:81E10080000033C1:9090909090909090
# CpuInitPei | Skylake-X
01359D99-9446-456D-ADA4-50A711C03ADA 12 P:BE0080000023CE0B:BE0000000023CE0B
# PpmInitialize | Skylake-X, Kaby Lake-X
3FFCAE95-23CF-4967-94F5-16352F68E43B 10 P:0FBAE80F:0FBAE00F

View File

@ -95,6 +95,7 @@ public:
UINT8 replace(const QModelIndex & index, const QByteArray & object, const UINT8 mode);
UINT8 remove(const QModelIndex & index);
UINT8 rebuild(const QModelIndex & index);
UINT8 doNotRebuild(const QModelIndex & index);
UINT8 dump(const QModelIndex & index, const QString & path, const QString & filter = QString());
UINT8 patch(const QModelIndex & index, const QVector<PatchData> & patches);

View File

@ -150,6 +150,8 @@ QString actionTypeToQString(const UINT8 action)
return QObject::tr("Rebuild");
case Actions::Rebase:
return QObject::tr("Rebase");
case Actions::DoNotRebuild:
return QObject::tr("Do not rebuild");
default:
return QObject::tr("Unknown");
}

View File

@ -26,7 +26,8 @@ namespace Actions
Replace,
Remove,
Rebuild,
Rebase
Rebase,
DoNotRebuild
};
}

View File

@ -17,7 +17,7 @@
UEFITool::UEFITool(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::UEFITool),
version(tr("0.22.4"))
version(tr("0.23.0"))
{
clipboard = QApplication::clipboard();
@ -43,6 +43,7 @@ version(tr("0.22.4"))
connect(ui->actionReplaceBody, SIGNAL(triggered()), this, SLOT(replaceBody()));
connect(ui->actionRemove, SIGNAL(triggered()), this, SLOT(remove()));
connect(ui->actionRebuild, SIGNAL(triggered()), this, SLOT(rebuild()));
connect(ui->actionDoNotRebuild, SIGNAL(triggered()), this, SLOT(doNotRebuild()));
connect(ui->actionMessagesCopy, SIGNAL(triggered()), this, SLOT(copyMessage()));
connect(ui->actionMessagesCopyAll, SIGNAL(triggered()), this, SLOT(copyAllMessages()));
connect(ui->actionMessagesClear, SIGNAL(triggered()), this, SLOT(clearMessages()));
@ -146,6 +147,7 @@ void UEFITool::populateUi(const QModelIndex &current)
// Enable actions
ui->actionExtract->setDisabled(model->hasEmptyHeader(current) && model->hasEmptyBody(current));
ui->actionRebuild->setEnabled(type == Types::Volume || type == Types::File || type == Types::Section);
ui->actionDoNotRebuild->setEnabled(type== Types::Region || type == Types::Volume || type == Types::File || type == Types::Section);
ui->actionExtractBody->setDisabled(model->hasEmptyBody(current));
ui->actionRemove->setEnabled(type == Types::Volume || type == Types::File || type == Types::Section);
ui->actionInsertInto->setEnabled((type == Types::Volume && subtype != Subtypes::UnknownVolume) ||
@ -220,6 +222,18 @@ void UEFITool::rebuild()
ui->actionSaveImageFile->setEnabled(true);
}
void UEFITool::doNotRebuild()
{
QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
if (!index.isValid())
return;
UINT8 result = ffsEngine->doNotRebuild(index);
if (result == ERR_SUCCESS)
ui->actionSaveImageFile->setEnabled(true);
}
void UEFITool::remove()
{
QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();

View File

@ -78,6 +78,7 @@ public:
void replaceBody();
void rebuild();
void doNotRebuild();
void remove();

View File

@ -180,7 +180,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
<height>31</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -225,6 +225,8 @@
</property>
<addaction name="actionExtract"/>
<addaction name="separator"/>
<addaction name="actionDoNotRebuild"/>
<addaction name="separator"/>
<addaction name="actionReplace"/>
</widget>
<widget class="QMenu" name="menuPaddingActions">
@ -243,6 +245,7 @@
<addaction name="actionExtractBody"/>
<addaction name="separator"/>
<addaction name="actionRebuild"/>
<addaction name="actionDoNotRebuild"/>
<addaction name="separator"/>
<addaction name="actionInsertInto"/>
<addaction name="separator"/>
@ -257,6 +260,7 @@
<addaction name="actionExtractBody"/>
<addaction name="separator"/>
<addaction name="actionRebuild"/>
<addaction name="actionDoNotRebuild"/>
<addaction name="separator"/>
<addaction name="actionInsertInto"/>
<addaction name="actionInsertBefore"/>
@ -275,6 +279,7 @@
<addaction name="actionExtractBody"/>
<addaction name="separator"/>
<addaction name="actionRebuild"/>
<addaction name="actionDoNotRebuild"/>
<addaction name="separator"/>
<addaction name="actionInsertInto"/>
<addaction name="actionInsertBefore"/>
@ -284,7 +289,6 @@
<addaction name="actionReplaceBody"/>
<addaction name="separator"/>
<addaction name="actionRemove"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuMessages">
<property name="title">
@ -536,6 +540,17 @@
<string>Ctrl+Shift+O</string>
</property>
</action>
<action name="actionDoNotRebuild">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Do not rebuild</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+Space</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>