返回首页

您好,
我想使我的应用程序检测它是否正在调试或代码项目]不,我找到了这样一个伟大的文章,并开始工作,然后我想出了这个:


    <system.runtime.interopservices.dllimport("kernel32.dll")> _

    Public Shared Function LoadLibrary(ByVal szFileName As String) As IntPtr

    End Function

 

    <system.runtime.interopservices.dllimport("kernel32.dll")> _

    Public Shared Function GetProcAddress(ByVal hLibrary As IntPtr, ByVal szProcName As String) As IntPtr

    End Function

 

    <system.runtime.interopservices.dllimport("kernel32.dll",> _

    Public Shared Function GetCurrentProcess() As IntPtr

    End Function

 

    Private Delegate Function Nt_QueryInformationProcess(ByVal hProc As IntPtr, ByVal DbgFlags As UInt32, ByRef NoDbg As Boolean, ByVal PiLen As Int32, ByVal RetLen As Int32) As Int32

 

    Private Function CheckProcessDebugFlags() As Boolean

        Dim NoDebugInherit As Boolean

        Dim Nt_QIP As Nt_QueryInformationProcess = _

            DirectCast(System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer(GetProcAddress(LoadLibrary("Ntdll.dll"), "NtQueryInformationProcess"), GetType(Nt_QueryInformationProcess)), Nt_QueryInformationProcess)

        Dim Status As Int32 = Nt_QIP.Invoke(GetCurrentProcess(), &H1F, NoDebugInherit, 4, 0)

        If Status = 0 Then

            If NoDebugInherit = False Then

                Return True

            Else

                Return False

            End If

        Else

            Return False

        End If

    End Function


问题是,它始终返回false,即使当它在调试模式下运行,所以它可以是我做错了什么,或者它只是不使用托管代码?

回答

评论会员:。SAKryukov 时间:2012/02/07
有一种方法来检测这个:

if (System.Diagnostics.Debugger.IsAttached)

    System.Diagnostics.Process.GetCurrentProcess().Kill(); //for example

的东西告诉我,它不能阻止一个真正先进的代码饼干。我什至不提不能影响或使用任何伎俩,以防止在调试器下运行的逆向工程。逆向工程分析的代码,而不是运行它。因此,逆向工程完成时,这些代码可以被简单地删除。

mdash;水杨酸
评论会员:游客 时间:2012/02/07
BobJanova:如果你的输出是一个净装配,然后有一个较高的水平攻击(逆向工程的CLRIL),这种低层次的东西,不是真的要帮助你多少,因为它会。很明显的人试图破解你的代码