子供が簡単なトリックを使用してソフトウェアをリバースエンジニアリングするのを防ぐために、非常に基本的なデバッガー保護を実装しようとしています。これらの単純な対策は簡単に回避できますが、少なくとも情報がない状態を防ぐことができます。次のコードはオンラインのチュートリアルからのものですが、これが本番コードで安全に使用できるかどうかについて意見を求めたいと思います。この機能はMicrosoftによって文書化されていないため、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;
}
これは安全に使用できますか?
敬具、
フィリップ・ベネフォール