I’ve continued working on my script hook for Watch Dogs and now also added support for GetAsyncKeyState in lua. Also, as it can be very handy, I allow lua scripts to run in a loop now, since each is spawned in a new thread. This allows code like this:
while true do -- Change time when C is down local result = wdHook.GetAsyncKeyState(67); if (result == 1) then test:SetScriptedTimeOfDay(18, 00); end wdHook.Wait(50) end
Quite useful, right?
In addition, I got a basic D3D11 hook working, so I’m now able to draw on the rendered image (upper left corner):
I need to move this into a lua callback to add drawing support for lua too, but that shouldn’t be too hard to implement. Once I got that working I’ll do some final tests and then hope to release my hook for all the scripters out there! 🙂
For those of you trying to get ad3d11 hook to work, keep in mind you need to save the jmp Steam places in the function, for instance at D3D11Present. I do this by reading the target address of the Steam call, adding the current location (RIP) to get the full address and then executing something like this:
mov rax, addr jmp rax
This will keep the Steam overlay working and you can still use your own hooked function by executing it right before.
Furthermore, if you have trouble detouring D3D11DrawIndexed, this might help you (reversed to C++ from original WD implementation):
DWORD64 dwContext = (DWORD64)pContext + 0x0009C08; D3D11DrawIndexedHook dwCallTarget = (D3D11DrawIndexedHook)*(DWORD64*)(pContext + 0x8D); return dwCallTarget((ID3D11DeviceContext*)dwContext, IndexCount, StartIndexLocation, BaseVertexLocation);