Hi Konstantin, this is really an issue need to be solved.

When GenSec tool uses the guidtools to encode the section, it differentiates 
how GenCrc32 is used from other tools..

GenSec defines a CRC32_SECTION_HEADER structure for GenCrc32, and calculate the 
DataOffset of the Section with this header.

However other guidtools just use the EFI_GUID_DEFINED_SECTION header and 
calculate the DataOffset with it.



"
typedef struct {
  EFI_GUID_DEFINED_SECTION  GuidSectionHeader;
  UINT32                    CRC32Checksum;
} CRC32_SECTION_HEADER;


Crc32GuidSect->GuidSectionHeader.DataOffset  = sizeof (CRC32_SECTION_HEADER);



"

Personally think that is the root cause of the 4 bytes issue.



I do not know why the GenCrc32 usage is different from other tools in origin 
design.

Propose to solve this issue from GenSec side to keep all the guidtool with same 
function.



Thanks,

Christine



> -----Original Message-----

> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of

> Konstantin Aladyshev

> Sent: Tuesday, July 19, 2022 9:45 PM

> To: devel@edk2.groups.io

> Cc: Feng, Bob C <bob.c.f...@intel.com>; Gao, Liming

> <gaolim...@byosoft.com.cn>; Chen, Christine <yuwei.c...@intel.com>;

> Konstantin Aladyshev <aladyshe...@gmail.com>

> Subject: [edk2-devel] [PATCH] BaseTools/VolInfo: Correct buffer for

> GenCrc32 tool

>

> If the guided section was encoded with GenCrc32 tool the resulting

> 'EFI_GUID_DEFINED_SECTION.DataOffset' field points to the start of the

> meaningfull data that follows the CRC32 value.

> But if we want to decode the section with GenCrc32 tool we need to provide

> a buffer that includes the CRC32 value itself.

>

> Signed-off-by: Konstantin Aladyshev 
> <aladyshe...@gmail.com<mailto:aladyshe...@gmail.com>>

> ---

>  BaseTools/Source/C/VolInfo/VolInfo.c | 7 +++++++

>  1 file changed, 7 insertions(+)

>

> diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c

> b/BaseTools/Source/C/VolInfo/VolInfo.c

> index f450796f9c..47a8f80f46 100644

> --- a/BaseTools/Source/C/VolInfo/VolInfo.c

> +++ b/BaseTools/Source/C/VolInfo/VolInfo.c

> @@ -1999,6 +1999,13 @@ Returns:

>            );         free (ExtractionTool); +        if (!CompareGuid (+     
>           EfiGuid,+

> &gEfiCrc32GuidedSectionExtractionProtocolGuid+               )+           ) {+

> DataOffset -= 4;+        }         Status =           PutFileImage (          
>    ToolInputFile,--

> 2.25.1

>

>

>

> -=-=-=-=-=-=

> Groups.io Links: You receive all messages sent to this group.

> View/Reply Online (#91530): https://edk2.groups.io/g/devel/message/91530

> Mute This Topic: https://groups.io/mt/92482555/4546272

> Group Owner: devel+ow...@edk2.groups.io<mailto:devel+ow...@edk2.groups.io>

> Unsubscribe: https://edk2.groups.io/g/devel/unsub [yuwei.c...@intel.com]

> -=-=-=-=-=-=

>




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91960): https://edk2.groups.io/g/devel/message/91960
Mute This Topic: https://groups.io/mt/92482555/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to