论坛风格切换切换到宽版
  • 1770阅读
  • 1回复

请教虎版主,这个dll 更改之后怎么怎么实现加密功能? [复制链接]

上一主题 下一主题
离线missyou
 

发帖
5
金钱
50
威望
5
只看楼主 倒序阅读 0 发表于: 2016-03-09
请教虎版主,我可以把你以前发的这个一机一码的代码,里面调用的kernel32.dll 换成 这个GetDiskSerial.dll吗?怎么实现?我直接改后,提示加载dll失败!这个dll的应用实例和说明在附件内(这里附件超限制传不了,百度网盘下载: 链接: http://pan.baidu.com/s/1qXo6L3I 密码:a27u )麻烦虎版指点,谢谢!


在下面这段代码中改: kernel32.dll 换成 这个GetDiskSerial.dll
CODE
; 脚本由 Inno Setup 脚本设计向导 创建。          
; 有关创建 INNO SETUP 脚本的详情请查阅帮助文档!                        

[Setup]
UserInfoPage=true
DisableStartupPrompt=yes
DirExistsWarning=no
CreateAppDir=no
DisableProgramGroupPage=yes
Uninstallable=no
AppName=安装示例
AppVerName=安装示例
DefaultDirName={pf}\安装示例

[MESSAGES]
UserInfoSerial=注册码(&R):

[INI]
Filename: "{app}\hanzify.url"; Section: "InternetShortcut"; Key: "URL"; String: "http://www.hanzify.org"

[Run]
Filename: "{app}\hanzify.url"; Description: "访问汉化新世纪主页"; Flags: postinstall shellexec unchecked

[UninstallDelete]
Type: files; Name: "{app}\hanzify.url"

[Code]
var HDSerial: LongInt;

function GetVolumeInformation(
    lpRootPathName: PChar;
    lpVolumeNameBuffer: PChar;
    nVolumeNameSize: LongInt;
    var lpVolumeSerialNumber: LongInt;
    lpMaximumComponentLength: LongInt;
    lpFileSystemFlags : LongInt;
    lpFileSystemNameBuffer: PChar;
    nFileSystemNameSize: LongInt ) : Integer;
external 'GetVolumeInformationA@kernel32.dll stdcall';

function GetLastError( ): Integer;
external 'GetLastError@kernel32.dll stdcall';

procedure RegURLOnClick(Sender: TObject);
var
tmp: Integer;
begin
InstShellExec('http://bbs.hanzify.org', '', '', SW_SHOWNORMAL, tmp);
end;

function GenMachineID(SerialNum: LongInt): String;
var
SN: LongInt;
MID, tmp1, tmp2: string;
begin
// 生成机器码
  if SerialNum > 567890123 then
    SN:= SerialNum-567890123
  else
    SN:= 567890123-SerialNum;
  tmp1:= IntToStr(SN);
  while length(tmp1)>3 do
    begin
    tmp2:= copy(tmp1,1,3);
    delete(tmp1,1,3);
    MID:= MID+Chr(65+StrToInt(tmp2)*26/999)+tmp2;
    end;
  MID:= MID+Chr(65+StrToInt(tmp1)*26/999)+tmp1;
  tmp1:= MID;
  MID:= '';
  while length(tmp1)>3 do
    begin
    tmp2:= copy(tmp1,1,3);
    delete(tmp1,1,3);
    MID:= MID+tmp2+'-';
    end;
  MID:= MID+tmp1;
  If SerialNum > 567890123 then
    MID:='6J7-'+MID
  else
    MID:='V94-'+MID;
result:= MID;
end;

function GenRegCode(SerialNum: LongInt): String;
var MID,tmp1,tmp2: string;
   SN: LongInt;
begin
// 生成注册码
  if SerialNum > 432109876 then
    SN:= SerialNum-432109876
  else
    SN:= 432109876-SerialNum;
  MID:='';
  tmp1:= IntToStr(SN);
  while length(tmp1)>3 do
    begin
    tmp2:= copy(tmp1,1,3);
    delete(tmp1,1,3);
    MID:= MID+Chr(65+StrToInt(tmp2)*26/999)+tmp2;
    end;
  MID:= MID+Chr(65+StrToInt(tmp1)*26/999)+tmp1;
  tmp1:= MID;
  MID:= '';
  while length(tmp1)>3 do
    begin
    tmp2:= copy(tmp1,1,3);
    delete(tmp1,1,3);
    MID:= MID+tmp2+'-';
    end;
  MID:= MID+tmp1;
  If SerialNum > 432109876 then
    MID:='3P6-'+MID
  else
    MID:='X5B-'+MID;
result:= MID;
end;

procedure InitializeWizard();
begin
WizardForm.USERINFOSERIALLABEL.top := WizardForm.USERINFOORGLABEL.top+
        2*(WizardForm.USERINFOORGLABEL.top - WizardForm.USERINFONAMELABEL.top);
WizardForm.USERINFOSERIALEDIT.top := WizardForm.USERINFOORGEDIT.top+
        2*(WizardForm.USERINFOORGEDIT.top - WizardForm.USERINFONAMEEDIT.top);
WizardForm.USERINFOSERIALLABEL.Font.Color := clRed;
end;

procedure curpagechanged(curpage: integer);
var
IDLabel, RegAdr, RegURL: TLabel;
IDEdit: TEdit;
RefDisk, DiskLabel: String;
begin
if curpage=wpUserInfo then
begin
    if DirExists('C:\') then
      RefDisk:= 'C:\'
    else
      RefDisk:= 'D:\';
  DiskLabel:= '                ';
  GetVolumeInformation(RefDisk, DiskLabel, 15, HDSerial, 0, 0, '', 0);

  IDLabel:= TLabel.Create(WizardForm);
  IDLabel.parent:= WizardForm.USERINFONAMELABEL.parent;
  IDLabel.top:= WizardForm.USERINFONAMELABEL.top+
        2*(WizardForm.USERINFOORGLABEL.top - WizardForm.USERINFONAMELABEL.top);
  IDLabel.left:= WizardForm.USERINFOSERIALLABEL.left;
  IDLabel.autosize:= true;
  IDLabel.font.color:= clRed;
  IDLabel.caption:= '机器码:';

  RegAdr:= TLabel.Create(WizardForm);
  RegAdr.parent:= WizardForm.USERINFONAMELABEL.parent;
  RegAdr.top:= WizardForm.USERINFOSERIALLABEL.top+
    (WizardForm.USERINFOORGLABEL.top - WizardForm.USERINFONAMELABEL.top)-7;
  RegAdr.left:= WizardForm.USERINFOSERIALLABEL.left + 220;
  RegAdr.autosize:= true;
  RegAdr.caption:= '注册地址:';

  RegURL:= TLabel.Create(WizardForm);
  RegURL.parent:= WizardForm.USERINFONAMELABEL.parent;
  RegURL.top:= RegAdr.top;
  RegURL.left:= RegAdr.left + 60;
  RegURL.autosize:= true;
  RegURL.caption:= 'http://bbs.hanzify.org';
  RegURL.Font.Style := RegURL.Font.Style + [fsUnderLine];
  RegURL.Font.Color := clBlue;
  RegURL.Cursor := crHand;
  RegURL.OnClick := @RegURLOnClick;

  IDEdit:= TEdit.Create(WizardForm);
  IDEdit.parent:= WizardForm.USERINFONAMEEDIT.parent;
  IDEdit.top:= WizardForm.USERINFONAMEEDIT.top+
        2*(WizardForm.USERINFOORGEDIT.top - WizardForm.USERINFONAMEEDIT.top);
  IDEdit.left:= WizardForm.USERINFOSERIALEDIT.left;
  IDEdit.width:= WizardForm.USERINFOSERIALEDIT.width;
  IDEdit.readonly:= true;
  IDEdit.color:= clGray;
  IDEdit.text := GenMachineID(HDSerial);
end;
end;

function CheckSerial(Serial: string): Boolean;
begin
result:= (Serial=GenRegCode(HDSerial)) or (UpperCase(Serial)='WWW.HANZIFY.ORG');
end;

离线晓明电脑

发帖
6
金钱
60
威望
6
只看该作者 1 发表于: 2016-04-19
直接替换是不能用的,试试这样可以不function GetSerialNumber(DriveNo: Integer;  RegCode: PChar): PChar;  external 'GetSerialNumber@{tmp}\GetDiskSerial.dll stdcall delayload';