Пример #1
0
        public static void Run()
        {
            TestDynamicCodeInjection demo = new TestDynamicCodeInjection();
            int result = demo.NetAsmAdd(1, 2);

            PerfManager.Instance.WriteLine("Result NetAsmAdd(1,2) = {0}", result);
            PerfManager.Assert(result == 3, "Error, NetAsm hook on method NetAsmAdd is not set");

            result = demo.NetAsmAddFromDll(1, 2);
            PerfManager.Instance.WriteLine("Result NetAsmAddFromDll(1,2) = {0}", result);
            PerfManager.Assert(result == 3, "Error, NetAsm hook on method NetAsmAddFromDll is not set");

            result = demo.ManagedAdd(1, 2);
            PerfManager.Instance.WriteLine("Result ManagedAdd(1,2) + 1 = {0}", result);
            PerfManager.Assert(result == 4, "Error, NetAsm hook on method ManagedAdd is not set");

            result = demo.ManagedAddInlined(1, 2);
            PerfManager.Instance.WriteLine("Result ManagedAddInlined(1,2) + 1 = {0}", result);
            PerfManager.Assert(result == 4, "Error, NetAsm hook on method ManagedAddInlined is not set");

            result = NetAsmIndirectCaller();
            PerfManager.Instance.WriteLine("Result NetAsmIndirectCaller() = {0}", result);
            PerfManager.Assert(result == 2, "Error, NetAsm hook on method NetAsmIndirectCaller is not set");

            // Test Nop Methods
            NetAsmNopMethod();
            NetAsmNopMethodWithArgs(1, 2, 3, 4);
        }
Пример #2
0
        public static void Run()
        {
            TestStaticCodeInjection demo = new TestStaticCodeInjection();
            int result = demo.NetAsmAdd(1, 2);

            PerfManager.Instance.WriteLine("Result NetAsmAdd(1,2) = {0}", result);
            PerfManager.Assert(result == 3, "Error, NetAsm hook on method NetAsmAdd is not set");
        }
Пример #3
0
        public static void Run()
        {
            byte[] byteBuffer = new byte[64];
            PerfManager.Instance.WriteLine("ByteBuffer Len before cast : {0}", byteBuffer.Length);

            float[] floatBuffer = CastConvert(byteBuffer);
            PerfManager.Instance.WriteLine("ByteBuffer Len after cast : {0}", byteBuffer.Length);
            PerfManager.Assert(floatBuffer.Length == 16, "Bad Length on float buffer. Expected 16");

            floatBuffer[0] = 1.0f;
            PerfManager.Assert(byteBuffer[3] == 0x3F, "Error, NetAsm hook on method NetAsmAdd is not set");

            PerfManager.Instance.WriteLine("Cast byte[] to float[] successfull");
        }
Пример #4
0
        static public void Run()
        {
            SimpleStructure simpleStructure;

            simpleStructure.x = 1;
            simpleStructure.y = 2;
            simpleStructure.z = 3;
            SimpleStructure outputSimpleStructure = new SimpleStructure();

            int resultInt = CalculateStructure(simpleStructure, ref outputSimpleStructure);

            PerfManager.Assert(resultInt == (simpleStructure.x + simpleStructure.y * 3 + simpleStructure.z * 5), "Invalid CalculateStructure ByValue");
            PerfManager.Assert((outputSimpleStructure.x == simpleStructure.x &&
                                outputSimpleStructure.y == simpleStructure.y &&
                                outputSimpleStructure.z == simpleStructure.z), "Invalid CalculateStructure ByRef");
        }
Пример #5
0
        public static void RunClrCall()
        {
            int    resultInt;
            double resultDouble;
            int    x = 1;
            int    y = 2;
            int    z = 3;
            int    w = 4;

            resultInt = Test0ArgClrCall();
            PerfManager.Assert(resultInt == 1, "Invalid result Test0ArgClrCall");

            resultInt = Test1ArgClrCall(x);
            PerfManager.Assert(resultInt == 1, "Invalid result Test01rgClrCall");

            resultInt = Test2ArgClrCall(x, y);
            PerfManager.Assert(resultInt == (x + y * 3), "Invalid result Test2ArgClrCall");

            resultInt = Test3ArgClrCall(x, y, z);
            PerfManager.Assert(resultInt == (x + y * 3 + z * 5), "Invalid result Test03rgClrCall");

            resultInt = Test4ArgClrCall(x, y, z, w);
            PerfManager.Assert(resultInt == (x + y * 3 + z * 5 + w * 7), "Invalid result Test4ArgClrCall");

            resultDouble = Test4ArgWith1DoubleClrCall(x, y, z, w);
            PerfManager.Assert(resultDouble == (x + y * 3 + z * 5 + w * 7), "Invalid result Test4ArgWith1DoubleClrCall");

            resultDouble = Test4ArgWith2DoubleClrCall(x, y, z, w);
            PerfManager.Assert(resultDouble == (x + y * 3 + z * 5 + w * 7), "Invalid result Test4ArgWith2DoubleClrCall");

            resultInt = Test4ArgWithRefAndOutClrCall(x, ref y, out z, w);
            PerfManager.Assert((resultInt == z) && (resultInt == (x + y * 3 + w * 5)), "Invalid result Test4ArgWithRefAndOutClrCall");

            z         = 3;
            resultInt = TestArgSizeClrCall((byte)x, (short)y, z, w, 5);
            PerfManager.Assert(resultInt == (x + y * 3 + z * 5 + w * 7 + 5 * 9), "Invalid result TestArgSizeClrCall");
        }