Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: In 1.3.x branch it is no longer possible to use 3DMigoto + Reshade 3.x #98

Closed
helifax opened this issue Jul 2, 2018 · 45 comments
Assignees

Comments

@helifax
Copy link
Collaborator

helifax commented Jul 2, 2018

Hi guys,

3DMigoto version 1.2.73 is the last known good version where I can use both 3DMigoto (d3d11.dll) and Reshade (dxgi.dll).
(Default 3Dmigoto from zip file, default Reshade from Installer. Nothing was modified.)

Starting with 1.3.1, they no longer work together as any game crashes. (I tested on Vampyr in particular, but I saw it in other games as well).

This is very easy to reproduce as is 100% repro case. The crash always originatest in Reshade as it can't hook one of the DXGI factories.
If you want a reshade log + a 3DMigoto log please let me as I can easily get them, (You can also get them just by putting the dlls one next to the other and run a game)

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Jan 2, 2019

This works fine for me (Win 10, tested in DOAXVV) and others, but still others report it broken. I'll need the logs and some details of your environment (What OS? If Windows 7 do you have the evil update installed?)

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Jan 2, 2019

This also works fine on my Windows 7 (with evil update KB 2670838 installed) box. Again testing in DOAXVV since some people report it doesn't work there. Reshade is version 4.0.1.488 since that's what the DOAXVV mod uses, so maybe this is something that has been fixed since 3.x?

@DarkStarSword
Copy link
Collaborator

I've just seen a forum post of someone who managed to work out that their compatibility issue between 3DMigoto and ReShade was actually caused by RiverTuner (this isn't the first time I've seen that tool implicated in all sorts of random issues - I guess it hooks into the whole universe... poorly). Are you using that or have it installed?

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Jan 4, 2019

Bad ReShade log from random user 1: dxgi.log
Bad ReShade log from random user 2: dxgi(1).log (confirmed not using RiverTuner)
Good ReShade log from my system: dxgi.log

No one has yet sent me a 3DMigoto debug log of this crash.

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Jan 4, 2019

One possible lead is that ReShade appears to do much what SpecialK did - hook D3D11CreateDevice and redirect it to D3D11CreateDeviceAndSwapChain, so it's possible we've hit another case of that game of hot potato since 3DMigoto does the opposite:
https://github.com/crosire/reshade/blob/fcda9bac61950c913138b1c4f90712d9f853fd00/source/d3d11/d3d11.cpp#L13

We do have code in 3DMigoto to protect against that scenario for SpecialK by ensuring that we don't ever call our own exported function that SpecialK hooked, but it appears that ReShade bypasses that by hooking the real d3d11.dll directly, which of course we do call:

17:06:02:785 [19612] | INFO  | Installing delayed hooks for "C:\\Windows\\system32\\d3d11.dll" (Just loaded via 'LoadLibrary(""C:\\Windows\\system32\\d3d11.dll"")') ...

My guess is that when we call the D3D11CreateDevice in the system d3d11.dll it gets redirected to ReShade, that then calls back into us and here we go with the hot potato again. I still need to actually confirm this and understand why it doesn't happen on either of my systems (maybe just something to do with the load order or delayed hooking in ReShade?).

@DarkStarSword
Copy link
Collaborator

Possibly related to #83

@DarkStarSword
Copy link
Collaborator

More discussion of the possibly related SpecialK issue in #78

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Jan 16, 2019

I could REALLY use a 3DMigoto debug log for this. Everyone has given me ReShade logs of this issue, but no one has yet given me a 3DMigoto log.

@DarkStarSword
Copy link
Collaborator

Possible lead worth investigating (if I can ever manage to reproduce this issue) - PCSX2 devs debugged a crash down to ReShade's D3D11CreateDevice to D3D11CreateDeviceAndSwapChain redirect, which suggests they are calling a NULL/invalid pointer for their trampoline in some cases. This would be an alternate explanation to the crash that does not involve a game of hot potato since the crash would be immediate on the ReShade side as opposed to running out of stack like SpecialK.

I still need a 3DMigoto debug log, which would very clearly show if we are playing pass the parcel or not.

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Jan 17, 2019

EDIT: The crash was not reproduced in this log file

3DMigoto debug log:

Edit: Log removed as irrelevant and to protect privacy

At first glance this log looks okay - initialisation is fine, I see multiple frames being rendered, it doesn't end in a crash and it appears the DLL is was unloaded cleanly. Based on this, I don't think the crash was properly reproduced in this log.

However I did notice something rather odd, just after this:

*** Hooked IDXGIFactory::CreateSwapChain(000001FC399960F0) called
  Device = 000001FC38DEA730
  SwapChain = 000001FC1F713090
  Description = 00000097E2EFF6A0
-- UnhookableCreateSwapChain called
HackerDevice::QueryInterface(class HackerDevice@000001FC38DEA730) called with IID: HackerDevice
lookup_hacker_device(000001FC38DEA730): Supports HackerDevice
Got resolution from swap chain: 1920x1080
     Windowed = 1
     Width = 1920
     Height = 1080
     Refresh rate = 59.996441
     BufferCount = 3
     SwapEffect = 0
     Flags = 0x0
   Hooked_LoadLibraryExW load: api-ms-win-core-synch-l1-2-0.
   Hooked_LoadLibraryExW load: api-ms-win-core-fibers-l1-1-1.
   Hooked_LoadLibraryExW load: api-ms-win-core-synch-l1-2-0.
   Hooked_LoadLibraryExW load: api-ms-win-core-fibers-l1-1-1.
   Hooked_LoadLibraryExW load: api-ms-win-core-localization-l1-2-1.

and just before this:

FrameAnalysisContext(class FrameAnalysisContext@000001A1E1798070)::VSSetShaderResources(StartSlot:0, NumViews:128, ppShaderResourceViews:0x000001A1C6246720)

We see a lot of NULL bytes in the log covering bytes 0x3416221 through 0x3E26BD3 inclusive... That's over 10 megabytes of missing data in the log. I'm not sure what to make of that - it could of course be something mundane like filesystem corruption or a bad upload, but if it isn't... it's quite bizarre.

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Jan 17, 2019

Edit: This log does NOT reproduce the crash

If that log does show the "crash", this is how it ended:

...
FrameAnalysisContext(class FrameAnalysisContext@000001A1DFEB8670)::3DMigoto  [Present] run = commandlistafterpresent
FrameAnalysisContext(class FrameAnalysisContext@000001A1DFEB8670)::3DMigoto  pre {
FrameAnalysisContext(class FrameAnalysisContext@000001A1DFEB8670)::3DMigoto   [commandlist\shaderfixes\auto_convergence.ini\afterpresent] if stereo_active && $prev_stereo_active && !$suppress && !$prev_suppress: false
FrameAnalysisContext(class FrameAnalysisContext@000001A1DFEB8670)::3DMigoto   [commandlist\shaderfixes\auto_convergence.ini\afterpresent] else {
FrameAnalysisContext(class FrameAnalysisContext@000001A1DFEB8670)::3DMigoto   } endif
FrameAnalysisContext(class FrameAnalysisContext@000001A1DFEB8670)::3DMigoto  }
FrameAnalysisContext(class FrameAnalysisContext@000001A1DFEB8670)::3DMigoto }
  returns 0
FrameAnalysisContext(class FrameAnalysisContext@000001A1DFEB8670)::GetData(pAsync:0x000001A1E20C2468, pData:0x0000000000000000, DataSize:0, GetDataFlags:0) = 0
FrameAnalysisContext(class FrameAnalysisContext@000001A1DFEB8670)::GetData(pAsync:0x000001A1E20C2468, pData:0x0000007B9F4FF820, DataSize:16, GetDataFlags:0) = 0
FrameAnalysisContext(class FrameAnalysisContext@000001A1DFEB8670)::GetData(pAsync:0x000001A1E20C0FA8, pData:0x0000007B9F4FF810, DataSize:8, GetDataFlags:0) = 0
FrameAnalysisContext(class FrameAnalysisContext@000001A1DFEB8670)::GetData(pAsync:0x000001A1E20C00A8, pData:0x0000007B9F4FF818, DataSize:8, GetDataFlags:0) = 0
HackerContext::Release counter=1, this=000001A1E1798070
HackerContext::Release counter=11, this=000001A1DFEB8670
HackerSwapChain::SetFullscreenState(class HackerSwapChain@000001A1DD90CB80) called with
  Fullscreen = 0
  Target = 0000000000000000
  returns 0
HackerSwapChain::Release(class HackerSwapChain@000001A1DD90CB80), counter=0, this=000001A1DD90CB80
  Clearing mHackerDevice->mHackerSwapChain
HackerDevice::Release counter=375, this=000001A1DF8D2E10
HackerContext::Release counter=7, this=000001A1DFEB8670
Overlay::~Overlay deleted for SwapChain 000001A1E0B17EE0
HackerContext::Release counter=6, this=000001A1DFEB8670
HackerDevice::Release counter=373, this=000001A1DF8D2E10
   Hooked_LoadLibraryExW load: advapi32.dll.
   Hooked_LoadLibraryExW load: D:\DOAX-VenusVacation\d3d11.dll.
   Hooked_LoadLibraryExW load: D:\DOAX-VenusVacation\d3d11.dll.
  counter=0, this=000001A1DD90CB80, deleting self.
HackerDevice::Release counter=0, this=000001A1DF8D2E10
  deleting self
unregister_hacker_device: Unregistering IUnknown 000001A1DD5E5890 -> HackerDevice 000001A1DF8D2E10
  releasing ini parameters resource view, result = 0
  releasing iniparams texture, result = 0
Destroying DLL...

@DarkStarSword
Copy link
Collaborator

Log from Helifax testing Resident Evil 2, 3DMigoto 1.3.14, ReShade 4.1, Windows 10 1809:

https://cdn.discordapp.com/attachments/515704137795633154/541392344927174670/d3d11_log.txt

Excerpt:

*** Hooked IDXGIFactory::CreateSwapChain(0000000062E8EB70) called
  Device = 0000000003942460
  SwapChain = 00000000B5FEFCB0
  Description = 00000000B5FEFCC0
-- UnhookableCreateSwapChain called
lookup_hacker_device(0000000003942460) IUnknown: 0000000003942460 HackerDevice: 0000000000000000
WARNING: Could not locate HackerDevice for 0000000003942460
Checking what interfaces 0000000003942460 supports...
  Supports IUnknown: 0000000003942460
  Supports IDXGIDevice: 0000000003942460
  Supports IDXGIDevice1: 0000000003942460
  Supports IDXGIDevice2: 0000000003942460
  Supports IDXGIObject: 0000000003942460
  Supports ID3D10Multithread: 0000000062E80118
  Supports ID3D11Device: 0000000062C84020
  Supports ID3D11Device1: 0000000062C84020
  Win 8.1 interfaces not checked (3DMigoto built with old SDK)
  Win 10 & DX12 interfaces not checked (3DMigoto built with old SDK)
  Win 10 RS3 interfaces not checked (3DMigoto built with old SDK)
BUG: Unwrapped ID3D11Device!

I haven't looked at the rest of the log yet or tried to reproduce myself with RE2, but this looks like the clue we need.

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Feb 6, 2019

More log files of the issue from an affected DOAXVV user. When they name ReShade d3d11.dll it works, when they name it dxgi.dll it doesn't. They were unable to generate a 3DMigoto log file in with this - I'm not certain if they didn't have the two tools configured correctly to generate one of if 3DMigoto was never initialised (would possibly fit in with the theory that ReShade is bypassing the d3d11.dll in the game directory), but if I'm understanding correctly it sounds like the issue exists with ReShade when named dxgi.dll regardless of whether 3DMigoto is present or not - if so, that would indicate that this is a ReShade bug. Leaving this open until the issue(s) are resolved somewhere.

Hi, I reproduced the crashed and made the new log files now, please check it.

During the period of reprodution, I found the log I sent to you last time is made after I renamed the reshader's dxgi.dll to d3d11.dll, so I think that might explain why you cannot find any issues in it. The key point is that only after i rename the dxgi.dll to d3d11, I can run the reshade. There are many cases like me on the Internet, and I also know this renaming method from them. However, as there cannot be two d3d11 at the same time, so it is impossible to enbale the 3DMigoto plugin at the same time. So, the problem is I cannot enalbe them together, as dxgi.dll will make the game crash. I also made a screentshot of the crash.

I uploaded two logs this time. The first d3d11.log is when I delete the 3DMigoto 's .dll file and turn on the reshade. It actually works fine. The second is the log when the game crashed with both reshade and 3DMigoto existed.

I have set the call, debug and unbuffered in d3dx.ini to 1, but I did not get a d3d11_log.txt this time and I think it should be beacause I disabled 3Dmigoto. Will it affect your search on the problem? Hope you to solve it soon. Really thanks

d3d11.log
dxgi.log

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Feb 6, 2019

Looking at Helifax' log file in a bit more depth:

 *** D3D11CreateDevice called with
...
  D3D11CreateDevice returned device handle = 0000000062DFC3E0, context handle = 0000000063FB5730
...
register_hacker_device: Registering IUnknown: 0000000062DFC3E0 -> HackerDevice: 000000006431E660
  HackerDevice 000000006431E660 created to wrap 0000000062DFC3E0
...
-> device handle = 0000000062DFC3E0, device wrapper = 000000006431E660, context handle = 0000000063FB5730, context wrapper = 0000000063FB7160

CreateDevice looks okay.

*** Hooked IDXGIFactory::CreateSwapChain(0000000062E8E620) called
  Device = 00000000038D4600

This is neither the device from DirectX, nor from 3DMigoto. Presumably this is something ReShade has wrapped.

  SwapChain = 00000000B5FEFCB0
  Description = 00000000B5FEFCC0
-- UnhookableCreateSwapChain called
lookup_hacker_device(00000000038D4600) IUnknown: 00000000038D4600 HackerDevice: 0000000000000000
WARNING: Could not locate HackerDevice for 00000000038D4600

QueryInterface(IID_HackerDevice) failed, meaning one or more of several possibilities:
a) This is not a 3DMigoto device wrapped in a ReShade device
b) ReShade has failed to pass through unrecognised interface IDs through QueryInterface and is blocking the query
c) ReShade has unwrapped the device we returned
d) ReShade has hooked itself in between 3DMigoto and DirectX so it never got our wrapped device.

This also means our backup lookup via IUnknown address also failed.

Checking what interfaces 00000000038D4600 supports...
  Supports IUnknown: 00000000038D4600

And there's why - this is a fundamental violation of COM since QueryInterface(IUnknown) did not return a consistent address regardless of which interface it was called from, refer to:
https://docs.microsoft.com/en-us/windows/desktop/com/rules-for-implementing-queryinterface

However, this is not entirely unexpected if ReShade wrapped the device as it is necessary to prevent certain games from unwrapping the device (and 3DMigoto also has this same violation), but in combination with the above issue prevents us from finding our HackerDevice.

  Supports IDXGIDevice: 00000000038D4600
  Supports IDXGIDevice1: 00000000038D4600
  Supports IDXGIDevice2: 00000000038D4600
  Supports IDXGIObject: 00000000038D4600

Presumably these are all the ReShade wrapper.

  Supports ID3D10Multithread: 0000000063FCA688
  Supports ID3D11Device: 0000000062DFC3E0
  Supports ID3D11Device1: 0000000062DFC3E0

These addresses do correspond to the DirectX device object, which we could potentially use to locate our HackerDevice object instead of IUnknown.

If ReShade ever chose to start wrapping these as well we would be screwed for this method, but we could also implement a third backup strategy to find our HackerDevice with SetPrivateData (probably not SetPrivateDataInterface - the refcounting could get weird).

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Feb 14, 2019

I can reproduce the issue with Resident Evil 2 with much the same d3d11_log.txt as Helifax, however the dxgi.log I get differs from the samples provided for the DOAXVV case (in particular, the fail is prior to swap chain creation), so I suspect there may be two separate issues here.

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Feb 14, 2019

I added a check for violations of the COM identity rule, which as expected showed that ReShade is violating it, but unexpectedly it also showed the D3D11Device4/5 and Multithreaded interfaces violate it, and I very much doubt ReShade would have touched those - meaning that Microsoft has violated their own rule and we might run into this issue in the future if allowing more recent device interfaces (for now, this is just noteworthy):

HackerDevice 000000005BFD33E0 created to wrap 000000005BEDF370
...
*** Hooked IDXGIFactory::CreateSwapChain(000000000522A120) called
  Device = 000000005BEF1E80
  SwapChain = 00000000E27EFCE0
  Description = 00000000E27EFCF0
-- UnhookableCreateSwapChain called
lookup_hacker_device(000000005BEF1E80) IUnknown: 000000005BEF1E80 HackerDevice: 0000000000000000
WARNING: Could not locate HackerDevice for 000000005BEF1E80
Checking what interfaces 000000005BEF1E80 supports...
  Supports IUnknown: 000000005BEF1E80
  Supports IDXGIDevice: 000000005BEF1E80
  Supports IDXGIDevice1: 000000005BEF1E80
  Supports IDXGIDevice2: 000000005BEF1E80
  Supports IDXGIObject: 000000005BEF1E80
  Supports ID3D10Multithread: 000000005BEF0860 (COM identity violation: 000000005BEF0000)
  Supports ID3D11Device: 000000005BEDF370 (COM identity violation: 000000005BEDF370)
  Supports ID3D11Device1: 000000005BEDF370 (COM identity violation: 000000005BEDF370)
  Supports IDXGIDevice3: 000000005BEF1E80
  Supports ID3D11Device2: 000000005BEDF370 (COM identity violation: 000000005BEDF370)
  Supports IDXGIDevice4: 000000005BEF1E80
  Supports ID3D11Device3: 000000005BEDF370 (COM identity violation: 000000005BEDF370)
  Supports ID3D11Device4: 000000005BEF0830 (COM identity violation: 000000005BEF0000)
  Supports ID3D11Multithread: 000000005BEF0860 (COM identity violation: 000000005BEF0000)
  Supports ID3D11Device5: 000000005BEF0830 (COM identity violation: 000000005BEF0000)
BUG: Unwrapped ID3D11Device!

Note that since this query starts with a ReShade object those are listed as not violating and the DX interfaces are listed as violating since they are not consistent with the ReShade identity. The unexpected thing is that the device 4+ and Multithread interfaces resolved to a different identity than the other DX interfaces.

@bo3b
Copy link
Owner

bo3b commented Feb 14, 2019

Might be worth reporting that as a bug to Microsoft. They are pretty lame, but there is an off chance they would care enough to fix it.

Assuming you are correct, that is actually kind of terrifying, because that means that internally Microsoft does not do any automated testing on this API.

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Feb 15, 2019

I've implemented a strategy to find our HackerDevice via Set/GetPrivateData on the DirectX device, which works - unfortunately it crashes immediately afterwards with this at the end of the d3d11_log.txt:

*** Hooked IDXGIFactory::CreateSwapChain(00000000055083D0) called
  Device = 000000005BEE4C60
  SwapChain = 00000000E0FEFCE0
  Description = 00000000E0FEFCF0
-- UnhookableCreateSwapChain called
Notice: Unwrapped device and COM Identity violation, Found HackerDevice via GetPrivateData strategy
lookup_hacker_device(000000005BEE4C60) IUnknown: 000000005BEE4C60 HackerDevice: 00007FFF2DA23560
Got resolution from swap chain: 1920x1061
     Windowed = 1
     Width = 1920
     Height = 1061
     Refresh rate = -nan(ind)
     BufferCount = 3
     SwapEffect = 0
     Flags = 0x2

And the dxgi.log reports this instead of exiting:
18:32:56:389 [09644] | INFO | Redirecting 'IDXGIFactory::CreateSwapChain(00000000055083D0, 00007FFF2D8604B0, 00000000E0FEFCF0, 00000000E0FEFCE0)' ...

The crash occurs when we call through to the original CreateSwapChain routine:
HRESULT hr = fnOrigCreateSwapChain(This, pDevice, pDesc, ppSwapChain);

This appears to have called into ReShade... I'm not entirely sure if that's what we expected because I don't know exactly how everything has managed to hook/wrap themselves in.

Edit: This was just down to a bug in my code missed due to lack of type safety in SetPrivateData.

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Feb 15, 2019

Notably, there are reports of crashes with ReShade in Resident Evil 2 without 3DMigoto:
https://reshade.me/forum/troubleshooting/5045-resident-evil-2-crash-at-start-with-reshade
However, in my case the game does launch with only ReShade.

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Feb 19, 2019

I'm able to reproduce this with a ReShade built myself in Release configuration, however when building ReShade in debug configuration I get a different crash earlier on - again a NULL pointer dereference, but this time when ReShade attempts to call into the original CreateDeviceAndSwapChain:

HRESULT hr = reshade::hooks::call(&D3D11CreateDeviceAndSwapChain)(pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion, nullptr, nullptr, ppDevice, &FeatureLevel, nullptr);

Call stack looks like this:

 	0000000000000000()	Unknown
 	d3d11_3SDKLayers.dll!00007ffa6da0c248()	Unknown
 	d3d11.dll!00007ffaaf817e7e()	Unknown
 	d3d11.dll!00007ffaaf817c9f()	Unknown
 	d3d11.dll!00007ffaaf84d292()	Unknown
 	d3d11.dll!00007ffaaf84cf85()	Unknown
 	d3d11.dll!00007ffaaf84cd84()	Unknown
 	d3d11.dll!00007ffaaf80dfe4()	Unknown
 	d3d11.dll!00007ffaaf80720b()	Unknown
 	d3d11.dll!00007ffaaf805db9()	Unknown
 	d3d11.dll!00007ffaaf805a38()	Unknown
>	dxgi.dll!D3D11CreateDeviceAndSwapChain(IDXGIAdapter * pAdapter, D3D_DRIVER_TYPE DriverType, HINSTANCE__ * Software, unsigned int Flags, const D3D_FEATURE_LEVEL * pFeatureLevels, unsigned int FeatureLevels, unsigned int SDKVersion, const DXGI_SWAP_CHAIN_DESC * pSwapChainDesc, IDXGISwapChain * * ppSwapChain, ID3D11Device * * ppDevice, D3D_FEATURE_LEVEL * pFeatureLevel, ID3D11DeviceContext * * ppImmediateContext) Line 31	C++
 	dxgi.dll!D3D11CreateDevice(IDXGIAdapter * pAdapter, D3D_DRIVER_TYPE DriverType, HINSTANCE__ * Software, unsigned int Flags, const D3D_FEATURE_LEVEL * pFeatureLevels, unsigned int FeatureLevels, unsigned int SDKVersion, ID3D11Device * * ppDevice, D3D_FEATURE_LEVEL * pFeatureLevel, ID3D11DeviceContext * * ppImmediateContext) Line 19	C++
 	d3d11.dll!UnhookableCreateDevice(IDXGIAdapter * pAdapter, D3D_DRIVER_TYPE DriverType, HINSTANCE__ * Software, unsigned int Flags, const D3D_FEATURE_LEVEL * pFeatureLevels, unsigned int FeatureLevels, unsigned int SDKVersion, ID3D11Device * * ppDevice, D3D_FEATURE_LEVEL * pFeatureLevel, ID3D11DeviceContext * * ppImmediateContext) Line 808	C++
 	d3d11.dll!D3D11CreateDevice(IDXGIAdapter * pAdapter, D3D_DRIVER_TYPE DriverType, HINSTANCE__ * Software, unsigned int Flags, const D3D_FEATURE_LEVEL * pFeatureLevels, unsigned int FeatureLevels, unsigned int SDKVersion, ID3D11Device * * ppDevice, D3D_FEATURE_LEVEL * pFeatureLevel, ID3D11DeviceContext * * ppImmediateContext) Line 878	C++
 	[External Code]	

Edit: This is somehow relates to the DirectX debug layer, which ReShade forces on in debug builds. While curious, this is getting side tracked from the issue at hand. Disabling the #ifdef _DEBUG in ReShade's d3d11.dll is sufficient to get past this.

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Feb 19, 2019

I've got the PrivateData strategy working and pushed a fix to master for the RE2 issue. This should also avoid any other issues where a violation of the COM identity rule interferes with our ability to find our HackerDevice.

I'm leaving this issue open for the time being, until I hear back from some of the affected DOAXVV users since I'm not certain if that is the same issue or not.

@crosire
Copy link

crosire commented Feb 22, 2019

Just found this by accident. To clear some things up:

ReShade's QueryInterface on a DXGI/D3D11 object can return two different ReShade objects:

Checking what interfaces 000000005BEF1E80 supports...
  Supports IUnknown: 000000005BEF1E80
  Supports IDXGIDevice: 000000005BEF1E80
  Supports IDXGIDevice1: 000000005BEF1E80
  Supports IDXGIDevice2: 000000005BEF1E80
  Supports IDXGIObject: 000000005BEF1E80
  Supports ID3D10Multithread: 000000005BEF0860 (COM identity violation: 000000005BEF0000)
  Supports ID3D11Device: 000000005BEDF370 (COM identity violation: 000000005BEDF370)
  Supports ID3D11Device1: 000000005BEDF370 (COM identity violation: 000000005BEDF370)
  Supports IDXGIDevice3: 000000005BEF1E80
  Supports ID3D11Device2: 000000005BEDF370 (COM identity violation: 000000005BEDF370)
  Supports IDXGIDevice4: 000000005BEF1E80
  Supports ID3D11Device3: 000000005BEDF370 (COM identity violation: 000000005BEDF370)
  Supports ID3D11Device4: 000000005BEF0830 (COM identity violation: 000000005BEF0000)
  Supports ID3D11Multithread: 000000005BEF0860 (COM identity violation: 000000005BEF0000)
  Supports ID3D11Device5: 000000005BEF0830 (COM identity violation: 000000005BEF0000)

Implementation is here: https://github.com/crosire/reshade/blob/2d179bd115591461b77613b7445772fcc5ee1c33/source/d3d11/d3d11_device.cpp#L54

By the way, you can check if a D3D11 device is hooked by ReShade by querying for this GUID: 72299288-2C68-4AD8-945D-2BFB5AA9C609 (that's the interface GUID for ReShade's D3D11Device).

@DarkStarSword
Copy link
Collaborator

Thanks for the feedback. You wouldn't necessarily need to derive D3D11Device from DXGIDevice, but ideally you would choose one of them to be the returned as the COM identity whenever QueryInterface(IID_IUnknown) is called on either.

Regardless we may still have to cope with potential violations if we are handed a newer version of the interface that isn't wrapped, such as the D3D11Device4/5 interface, so having this backup strategy of locating our device via Set/GetPrivateData is worthwhile I think.

Going the other way, 3DMigoto also violates the COM identity rule as we dropped wrapping IDXGIDevice objects a while back (opting to hook the minimum functions we needed to get the swap chain instead) and therefore no longer intercept IDXGIDevice::QueryInterface. So far this hasn't caused us any issues, but it has the potential to - we should consider hooking the IDXGIDevice's QueryInterface so that we can redirect queries for D3D11Device[1] and IUnknown back to our HackerDevice.

Likewise if you ever needed to check if a device object is wrapped or hooked by 3DMigoto you can query for 83FFD841-A5C9-46F4-8109-BC259558FEF4 (3DMigoto's HackerDevice IID) and wrapped or hooked DeviceContext objects will respond to A3046B1E-336B-4D90-9FD6-234BC09B8687

@DarkStarSword
Copy link
Collaborator

We can probably close this now that 1.3.15, but I'll wait until I hear back from some of the DOAXVV users because I'm still not sure if that is the same issue or not.

@DarkStarSword
Copy link
Collaborator

I'm closing this. There might still be an issue on DOAXVV for a minority of users, but as far as I can tell it's a problem with ReShade not loading when named dxgi.dll REGARDLESS of 3DMigoto, and the PEBKACs don't understand that when they remove 3DMigoto they remove 3DMigoto, nor can they follow simple instructions to enable proxy_d3d11. ReShade is fundamentally broken in DOAXVV anyway (breaks the news) so I don't damn well care anymore.

@WaterVes82
Copy link

WaterVes82 commented Nov 23, 2020

This works fine for me (Win 10, tested in DOAXVV) and others, but still others report it broken. I'll need the logs and some details of your environment (What OS? If Windows 7 do you have the evil update installed?)

Hello. i use 3dmigoto. luckily it helped me disable tsaa in a game. I want to use Reshade with this specific game at the same time as migoto .

Problem is to get reshade to work in that game, i need to rename reshade dll to d3d11.dll. and 3DMigoto also used d3d11.dll. So i cant get them into the same folder because It dont let two dlls with the same name. i tried a few different ways to get this to work to no avail. Any help and advice you can give me would be thankful for DarkStarSword .

I want to use 3DMigoto to disable the TSAA in the game, and then Reshade to polish up any aliasing left over from doing that.
They both work in the game, but not at the same time, because i assume this d3d11.dll issue. help ?

@DarkStarSword
Copy link
Collaborator

Try naming ReShade something else entirely and chain loading it via 3DMigoto's proxy_d3d11 option

@WaterVes82
Copy link

Try naming ReShade something else entirely and chain loading it via 3DMigoto's proxy_d3d11 option

I guess im a bit too inexperienced.
but i tried and i got someone to help me too on discord. But they are stumped
My next step was to ask on the forum here

https://www.mtbs3d.com/phpBB/viewtopic.php?f=181&t=25451#top

@DarkStarSword
Copy link
Collaborator

DarkStarSword commented Nov 25, 2020

If that didn't work then try the loader method:

  • Disable the proxy_d3d11 option since this method does not use it

  • Name Reshade as d3d11.dll within the game directory

  • Name 3DMigoto as 3dmigoto.dll within the game directory

  • Add the 3DMigoto Loader.exe to the game directory (32bit vs 64bit should match the game + 3DMigoto)

  • Edit the d3dx.ini and edit the [Loader] section as follows (adjust target to match the game):

    [Loader]
    target=game_executable.exe
    module=3dmigoto.dll

  • Run the loader and leave the window open

  • Launch the game as normal (alternatively set the launch option in the [Loader] section to do this automatically)

Troubleshooting:

  • You may notice your system will be extra laggy while the loader window is open - in most cases it will close automatically once it confirms a successful injection to restore performance, but if for whatever reason it remains open you may wish to close it manually. It only needs to be open while launching the game - once the game is running it is safe to close.
  • If the game runs as admin you may need to set require_admin=true in the d3dx.ini
  • The 3DMigoto loader can also be used from outside the game directory, which in some cases may work better than running it from within the game directory. In this setup all 3DMigoto files (the loader exe, 3dmigoto DLL, d3dx.ini, ShaderFixes, etc) should all be located in the same directory as the loader rather than the game directory.

@WaterVes82
Copy link

WaterVes82 commented Nov 25, 2020

To: DarkStarSword

I got a configure issue with CMD pop up.

https://i.imgur.com/4S165EA.png

I ran into this before and unsure what i did or didnt do yet to cause this .

Update : Unsure how to set require_admin=true in the d3dx.ini ? this option appears missing in d3dx.ini . Do i have add a entry somewhere ?

@WaterVes82
Copy link

WaterVes82 commented Nov 25, 2020

Okay i think getting close. forget to put exe game name in the loader entry.

But . the issue is, the game has a launcher that has to trigger the game exe. if i start exe itself, as the loader appeared to have done, the game crashes, seems it needs the launcher exe which is in a folder or two back along the path. what to do in that case ?.

edit -
3DMigoto before does works no prob if its named d3d11.dll. without fail .
but i guess the loader is different when a launcher exe is involved in another folder. unsure. trying to figure it out . reshade installed this time. But now migoto gotta get to work . still messing with loader. unsure i think i got the entry wrong or something.

@WaterVes82
Copy link

WaterVes82 commented Nov 25, 2020

the game seems to only like d3d11.dll works without fail. But when its not present its like it dont exist. Unsure if im doing something wrong. Or the game just dont regard the loader . it wants a d3d11.dll. specially a dll in the main game folder. with the exe.

@DarkStarSword
Copy link
Collaborator

But . the issue is, the game has a launcher that has to trigger the game exe. if i start exe itself, as the loader appeared to have done, the game crashes, seems it needs the launcher exe which is in a folder or two back along the path. what to do in that case ?.

  1. Set the target to the game's executable, not the game's loader.
  2. Launch 3DMigoto Loader.exe, leave the window open.
  3. Launch the game via it's loader or however you would normally run it.

The 3DMigoto loader should notice when the game itself launches and inject 3DMigoto.

In the event that both the loader and game executables have the same name, but are in different directories, you can specify part of the path in the target setting. The template d3dx.ini has an example of this: target = \Dead or Alive 6\DOA6.exe

The delay setting may also help if the game's executable spawns multiple times while launching, e.g. delay=20 will keep the loader open for 20 seconds after a confirmed injection in case any other instances of the game's executable show up during launch. You should set this long enough to get through the launcher, past any splash screens, etc until the game's window is visible full screen.

Update : Unsure how to set require_admin=true in the d3dx.ini ? this option appears missing in d3dx.ini . Do i have add a entry somewhere ?

This is in the d3dx.ini shipped with 3DMigoto 1.3.16. If your d3dx.ini is based on template from a previous version it may be missing this option, but you can simply add it to the [Loader] section, provided that the 3DMigoto loader is a recent version (i.e. from the 3DMigoto 1.3.16 zip file). Alternatively you can just right click on the 3DMigoto loader -> run as administrator (the option only exists so you don't have to remember to manually run as admin every time for games that require it).

For reference, the template d3dx.ini looks like this:

;------------------------------------------------------------------------------------------------------
; Settings used by the external 3DMigoto Loader
;------------------------------------------------------------------------------------------------------
[Loader]
; Target process to load into. You can optionally include part of the directory
; structure in case the game's executable name is generic.
;target = \Dead or Alive 6\DOA6.exe

; This tells the loader where to find 3DMigoto. This DLL must be located
; in the same directory as 3DMigoto Loader.exe and will be loaded in the target
; process under the same name. If d3d11.dll doesn't work try 3dmigoto.dll
;module = d3d11.dll

; Uncomment to always elevate the loader to support games that run as admin.
; This will display a UAC prompt so only enable it if you actually need it.
;require_admin = true

; Automatically launch the game from the loader. If you put the executable name
; here than the loader will need to be located in the game directory. You can
; use the full path, but that is not recommended to ship any fixes with since
; it will vary on a user's system. If the game is on Steam you can use the
; steam browser protocol to launch it, optionally passing it any command line
; arguments you need (unfortunately Steam pops a dialog to confirm command line
; parameters, which tends to end up behind other windows):
;launch = DOA6.exe
;launch = steam://run/838380/
;launch = steam://run/237850//-window-mode exclusive/

; Delay this many extra seconds after confirming that 3DMigoto was loaded in
; the target process. For games that respawn themselves or have multiple
; executables of the same name when the first process we see may not be the
; actual one we need. Set to -1 to disable automatic shut down.
;delay = 20

@WaterVes82
Copy link

Reading your post now . Thanks .
3dMigoto messages so far.
https://imgur.com/a/eaXG3q6

@WaterVes82
Copy link

Okay so i think i did it right this time just using the regular launcher , but this got a new error message that crashes the game before it loads
https://imgur.com/uKq9kJM

@WaterVes82
Copy link

WaterVes82 commented Nov 25, 2020

from one of these pics here, https://imgur.com/a/eaXG3q6 i almost got it running i think. guess not .

frustrating i cant figure this out yet.
( ill clean all this up after you give up on me here hehe ). trying.

@DarkStarSword
Copy link
Collaborator

Star Citizen? Last I heard they were planning to switch their engine to Vulkan - if they do so and no longer provide a DX11 option 3DMigoto will be unusable in that game at that time (though considering their rate of development that could well be years away, if ever - just a caution that any modding on Star Citizen is very likely to break in the future).

Looks like you have target and launch mixed up. Should be:

[Loader]
target = StarCitizen.exe
launch = C:\Program Files\Roberts Space Industries\RSI Launcher\RSI Launcher.exe

@WaterVes82
Copy link

Yes. May take them a long time as you noted ; for vulkan . Still I hope you guys can get it working on vulkcan too XD.
I'm still having problems getting it to load with reshades d3d11.dll in there using module=3dmigoto.dll Loader. ill keep trying. REALLY want to use 3Dmigot with Reshade. Thanks for all the advice here. ill keep at it .

@WaterVes82
Copy link

WaterVes82 commented Nov 25, 2020

To : DarkStarSword .
New CMD message. whats this mean https://i.imgur.com/4j7BqjX.png ?
This time the game ran, even with the launcher
with [Loader]
target = StarCitizen.exe
launch = C:\Program Files\Roberts Space Industries\RSI Launcher\RSI Launcher.exe.

Yet again the UI of 3DMigoto is not showing yet . Unsure what this means .

@WaterVes82
Copy link

WaterVes82 commented Nov 25, 2020

Cool what is this ? new CMD. But still not appearing in game. reshade is there. Not 3dmigoto yet .
https://i.imgur.com/6IHFqNU.png ? I covered some info because was not certain it was sensitive or not ; ip ,and my email .
gallery https://imgur.com/a/eaXG3q6

@WaterVes82
Copy link

was i supposed to fill out the proxy line with something ? i sent the ini file to your discord. i think thats you. 3D Vision.

@DarkStarSword
Copy link
Collaborator

Reshade works fine for me named dxgi.dll, which allows the two tools to be used together. This is just using the stock template d3dx.ini with no modifications (no proxy dll, no loader settings), and 3DMigoto located within the game directory as d3d11.dll:
image

All other methods of combining the two tools have hit one issue or another for me. I suggest you focus on trying to get ReShade working named dxgi.dll without 3DMigoto first, then add 3DMigoto to the mix.

To answer your questions:

New CMD message. whats this mean https://i.imgur.com/4j7BqjX.png ?

Usually means the game was run as admin and the 3DMigoto loader was not. This is what the require_admin=true option is for, though I'm not entirely sure why you would be hitting this since I've installed Star Citizen on my system and it does not require admin.

Cool what is this ? new CMD. But still not appearing in game. reshade is there. Not 3dmigoto yet .
https://i.imgur.com/6IHFqNU.png ?

Seems the RSI Launcher is writing it's log to stdout which shows up in our launcher window if using the launch= option. Unexpected, but mostly harmless - it does mean the loader window won't close automatically since a second program is using it, and that you should leave it open while the game is running, then manually close it afterwards.

i sent the ini file to your discord.

You have multiple target and module lines in your loader section - there should only be one of each. As noted above, I was only able to get 3DMigoto to work in this game when it is named d3d11.dll (regardless of being loaded from within the game directory or externally), however that prevents ReShade from using that name.

i think thats you. 3D Vision.

Yeah, that's me. Lately I've been using Discord for work so I'm not signed in to my personal account much and may not see messages there.

@WaterVes82
Copy link

WaterVes82 commented Nov 26, 2020

Thanks for all the help. you have given me good information to use the loader if i need to.
I have to understand why you can use reshades dxgi.dll, and i cant ?

@WaterVes82
Copy link

WaterVes82 commented Nov 26, 2020

DarkStarSword - any clue as to why dxgi.dll is not displaying reshade UI like yours ? Mine used to work months ago. Has not worked since. inorder now for reshade to UI ro appear in game, i gotta rename it to d3d11.dll. but what changed that ?
so frustrating . i assume some dependency was change or created, forcing me to use d3d11.dll to display Reshade UI .
i think reshade installs just its UIs not showing with dxgi.dll . why ?

this is beyond my education- im just a video game player .Searching through forums ive seen others experience this through the years so far with no resolution .

@WaterVes82
Copy link

WaterVes82 commented Nov 26, 2020

maybe its a order to load. Or dynamic link library , maybe a dependency was added or changed for the dxgi
how it interacts with reshade and the game .. dependencies are prob all messed. unsure .

Maybe, its actually that reshade did install, but its UI is not using dxgi right to display .
i dont understand since d3d11.dll displays reshade UI no issue . but not dxgi.dll . : ( -_-
What changed in my system ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants