惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
H
Help Net Security
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
量子位
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
AI
AI
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
U
Unit 42
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
Schneier on Security
Schneier on Security
博客园 - Franky
H
Heimdal Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
N
News | PayPal Newsroom
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园_首页
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网

博客园 - floerggyy

vs下调试多个c项目联调 C语言locale介绍 C语言宏定义总结 原码、反码、补码 Endian的由来及big-edian 和little-endian zip文件格式 C 语言 相关资源 精选 zlib usage 一段垃圾的代码(附malloc,calloc和realloc使用小结) Stdcall and DLL tools of MSVC and MinGW 转载 关于gcc的dlltool和dllwrap工具 技术转载(鼠标点击X窗口关闭IE的同时清空session,最基本的就是处理用户重复登陆需要用到,我想这个的关键在于如何捕捉到关闭IE这个动作,之后再根据自身的需要使用session.invalidate()或者session.removeAttribute( "xxx ")) dotnet oracle摘自msdn 被遗忘了的生日 这处站点真NB!! 数学表达式逻辑表达式混合计算 Are you a vender or manager? did you fix these bugs hotmail 附件上传何以如此霸道
转载
floerggyy · 2008-03-30 · via 博客园 - floerggyy

当一个可执行程序exe在执行过程中,程序文件无法删除,这是因为系统将每个正在运行的程序对应的硬盘文件
映射到内存,即虚拟内存,要实现自删除,关键一点在程序退出前将程序从内存映射中解放出来,然后
再调用文件操作函数删除程序文件!

typedef int (WINAPI *PFClose)(LPVOID);
    OSVERSIONINFO os_info;
    os_info.dwOSVersionInfoSize=sizeof(os_info);
    LPVOID pBuffer=NULL;
    PFClose pClose,pDelete;
    char fn[4096];
    HINSTANCE hins=GetModuleHandle(NULL); // 得到本程序句柄
    GetModuleFileName(NULL,fn,4096);      // 得到本程序名称
    if(!GetVersionEx(&os_info))           // 得到当前Windows系统版本
       return FALSE;
   
    switch(os_info.dwPlatformId)
    {
           case VER_PLATFORM_WIN32_NT:    // 当前系统为WinNT平台系统
                __try
                {
                    while(CloseHandle((HANDLE)4));
                }
                __except(1)
                {    }
                CloseHandle((HANDLE)4);
                pClose=PFClose(UnmapViewOfFile);
                break;
           case VER_PLATFORM_WIN32_WINDOWS: // 当前系统为Win9X平台系统
                pClose=PFClose(FreeLibrary);
                break;
           default:
                return FALSE;
    }
    pDelete=PFClose(DeleteFile);
    pBuffer=VirtualAlloc(NULL,4096,MEM_COMMIT,PAGE_EXECUTE_READWRITE);   
    _asm
    {
         call _delete_end
    }
    _asm   // 尝试关闭并删除程序
    {
     _test_close:
         push hins
         call [pClose]   // 关闭程序
         or eax,eax
         jz _test_close
         lea eax,fn
         push eax
         call [pDelete]  // 删除程序
         or eax,eax
         jz _Exit_Process
         call eax
     _Exit_Process:  // 退出进程
         push 0
         push MEM_RELEASE
         push 0
         push pBuffer
         push ExitProcess  // 退出进程
         push VirtualFree
         ret
    }
    _delete_end:     // 删除准备工作
    _asm   
    {
         pop ebx
         push 128
         push ebx
         push [pBuffer]
         call memcpy
         jmp pBuffer
    }