如何在Windows应用程序中实现电子注册功能
2008-11-13 19:28:28 来源:WEB开发网应用程序中解密密钥和注册密钥的位置,可先用特殊字符来标识,然后用DEBUG 等程序直接查找其位置,再修改其它程序中读取或写入数据的地址值。至于解密密钥显示和注册密钥的输入方式,可由开发者确定是用安装程序的方法还是在应用程序中直接处理的方法。
/*电子注册功能密钥读取程序清单READKEY.C*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
void readser(void);
void readser1(void);
unsigned char Buff[18];
unsigned int keyrom[9];
unsigned int sum,sumi,sumj;
unsigned int far *pt=
(unsigned int far *)0xf000fff6L;
unsigned int i=0,j=0,m;
unsigned char p;
unsigned int nn,nn1,nn2;
unsigned char rbuff[100],cc,cc1,cc2;
int fp;
void main(int argc,char *argv[])
{ if((argc>3)||((argc==2)&&(argv[1][1]!=':'))){
printf("USAGE:READKEY 程序路径及名称.n");
scanf("%s",rbuff); //手工输入加密密钥
printf("sss:%s,%un",rbuff,strlen(rbuff));
j=strlen(rbuff);
if(j!=20) exit(1);
for(i=0;i<20;i++){
if((rbuff[i]>='a')&&(rbuff[i]<='f')) rbuff[i]&=0xdf;
if((rbuff[i]>='A')&&(rbuff[i]<='F')) rbuff[i]-=0x37;
else if((rbuff[i]>='0')&&(rbuff[i]<='9')) rbuff[i]-=0x30;
else exit(1);
}
printf("num:");
for(i=0;i<5;i++){
cc1=rbuff[i*4]&0xf;
cc2=rbuff[i*4+1]&0xf;
cc=(cc1<<4)|cc2;
nn1=(unsigned int)cc;
cc1=rbuff[i*4+2]&0xf;
cc2=rbuff[i*4+3]&0xf;
cc=(cc1<<4)|cc2;
nn2=(unsigned int)cc;
nn=(nn1<<8)|nn2;
keyrom[i]=nn;
printf("%04x",keyrom[i]);
}
printf("n");
sum=0x2020;
for(sumj=0;sumj<4;sumj++){ //形成16位密钥
for(sumi=0;sumi<5;sumi++)
sum-=keyrom[sumi]; //形成解密密钥
sum^=0x0404< sprintf(Buff+4*sumj,"%04x",sum);
}
printf(Buff);
exit(1);
}
if(argc>1){
strlwr(argv[1]);
if(strstr(argv[1],".EXE")==NULL){
printf("USAGE:READKEY 路径及文件名.n");
exit(1);
}
if((fp=open(argv[1],O_RDWR|O_BINARY))==-1){
printf("File %s open error!",argv[1]);
exit(1);
}
lseek(fp,0xf040L,SEEK_SET);//ROM 10个数据地址+200H
read(fp,keyrom,0xaL); //读取数据
readser1(); //读文件中的注册密钥
} else readser(); //读机器中的注册密钥
}
void readser(void)
{
sum=0x2020;
for(sumj=0;sumj<4;sumj++){//形成16位密钥
for(sumi=0;sumi<5;sumi++)
sum-=(*(pt+sumi)-0x2020);//形成解密密钥
sum^=0x0404< sprintf(Buff+4*sumj,"%04x",sum);
}
printf(Buff);
}
void readser1(void)
{
sum=0x2020;
for(sumj=0;sumj<4;sumj++){//形成16位密钥
for(sumi=0;sumi<5;sumi++)
sum-=keyrom[sumi]; //形成解密密钥
sum^=0x0404< sprintf(Buff+4*sumj,"%04x",sum);
}
printf(Buff);
}
更多精彩
赞助商链接