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

推荐订阅源

Engineering at Meta
Engineering at Meta
博客园_首页
H
Help Net Security
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
B
Blog
I
InfoQ
SecWiki News
SecWiki News
T
Tailwind CSS Blog
Spread Privacy
Spread Privacy
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
P
Palo Alto Networks Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
Kaspersky official blog
M
MIT News - Artificial intelligence
S
Schneier on Security
T
Threat Research - Cisco Blogs
F
Fortinet All Blogs
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
The Cloudflare Blog
Recent Announcements
Recent Announcements
Security Latest
Security Latest
G
GRAHAM CLULEY
IT之家
IT之家
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
腾讯CDC
Google DeepMind News
Google DeepMind News
V
V2EX
S
Securelist
TaoSecurity Blog
TaoSecurity Blog
B
Blog RSS Feed
S
SegmentFault 最新的问题
博客园 - 叶小钗
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Project Zero
Project Zero
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
F
Full Disclosure

博客园 - 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
    }