2014-05-25 176 views
5

我想要做什麼:繪製覆蓋DX11遊戲(的CryEngine)用C#內外EasyHook

我有一個基於CrySDK一個遊戲,這是DirectX11的,我想畫一個遊戲內的覆蓋,如蒸汽覆蓋。我寫C#因爲我不知道任何C++,所以我正在尋找方法在C#中做到這一點。

- >我使用EasyHook和SharpDX Libaries,因爲看起來這是最好的方法。

- >我發現一個reference project這顯然是SC2的一種破解,但我只是對覆蓋部分感興趣。

- >我使用Visual Studio 2013

- >現在我會很高興,如果我能在所有

繪製隨機的東西一個遊戲裏面我做了什麼至今:

我正在通過谷歌和搜索結果搜索,問題是,無論是在C++,C或其他的東西,結果是從2010年,而不是最新的當前DX11,包含死鏈接或不能用於任何其他原因。這涵蓋了我自己出現的95%,一些有用的提示已經包含在我的代碼中。

我設法創造一個Injector.dll並注入到遊戲(至少我認爲它被注入,還沒有到目前爲止任何usuable結果)

我有什麼:

它執行注射的文件:

...     
// Try inject thingy 

      EasyHook.Config.Register("Star Citizen Noise.sc Client Overlay", 
            //   "Direct3D9Hook.dll", 
              "SharpDX.dll", 
              "SharpDX.Direct3D11.dll", 
              "Injector.dll"); 

      // Do the inject 
      RemoteHooking.Inject(scProcess.Id, InjectionOptions.DoNotRequireStrongName, "Injector.dll", "Injector.dll", "Star Citizen Noise.sc Injector.dll"); 
      Console.WriteLine("DLL Injected."); 
... 

本身包含該文件的injector.dll,叫鉤/圖形/ Direct3D11Hook.cs(我試圖保持結構類似oter SC2參考項目)

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Drawing; 
using System.Runtime.InteropServices; 
using EasyHook; 
using SharpDX; 
using SharpDX.Direct3D11; 
using Rectangle = SharpDX.Rectangle; 

namespace Injector.Hooks.Graphics 
{ 
    public class Direct3D11Hook : HookBase 
    { 

     private Device device = null; 

     [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)] 
     private delegate Result EndSceneDelegate(IntPtr devicePointer); 

     public delegate void EndSceneEventDelegate(ref IntPtr devicePointer); 
     public event EndSceneEventDelegate OnEndScene; 

     private Result EndScene(IntPtr devicePointer) 
     { 
      try 
      { 
       //this.Log.LogMethodSignatureTypesAndValues(devicePointer); 

       //GetOrCreateDevice 
       if (this.device == null) 
        this.device = Device.FromPointer<Device>(devicePointer); 

       if (this.OnEndScene != null) 
        this.OnEndScene(ref devicePointer); 

       System.Drawing.Graphics g = System.Drawing.Graphics.FromHdc(devicePointer); 
       //System.Drawing.Graphics g = System.Drawing.Graphics.FromHwndInternal(devicePointer); 

       // lets try to draw something 
       Pen myPen = new Pen(System.Drawing.Color.Pink, 4); 
       System.Drawing.Point P1 = new System.Drawing.Point(50, 50); 
       System.Drawing.Point P2 = new System.Drawing.Point(500, 500); 
       g.DrawLine(myPen, P1, P2); 
       g.Dispose(); 
       //this.device.EndScene(); 

       return Result.Ok; 
      } 
      catch (SharpDXException ex) 
      { 
       //Log.Warn(ex); 
       Console.WriteLine(ex); 
       return ex.ResultCode; 
      } 
      catch (Exception ex) 
      { 
       //this.Log.Fatal(ex); 
       Console.WriteLine(ex); 
       return Result.UnexpectedFailure; 
      } 
     } 

     public override void Install() 
     { 
      try 
      { 
       EndSceneDelegate esd = new EndSceneDelegate(this.EndScene); 

      } 
      catch (Exception) 
      { 

       throw; 
      } 
     } 

     public override void Uninstall() 
     { 

     } 

    } 
} 

這裏我試圖爲EndScene函數提供一個覆蓋函數,因爲我認爲這是我需要的地方。不用說,似乎沒有任何東西可以畫出來。

委託定義有點copypaste from the reference project但是我還沒有找到如何實際掛鉤我的功能到渲染管道和/或對可能有助於我的事業的事件作出反應。

還有這個巨大的文件[https://github.com/jasonpang/Starcraft2Hook/blob/master/Game/Hooks/Graphics/Direct3D9.cs]它定義了功能地址,似乎適用於DX9,我不認爲它可以複製粘貼和用於DX11以及,因此可能有新的功能地址在DX11?我怎樣才能找到那些?我需要看什麼? SharpDX可以幫助我嗎?

TL; DR

要創建DX11遊戲蒸汽狀覆蓋,需要掛接到D3D的東西,魔術和狗屎,得到了DLL注入工作,需要用管道注入

+0

相關提示我不是唯一一個有問題找到覆蓋層的可靠信息的人。你的遊戲是全屏模式還是窗口模式?我能夠覆蓋所有dx窗口遊戲,但不能在全屏模式下工作。你可以嘗試窗口模式,看看是否有任何東西出現在你的覆蓋。 – Tyler

回答