I found the solution for this. I am trying to explain it below:
First, get the DXGISurface by using:
hr =ID3D11Texture2D->QueryInterface(IID_PPV_ARGS(&lIDXGISurface1)); // ID3D11Texture2D is the catured texture
Next step is to make an object for CURSORINFO to store the information about the cursor:
lCursorInfo.cbSize = sizeof(lCursorInfo);
auto lBoolres = GetCursorInfo(&lCursorInfo);
if (lBoolres == TRUE)
{
if (lCursorInfo.flags == CURSOR_SHOWING)
{
// currently lCursorInfo.hCursor has the shape of actual cursor that is coming to your system to modify it you can use the below line
std::string path = "cursor.cur"; // this is path to the file where .cur file available in your system
lCursorInfo.hCursor = LoadCursorFromFileA(path.c_str());
// You can refer https://docs.microsoft.com/en-us/windows/win32/menurc/using-cursors for creating your own cursor
auto lCursorPosition = lCursorInfo.ptScreenPos;
auto lCursorSize = lCursorInfo.cbSize;
HDC lHDC;
lIDXGISurface1->GetDC(FALSE, &lHDC); // getting handle to draw the cursor
// Draw the cursor
DrawIconEx(
lHDC,
lCursorPosition.x,
lCursorPosition.y,
lCursorInfo.hCursor,
0,
0,
0,
0,
DI_NORMAL | DI_DEFAULTSIZE);
// Release the handle
lIDXGISurface1->ReleaseDC(nullptr);
}
}