Example #1
0
        private void OverrideFunctions()
        {
            LuaInterface.LoggingInterface.Log(string.Format("Address of Native EndScene (VFTable**) is {0:X}",
                                                            (uint)NativeIDirect3DDevice9->VFTable[0][42]));

            LuaInterface.LoggingInterface.Log("Backing up original end scene hook");
            OriginalEndScene = NativeIDirect3DDevice9->VFTable[0][42];

            RealEndScene =
                (DelegateEndScene)Marshal.GetDelegateForFunctionPointer(OriginalEndScene, typeof(DelegateEndScene));

            LuaInterface.LoggingInterface.Log(string.Format("Address of Original EndScene Backup is {0:X}",
                                                            (uint)OriginalEndScene));


            // get delegate and pointer to delegate for custom end scene
            // DelegateEndScene fuckinggarbagecollector = EndScene;

            MyEndScene = EndScene;
            IntPtr PointerToMyEndScene = Marshal.GetFunctionPointerForDelegate(MyEndScene);

            LuaInterface.LoggingInterface.Log(string.Format("Address of MyEndScene is {0:X}", (uint)PointerToMyEndScene));

            // do actual re-routing of the function to run our own custom end scene
            LuaInterface.LoggingInterface.Log("Redirect EndScene to New Function...");
            NativeIDirect3DDevice9->VFTable[0][42] = PointerToMyEndScene;
            LuaInterface.LoggingInterface.Log(string.Format("Address of New 'Native' EndScene is {0:X}",
                                                            (uint)NativeIDirect3DDevice9->VFTable[0][42]));
        }
Example #2
0
        private void OverrideFunctions()
        {
            LuaInterface.LoggingInterface.Log(string.Format("Address of Native EndScene (VFTable**) is {0:X}",
                                                            (uint) NativeIDirect3DDevice9->VFTable[0][42]));

            LuaInterface.LoggingInterface.Log("Backing up original end scene hook");
            OriginalEndScene = NativeIDirect3DDevice9->VFTable[0][42];

            RealEndScene =
                (DelegateEndScene) Marshal.GetDelegateForFunctionPointer(OriginalEndScene, typeof (DelegateEndScene));

            LuaInterface.LoggingInterface.Log(string.Format("Address of Original EndScene Backup is {0:X}",
                                                            (uint) OriginalEndScene));

            // get delegate and pointer to delegate for custom end scene
            // DelegateEndScene fuckinggarbagecollector = EndScene;

            MyEndScene = EndScene;
            IntPtr PointerToMyEndScene = Marshal.GetFunctionPointerForDelegate(MyEndScene);
            LuaInterface.LoggingInterface.Log(string.Format("Address of MyEndScene is {0:X}", (uint) PointerToMyEndScene));

            // do actual re-routing of the function to run our own custom end scene
            LuaInterface.LoggingInterface.Log("Redirect EndScene to New Function...");
            NativeIDirect3DDevice9->VFTable[0][42] = PointerToMyEndScene;
            LuaInterface.LoggingInterface.Log(string.Format("Address of New 'Native' EndScene is {0:X}",
                                                            (uint) NativeIDirect3DDevice9->VFTable[0][42]));
        }