如何取主板的bios的ID?在线等!!

li_zhifu 2003-01-08 10:28:29
加精
如题
...全文
40 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
li_zhifu 2003-01-08
行了,非常感谢!
回复
li_zhifu 2003-01-08
谢谢,试试先
回复
shb80 2003-01-08
DWORD CComputerInfo::GetMainboardBIOSIdentification(LPSTR lpbuf,BYTE *buflen)
{
DWORD retvalue=RET_BIOS_FAILED_CHECK;
DWORD Add=0;
HANDLE physmem;
DWORD dwPlatformId=dllGetPlatformId();

if(m_bBIOSCheckSuccess){
retvalue=(DWORD)strlen(m_pBIOSData);
goto RETURN_DATA;
}

if(dwPlatformId==VER_PLATFORM_WIN32_NT){//NT/2k
UNICODE_STRING physmemString;
OBJECT_ATTRIBUTES attributes;
WCHAR physmemName[] = L"\\Device\\PhysicalMemory";

NTSTATUS ntStatus;

HMODULE hNTDLL=::GetModuleHandle(TEXT("NTDLL.DLL"));//ntdll.dll must be loaded,it is OK.

ZwOpenSection=(TZwOpenSection)GetProcAddress(hNTDLL,"ZwOpenSection");
ZwMapViewOfSection=(TZwMapViewOfSection)GetProcAddress(hNTDLL,"ZwMapViewOfSection");
ZwUnmapViewOfSection=(TZwUnmapViewOfSection)GetProcAddress(hNTDLL,"ZwUnmapViewOfSection");
RtlInitUnicodeString=(TRtlInitUnicodeString)GetProcAddress(hNTDLL,"RtlInitUnicodeString");

RtlInitUnicodeString( &physmemString, physmemName );
InitializeObjectAttributes( &attributes,
&physmemString,
OBJ_CASE_INSENSITIVE,
NULL,
NULL
);

ntStatus = ZwOpenSection( &physmem,
SECTION_MAP_READ,
&attributes
);

if( !NT_SUCCESS( ntStatus ))
return retvalue;

DWORD PAdd = 0xF0000;
DWORD LPAdd = 0xFFFF;
if(!biosMapView(physmem,&PAdd,&LPAdd,&Add))
return retvalue;
}

if(!((retvalue=biosCheckAward(Add)) > 0 || \
(retvalue=biosCheckPhoenix(Add)) > 0 || \
(retvalue=biosCheckAMI(Add)) > 0)){//No supported

m_bBIOSCheckSuccess=_BIOS_CHECK_UNKNOWN;

if(dwPlatformId==VER_PLATFORM_WIN32_NT)
ZwUnmapViewOfSection((HANDLE)-1,(PVOID)Add);
return RET_BIOS_UNKNOWN;
}

if(dwPlatformId==VER_PLATFORM_WIN32_NT)
ZwUnmapViewOfSection((HANDLE)-1,(PVOID)Add);

m_bBIOSCheckSuccess=_BIOS_CHECK_SUCCESS;

RETURN_DATA:
if(lpbuf!=NULL){
if(*buflen > retvalue){
__try{
strcpy(lpbuf,m_pBIOSData);
}
__except(1)
{
retvalue=RET_BIOS_INALID_BUFFER;
}
}
else
{
*buflen=(BYTE)(retvalue+1);
retvalue=RET_BIOS_INSUFFICIENT_LEN;
}
}
return retvalue;
}

BYTE CComputerInfo::biosCheckAward(DWORD Add)
{
size_t nlen;

if(dllGetPlatformId()==VER_PLATFORM_WIN32_NT)//NT/2k
Add+=0xEC71;
else
Add=0xFEC71;

//Validate
memcpy(m_pBIOSData,(LPBYTE)Add,MAX_BIOS_IDENTIFICATION);
m_pBIOSData[MAX_BIOS_IDENTIFICATION+1]='\0';

if((nlen=strlen(m_pBIOSData)) < MAX_BIOS_IDENTIFICATION && nlen > 0){
//Example
//AWard:07/08/2002-i845G-ITE8712-JF69VD0CC-00
// 10/10/98-xxx……
//Phoenix-Award:03/12/2002-sis645-p4s333
if(m_pBIOSData[2]=='/' && m_pBIOSData[5]=='/'){
CHAR *p=m_pBIOSData;
while(*p){
if(*p < 0x20 || *p > 0x71)
goto NOT_AWARD;
p++;
}
return (BYTE)nlen;
}
}

NOT_AWARD:
return 0;
}

BYTE CComputerInfo::biosCheckPhoenix(DWORD Add)
{
size_t nlen;

if(dllGetPlatformId()==VER_PLATFORM_WIN32_NT)//NT/2k
Add+=0x6577;
else
Add=0xF6577;

//Validate
memcpy(m_pBIOSData,(LPBYTE)Add,MAX_BIOS_IDENTIFICATION);
m_pBIOSData[MAX_BIOS_IDENTIFICATION+1]='\0';

if((nlen=strlen(m_pBIOSData)) < MAX_BIOS_IDENTIFICATION && nlen > 0){
//Example
//Phoenix:NITELT0.86B.0044.P11.9910111055
if(m_pBIOSData[7]=='.' && m_pBIOSData[11]=='.'){
CHAR *p=m_pBIOSData;
while(*p){
if(*p < 0x20 || *p > 0x71)
goto NOT_PHOENIX;
p++;
}
return (BYTE)nlen;
}
}

NOT_PHOENIX:
return 0;
}

BYTE CComputerInfo::biosCheckAMI(DWORD Add)
{
size_t nlen;

if(dllGetPlatformId()==VER_PLATFORM_WIN32_NT)//NT/2k
Add+=0xF478;
else
Add=0xFF478;

//Validate
memcpy(m_pBIOSData,(LPBYTE)Add,MAX_BIOS_IDENTIFICATION);
m_pBIOSData[MAX_BIOS_IDENTIFICATION+1]='\0';

if((nlen=strlen(m_pBIOSData)) < MAX_BIOS_IDENTIFICATION && nlen > 0){
//Example
//AMI:51-2300-000000-00101111-030199-
if(m_pBIOSData[2]=='-' && m_pBIOSData[7]=='-'){
CHAR *p=m_pBIOSData;
while(*p){
if(*p < 0x20 || *p > 0x71)
goto NOT_AMI;
p++;
}
return (BYTE)nlen;
}
}

NOT_AMI:
return 0;
}

BOOL CComputerInfo::biosMapView( HANDLE hPMemory,DWORD *dwPAddress,DWORD *dwLength,DWORD *dwVAddress)
{
NTSTATUS Status;
PHYSICAL_ADDRESS ViewBaseAddress;

*dwVAddress = 0;
ViewBaseAddress.QuadPart = (ULONGLONG) (*dwPAddress);

Status = ZwMapViewOfSection ( hPMemory,
(HANDLE) -1,
(PVOID*)dwVAddress,
0,
*dwLength,
&ViewBaseAddress,
dwLength,
ViewShare,
0,
PAGE_READONLY
);

return NT_SUCCESS( Status);
}
回复
相关推荐
发帖
硬件/系统
创建于2007-09-28

2594

社区成员

VC/MFC 硬件/系统
申请成为版主
帖子事件
创建了帖子
2003-01-08 10:28
社区公告
暂无公告