I have writed a program to delete itself, but it cannot work, why?
and it work on XP sp2

.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib

.data
MsgBoxCaption db "My self-del program",0
MsgBoxText db "Now you will see the resule!",0
progname db 256 dup(0)

.data?
module HMODULE ?

.code
start:
invoke GetModuleHandle,0
mov module,eax
invoke GetModuleFileName,module,addr progname,256
invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK

invoke CloseHandle,HANDLE+4
lea eax,progname
push 0
push 0
push eax
push ExitProcess
push module
push DeleteFile
push UnmapViewOfFile
ret
invoke ExitProcess,NULL
end start
Posted on 2004-11-11 22:07:41 by miaomiao
http://board.flatassembler.net/viewtopic.php?t=1979
Posted on 2004-11-11 22:37:58 by comrade
http://board.flatassembler.net/viewtopic.php?t=1979

thanks a lot, but I cannot open the URL
Posted on 2004-11-11 22:50:39 by miaomiao
Posted on 2004-11-12 08:17:10 by miaomiao
invoke CloseHandle,HANDLE+4

Why the "HANDLE+"?
I don't like that code at all.
Posted on 2004-11-12 10:42:21 by death
Hardcoded value? hmm
Posted on 2004-11-12 11:05:00 by roticv
file section has handle of 4 on win2000, i believe
that's part of the trick
Posted on 2004-11-12 11:06:37 by comrade