Esempio n. 1
0
        public static bool CheckTamper(ModuleDefMD module)
        {
            bool      IsTampred;
            MethodDef cctor = module.GlobalType.FindStaticConstructor();

            if (cctor == null)
            {
                IsTampred = false;
            }
            else
            {
                for (int i = 0; i < cctor.Body.Instructions.Count; i++)
                {
                    if (cctor.Body.Instructions[i].OpCode == OpCodes.Call)
                    {
                        try
                        {
                            MethodDef method = (MethodDef)cctor.Body.Instructions[i].Operand;
                            for (int z = 0; z < method.Body.Instructions.Count; z++)
                            {
                                if (method.Body.Instructions[z].OpCode == OpCodes.Call)
                                {
                                    string operand = method.Body.Instructions[z].Operand.ToString();
                                    if (operand.Contains("GetHINSTANCE"))
                                    {
                                        if (method.FindInstructionsNumber(OpCodes.Call, "(System.IntPtr,System.UInt32,System.UInt32,System.UInt32&)") == 1)
                                        {
                                            ATMeth = method;
                                            return(true);
                                        }
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                IsTampred = false;
            }
            return(IsTampred);
        }