From 451076dcbe94d585e5eb58c6073287d94edfc21e Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Fri, 11 Feb 2022 20:49:57 -0700 Subject: [PATCH] Fix Win32 Unknown Device function handling The handling of unknown device functions queried with vkGetInstanceProcAddr required an additional pointer dereference to get the dispatch table. The VkDevice handle is a pointer to the `chain_device` member of `loader_device`. This member is actually a pointer to `loader_dispatch`, or put another way, the "start" of `loader_device`. Thus, to get access to the dispatch table, we need to dereference the VkDevice passed into the function then dereference the chain_device to get loader_dispatch`. --- loader/unknown_ext_chain_masm.asm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loader/unknown_ext_chain_masm.asm b/loader/unknown_ext_chain_masm.asm index 52441fae..f1323bde 100644 --- a/loader/unknown_ext_chain_masm.asm +++ b/loader/unknown_ext_chain_masm.asm @@ -108,7 +108,8 @@ endm DevExtTramp macro num public _vkdev_ext&num&@4 _vkdev_ext&num&@4: - mov eax, dword ptr [esp + 4] ; Dereference the handle to get the dispatch table + mov eax, dword ptr [esp + 4] ; Dereference the handle to get VkDevice chain_device + mov eax, dword ptr [eax] ; Dereference the chain_device to get the loader_dispatch jmp dword ptr [eax + (EXT_OFFSET_DEVICE_DISPATCH + (PTR_SIZE * num))] ; Jump to the appropriate call chain endm -- 2.34.1