Hi everybody
I am trying to write an application that gets mainboard serial number.
According to the information that I found on http://www.dmtf.org/standards/smbios I have tried to access to the physical memory address range 000F0000h to 000FFFFFh.
I used VirtualProtect but I received the following error: Error 487 - "Attempt to access invalid address".

Can I use VirtualProtect in this purpose?
What should I use instead?

This is some part of my code:
void find_structure()
unsigned long start_address = 0x000F0000;
unsigned long end_address = 0x000FFFFF;
void *start_point = (void *) start_address;
void *end_point = (void *) end_address;

char anchor[5] = "_SM_"; /* 5F,53,4D,5F */
long range = end_address - start_address;
DWORD OldAttr, OldAttr2;

printf("Hardware information: \n");
printf(" Page size: %u\n", siSysInfo.dwPageSize);
printf(" Minimum application address: %lx\n", siSysInfo.lpMinimumApplicationAddress);
printf(" Maximum application address: %lx\n", siSysInfo.lpMaximumApplicationAddress);
printf(" My start point: %lx\n", start_point);

BOOL result = VirtualProtect(start_point, siSysInfo.dwPageSize, PAGE_READONLY, &OldAttr);
if(result ==0) DisplayError(GetLastError());
//Error 487: Attempt to access invalid address.
Posted on 2004-12-14 04:55:02 by adamrogoz
VirtualProtect is for re-protecting virtual memory. You want to read physical memory. One way to do this is to map a view of \Device\PhysicalMemory at the physical range that you're describing. This can be done by first calling NtOpenSection with \Device\PhysicalMemory being the section's name and then calling NtMapViewOfSection to map a view of the section into the address space of your process (thus mapping the physical address to a virtual address). You can reference http://www.phrack.org/show.php?p=59&a=16 to see examples on how this can be done.
Posted on 2004-12-14 10:20:50 by nohaven
Posted on 2004-12-15 08:53:58 by roaknog