⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reg.c

📁 读硬盘序列号进行注册
💻 C
字号:
// Hero Tech. Copyright 2007 by AlexMozh

/*	My 200 In 1 Register    */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <process.h>
#include <dos.h>
#include <bios.h>

int main()
{

  FILE *fp,*fromfp,*tofp;
  int i,j,k,l;
  long unitlen=2048;
  long baseadd=0x1000;
  char ch;
  char sh[21];
  char pw[21]={"AronAlex2006"};
  char pw1[21]={"HeroTech"};
  char filename[128]={"c:\\emu\\roms\\kov.zip"};
  char toname[128]={"d:\\sre.bmp"};
  char buf[2048];
  unsigned attrib,old_attr;
  unsigned id;
  unsigned cw[257];
  unsigned long m=0;
  long len,adds;
  unsigned char hdno=0x80;
  char secbuf[512];

// =========== Read the SN of Hard Disk =============

  // ======== Main Hard Disk ===============
  outp(0x1f6,0xa0);
  outp(0x1f7,0xec);
  while(inp(0x1f7)!=0x58 && m++<0xffff)
  ;
  for(id=0;id!=256;id++)
    cw[id]=inpw(0x1f0);


  for (j=10,k=0;j<=19;j++)
    {
      sh[k++]=(char)(cw[j]/256);
      sh[k++]=(char)(cw[j]%256);
    }
  sh[k]='\0';

  l=strlen(pw);
  for(i=l;i<20;i++)
    pw[i]=pw[i-l];
  pw[i]='\0';

  l=strlen(pw1);
  for(i=l;i<20;i++)
    pw1[i]=pw1[i-l];
  pw1[i]='\0';


  for(i=0;i<20;i++)
  {
    sh[i]=sh[i]^pw[i];
    sh[i]=sh[i]^pw1[i];
  }

// =========== Change file attrib which named by <filename> =======

  if (_dos_getfileattr(filename,&attrib) != 0)
    return 1;
  old_attr=attrib;

  if (attrib & _A_RDONLY)
  {
    attrib &= ~_A_RDONLY;
    _dos_setfileattr(filename,attrib);
  }



  if ((fp=fopen(filename,"r+b"))==NULL)
  {
    return 1 ;
  }

  if ((tofp=fopen(toname,"wb"))==NULL)
  {
    return 1 ;
  }

// ========== Write the SN to file Named by <filename> ============

  fseek(fp,baseadd+0x200,SEEK_SET);
  fwrite(sh,20,1,fp);


// ========== Write the SN to 0 Head,0 Tract,35 Sector ============

  biosdisk(0x02,hdno,0,0,35,1,secbuf);
  for(i=0;i<20;i++)
  {

    secbuf[128+i*3]=sh[i];

  }
  biosdisk(0x03,hdno,0,0,35,1,secbuf);

// =============== Restore the sre.bmp =======================

  fseek(fp,baseadd,SEEK_SET);
  fread(&adds,4,1,fp);
  fread(&len,4,1,fp);
  j=len / unitlen;
  k=len % unitlen;

  fseek(fp,adds,SEEK_SET);

  for (i=0;i<j;i++)
  {
    fread(buf,unitlen,1,fp);
    fwrite(buf,unitlen,1,tofp);
    fseek(fp,1,SEEK_CUR);
  }

  if (k>0)
  {
    fread(buf,k,1,fp);
    fwrite(buf,k,1,tofp);
  }

  fclose(tofp);

// =============== Restore the alexme.exe =======================

  strcpy(toname,"d:\\alexme.exe");
  if ((tofp=fopen(toname,"wb"))==NULL)
  {
    return 1 ;
  }
  fseek(fp,baseadd+8,SEEK_SET);
  fread(&adds,4,1,fp);
  fread(&len,4,1,fp);
  j=len / unitlen;
  k=len % unitlen;

  fseek(fp,adds,SEEK_SET);

  for (i=0;i<j;i++)
  {
    fread(buf,unitlen,1,fp);
    fwrite(buf,unitlen,1,tofp);
  }

  if (k>0)
  {
    fread(buf,k,1,fp);
    fwrite(buf,k,1,tofp);
  }

  fclose(tofp);
  fclose(fp);

  _dos_setfileattr(filename,old_attr);

// =============== Restore the ok.bat =======================

  strcpy(toname,"d:\\ok.bat");
  if ((tofp=fopen(toname,"wt"))==NULL)
  {
    return 1 ;
  }
  fputs("@echo off \n",tofp);
  fputs("del c:\\emu\\alexme.exe \n",tofp);
  fputs("copy d:\\alexme.exe c:\\emu\\alexme.exe /y \n",tofp);
  //fputs("del d:\\alexme.exe \n",tofp);
  //fputs("del d:\\ok.bat \n",tofp);


  fclose(tofp);

  system("d:\\ok.bat");

  return 0;


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -