From 6f1607446671b772fd80f96e02fe6945e5c3c6b9 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Thu, 14 Apr 2022 18:00:42 -0300 Subject: [PATCH] bios_extract: Save Phoenix BCPSEGMENT data, as at least one 4.0x doesn't include it in the extracted payload --- bios_extract/src/phoenix.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bios_extract/src/phoenix.c b/bios_extract/src/phoenix.c index 05b08de..811eaf8 100644 --- a/bios_extract/src/phoenix.c +++ b/bios_extract/src/phoenix.c @@ -1251,5 +1251,22 @@ PhoenixExtract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset, write(fd, BIOSImage + Offset, Length); close(fd); + /* Extract BCPSEGMENT data */ + Offset = BCPSegmentOffset; + Length = ((unsigned char *)ID) - (BIOSImage + Offset); + if ((Offset + Length) > BIOSLength) + Length = BIOSLength - Offset; + fd = open("bcpsegment.rom", O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); + if (fd < 0) { + fprintf(stderr, "Error: unable to open bcpsegment.rom: %s\n\n", + strerror(errno)); + return FALSE; + } + printf("0x%05X (%6d bytes) -> bcpsegment.rom\n", + Offset, Length); + write(fd, BIOSImage + Offset, Length); + close(fd); + + return TRUE; }