public DX9Controller(HWSettings settings) { this._settings = settings; this.Name = typeof(DX9Controller).Name; IntPtr direct3D = Direct3DCreate9(32); try { if (direct3D == IntPtr.Zero){ MessageBox.Show("error"); throw new Exception("Failed to create D3D."); } IntPtr adapterIdentPtr = Marshal.ReadIntPtr(Marshal.ReadIntPtr(direct3D), 20); GetAdapterIdentifierOriginal = (GetAdapterIdentifierDelegate)Marshal.GetDelegateForFunctionPointer(adapterIdentPtr, typeof(GetAdapterIdentifierDelegate)); _name = string.Format("GetAdapterIdentHook_{0:X}", adapterIdentPtr.ToInt32()); _hook = LocalHook.Create(adapterIdentPtr, new GetAdapterIdentifierDelegate(GetAdapterIdentifierDetour), this); _hook.ThreadACL.SetExclusiveACL(new Int32[] { 1 }); } catch (Exception ex) { HookManager.Log("[DX9Controller] Exception: " + ex.ToString()); this.Error = true; } }
public DX9Controller(HWSettings settings) { this._settings = settings; this.Name = typeof(DX9Controller).Name; IntPtr direct3D = Direct3DCreate9(32); try { if (direct3D == IntPtr.Zero) { MessageBox.Show("error"); throw new Exception("Failed to create D3D."); } IntPtr adapterIdentPtr = Marshal.ReadIntPtr(Marshal.ReadIntPtr(direct3D), 20); GetAdapterIdentifierOriginal = (GetAdapterIdentifierDelegate)Marshal.GetDelegateForFunctionPointer(adapterIdentPtr, typeof(GetAdapterIdentifierDelegate)); _name = string.Format("GetAdapterIdentHook_{0:X}", adapterIdentPtr.ToInt32()); _hook = LocalHook.Create(adapterIdentPtr, new GetAdapterIdentifierDelegate(GetAdapterIdentifierDetour), this); _hook.ThreadACL.SetExclusiveACL(new Int32[] { 1 }); } catch (Exception ex) { HookManager.Log("[DX9Controller] Exception: " + ex.ToString()); this.Error = true; } }
public GraphicsCardDX9Hook(Settings settings) { this._settings = settings; IntPtr direct3D = Direct3DCreate9(32); if (direct3D == IntPtr.Zero) { throw new Exception("Failed to create D3D."); } IntPtr adapterIdentPtr = Marshal.ReadIntPtr(Marshal.ReadIntPtr(direct3D), 20); GetAdapterIdentifierOriginal = (GetAdapterIdentifierDelegate)Marshal.GetDelegateForFunctionPointer(adapterIdentPtr, typeof(GetAdapterIdentifierDelegate)); _name = string.Format("GetAdapterIdentHook_{0:X}", adapterIdentPtr.ToInt32()); _hook = LocalHook.Create(adapterIdentPtr, new GetAdapterIdentifierDelegate(GetAdapterIdentifierDetour), this); _hook.ThreadACL.SetExclusiveACL(new Int32[] { 0 }); }