当前位置: 首页>>代码示例>>C#>>正文


C# IntPtr.VTable方法代码示例

本文整理汇总了C#中System.IntPtr.VTable方法的典型用法代码示例。如果您正苦于以下问题:C# IntPtr.VTable方法的具体用法?C# IntPtr.VTable怎么用?C# IntPtr.VTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IntPtr的用法示例。


在下文中一共展示了IntPtr.VTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IDirect3D9CreateDeviceHandler

        private static uint IDirect3D9CreateDeviceHandler(IntPtr thisPtr, uint adapter, uint deviceType, IntPtr hFocusWindow, uint behaviorFlags, IntPtr pPresentationParameters, [Out] IntPtr ppReturnedDeviceInterface)
        {
            uint ret;
            if (!_isXnaCreateDeviceCall)
            {
                try
                {
                    var nativePresentationParameters =
                        (NativePresentationParameters)Marshal.PtrToStructure(pPresentationParameters, typeof(NativePresentationParameters));
                    var presentationParameters = nativePresentationParameters.ToXnaPresentationParameters(hFocusWindow);

                    _preservedBehaviorFlags = behaviorFlags;
                    _isXnaCreateDeviceCall = true;

                    _xnaGraphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach,
                                                            presentationParameters);

                    var pComPtrField = _xnaGraphicsDevice.GetType().GetField("pComPtr", BindingFlags.NonPublic | BindingFlags.Instance);
                    if (pComPtrField == null)
                        throw new Exception("Unable to get pComPtr field from XNA Graphics Device");

                    unsafe
                    {
                        var pComPtr = new IntPtr(Pointer.Unbox(pComPtrField.GetValue(_xnaGraphicsDevice)));
                        Marshal.WriteIntPtr(ppReturnedDeviceInterface, pComPtr);

                        _endSceneDetour = pComPtr.VTable(IDirect3DDevice9VTable.EndScene)
                            .DetourWith(EndSceneFunc);

                        _resetDetour = pComPtr.VTable(IDirect3DDevice9VTable.Reset)
                            .DetourWith(ResetFunc);
                    }
                    // TODO
                    OnCreateDevice();
                    ret = 0;
                }
                catch (Exception)
                {
                    // If we get an exception trying to create the XNA device, just call the original method and pass out the return
                    ret = (uint)_createDeviceDetour.CallOriginal(
                        thisPtr, adapter, deviceType, hFocusWindow,
                        behaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
                }
            }
            else
            {
                // Now we're inside the XNA Device's call to CreateDevice - get our cached presentation parameters and add a required flag
                // TODO: check this process / flag
                var pp = (NativePresentationParameters)Marshal.PtrToStructure(pPresentationParameters, typeof(NativePresentationParameters));
                pp.Flags |= 0x1;
                Marshal.StructureToPtr(pp, pPresentationParameters, true);

                ret = (uint) _createDeviceDetour.CallOriginal(
                    thisPtr, adapter, deviceType, hFocusWindow,
                    _preservedBehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
            }
            return ret;
        }
开发者ID:jeffora,项目名称:InjectedXna,代码行数:58,代码来源:InjectedGraphicsDeviceManager.Static.cs


注:本文中的System.IntPtr.VTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。