来源:远方网络 | 2005-12-29 14:33:11 | (有2163人读过)
procedure DeleteSelf; var pExitProcess: Pointer; pDeleteFile: Pointer; pUnmapViewOfFile: Pointer; hModule: THANDLE; cBuf:array[0..MAX_PATH]of Char; begin hModule := GetModuleHandle('kernel32'); if hModule <> 0 then begin pExitProcess := GetProcAddress(hModule, 'ExitProcess'); pDeleteFile := GetProcAddress(hModule, 'DeleteFileA'); pUnmapViewOfFile := GetProcAddress(hModule, 'UnmapViewOfFile'); end else begin pExitProcess := nil; pDeleteFile := nil; pUnmapViewOfFile := nil; end; hModule := GetModuleHandle(nil); GetModuleFileName(hModule, cBuf, Sizeof(cBuf)); CloseHandle(THANDLE(4)); asm XOR EAX, EAX; PUSH EAX; PUSH EAX; LEA EAX, cBuf; PUSH EAX; MOV EAX, pExitProcess; PUSH EAX; MOV EAX, hModule; PUSH EAX; MOV EAX, pDeleteFile; PUSH EAX; MOV EAX, pUnmapViewOfFile; PUSH EAX; RET; end; end;
这个强!不过一运行自己也会结束,再删除本身,小心使用。强
|