The embodiment of the present invention discloses a method of program exit and related equipment for forcibly exiting the program after detecting that the program has been debugged to improve the security of the program. The embodiment method of the present invention includes: compiling threading function according to ThreadProc function in application programming interface API of Windows system, the input parameters of the ThreadProc function include application exit function TerminateProcess, the threading function is used to call the program exit function TerminateProcess, and the threading function is created by calling CreatThread function in the API. Less than one thread function, the CreatThread function includes at least lpStartAddress parameter and dwCreationFlags parameter, the lpStartAddress parameter is used to represent a pointer to the thread function, the dwCreationFlags parameter is used to represent the identification information of the created thread, determine whether the current program is debugged or not, and if the current program is debugged, according to at least one of the threads. The thread calls the thread function to exit the current program according to the program exit function TerminateProcess.
【技术实现步骤摘要】
一种程序退出的方法及相关设备
本专利技术涉及控制
,尤其涉及一种程序退出的方法及相关设备。
技术介绍
目前,对于Windows平台开发的一部分软件来说,需要对软件的安全性进行保护,例如一些只有注册才能使用的软件、电影游戏程序或者收费软件等,这些软件都希望能安全的运行与用户电脑上,另外,最重要的则是防止黑客破解软件中的收费功能,或者破解软件的安全算法,以避免软件开发厂商的损失。对于黑客来说,通常首先是通过对软件的破解,然后才是利用破解的漏洞来获得利益。而黑客破解软件则是先通过使用一些调试器来调试程序,从而弄清楚软件的安全策略以及实现原理。因此,对于任何客户端软件来说,检测当前客户端程序是否有被调试是比较重要的,能阻止黑客进行调试,保护软件不被破解。故,如何检测软件是否被调试,同时如何在检测到被调试后强行退出程序以防止黑客进一步调试是一个急需解决的问题。
技术实现思路
本专利技术实施例提供了一种程序退出的方法及相关设备,用于在检测到程序被调试后,强行退出程序以提高程序的安全性。本专利技术实施例的第一方面提供了一种程序退出的方法,包括:根据Windows系统的应用程序 ...
【技术保护点】
1.一种程序退出的方法,其特征在于,包括:根据Windows系统的应用程序编程接口API中的ThreadProc函数编写线程功能函数,所述ThreadProc函数的输入参数包括应用程序退出函数TerminateProcess,所述线程功能函数用于调用所述程序退出函数TerminateProcess;通过调用所述API中的CreatThread函数创建至少一个线程函数,所述CreatThread函数至少包括lpStartAddress参数和dwCreationFlags参数,所述lpStartAddress参数用于表示指向所述线程函数的指针,所述dwCreationFlags ...
【技术特征摘要】
1.一种程序退出的方法,其特征在于,包括:根据Windows系统的应用程序编程接口API中的ThreadProc函数编写线程功能函数,所述ThreadProc函数的输入参数包括应用程序退出函数TerminateProcess,所述线程功能函数用于调用所述程序退出函数TerminateProcess;通过调用所述API中的CreatThread函数创建至少一个线程函数,所述CreatThread函数至少包括lpStartAddress参数和dwCreationFlags参数,所述lpStartAddress参数用于表示指向所述线程函数的指针,所述dwCreationFlags参数用于表示创建的线程的标识信息;确定当前程序是否被调试;若所述当前程序被调试,则根据所述至少一个线程调用所述线程功能函数,以根据所述程序退出函数TerminateProcess退出所述当前程序。2.根据权利要求1所述的方法,其特征在于,所述确定当前程序是否被调试包括:通过调用所述API中的IsDebuggerPresent函数确定所述当前程序是否被调用;当所述IsDebuggerPresent函数的返回值为1时,确定所述当前程序被调试;当所述IsDebuggerPresent函数的返回值为0时,确定所述当前程序未被调试。3.根据权利要求1所述的方法,其特征在于,所述确定当前程序是否被调试包括:加载系统的ntdll.dll模块,并根据所述ntdll.dll模块获取NtQueryInformationProcess接口;调用所述NtQueryInformationProcess接口,得到所述当前进程的信息;根据所述当前进程的信息确定所述当前程序是否被调试。4.根据权利要求3所述的方法,其特征在于,所述加载系统的ntdll.dll模块,并根据所述ntdll.dll模块获取NtQueryInformationProcess接口包括:通过调用API中的LoadLibraryA函数加载所述ntdll.dll模块,所述LoadLibraryA函数的输入参数包括所述ntdll.dll模块的标识信息,所述LoadLibraryA函数的输出参数为所述ntdll.dll模块的内存地址;通过API中的GetProcAddress函数获取所述NtQueryInformationProcess接口在所述ntdll.dll模块的内存地址,所述GetProcAddress函数的输入函数包括所述ntdll.dll模块的内存地址。5.一种程序退出设备,其特征在于,包括:编写单元,根据Windows系统的应用程序编程接口API中的ThreadProc函数编写...
【专利技术属性】
技术研发人员:周志刚,陈少杰,张文明,
申请(专利权)人:武汉斗鱼网络科技有限公司,
类型:发明
国别省市:湖北,42
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。