我正在尝试实现一些非常基本的调试器保护,以防止孩子们使用简单的技巧对我的软件进行逆向工程。虽然这些简单的措施很容易绕过,但它们至少可以将不知情的人拒之门外。以下代码来自在线教程,我想请教您对在生产代码中使用这是否安全的意见?我很犹豫,因为这个功能没有被微软记录在案,因此可能会也可能不会从一个版本的 Windows 完全改变到另一个版本。我想要的最后一件事是我的应用程序开始在 Windows 8、9 等上崩溃,因为函数签名是错误的。
代码如下:
// HideThread will attempt to use
// NtSetInformationThread to hide a thread
// from the debugger, Passing NULL for
// hThread will cause the function to hide the thread
// the function is running in. Also, the function returns
// false on failure and true on success
inline bool HideThread(HANDLE hThread)
{
typedef NTSTATUS (NTAPI *pNtSetInformationThread)
(HANDLE, UINT, PVOID, ULONG);
NTSTATUS Status;
// Get NtSetInformationThread
pNtSetInformationThread NtSIT = (pNtSetInformationThread)
GetProcAddress(GetModuleHandle( TEXT("ntdll.dll") ),
"NtSetInformationThread");
// Shouldn't fail
if (NtSIT == NULL)
return false;
// Set the thread info
if (hThread == NULL)
Status = NtSIT(GetCurrentThread(),
0x11, // HideThreadFromDebugger
0, 0);
else
Status = NtSIT(hThread, 0x11, 0, 0);
if (Status != 0x00000000)
return false;
else
return true;
}
这可以安全使用吗?
亲切的问候,
菲利普·班尼法尔