static unsafe MemTools()
        {
            if (Memcpy == null)
            {
                var dynamicMethod = new DynamicMethod("memcpy", typeof(void),
                                                      new[] { typeof(void *), typeof(void *), typeof(int) },
                                                      typeof(MemTools));

                var ilGenerator = dynamicMethod.GetILGenerator();

                ilGenerator.Emit(OpCodes.Ldarg_0);
                ilGenerator.Emit(OpCodes.Ldarg_1);
                ilGenerator.Emit(OpCodes.Ldarg_2);
                ilGenerator.Emit(OpCodes.Cpblk);
                ilGenerator.Emit(OpCodes.Ret);

                Memcpy = (MemCpyFunction)dynamicMethod.CreateDelegate(typeof(MemCpyFunction));
            }

            if (Memset == null)
            {
                var dynamicMethod = new DynamicMethod("memset", typeof(void),
                                                      new[] { typeof(void *), typeof(int), typeof(int) },
                                                      typeof(MemTools));

                var ilGenerator = dynamicMethod.GetILGenerator();
                ilGenerator.Emit(OpCodes.Ldarg_0);
                ilGenerator.Emit(OpCodes.Ldarg_1);
                ilGenerator.Emit(OpCodes.Ldarg_2);
                ilGenerator.Emit(OpCodes.Initblk);
                ilGenerator.Emit(OpCodes.Ret);

                Memset = (MemSetFunction)dynamicMethod.CreateDelegate(typeof(MemSetFunction));
            }
        }
        static Program()
        {
            var dynamicMethod = new DynamicMethod("memcpy", typeof(void),
                                                  new[] { typeof(void *), typeof(void *), typeof(uint) }, typeof(Program));
            var ilGenerator = dynamicMethod.GetILGenerator();

            ilGenerator.Emit(OpCodes.Ldarg_0);
            ilGenerator.Emit(OpCodes.Ldarg_1);
            ilGenerator.Emit(OpCodes.Ldarg_2);
            ilGenerator.Emit(OpCodes.Cpblk);
            ilGenerator.Emit(OpCodes.Ret);
            memcpy = (MemCpyFunction)dynamicMethod.CreateDelegate(typeof(MemCpyFunction));
        }
        static MemoryUtil()
        {
            var dynamicMethod = new System.Reflection.Emit.DynamicMethod
                                (
                "MemCpy",
                typeof(void),
                new[] { typeof(void *), typeof(void *), typeof(uint) },
                typeof(MemoryUtil)
                                );

            var ilGenerator = dynamicMethod.GetILGenerator();

            ilGenerator.Emit(System.Reflection.Emit.OpCodes.Ldarg_0);
            ilGenerator.Emit(System.Reflection.Emit.OpCodes.Ldarg_1);
            ilGenerator.Emit(System.Reflection.Emit.OpCodes.Ldarg_2);

            ilGenerator.Emit(System.Reflection.Emit.OpCodes.Cpblk);
            ilGenerator.Emit(System.Reflection.Emit.OpCodes.Ret);

            MemCpy = (MemCpyFunction)dynamicMethod.CreateDelegate(typeof(MemCpyFunction));
        }
Beispiel #4
0
        static MemoryBuffer()
        {
            var dynamicMethod = new DynamicMethod
                                (
                nameof(MemCpy),
                typeof(void),
                new[] { typeof(void *), typeof(void *), typeof(uint) },
                typeof(MemoryBuffer)
                                );

            var ilGenerator = dynamicMethod.GetILGenerator();

            ilGenerator.Emit(OpCodes.Ldarg_0);
            ilGenerator.Emit(OpCodes.Ldarg_1);
            ilGenerator.Emit(OpCodes.Ldarg_2);

            ilGenerator.Emit(OpCodes.Cpblk);
            ilGenerator.Emit(OpCodes.Ret);

            MemCpy = (MemCpyFunction)dynamicMethod.CreateDelegate(typeof(MemCpyFunction));
        }
        static MemoryBuffer()
        {
            var dynamicMethod = new DynamicMethod
            (
                "MemCpy",
                typeof(void),
                new[] { typeof(void*), typeof(void*), typeof(uint) },
                typeof(DumpFileMemoryReader)
            );

            var ilGenerator = dynamicMethod.GetILGenerator();

            ilGenerator.Emit(OpCodes.Ldarg_0);
            ilGenerator.Emit(OpCodes.Ldarg_1);
            ilGenerator.Emit(OpCodes.Ldarg_2);

            ilGenerator.Emit(OpCodes.Cpblk);
            ilGenerator.Emit(OpCodes.Ret);

            MemCpy = (MemCpyFunction)dynamicMethod.CreateDelegate(typeof(MemCpyFunction));
        }