Windows kernel extracts various BIOS information at boot-time. The method it uses to extract SystemBiosDate is very hueristic. It is done by nt!CmpGetBiosDate().
nt!CmpGetBiosDate() works by scanning all BIOS memory from 0xF0000 to 0xFFFF5 (FSEG) in search for a string which is formatted like a date. It then chooses the string which represents the most recent date, and writes it to:
HKLM/HARDWARE/DESCRIPTION/System SystemBiosDate
This date should usually be BiosDate located at FSEG(0xFFF5).
BIOS_DATE and RELEASE_DATE_STR appear in FSEG together with BiosDate. This makes Windows report BIOS_DATE, which is the most recent one, as the date in HKLM/HARDWARE/DESCRIPTION/System SystemBiosDate.
In some cases we would like to control the value that Windows will calculate and store in SystemBiosDate (This value is popular among activation an licensing software). To do that we must clean FSEG from date strings which may interfere with our intended calculation. In this commit we remove all static dates from FSEG which are not BiosDate. In the next commit we will deal with dynamic strings that may sometimes appear in FSEG (from SMBIOS tables).
Removing BIOS_DATE and RELEASE_DATE_STR static strings from FSEG will only affect machines using legacy SMBIOS:
* SystemBiosDate will change from 04/01/2014 (BIOS_DATE) to 01/01/2011 (RELEASE_DATE_STR).
For reference implementation of nt!CmpGetBiosDate(), see ReactOS: https://doxygen.reactos.org/d5/dd2/i386_2cmhardwr_8c.html
Reviewed-by: Konrad Rzeszutek Wilk konrad.wilk@oracle.com Reviewed-by: Arbel Moshe arbel.moshe@oracle.com Signed-off-by: Sam Eiderman shmuel.eiderman@oracle.com Signed-off-by: Liran Alon liran.alon@oracle.com --- src/fw/biostables.c | 2 +- src/fw/smbios.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/fw/biostables.c b/src/fw/biostables.c index fe8626ef..269b8582 100644 --- a/src/fw/biostables.c +++ b/src/fw/biostables.c @@ -401,7 +401,7 @@ smbios_new_type_0(void *start, }
#define BIOS_NAME "SeaBIOS" -#define BIOS_DATE "04/01/2014" +static const char BIOS_DATE[] = "04/01/2014";
static int smbios_romfile_setup(void) diff --git a/src/fw/smbios.c b/src/fw/smbios.c index f3b5ad9d..6f33a329 100644 --- a/src/fw/smbios.c +++ b/src/fw/smbios.c @@ -134,7 +134,7 @@ get_external(int type, char **p, unsigned *nr_structs, end += size; \ p->field = ++str_index; \ } else { \ - memcpy(end, def, sizeof(def)); \ + memcpy(end, (void*)def, sizeof(def)); \ end += sizeof(def); \ p->field = ++str_index; \ } \ @@ -161,7 +161,7 @@ get_external(int type, char **p, unsigned *nr_structs, } while (0)
/* Type 0 -- BIOS Information */ -#define RELEASE_DATE_STR "01/01/2011" +static volatile const char RELEASE_DATE_STR[] = "01/01/2011"; static void * smbios_init_type_0(void *start) {