荔园在线
荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀
[回到开始]
[上一篇][下一篇]
发信人: Deny (king of lanza), 信区: Program
标 题: 读 PIII 系列号的源码 :-)(转寄)[转载]
发信站: 荔园晨风BBS站 (Thu May 9 12:36:41 2002), 转信
【 以下文字转载自 Deny 的信箱 】
【 原文由 denick@bbs.edu.cn 所发表 】
发信人: suzhe (烦着呢), 信区: Programming
标 题: 读 PIII 系列号的源码 :-)
发信站: BBS 水木清华站 (Fri Mar 29 22:17:36 2002)
从网上找的, 很简单. VC 下编译
#include <stdio.h>
typedef unsigned int DWORD;
bool DetectSerialNumber()
{
bool found_sn;
_asm
{
pushfd
pop eax // get EFLAGS into eax
mov ebx,eax // keep a copy
xor eax,0x200000 // toggle CPUID bit
push eax
popfd // set new EFLAGS
pushfd
pop eax // EFLAGS back into eax
// have we changed the ID bit?
xor eax,ebx
je NO_SERIAL_NUM
// we could toggle the bit so CPUID
// is present
mov eax,1
cpuid // get processor features
// check the serial number bit
test edx,1<<18
jz NO_SERIAL_NUM
mov found_sn,1
jmp DONE
NO_SERIAL_NUM:
mov found_sn,0
DONE:
}
return found_sn;
}
void ReadSerialNumber(DWORD* serial)
{
DWORD t,m,b;
_asm
{
mov eax,1
cpuid
// top 32 bits are the processor
// signature bits
mov t,eax
// A new CPUID code for the
// Pentium III
mov eax,3
cpuid
mov m,edx
mov b,ecx
}
// copy the locals into the pointer variables passed in
serial[0] = b;
serial[1] = m;
serial[2] = t;
}
int main ()
{
DWORD serial [3];
if (DetectSerialNumber()) {
ReadSerialNumber (serial);
printf ("PIII Serial Number = %04X-%04X-%04X-%04X-%04X-%04X\n",
serial [0]&0xFFFF, serial [0] >> 16,
serial [1]&0xFFFF, serial [1] >> 16,
serial [2]&0xFFFF, serial [2] >> 16);
} else {
printf ("No PIII Serial Number found!\n");
}
return 0;
}
--
Smart Boot Manager -- One of the most powerful Boot Managers in the world!
http://www.gnuchina.org/~suzhe/
http://btmgr.gnuchina.org/
http://bootmanager.gnuchina.org/
http://btmgr.sourceforge.net/
※ 来源:·BBS 水木清华站 smth.org·[FROM: 166.111.148.127]
--
※ 转载:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 218.17.92.250]
[回到开始]
[上一篇][下一篇]
荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店