I'm trying to create a shared texture between Vulkan and OpenGL, and as I understand the process, it's split in two parts: exporting the memory during allocation and then getting a Windows HANDLE to duplicate and pass to another process.
Allocating the memory passes with no obvious issues:
auto vulkanImage = ...;
auto memoryRequirements = device.getImageMemoryRequirements(vulkanImage);
vk::ExportMemoryAllocateInfo exportInfo{
.handleTypes = vk::ExternalMemoryHandleTypeFlagBits::eOpaqueWin32
};
vulkanImageMemory = device.allocateMemory({
.pNext = &exportInfo,
.allocationSize = memoryRequirements.size,
.memoryTypeIndex = findMemoryType(physicalDevice, memoryRequirements.memoryTypeBits, vk::MemoryPropertyFlagBits::eDeviceLocal),
});
device.bindImageMemory(vulkanImage, vulkanImageMemory, 0);
Trying to get the handle however fails with access violation trying to dereference a null pointer:
auto hTextureMem = (HANDLE)device.getMemoryWin32HandleKHR({
.memory = vulkanImageMemory,
.handleType = vk::ExternalMemoryHandleTypeFlagBits::eOpaqueWin32
});
Debugging notes:
vkGetMemoryWin32HandleKHR pointer that device.getMemoryWin32HandleKHR calls is pointing to valid memory, that is not the source of the access violation. In fact the violation happens inside this function according to the stack frame. 
pNext in the vkGetMemoryWin32HandleKHR call info struct is null, but as far as I can tell that's how it's supposed to be (?), only the pNext in the memory allocation info struct needs an actual object (as per my code above)Any ideas how to get my HANDLE object?
So as it turns out, I didn't explicitly request the external memory extensions. Even though the function pointers existed, internally they weren't bound correctly I suppose.
The necessary instance extensions were:
VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME
VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME
And the necessary device extensions were:
VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME
VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME
VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME
VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME