hudhook: rendering error in Black Myth
The same code can run in “Elden Ring” and work, but it will crash in “Black Myth”.
I am using sample code: examples/demo_hook_dx12.rs
Error:
Render error: Error { code: HRESULT(0x887A0005), message: "The GPU device instance has been suspended. Use GetDeviceRemovedReason to determine the appropriate action." }
Elden Ring
Black Myth Wukong
log:
2024-09-19T12:30:34.434333Z TRACE ThreadId(01) black_myth_map: src\lib.rs:79: DllMain()
2024-09-19T12:30:34.436849Z DEBUG ThreadId(02) hudhook::hooks: C:\hudhook-0.7.1\src\hooks\mod.rs:87: WNDCLASSEXW { cbSize: 80, style: WNDCLASS_STYLES(3), cbClsExtra: 0, cbWndExtra: 0, hInstance: HINSTANCE(5368709120), hIcon: HICON(0), hCursor: HCURSOR(0), hbrBackground: HBRUSH(0), lpszMenuName: PCWSTR(0x0), lpszClassName: PCWSTR(0x7ffe3ef1dcf8), hIconSm: HICON(0) }
2024-09-19T12:30:34.440773Z DEBUG ThreadId(02) hudhook::hooks: C:\hudhook-0.7.1\src\hooks\mod.rs:107: HWND(1380404)
2024-09-19T12:30:34.490453Z TRACE ThreadId(02) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:259: IDXGISwapChain::Present = 0x7ffeeff34700
2024-09-19T12:30:34.526547Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x242aa840) invoked
2024-09-19T12:30:34.526828Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 2, 0x182b99b0) invoked
2024-09-19T12:30:34.526992Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x242a74a0) invoked
2024-09-19T12:30:34.527156Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x28595fc0) invoked
2024-09-19T12:30:34.527416Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x28595ac0) invoked
2024-09-19T12:30:34.527578Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x28595e00) invoked
2024-09-19T12:30:34.527769Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x28593fc0) invoked
2024-09-19T12:30:34.528266Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x28593920) invoked
2024-09-19T12:30:34.528708Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x28595aa0) invoked
2024-09-19T12:30:34.529062Z TRACE ThreadId(04) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0xab3cc8c0)), 1, 0xbb89f828) invoked
2024-09-19T12:30:34.573191Z TRACE ThreadId(04) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0xcb7f2220)), 1, 0xbb89e3f0) invoked
2024-09-19T12:30:34.574151Z TRACE ThreadId(04) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 1, 0xbb89f408) invoked
2024-09-19T12:30:34.574500Z TRACE ThreadId(04) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:122: Call IDXGISwapChain::Present trampoline
2024-09-19T12:30:34.575692Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x242a40e0) invoked
2024-09-19T12:30:34.576077Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 2, 0x3c569d90) invoked
2024-09-19T12:30:34.576721Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x242a74a0) invoked
2024-09-19T12:30:34.577193Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x242ad5e0) invoked
2024-09-19T12:30:34.577528Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x242aa840) invoked
2024-09-19T12:30:34.577889Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x242a8c80) invoked
2024-09-19T12:30:34.578237Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x28593920) invoked
2024-09-19T12:30:34.578673Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x2859ad80) invoked
2024-09-19T12:30:34.578977Z TRACE ThreadId(03) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0x629223e0)), 3, 0x28593fc0) invoked
2024-09-19T12:30:34.579298Z TRACE ThreadId(04) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:146: ID3D12CommandQueue::ExecuteCommandLists(ID3D12CommandQueue(IUnknown(0xab3cc8c0)), 1, 0xbb89f828) invoked
2024-09-19T12:30:34.579993Z ERROR ThreadId(04) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:119: Render error: Error { code: HRESULT(0x887A0005), message: "The GPU device instance has been suspended. Use GetDeviceRemovedReason to determine the appropriate action." }
2024-09-19T12:30:34.580299Z TRACE ThreadId(04) hudhook::hooks::dx12: C:\hudhook-0.7.1\src\hooks\dx12.rs:122: Call IDXGISwapChain::Present trampoline
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (9 by maintainers)
It works very well. 👍
@jaskang I just merged #200, then #210 into #209 and rebased #209. I’m now gonna test that against my use cases on Linux. If you want to give the branch another spin and confirm it all works well, we can merge this in and release 0.8.
EDIT: Tested against Elden Ring, it works fine. As far as I’m concerned, we can merge this in and begin the release process. I’ll hold off a bit waiting for confirmation but I think we’re good to go!
This is awesome, thank you so much!
The textures fix branch was going to get merged as soon as I could run in-depth testing on my own use cases, but you are already successfully working based on it, that gives me more confidence. If I find no issues, I plan to merge both this new branch and that older PR and cut an official release within this week.
I have tested the Black Myth 、Elden Ring and Hades II. it works very well. Thank you very much~~~~~
By the way, may I ask when the many-textures branch can be merged? I have been developing based on this branch and can provide some test samples.
I have added a better heuristic. Now the swapchain is recorded first try, and whenever
ID3D12CommandQueue::ExecuteCommandListis invoked, this command queue is checked against the swapchain to see that it belongs to it. If that’s the case, the hook is initialized and no further checks are run against the swap chain and the command queue in their hooked methods. We will still pay the cost of locking the mutex, though we might be able to sidestep that by using a static atomic boolean. This is probably the most robust solution against the issue I raised in my previous comment. Checking the pointers is still a potentially imperfect heuristic, but I think it should always work in practice.I still need to test it against a UE game, on Windows, and on Elden Ring to check for regressions, but @jaskang I’d like to ask you if you could please confirm it works on Black Myth. If that’s the case I’ll do my checks, open the PR, merge that in and release 0.8, otherwise we can keep iterating ideas.
That method is actually brilliant. People used to do this by using a single, hardcoded offset, which was very brittle because the offset might change from one version of DirectX 12 to the other, and we have no static guarantee about that. The specific implementation I’m not super confident about, but looping through the vtable and doing some check to ensure we’re at a
ID3D12CommandQueuepointer is a great idea. Not to mention it would allow us to remove one hook and vastly simplify the hook workflow.I’ll do a couple experiment, open a PR and ping you for review!
To sync the progress of this issue, I am a beginner in Rust and making a floating mini-map for this game.
Following your advice, I tried some methods:
Changed
COMMAND_QUEUEfromOnceCellto mutable, updated it inExecuteCommandLists. (Honestly, I don’t know how to filter it)Although the code is rough, miraculously the problem was solved like that.
Sincerely thank you.
I’m sorry I provided the wrong information, load_texture is not the key issue. The game crash problem still exists, and I am using basic sample code.
Even when I tried multiple other repositories for hooking DirectX12, including C++, all of them caused the game to crash without exception. Other games work fine though, such as Elden Ring (no more games available for testing).
However, I found some clues: https://www.unknowncheats.me/forum/unreal-engine-4-a/635608-d3d12-hook-crashes-ue5-03-a.html