博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
得到CPU 及硬盘序列号(网友给的,未证实)
阅读量:5893 次
发布时间:2019-06-19

本文共 4191 字,大约阅读时间需要 13 分钟。

// CPU系列号:FUNCTION GetCPUID: TCPUID; assembler; register;asm  PUSH    EBX         {
Save affected register} PUSH EDI MOV EDI,EAX {
@Resukt} MOV EAX,1 {
0 cpu 厂商 1 cpu id 2 3} DW $A20F {
CPUID Command} STOSD {
CPUID[1]} MOV EAX,EBX STOSD {
CPUID[2]} MOV EAX,ECX STOSD {
CPUID[3]} MOV EAX,EDX STOSD {
CPUID[4]} POP EDI {
Restore registers} POP EBXEND;function GetCPUIDStr: String;var CPUID: TCPUID;begin CPUID := GetCPUID; Result := IntToHex(CPUID[1], 8) + {
IntToHex(CPUID[2], 8) + IntToHex(CPUID[3], 8) + } IntToHex(CPUID[4], 8);end;
function GetIdeSerialNumber: PAnsiChar; // 获取硬盘的出厂系列号;const  IDENTIFY_BUFFER_SIZE = 512;type  TIDERegs = packed record    bFeaturesReg: Byte;    bSectorCountReg: Byte;    bSectorNumberReg: Byte;    bCylLowReg: Byte;    bCylHighReg: Byte;    bDriveHeadReg: Byte;    bCommandReg: Byte;    bReserved: Byte;  end;  TSendCmdInParams = packed record    cBufferSize: dword;    irDriveRegs: TIDERegs;    bDriveNumber: Byte;    bReserved: array [0 .. 2] of Byte;    dwReserved: array [0 .. 3] of dword;    bBuffer: array [0 .. 0] of Byte;  end;  TIdSector = packed record    wGenConfig: Word;    wNumCyls: Word;    wReserved: Word;    wNumHeads: Word;    wBytesPerTrack: Word;    wBytesPerSector: Word;    wSectorsPerTrack: Word;    wVendorUnique: array [0 .. 2] of Word;    sSerialNumber: array [0 .. 19] of AnsiChar;    wBufferType: Word;    wBufferSize: Word;    wECCSize: Word;    sFirmwareRev: array [0 .. 7] of AnsiChar;    sModelNumber: array [0 .. 39] of AnsiChar;    wMoreVendorUnique: Word;    wDoubleWordIO: Word;    wCapabilities: Word;    wReserved1: Word;    wPIOTiming: Word;    wDMATiming: Word;    wBS: Word;    wNumCurrentCyls: Word;    wNumCurrentHeads: Word;    wNumCurrentSectorsPerTrack: Word;    ulCurrentSectorCapacity: dword;    wMultSectorStuff: Word;    ulTotalAddressableSectors: dword;    wSingleWordDMA: Word;    wMultiWordDMA: Word;    bReserved: array [0 .. 127] of Byte;  end;  PIdSector = ^TIdSector;  TDriverStatus = packed record    bDriverError: Byte;    bIDEStatus: Byte;    bReserved: array [0 .. 1] of Byte;    dwReserved: array [0 .. 1] of dword;  end;  TSendCmdOutParams = packed record    cBufferSize: dword;    DriverStatus: TDriverStatus;    bBuffer: array [0 .. 0] of Byte;  end;var  hDevice: THandle;  cbBytesReturned: dword;  SCIP: TSendCmdInParams;  aIdOutCmd: array [0 .. (SizeOf(TSendCmdOutParams) + IDENTIFY_BUFFER_SIZE - 1) - 1] of Byte;  IdOutCmd: TSendCmdOutParams absolute aIdOutCmd;  procedure ChangeByteOrder(var Data; Size: Integer); // 函数中的过程  var    ptr: PAnsiChar;    I: Integer;    c: AnsiChar;  begin    ptr := @Data;    for I := 0 to (Size shr 1) - 1 do    begin      c := ptr^;      ptr^ := (ptr + 1)^;      (ptr + 1)^ := c;      Inc(ptr, 2);    end;  end;begin // 函数主体  Result := '';  if Win32Platform = VER_PLATFORM_WIN32_NT then  begin // Windows NT, Windows 2000    hDevice := CreateFile('\\.\PhysicalDrive0', GENERIC_READ or GENERIC_WRITE,      FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0);  end  else // Version Windows 95 OSR2, Windows 98    hDevice := CreateFile('\\.\SMARTVSD', 0, 0, nil, CREATE_NEW, 0, 0);  if hDevice = INVALID_HANDLE_VALUE then    exit;  try    FillChar(SCIP, SizeOf(TSendCmdInParams) - 1, #0);    FillChar(aIdOutCmd, SizeOf(aIdOutCmd), #0);    cbBytesReturned := 0;    with SCIP do    begin      cBufferSize := IDENTIFY_BUFFER_SIZE;      with irDriveRegs do      begin        bSectorCountReg := 1;        bSectorNumberReg := 1;        bDriveHeadReg := $A0;        bCommandReg := $EC;      end;    end;    if not DeviceIoControl(hDevice, $0007C088, @SCIP, SizeOf(TSendCmdInParams) - 1, @aIdOutCmd,      SizeOf(aIdOutCmd), cbBytesReturned, nil) then      exit;  finally    CloseHandle(hDevice);  end;  with PIdSector(@IdOutCmd.bBuffer)^ do  begin    ChangeByteOrder(sSerialNumber, SizeOf(sSerialNumber));    (PAnsiChar(@sSerialNumber) + SizeOf(sSerialNumber))^ := #0;    Result := PAnsiChar(@sSerialNumber);  end;end;

 

转载于:https://www.cnblogs.com/yagzh2000/archive/2013/01/15/2860583.html

你可能感兴趣的文章
linux 将大文件分成小文件
查看>>
CCNA- 距离矢量路由协议学习
查看>>
jira 配置 LDAP 访问
查看>>
Canonical发布Ubuntu server 11.10版本
查看>>
企业实践用户邮箱导入/导出(第2部分)
查看>>
我的友情链接
查看>>
nagios搭建(五):nagios监控mysql
查看>>
AIX ftp 530 User root access denied
查看>>
【Java记录】try-with-resources的一个坑
查看>>
如何学习Linux命令-初级篇
查看>>
从Oracle Public Yum为Oracle Linux建立本地的Yum源
查看>>
jQuery实现页面内锚点平滑跳转特效的方法总结
查看>>
[windows]-windows安装Mac OSX
查看>>
com.sun.image.codec.jpeg.*导入错误
查看>>
JavaScript学习笔记(二)
查看>>
ROS实操笔记 三 topic (主题)
查看>>
关于博客笔记大汇总,持续更新迭代
查看>>
Elasticsearch中refresh和flush的区别是什么
查看>>
MySQL数据库的常用命令语句记录——存储过程语句
查看>>
数据 的存储(1)使用SharedPreferences
查看>>