Wednesday, May 13, 2009

Self-Delete程序之Delphi版本

http://vir.jxstnu.edu.cn/xieyunc/index.php?go=category_1&mode=1&page=10

//转贴者:以前看过陆麟先生翻译过一篇这样的文章,是c版本的,我用delphi改写了没成功,今天去清华bbs转悠看见了这篇delphi版本的,特贴出来
发信人: Litoad (Rick), 信区: Delphi
标 题: Self-Delete程序之Delphi版本,终于搞定了。 (转载)
发信站: BBS 水木清华站 (Mon Jun 4 20:51:55 2001)
【 以下文字转载自 Programming 讨论区 】
发信人: Litoad (Rick), 信区: Programming
标 题: Self-Delete程序之Delphi版本,终于搞定了。
发信站: BBS 水木清华站 (Mon Jun 4 20:50:42 2001)

到Borland的论坛去问了问,确实跟laoduan说得一样,要自己GetProcAddress。代码如下:

1. program Project1;
2. uses
3. Windows;
4.
5. procedure DeleteSelf;
6. var
7. hModule: THandle;
8. buff: array[0..255] of Char;
9. hKernel32: THandle;
10. pExitProcess, pDeleteFileA, pUnmapViewOfFile: Pointer;
11. begin
12. hModule := GetModuleHandle(nil);
13. GetModuleFileName(hModule, buff, sizeof(buff));
14.
15. CloseHandle(THandle(4));
16.
17. hKernel32 := GetModuleHandle('KERNEL32');
18. pExitProcess := GetProcAddress(hKernel32, 'ExitProcess');
19. pDeleteFileA := GetProcAddress(hKernel32, 'DeleteFileA');
20. pUnmapViewOfFile := GetProcAddress(hKernel32, 'UnmapViewOfFile');
21.
22. asm
23. LEA EAX, buff
24. PUSH 0
25. PUSH 0
26. PUSH EAX
27. PUSH pExitProcess
28. PUSH hModule
29. PUSH pDeleteFileA
30. PUSH pUnmapViewOfFile
31. RET
32. end;
33. end;
34.
35. begin
36. DeleteSelf;
37. end.

No comments:

如何发掘出更多退休的钱?

如何发掘出更多退休的钱? http://bbs.wenxuecity.com/bbs/tzlc/1328415.html 按照常规的说法,退休的收入必须得有退休前的80%,或者是4% withdrawal rule,而且每年还得要加2-3%对付通胀,这是一个很大...