@@ -3851,20 +3851,14 @@ static void dmi_table_dump(u32 base, u16 len, const char *devmem)
3851
3851
{
3852
3852
u8 * buf ;
3853
3853
3854
- if (base + len > 0xFFFFF )
3855
- {
3856
- fprintf (stderr , "Table is too far away in memory, can't dump, sorry.\n" );
3857
- return ;
3858
- }
3859
-
3860
3854
if ((buf = mem_chunk (base , len , devmem ))== NULL )
3861
3855
{
3862
3856
fprintf (stderr , "Failed to read table, sorry.\n" );
3863
3857
return ;
3864
3858
}
3865
3859
3866
3860
printf ("# Writing %d bytes to %s.\n" , len , opt .dumpfile );
3867
- write_dump (base , len , buf , opt .dumpfile );
3861
+ write_dump (32 , len , buf , opt .dumpfile );
3868
3862
free (buf );
3869
3863
}
3870
3864
@@ -3990,6 +3984,20 @@ static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem)
3990
3984
}
3991
3985
3992
3986
3987
+ /*
3988
+ * Build a crafted entry point with table address hard-coded to 32,
3989
+ * as this is where we will put it in the output file. We adjust the
3990
+ * DMI checksum appropriately. The SMBIOS checksum needs no adjustment.
3991
+ */
3992
+ static void overwrite_dmi_address (u8 * buf )
3993
+ {
3994
+ buf [0x05 ]+= buf [0x08 ]+ buf [0x09 ]+ buf [0x0A ]+ buf [0x0B ]- 32 ;
3995
+ buf [0x08 ]= 32 ;
3996
+ buf [0x09 ]= 0 ;
3997
+ buf [0x0A ]= 0 ;
3998
+ buf [0x0B ]= 0 ;
3999
+ }
4000
+
3993
4001
static int smbios_decode (u8 * buf , const char * devmem )
3994
4002
{
3995
4003
if (!checksum (buf , buf [0x05 ])
@@ -4004,6 +4012,17 @@ static int smbios_decode(u8 *buf, const char *devmem)
4004
4012
dmi_table (DWORD (buf + 0x18 ), WORD (buf + 0x16 ), WORD (buf + 0x1C ),
4005
4013
(buf [0x06 ]<<8 )+ buf [0x07 ], devmem );
4006
4014
4015
+ if (opt .flags & FLAG_DUMP_BIN )
4016
+ {
4017
+ u8 crafted [32 ];
4018
+
4019
+ memcpy (crafted , buf , 32 );
4020
+ overwrite_dmi_address (crafted + 0x10 );
4021
+
4022
+ printf ("# Writing %d bytes to %s.\n" , crafted [0x05 ], opt .dumpfile );
4023
+ write_dump (0 , crafted [0x05 ], crafted , opt .dumpfile );
4024
+ }
4025
+
4007
4026
return 1 ;
4008
4027
}
4009
4028
@@ -4019,6 +4038,17 @@ static int legacy_decode(u8 *buf, const char *devmem)
4019
4038
dmi_table (DWORD (buf + 0x08 ), WORD (buf + 0x06 ), WORD (buf + 0x0C ),
4020
4039
((buf [0x0E ]& 0xF0 )<<4 )+ (buf [0x0E ]& 0x0F ), devmem );
4021
4040
4041
+ if (opt .flags & FLAG_DUMP_BIN )
4042
+ {
4043
+ u8 crafted [16 ];
4044
+
4045
+ memcpy (crafted , buf , 16 );
4046
+ overwrite_dmi_address (crafted );
4047
+
4048
+ printf ("# Writing %d bytes to %s.\n" , 0x0F , opt .dumpfile );
4049
+ write_dump (0 , 0x0F , crafted , opt .dumpfile );
4050
+ }
4051
+
4022
4052
return 1 ;
4023
4053
}
4024
4054
@@ -4137,16 +4167,6 @@ int main(int argc, char * const argv[])
4137
4167
goto exit_free ;
4138
4168
}
4139
4169
4140
- if (opt .flags & FLAG_DUMP_BIN )
4141
- {
4142
- printf ("# Writing %d bytes to %s.\n" , 0x10000 , opt .dumpfile );
4143
- if (write_dump (0xF0000 , 0x10000 , buf , opt .dumpfile ))
4144
- {
4145
- ret = 2 ;
4146
- goto exit_free_buf ;
4147
- }
4148
- }
4149
-
4150
4170
for (fp = 0 ; fp <=0xFFF0 ; fp += 16 )
4151
4171
{
4152
4172
if (memcmp (buf + fp , "_SM_" , 4 )== 0 && fp <=0xFFE0 )
@@ -4168,7 +4188,6 @@ int main(int argc, char * const argv[])
4168
4188
if (!found && !(opt .flags & FLAG_QUIET ))
4169
4189
printf ("# No SMBIOS nor DMI entry point found, sorry.\n" );
4170
4190
4171
- exit_free_buf :
4172
4191
free (buf );
4173
4192
exit_free :
4174
4193
free (opt .type );
0 commit comments