C ++保护进程不被暂停 [英] C++ Protect Process from being suspended

查看:81
本文介绍了C ++保护进程不被暂停的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么可能的方法来保护exe免受挂起?

Is there any possible way to protect an exe from being suspended ?

请注意,我是应用程序的所有者.

Note that the i'm the owner of the application.

推荐答案

有诸如Sysinternals ProcessExpert之类的工具,可以让您暂停任何进程.如果用户具有管理员权限,则无法避免这种情况.

There are tools such as Sysinternals ProcessExpert that allows you to suspend any process. If the user has admin authorisations there is no way to avoid this.

此SO答案显示了三种暂停Windows进程的解决方案.

This SO answer shows three solutions to suspend a windows process.

但是,有一种方法可以使这一过程变得极为困难:解决方案包括为您的应用程序提供一个影子进程.然后,应用程序和影子进程将监视彼此的暂停状态,并在必要时恢复暂停的进程:

However there is a way to make this extremely difficult : the solution consist of having a shadow process for your application. The application and the shadow process then shall monitor each other's suspension status and resume the suspended process if necessary:

  • 由于必须一个接一个地挂起进程,因此这种双重方法可确保两个进程中的一个处于活动状态并可以防止挂起.

  • as processes have to be suspended one after the other, this twin approach ensures that one of the two process is active and can prevent the suspension.

但是,这种持续监视会消耗CPU资源,因此您会真正考虑是否有必要这样做,并且对于您的应用程序性能而言是可以接受的.

however this constant monitoring is CPU consuming, so you'd really think whether it's necessary to do so, and acceptable for your application's performance.

如果要避免挂起,以避免使用调试器对代码进行反向工程,则还有另一个更有效的选择.您在整个关键代码中插入了几个计时器调用,并检查异常执行时间是否显示了挂起/调试,如果是这种情况,则停止代码.

If you want to prevent suspension to avoid reverse engineering of your code with a debugger, you have another more effective option. You insert several timer calls throughout your critical pieces of code, and check if abnormal execution time reveals suspension/debugging and if it's the case, you stop your code.

这篇关于C ++保护进程不被暂停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆