Home > Net >  Getting the Address of a function that can only be called
Getting the Address of a function that can only be called

Time:07-05

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.

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;

CodePudding user response:

Taking the address of the member function:

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

Calling the member function:

(d3d12::pCommandList->*RegionHookAddress)(...);
  • Related