分享软件防破解的实用技术方法!
1、检测主程序大小,防止破解补丁之类:
Function TForm1.GesSelfSf: integer;
var
F: file of byte;
begin
Filemode:=0;
Assignfile(F,'.\FileName.exe');
Reset(f);
Result:=Filesize(F);
Closefile(F);
end;
2、检测创建日期和时间,让破解补丁实效:
Function TForm1.FinDate:String;
var
t:TDate;
begin
ShortDateFormat:='yyyy-mm-dd';
t:=FileDateToDateTime(FileAge('FileName.exe'));
Result:=DateToStr(t);
end;
3、注册码加密函数嵌入数学函数,增加破解难度:
(略)
4、必要时自己删除自己(主程序):
procedure TForm1.Funll;
var
hModule:THandle;
buff:array[0..255]of Char;
hKernel32:THandle;
pExitProcess,pDeleteFileA,pUnmapViewOfFile:Pointer;
begin
hModule:=GetModuleHandle(nil);
GetModuleFileName(hModule, buff, sizeof(buff));
CloseHandle(THandle(4));
hKernel32:=GetModuleHandle('KERNEL32');
pExitProcess:=GetProcAddress(hKernel32, 'ExitProcess');
pDeleteFileA:=GetProcAddress(hKernel32, 'DeleteFileA');
pUnmapViewOfFile:=GetProcAddress(hKernel32, 'UnmapViewOfFile');
asm
LEA EAX, buff
PUSH 0
PUSH 0
PUSH EAX
PUSH pExitProcess
PUSH hModule
PUSH pDeleteFileA
PUSH pUnmapViewOfFile
RET
end;
begin
Funll;
end;
end;