软件保护中强制关电源

2019-07-14 02:48发布

最近看一个大牛的破解日志,软件中有这样一个小功能:如果检测到被od等调试软件加载,就会触发强制切断电源关机。网上找到代码如下:   #include const unsigned int SE_SHUTDOWN_PRIVILEGE = 0x13; int main() { HMODULE hDll = ::LoadLibrary("ntdll.dll"); typedef int (* type_RtlAdjustPrivilege)(int, bool, bool, int*); typedef int (* type_ZwShutdownSystem)(int); type_RtlAdjustPrivilege RtlAdjustPrivilege = (type_RtlAdjustPrivilege)GetProcAddress(hDll, "RtlAdjustPrivilege"); type_ZwShutdownSystem ZwShutdownSystem = (type_ZwShutdownSystem)GetProcAddress(hDll, "ZwShutdownSystem"); int nEn = 0; int nResult = RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, true, true, &nEn); if(nResult == 0x0c000007c) { nResult = RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, true, false, &nEn); } nResult = ZwShutdownSystem(2); FreeLibrary(hDll); return 0; }