大家通常是不是通过给进程堆作快照,然后比照 ExeName ,杀进程?但这样有个致命的弱点,只要别人把文件名给改了,那这样就行不同了。
因此,在这里求教可以避免这种问题的方法!先谢过了!
因此,在这里求教可以避免这种问题的方法!先谢过了!
解决方案 »
- 请问if和case语句如何在表达式成立的时候什么也不做?
- vb.net2005編寫的DLL文件怎麽在delphi中調用?
- 如何加动态库到注册表里呢?
- RichEdit中字体的问题。
- ****如何解决多个客户同时操作一条记录的问题?
- 求救,我在学习李维的《Delphi5.x ADO/MTS/COM+》的第九章的程序实例中,编写的更新组件总是不好用,请各位帮帮忙,谢谢
- 1000分,请你增长见识,当然还要讨论哦...
- 高手们请问deiphi如何实玩宏代换???????????十分火急!!!!!!!
- 关于窗口得操作
- 大家快看,中美网络大战有动静了。
- delphi的installshield教程!!(不是VB的)哪裡有下載啊 (100分送上)
- 紧急求就`~ 哪里有delphi6,5等等自带的报表控件下载呢?
HANDLE hProcess; // 将被结束进程的句柄
UINT uExitCode; // 指定进程的退出码
); 看到这里,是不是觉得不必往下看都知道接下来要做什么:Hook TerminateProcess()函数,每次TerminateProcess()被调用的时候先判断企图结束的进程是否是我的进程,如果是的话就简单地返回一个错误码就可以了。真的是这么简单吗?先提出一个问题,如何根据hProcess判断它是否是我的进程的句柄?答案是:在我的进程当中先获得我的进程的句柄,然后通过进程间通讯机制传递给钩子函数,与hProcess进行比较不就行了?错!因为句柄是一个进程相关的值,不同进程中得到的我的进程的句柄的值在进程间进行比较是无意义的。 怎么办?我们来考察一下我的hProcess它是如何得到的。一个进程只有它的进程ID是独一无二的,操作系统通过进程ID来标识一个进程,当某个程序要对这个进程进行访问的话,它首先得用OpenProcess这个函数并传入要访问的进程ID来获得进程的句柄,来看看它的参数:HANDLE OpenProcess(
DWORD dwDesiredAccess, // 希望获得的访问权限
BOOL bInheritHandle, // 指明是否希望所获得的句柄可以继承
DWORD dwProcessId // 要访问的进程ID
); 脉络渐渐显现:在调用TerminateProcess()之前,必先调用OpenProcess(),而OpenProcess()的参数表中的dwProcessId是在系统范围内唯一确定的。得出结论:要Hook的函数不是TerminateProcess()而是OpenProcess(),在每次调用OpenProcess()的时候,我们先检查dwProcessId是否为我的进程的ID(利用进程间通讯机制),如果是的话就简单地返回一个错误码就可以了,任务管理器拿不到我的进程的句柄,它如何结束我的进程呢? 至此,疑团全部揭开了。由Hook TerminateProcess()到Hook OpenProcess()的这个过程,体现了一个逆向思维的思想。其实我当初钻进了TerminateProcess()的死胡同里半天出也不来,但最终还是蹦出了灵感的火花,注意力转移到了OpenProcess()上面,实现了进程防杀。喜悦之余,将这心得体会拿出来与大家分享。
我要杀别的进程,不是要实现进程防杀!
Works well???
首先,我要中止进程,不是要隐藏窗体;其次,单凭类名如何能找到我要的进程;再次,Openprocess() 和 TerminateProcess() 都是针对进程的操作,与窗体有什么关系!
AV_15(C.C.Q.):U'd better review the delphihelp and windowsSDK first !search 'findwindow' for keywords and findout...----------------------------------------------------------------------------------The FindWindow function retrieves the handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. HWND FindWindow( LPCTSTR lpClassName, // pointer to class name
LPCTSTR lpWindowName // pointer to window name
); ParameterslpClassNamePoints to a null-terminated string that specifies the class name or is an atom that identifies the class-name string. If this parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of lpClassName; the high-order word must be zero. lpWindowNamePoints to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match. Return ValuesIf the function succeeds, the return value is the handle to the window that has the specified class name and window name.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
----------------------------------------------------------------------------------HAVE A GOOD READ AND STUDYIT IS YOUR PROBLEM NOT OURS
try SENDMESSAGE(HANDLE,SYSCOMMAND,SC_CLOSE,0);^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^