Hi,
is there any1 who has tried to read the SMBIOS using C. If yes, then i m having some problems in it. If possible help me out.
As a starting to extracting Hardware information from SMBIOS, i hv written this code to find out the Structure Table Address.
First i m able to locate the SMBIOS Structure Table Entrypoint's Address by finding the Anchor String 0x5F 0x53 0x4D 0x5F (as per the SMBIOS specification). The specification says that Structure Table Address is specified as a DWORD at an offset of 18h (24 Decimal) from Structure Table's Entrypoint. Now, the 4 bytes at offset 18h from the Entrypoint that i m getting are: 0xF0 0xC2 0x0F 0x00. What i m not sure is how to determine a 32bit address using these 4 bytes. I tried to guess by forming the address as 0x000FC2F0 by putting the bytes in reverse order of their occurence. But this is not the correct address of Structure Table. (I can say this because i have an application, SMBIOSViewer.exe that displays the Hardware info from SMBIOS and also shows the RAW Data of Structure table in Hex).
The application (SMBIOSViewer.exe) shows me that the Stucture table starts with Type 0's structure (Raw Data: 00h 14h 00h 00h 01h 02h ... But at the location 000FC2F0 i am getting this sequence: F6h 05h E8h a4h 05h E8h.
Thing i want to know is:
How to interpret the Sequence: 0x5F 0x53 0x4D 0x5F into a 32-bit physical address?
If there is any other help that anyone can provide related 2 this then i will be highly obliged to him / her.
The code is given below. The SMBIOS Specification file and the Application, SMBIOSViewer.exe are attached with this Post.
-------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <conio.h>
void main(){
char far *a;
char far *SMBIOS_BEGIN;
char *anchor;
int i,proceed,match;
long n;
char far *STRUCTURE_TABLE;
long ST;
long temp;
clrscr();
anchor[0]=0x5f;
anchor[1]=0x53;
anchor[2]=0x4d;
anchor[3]=0x5f;
/**********The Documentation says "the SMBIOS Entry Point structure, described below, can be located by application software by searching for the anchor-string on paragraph (16-byte) boundaries within the physical memory address range 000F0000h to 000FFFFFh". But the SMBIOS Entry Point in my machine was found at F0009060h! I checked this by using another application, SMBIOSW.exe (ALSO ATTACHED WITH THIS POST). This application gives accurate Hardware information and also mentions that the SMBIOS header is located at F0009060h. And starting from this address the byte seqence also matches the output given by this application. that's why i m initializing the search from 0xF0000000 and not from 0x000F0000.***********/
a=0xF0000000;
proceed=1;
match=1;
while (proceed==1)
{
for(i=0;i<4;i++)
{
if(a[i]!=anchor[i])
{
match=0;
break;
}
else
{
match=1;
}
}
if(match==1)
{
proceed=0;
}
else
{
a+=4;
}
}
printf("SMBIOS Address: %lx",a);
printf("\nHow many Bytes to look ahead from SMBIOS Address?: ");
scanf("%ld",&n);
for(i=0;i<n;i+=4)
{
printf("\n%2x,%2x,%2x,%2x",a[i],a[i+1],a[i+2],a[i+3]);
}
getch();
ST=0;
a=a+27;
temp=0;
printf("\n");
for(i=0;i<4;i++)
{
temp=*a;
a--;
temp=temp & 0x000000ff;
ST=ST * 0x00000100;
ST=ST | temp;
}
STRUCTURE_TABLE=ST;
printf("\nStructure Table Address: %lx",STRUCTURE_TABLE);
a=STRUCTURE_TABLE;
printf("\nStructure Table Address: %lx",a);
printf("\nHow many Bytes to look ahead from Sturcture Table Address?: ");
scanf("%ld",&n);
for(i=0;i<n;i+=4,a+=4)
{
printf("\n%x,%x,%x,%x",a[0],a[1],a[2],a[3]);
printf("\t%lx",a);
}
getch();
}
----------------------------------------------------------------------------------------------------