Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
AlfaOmega08
Member
Posts: 226 Joined: Wed Nov 07, 2007 12:15 pm
Location: Italy
Post
by AlfaOmega08 » Sun Mar 02, 2008 9:03 am
In the SMBIOS Specification, is written that the SMBIOS table starts with the "_SM_" string.
Now, I need an algorithm to find this string in memory.
I've tried with:
Code: Select all
int *mem;
mem = (int *) 0xF0000;
while (*mem < 0xFFFFF) {
if (*mem == '_') {
monitor << "Found a '_'";
i++;
}
*mem++;
}
But it didn't work. It doesn't find any "_";
How can I find all the string???
Ready4Dis
Member
Posts: 571 Joined: Sat Nov 18, 2006 9:11 am
Post
by Ready4Dis » Sun Mar 02, 2008 9:55 am
Where to start...
Code: Select all
char *mem = (char*)0xF0000;
while (mem < 0xFFFFF) //mem == addr of mem, *mem = data stored at pointed to location!
{
if (mem[0] == '_' && mem[1] == 'S' && mem[2] == 'M' && mem[3] == '_')
{
monitor << "Found it!"
break;
}
mem+=4; //Is it 4 byte aligned, then increment by 4 instead, or whatever alignment it has
}
The other way you can do is like this (assuming 4-byte alignment)
Code: Select all
uint32 *mem (uint*)0xF0000; //32-bit unsigned...
uint32 val = ('_'<<24) + ('M'<<16) + ('S'<<8) + '_'; //Make dword
while (mem < 0xFFFFF)
{
if (*mem == val)
{
monitor << "Found it";
}
++mem; //Increments mem by 4-bytes since it's a 32-bit int!
}
AlfaOmega08
Member
Posts: 226 Joined: Wed Nov 07, 2007 12:15 pm
Location: Italy
Post
by AlfaOmega08 » Sun Mar 02, 2008 10:25 am
Each method give me error on the while line:
error: ISO C++ forbids comparison between pointer and integer
cyr1x
Member
Posts: 207 Joined: Tue Aug 21, 2007 1:41 am
Location: Germany
Post
by cyr1x » Sun Mar 02, 2008 10:30 am
You should know how to fix this problem if you know the language properly.
Please learn your language first before you tackle something like an operating system.
But anyway here's the fix:
Code: Select all
while ((unsinged int)mem < 0xFFFFF)
AlfaOmega08
Member
Posts: 226 Joined: Wed Nov 07, 2007 12:15 pm
Location: Italy
Post
by AlfaOmega08 » Sun Mar 02, 2008 10:56 am
Ok now it works (on vmware not on bochs)
Thanks