软件加密系列问题1:取得机器码(150分)

  • 主题发起人 主题发起人 oceanwave
  • 开始时间 开始时间
O

oceanwave

Unregistered / Unconfirmed
GUEST, unregistred user!
机器码的泛指如:CPUID、硬盘物理序列号、硬盘分区序列号、网卡MAC、BIOS序列号等等
已经有硬盘分区序列号代码如下:(由zw84611兄提供,请来此拿150分)
-------------------------------------
function GetHDNumber(Drv : String): DWORD;
//得到硬盘序列号
var
VolumeSerialNumber : DWORD;
MaximumComponentLength : DWORD;
FileSystemFlags : DWORD;
begin
if Drv[Length(Drv)] =':' then
Drv := Drv + '/';
GetVolumeInformation(pChar(Drv),
nil,
0,
@VolumeSerialNumber,
MaximumComponentLength,
FileSystemFlags,
nil,
0);
Result:= (VolumeSerialNumber);
end;
-------------------------------------
另有网卡MAC(摘自http://www.delphibbs.com/delphibbs/dispq.asp?lid=444873,房客)
//uses Windows, SysUtils, NB30, 以下为类型定义及函数代码
const sNetBiosError = "NetBIOS错误%d";
type TMACAddress = packed array[0..5] of Byte;
ENetBiosError = class( Exception );
TAStat = record Adapt : TAdapterStatus;
NameBuff : array[0..30] of TNameBuffer;
end;
function GetMacAddress( AdapterNum : Integer ) : TMACAddress;
var
Ncb : TNCB;
uRetCode : Char;
 J : Integer;
Adapter : TAStat;
begin

FillChar( NCB, SizeOf(NCB), 0 );
 with NCBdo
begin

 ncb_command := Char(NCBRESET);
 ncb_lana_num := Char( AdapterNum );
end;

 uRetCode := Netbios( @Ncb );
 if uRetCode <> #0 then
raise Exception.CreateFmt( sNetBIOSError, [Ord(uRetCode)] );
  FillChar( NCB, SizeOf(NCB), 0 );
  with NCBdo
begin
  ncb_command := Char(NCBASTAT);
  ncb_lana_num := Char( AdapterNum );
  StrCopy( ncb_callname, "* " );
  ncb_buffer := @Adapter;
  ncb_length := sizeof(Adapter);
end;

 uRetCode := Netbios( @Ncb );
 if uRetCode <> #0 then
raise Exception.CreateFmt( sNetBIOSError, [Ord(uRetCode)] );
 for J := 0 to 5do

  Result[J] := Ord( Adapter.Adapt.Adapter_address[J] );
end;

-------------------------------------------
 
哦 原来如此··谢谢啊
 
老问题了。
type
TCPUID = array[1..4] of Longint;
function GetCPUID : TCPUID;
assembler;
register;
//得到CPU序列号
asm
PUSH EBX {Save affected register}
PUSH EDI
MOV EDI,EAX {@Resukt}
MOV EAX,1
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 EBX
end;
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1390731
 
散分,收贴。
 
接受答案了.
 
如果多硬盘测试过嘛
 
后退
顶部