Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting the Address of a function that can only be called

I already asked a Question but I think thats very special and will not get a concrete answer.

Im trying to give a simpler Explanation of what i need help with.

The Issue is that d3d12::pCommandList->CopyTextureRegion; doesnt work because CopyTextureRegion is a function that can only be called, but i need the address of it.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

For example this will give me the Address of the ID3D12GraphicsCommandList: d3d12::pCommandList;

This is a small part of my code:

namespace d3d12
{
    
    IDXGISwapChain3* pSwapChain;
    ID3D12Device* pDevice;
    ID3D12CommandQueue* pCommandQueue;
    ID3D12Fence* pFence;
    ID3D12DescriptorHeap* d3d12DescriptorHeapBackBuffers = nullptr;
    ID3D12DescriptorHeap* d3d12DescriptorHeapImGuiRender = nullptr;
    ID3D12DescriptorHeap* pSrvDescHeap = nullptr;;
    ID3D12DescriptorHeap* pRtvDescHeap = nullptr;;
    ID3D12GraphicsCommandList* pCommandList;

    
    FrameContext* FrameContextArray;
    ID3D12Resource** pID3D12ResourceArray;
    D3D12_CPU_DESCRIPTOR_HANDLE* RenderTargetDescriptorArray;

    
    HANDLE hSwapChainWaitableObject;
    HANDLE hFenceEvent;

    
    UINT NUM_FRAMES_IN_FLIGHT;
    UINT NUM_BACK_BUFFERS;

    
    UINT   frame_index = 0;
    UINT64 fenceLastSignaledValue = 0;
}


d3d12::pDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, d3d12::FrameContextArray[0].CommandAllocator, NULL, IID_PPV_ARGS(&d3d12::pCommandList));

// issue, CopyTextureRegion can only be called. I need the address of it
auto RegionHookAddress = d3d12::pCommandList->CopyTextureRegion;

>Solution :

Taking the address of the member function:

auto RegionHookAddress = &d3d12::ID3D12GraphicsCommandList::CopyTextureRegion;

Calling the member function:

(d3d12::pCommandList->*RegionHookAddress)(...);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading