SETPASSK.C
资源名称:schddog.zip [点击查看]
上传用户:haocheng
上传日期:2007-01-06
资源大小:24k
文件大小:3k
源码类别:
磁盘编程
开发平台:
Others
- #include<stdio.h>
- #include<dos.h>
- #define MemSize *(unsigned far *)0x00400013
- void ReadStr(char *str)
- {
- unsigned char Plength=1;
- unsigned xx,yy,x;
- union REGS r;
- xx=wherex();yy=wherey();
- x=xx;
- do{
- gotoxy(xx,yy);
- r.h.ah=0;
- int86(0x16,&r,&r);
- if((r.h.ah!=28)&&(r.h.ah!=14)&&(r.h.ah!=1))
- {
- *(str+Plength)=(r.h.al-20)|0x80;
- gotoxy(xx,yy);
- putch('*');
- xx++;Plength++;
- }
- else if(r.h.ah==14)
- {
- xx--;
- if(xx<x)xx=x;
- gotoxy(xx,yy);
- putch(' ');
- if(Plength>1)Plength--;
- }
- else if(r.h.ah==1)Plength=0;
- }while((r.h.ah!=28)&&(r.h.ah!=1)&&(Plength<15));
- *(str+0)=Plength-1;
- }
- int ReadPass(char *buffer)
- {
- union REGS ireg;
- struct SREGS oreg;
- ireg.x.ax=0x0201;
- ireg.x.bx=FP_OFF(buffer);
- ireg.x.cx=0x0006;
- ireg.x.dx=0x0080;
- oreg.es=FP_SEG(buffer);
- int86x(0x50,&ireg,&ireg,&oreg);
- return ireg.h.ah;
- }
- int WritePass(char *buffer)
- {
- union REGS ireg;
- struct SREGS oreg;
- ireg.x.ax=0x0301;
- ireg.x.bx=FP_OFF(buffer);
- ireg.x.cx=0x0006;
- ireg.x.dx=0x0080;
- oreg.es=FP_SEG(buffer);
- int86x(0x50,&ireg,&ireg,&oreg);
- return ireg.h.ah;
- }
- int CheckPass(char *src,char *dest)
- {
- unsigned char Plength,p2;
- Plength=*(src+0);
- p2=*(dest+0);
- if(Plength!=p2)return -1;
- while(Plength>0)
- {
- if(*(src+Plength)!=*(dest+Plength))return -1;
- Plength--;
- }
- return 1;
- }
- int CopyPass(char *src,char *dest)
- {
- char Plength;
- Plength=*(src+0);
- while(Plength>=0)
- {
- *(dest+Plength)=*(src+Plength);
- Plength--;
- }
- return 0;
- }
- void reboot(void)
- {
- void (far *reboot_ptr)(void);
- unsigned int far *i_ptr;
- clrscr();
- i_ptr=MK_FP(0x0040,0x0072);
- *i_ptr=0x1234;
- reboot_ptr=MK_FP(0xF000,0xFFF0);
- reboot_ptr();
- }
- void copyright()
- {
- printf("n Babysoft (R) Password Changer for Hard Disk Keeper version 1.0");
- printf("n Copyright (C) 1997.12 LiuYaDing,Babysoft Corp.n");
- }
- void main()
- {
- char buffer[512];
- char passwd[16],passwd1[16];
- char *source;
- char key;
- copyright();
- if(MemSize==0x280)
- {
- printf("na Babysoft-HDKeeper Not Installed.n");
- exit(1);
- }
- while(ReadPass(buffer)!=0);
- source=buffer+0x200-32;
- printf("n Old Password: ");
- ReadStr(passwd);
- if(CheckPass(source,passwd)==1)
- {
- printf("n New Password: ");
- ReadStr(passwd);
- printf("n V e r i f y : ");
- ReadStr(passwd1);
- if(CheckPass(passwd,passwd1)==1)
- {
- CopyPass(passwd,source);
- WritePass(buffer);
- printf("n Do you want to reboot to enable new password?(Y/N)");
- key=getch();
- if((key=='Y')||(key=='y'))reboot();
- else {printf("n Password changed ok.");exit(1);}
- }
- else {printf("na Password dismatch!");exit(1);}
- }
- else {printf("na Wrong Password!");exit(0);}
- }