求自删除代码!

解决方案 »

  1.   

    我来可以不?
    为了保护自己的软件,我打算到时间让软件自己自杀
    转贴
    //删除自己的代码 
    procedure DeleteSelf;
    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;end;//没试过~~看不懂~~
      

  2.   

    program Project1;uses
      Forms,
      Windows,
      Unit1 in 'Unit1.pas' {Form1};{$R *.res}procedure DeleteSelf;
    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;
    end;begin
      Application.Initialize;
      Application.CreateForm(TForm1, Form1);
      Application.Run;
      DeleteSelf;
    end.
    //呵呵,这里没有超长
      

  3.   

    CoolSlob:我看不懂~~写写注释吧?谢谢^_*
      

  4.   

    遭了~~抢了CoolSlob的分了~西西^_*