Ejemplo n.º 1
0
        static DetourHelper()
        {
            if (Type.GetType("Mono.Runtime") != null)
            {
                Runtime = new DetourRuntimeMonoPlatform();
            }
            else
            {
                Runtime = new DetourRuntimeNETPlatform();
            }

            if (PlatformHelper.Is(Platform.ARM))
            {
                Native = new DetourNativeARMPlatform();
            }
            else
            {
                Native = new DetourNativeX86Platform();
            }

            if ((PlatformHelper.Current & Platform.Windows) == Platform.Windows)
            {
                Native = new DetourNativeWindowsPlatform(Native);
            }
            // TODO: Do Linux, macOS and other systems require protection lifting?
        }
Ejemplo n.º 2
0
        static DetourManager()
        {
            if (Type.GetType("Mono.Runtime") != null)
            {
                Runtime = new DetourRuntimeMonoPlatform();
            }
            else
            {
                Runtime = new DetourRuntimeNETPlatform();
            }

            // Detect X86 vs ARM and use the proper platform.
            typeof(object).Module.GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine);
            if (machine == (ImageFileMachine)0x01C4 /* ARM, .NET 4.5 */)
            {
                Native = new DetourNativeARMPlatform();
            }
            else
            {
                Native = new DetourNativeX86Platform();
            }

            if ((PlatformHelper.Current & Platform.Windows) == Platform.Windows)
            {
                Native = new DetourNativeWindowsPlatform(Native);
            }
            // TODO: Do Linux, macOS and other systems require protection lifting?
        }
Ejemplo n.º 3
0
        public DetourNativeLibcPlatform(IDetourNativePlatform inner)
        {
            Inner = inner;

            // Environment.SystemPageSize is part of .NET Framework 4.0+ and .NET Standard 2.0+
#if NETSTANDARD
            _Pagesize = Environment.SystemPageSize;
#else
            PropertyInfo p_SystemPageSize = typeof(Environment).GetProperty("SystemPageSize");
            if (p_SystemPageSize == null)
            {
                throw new NotSupportedException("Unsupported runtime");
            }
            _Pagesize = (int)p_SystemPageSize.GetValue(null, new object[0]);
#endif
        }
        public DetourNativeMonoPlatform(IDetourNativePlatform inner, string libmono)
        {
            Inner = inner;

            Dictionary <string, List <DynDllMapping> > mappings = new Dictionary <string, List <DynDllMapping> >();

            if (!string.IsNullOrEmpty(libmono))
            {
                mappings.Add("mono", new List <DynDllMapping>()
                {
                    libmono
                });
            }
            DynDll.ResolveDynDllImports(this, mappings);

            _Pagesize = mono_pagesize();
        }
        public DetourNativeMonoPlatform(IDetourNativePlatform inner, string libmono)
        {
            Inner = inner;

#if MONOMOD_RUNTIMEDETOUR
            Dictionary <string, DynDllMapping> mappings = new Dictionary <string, DynDllMapping>();
            if (!string.IsNullOrEmpty(libmono))
            {
                mappings.Add("mono", new DynDllMapping {
                    ResolveAs = libmono
                });
            }
            DynDll.ResolveDynDllImports(this, mappings);
#endif

            _Pagesize = mono_pagesize();
        }
Ejemplo n.º 6
0
 public DetourNativeWindowsPlatform(IDetourNativePlatform inner)
 {
     Inner = inner;
 }
Ejemplo n.º 7
0
 public DetourNativePosixPlatform(IDetourNativePlatform inner)
 {
     Inner = inner;
 }
        public DetourNativeMonoPosixPlatform(IDetourNativePlatform inner)
        {
            Inner = inner;

            _Pagesize = sysconf(SysconfName._SC_PAGESIZE, 0);
        }