code to change the characteristics flag:
char buf[]="C:\\Documents and
Settings\\Administrator\\Desktop\\imghlptst\\hello\\Debug\\hello.exe";
WORD wChar = 0;
DWORD dwRead;
DWORD signature_offset;
BOOL b;
DWORD char_offset;
HANDLE file =
CreateFile(buf,GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FI
LE_ATTRIBUTE_NORMAL,NULL);
SetFilePointer(file,0x3c,0,FILE_BEGIN);
b = ReadFile(file,&signature_offset,4,&dwRead,0);
char_offset = signature_offset+4+18;
SetFilePointer(file,char_offset,0,FILE_BEGIN);
b = ReadFile(file,&wChar,2,&dwRead,0);
wChar = wChar | IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP;
SetFilePointer(file,char_offset,0,FILE_BEGIN);
b = WriteFile(file,&wChar,2,&dwRead,0);
code for hello.exe:
int main(int argc, char* argv[])
{
BOOL b = DeleteFile("hello.exe");
if (b)
printf("delete ok\n");
else
printf("delete failed\n");
printf("err %d\n",GetLastError());
getchar();
return 0;
}
(1) Have your program use CreateFile() to create a batch file
(2) Into the batch file write the following:
:again
del hello.exe
if exist hello.exe goto again
(3) Use CreateProcess() to run that batch file, low priority, hidden window
(4) Let your application close normally. When it does, *poof*, it will be
deleted.
--Richard
"Richard Jernigan" <ric...@randomly.com> wrote in message
news:G80C6.2496$B22.6...@news1.rdc2.pa.home.com...
Regards,
Jackson Yee
http://jacksonyee.welcome.to/
E-mails for help will be ignored unless I had asked for them. Please post
to the group.
"oknp" <ok...@hotmail.com> wrote in message
news:9bdgrf$p2...@imsp212.netvigator.com...