daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/effects11/effects11.cpp b/effects11/effects11.cpp
  2. new file mode 100644
  3. index 0000000..858cea6
  4. --- /dev/null
  5. +++ b/effects11/effects11.cpp
  6. @@ -0,0 +1,47 @@
  7. +#include "d3dx11effect.h"
  8. +
  9. +static HRESULT(__stdcall *pD3DReflect)(LPCVOID, SIZE_T, REFIID, void **) = NULL;
  10. +static HRESULT(__stdcall *pD3DGetInputSignatureBlob)(LPCVOID, SIZE_T, ID3DBlob **) = NULL;
  11. +
  12. +extern "C" __declspec(dllexport) HRESULT __cdecl
  13. +CreateEffectFromMemory(CONST void *p, SIZE_T size, UINT flags, ID3D11Device *pD, ID3DX11Effect **ppE)
  14. +{
  15. +       return D3DX11CreateEffectFromMemory(p, size, flags, pD, ppE);
  16. +}
  17. +
  18. +static HRESULT LoadD3DCompiler()
  19. +{
  20. +       LPCSTR libraries[] = {"d3dcompiler_43.dll", "d3dcompiler_42.dll", "d3dcompiler_41.dll", "d3dcompiler_40.dll", NULL};
  21. +
  22. +       int i = 0;
  23. +       while (LPCSTR l = libraries[i++]) {
  24. +               HMODULE d3dcompiler = LoadLibrary(l);
  25. +               if (d3dcompiler) {
  26. +                       pD3DReflect = (HRESULT(__stdcall *)(LPCVOID, SIZE_T, REFIID, void**)) GetProcAddress(d3dcompiler, "D3DReflect");
  27. +                       pD3DGetInputSignatureBlob = (HRESULT(__stdcall *)(LPCVOID, SIZE_T, ID3DBlob **))GetProcAddress(d3dcompiler, "D3DGetInputSignatureBlob");
  28. +                       if (pD3DReflect && pD3DGetInputSignatureBlob)
  29. +                               break;
  30. +               }
  31. +       }
  32. +       if (!pD3DReflect || !pD3DGetInputSignatureBlob)
  33. +               return -1;
  34. +       return 0;
  35. +}
  36. +
  37. +extern "C" HRESULT __stdcall D3DReflect(LPCVOID p, SIZE_T s, REFIID r, void **pp)
  38. +{
  39. +       if (!pD3DReflect) {
  40. +               HRESULT hr = LoadD3DCompiler();
  41. +               if (hr) return -1;
  42. +       }
  43. +       return pD3DReflect(p, s, r, pp);
  44. +}
  45. +
  46. +extern "C" HRESULT __stdcall D3DGetInputSignatureBlob(LPCVOID p, SIZE_T s, ID3DBlob **pp)
  47. +{
  48. +       if (!pD3DGetInputSignatureBlob) {
  49. +               HRESULT hr = LoadD3DCompiler();
  50. +               if (hr) return -1;
  51. +       }
  52. +       return pD3DGetInputSignatureBlob(p, s, pp);
  53. +}
  54. diff --git a/effects11/effects11.pro b/effects11/effects11.pro
  55. new file mode 100644
  56. index 0000000..bcccb56
  57. --- /dev/null
  58. +++ b/effects11/effects11.pro
  59. @@ -0,0 +1,33 @@
  60. +include (../compiler.pri)
  61. +
  62. +TEMPLATE = lib
  63. +CONFIG *= dll debug_and_release warn_on
  64. +CONFIG -= embed_manifest_dll
  65. +TARGET = effects11
  66. +SOURCES = effects11.cpp
  67. +
  68. +DEFINES -= UNICODE
  69. +
  70. +QMAKE_CXXFLAGS_RELEASE -= -MD
  71. +QMAKE_CXXFLAGS_DEBUG   -= -MDd
  72. +
  73. +QMAKE_CXXFLAGS_RELEASE *= -MT
  74. +QMAKE_CXXFLAGS_DEBUG   *= -MTd
  75. +
  76. +INCLUDEPATH *= "$$(DXSDK_DIR)Include"
  77. +
  78. +EFFECTS11DIR = $$(DXSDK_DIR)Samples/C++/Effects11/
  79. +EFFECTS11PATH = . Inc Binary
  80. +EFFECTS11SOURCES = EffectAPI.cpp EffectLoad.cpp EffectNonRuntime.cpp EffectReflection.cpp EffectRuntime.cpp d3dx11dbg.cpp d3dxGlobal.cpp
  81. +
  82. +SOURCES *= $$join(EFFECTS11SOURCES," $$EFFECTS11DIR","$$EFFECTS11DIR")
  83. +INCLUDEPATH *= $$join(EFFECTS11PATH," $$EFFECTS11DIR","$$EFFECTS11DIR")
  84. +
  85. +CONFIG(release, debug|release) {
  86. +  DESTDIR       = ../release
  87. +}
  88. +
  89. +CONFIG(debug, debug|release) {
  90. +  DESTDIR       = ../release
  91. +  DEFINES      *= DEBUG
  92. +}
  93. diff --git a/main.pro b/main.pro
  94. index f2b3ce9..2674796 100644
  95. --- a/main.pro
  96. +++ b/main.pro
  97. @@ -27,6 +27,7 @@ CONFIG *= ordered debug_and_release
  98.  
  99.    win32 {
  100.      SUBDIRS *= overlay
  101. +    SUBDIRS *= effects11
  102.    }
  103.  
  104.    unix:!macx:!CONFIG(no-overlay) {
  105. diff --git a/overlay/d3d11.cpp b/overlay/d3d11.cpp
  106. index ec45122..0e1c8ca 100644
  107. --- a/overlay/d3d11.cpp
  108. +++ b/overlay/d3d11.cpp
  109. @@ -49,6 +49,7 @@ typedef HRESULT(__stdcall *PresentType)(IDXGISwapChain *, UINT, UINT);
  110.  typedef HRESULT(__stdcall *ResizeBuffersType)(IDXGISwapChain *, UINT, UINT, UINT, DXGI_FORMAT, UINT);
  111.  typedef ULONG(__stdcall *AddRefType)(ID3D11Device *);
  112.  typedef ULONG(__stdcall *ReleaseType)(ID3D11Device *);
  113. +typedef HRESULT(__cdecl *CreateEffectFromMemoryType)(CONST void *, SIZE_T, UINT, ID3D11Device *, ID3DX11Effect **);
  114.  
  115.  #define HMODREF(mod, func) func##Type p##func = (func##Type) GetProcAddress(mod, #func)
  116.  
  117. @@ -251,6 +252,38 @@ void D11State::newTexture(unsigned int w, unsigned int h) {
  118.         }
  119.  }
  120.  
  121. +static CreateEffectFromMemoryType GetCreateEffectFromMemory(void)
  122. +{
  123. +       HMODULE o = GetModuleHandle("mumble_ol.dll");
  124. +       if (!o) {
  125. +               ods("failed to find mumble_ol.dll");
  126. +               return NULL;
  127. +       }
  128. +
  129. +       TCHAR path[2048];
  130. +       GetModuleFileName(o, path, sizeof(path));
  131. +       path[2047]='\0';
  132. +       char *p=strrchr(path,'\\');
  133. +       if (!p) {
  134. +               ods("bad path %s", path);
  135. +               return NULL;
  136. +       }
  137. +
  138. +       *p='\0';
  139. +       strcat_s(path, sizeof(path), "\\effects11.dll");
  140. +       HMODULE effects11 = LoadLibrary(path);
  141. +       if (!effects11) {
  142. +               ods("failed to load %s", path);
  143. +               return NULL;
  144. +       }
  145. +
  146. +       CreateEffectFromMemoryType pCEFM =
  147. +               (HRESULT(__cdecl *)(CONST void *, SIZE_T, UINT, ID3D11Device *, ID3DX11Effect **))
  148. +               GetProcAddress(effects11, "CreateEffectFromMemory");
  149. +
  150. +       return pCEFM;
  151. +}
  152. +
  153.  void D11State::init() {
  154.         HRESULT hr;
  155.  
  156. @@ -305,7 +338,8 @@ void D11State::init() {
  157.         float bf[4];
  158.         pDeviceContext->OMSetBlendState(pBlendState, bf, 0xffffffff);
  159.  
  160. -       hr = D3DX11CreateEffectFromMemory((void *) g_main11, sizeof(g_main11), 0, pDevice, &pEffect);
  161. +       CreateEffectFromMemoryType pCreateEffectFromMemory = GetCreateEffectFromMemory();
  162. +       hr = pCreateEffectFromMemory((void *) g_main11, sizeof(g_main11), 0, pDevice, &pEffect);
  163.  
  164.         pTechnique = pEffect->GetTechniqueByName("Render");
  165.         pDiffuseTexture = pEffect->GetVariableByName("txDiffuse")->AsShaderResource();
  166. diff --git a/overlay/overlay.pro b/overlay/overlay.pro
  167. index 360fda1..c084672 100644
  168. --- a/overlay/overlay.pro
  169. +++ b/overlay/overlay.pro
  170. @@ -6,7 +6,7 @@ CONFIG *= dll shared debug_and_release warn_on
  171.  CONFIG -= embed_manifest_dll
  172.  TARGET = mumble_ol
  173.  SOURCES = lib.cpp d3d9.cpp d3d10.cpp d3d11.cpp ods.cpp opengl.cpp HardHook.cpp D11StateBlock.cpp
  174. -HEADERS = lib.h ods.h HardHook.h overlay_blacklist.h
  175. +HEADERS = lib.h ods.h HardHook.h D11StateBlock.h overlay_blacklist.h
  176.  EFFECTS = overlay.fx
  177.  DIST = overlay.h overlay.fx HardHook.h
  178.  
  179. @@ -19,16 +19,9 @@ QMAKE_CXXFLAGS_RELEASE       *= -MT
  180.  QMAKE_CXXFLAGS_DEBUG   *= -MTd
  181.  
  182.  INCLUDEPATH *= "$$(DXSDK_DIR)Include"
  183. +INCLUDEPATH *= "$$(DXSDK_DIR)Samples/C++/Effects11/Inc"
  184.  
  185.  LIBS *= -l"$$(DXSDK_DIR)Lib/x86/dxguid" -luuid -lole32 -luser32 -ladvapi32
  186. -LIBS *= -l"$$(DXSDK_DIR)Lib/x86/d3dcompiler"
  187. -
  188. -EFFECTS11DIR = $$(DXSDK_DIR)Samples/C++/Effects11/
  189. -EFFECTS11PATH = Inc Binary
  190. -EFFECTS11SOURCES = EffectAPI.cpp EffectLoad.cpp EffectNonRuntime.cpp EffectReflection.cpp EffectRuntime.cpp d3dx11dbg.cpp d3dxGlobal.cpp
  191. -
  192. -SOURCES *= $$join(EFFECTS11SOURCES," $$EFFECTS11DIR","$$EFFECTS11DIR")
  193. -INCLUDEPATH *= $$join(EFFECTS11PATH," $$EFFECTS11DIR","$$EFFECTS11DIR")
  194.  
  195.  CONFIG(release, debug|release) {
  196.    DESTDIR       = ../release
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top