|
5#
楼主 |
发表于 2012-12-29 21:16:38
|
只看该作者
回复 #4 不点 的帖子
6f5df6935f28.rar
(940 Bytes, 下载次数: 15)
这是网上找到的dos下查看硬盘id的源码 这个好像只能查看ide硬盘的序列号
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <conio.h>
#include <string.h>
char *getascii (unsigned int in_data [], int off_start, int off_end);
void main (void)
{
unsigned int dd [256]; /* DiskData */
unsigned int dd_off; /* DiskData offset */
char * sn;
char * test;
char ch;
FILE * fp;
int i;
int temp;
char key[]="TJFM5~SZGLQ^q6WP0.07";
if((fp=fopen("C:\TLQJFD.BIN","w+b"))==NULL){
printf("cannot opent file\n");
exit(1);
}
while (inp (0x1F7) != 0x50)/* Wait for controller not busy */;
outp (0x1F6, 0xA0); /* Get first/second drive */
outp (0x1F7, 0xEC); /* Get drive info data */
while (inp (0x1F7) != 0x58) /* Wait for data ready */;
for (dd_off = 0; dd_off != 256; dd_off++) /* Read "sector" */
dd [dd_off] = inpw (0x1F0);
sn=getascii(dd,10,19);
test=sn;
printf ("\nThe Serial Number Hard Disk is %s",sn);
for(i=0;i<=1024;i++)
putc(rand(),fp);
for(i=0;i<20;i++){
temp=3*i*i-14*i+159;
*sn=*sn^key;
fseek(fp,temp,0);
putc(*sn,fp);
sn++;
}
printf ("\nTest Serial Number Hard Disk is ");
for(i=0;i<20;i++){
temp=3*i*i-14*i+159;
fseek(fp,temp,0);
ch=getc(fp);
if(*test!=ch) {
printf("\nfailure!");
ch=0;
break;
}
printf("%c",ch^key);
test++;
}
if(ch!=0) printf("\n\nCongraduate! Successfully register!");
fclose(fp);
}
char *getascii (unsigned int in_data [], int off_start, int off_end)
{
static char ret_val [255];
int loop, loop1;
for (loop = off_start, loop1 = 0; loop <= off_end; loop++)
{
ret_val [loop1++] = (char) (in_data [loop] / 256); /* Get High byte */
ret_val [loop1++] = (char) (in_data [loop] % 256); /* Get Low byte */
}
ret_val [loop1] = '\0'; /* Make sure it ends in a NULL character */
return (ret_val);
}
[ 本帖最后由 2012ybds8 于 2012-12-29 22:25 编辑 ] |
|