From 3013398a9d66eeecfb89d7772df5825a103950bb Mon Sep 17 00:00:00 2001
From: Nikolaj Schlej <schlej@live.de>
Date: Sun, 17 May 2015 10:38:04 +0200
Subject: [PATCH] Engine 0.20.5

- raw file header was included twice during reconstruction as region
---
 ffsengine.cpp | 9 +++++----
 ffsengine.h   | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/ffsengine.cpp b/ffsengine.cpp
index 2e0a8fe..0029f04 100644
--- a/ffsengine.cpp
+++ b/ffsengine.cpp
@@ -2740,7 +2740,7 @@ UINT8 FfsEngine::reconstructIntelImage(const QModelIndex& index, QByteArray& rec
     return ERR_NOT_IMPLEMENTED;
 }
 
-UINT8 FfsEngine::reconstructRegion(const QModelIndex& index, QByteArray& reconstructed)
+UINT8 FfsEngine::reconstructRegion(const QModelIndex& index, QByteArray& reconstructed, bool includeHeader)
 {
     if (!index.isValid())
         return ERR_SUCCESS;
@@ -2790,7 +2790,8 @@ UINT8 FfsEngine::reconstructRegion(const QModelIndex& index, QByteArray& reconst
         }
 
         // Reconstruction successful
-        reconstructed = model->header(index).append(reconstructed);
+        if (includeHeader)
+            reconstructed = model->header(index).append(reconstructed);
         return ERR_SUCCESS;
     }
 
@@ -3207,9 +3208,9 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
         if (model->rowCount(index)) {
             reconstructed.clear();
             // Construct new file body
-            // File contains raw data, must be parsed as region
+            // File contains raw data, must be parsed as region without header
             if (model->subtype(index) == EFI_FV_FILETYPE_ALL || model->subtype(index) == EFI_FV_FILETYPE_RAW) {
-                result = reconstructRegion(index, reconstructed);
+                result = reconstructRegion(index, reconstructed, false);
                 if (result)
                     return result;
             }
diff --git a/ffsengine.h b/ffsengine.h
index 41d9e0a..281aa6e 100644
--- a/ffsengine.h
+++ b/ffsengine.h
@@ -81,7 +81,7 @@ public:
     UINT8 reconstructImageFile(QByteArray &reconstructed);
     UINT8 reconstruct(const QModelIndex &index, QByteArray & reconstructed);
     UINT8 reconstructIntelImage(const QModelIndex& index, QByteArray & reconstructed);
-    UINT8 reconstructRegion(const QModelIndex& index, QByteArray & reconstructed);
+    UINT8 reconstructRegion(const QModelIndex& index, QByteArray & reconstructed, bool includeHeader = true);
     UINT8 reconstructBios(const QModelIndex& index, QByteArray & reconstructed);
     UINT8 reconstructVolume(const QModelIndex& index, QByteArray & reconstructed);
     UINT8 reconstructFile(const QModelIndex& index, const UINT8 revision, const UINT8 erasePolarity, const UINT32 base, QByteArray& reconstructed);