首页
社区
课程
招聘
[求助]D3D11CreateDeviceAndSwapChain The problem of hijacking other process windows
发表于: 2018-5-16 13:16 4448

[求助]D3D11CreateDeviceAndSwapChain The problem of hijacking other process windows

2018-5-16 13:16
4448
HRESULT CreateDeviceD3D(HWND hWnd)
{
    // Setup swap chain
    DXGI_SWAP_CHAIN_DESC sd;
    ZeroMemory(&sd, sizeof(sd));
    sd.BufferCount = 2;
    sd.BufferDesc.Width = 0;
    sd.BufferDesc.Height = 0;
    sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    sd.BufferDesc.RefreshRate.Numerator = 60;
    sd.BufferDesc.RefreshRate.Denominator = 1;
    sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
    sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    sd.OutputWindow = hWnd;
    sd.SampleDesc.Count = 1;
    sd.SampleDesc.Quality = 0;
    sd.Windowed = TRUE;
    sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
    UINT createDeviceFlags = 0;
    //createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
    D3D_FEATURE_LEVEL featureLevel;
    const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, };
    if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK)
        return E_FAIL;
    CreateRenderTarget();
    return S_OK;
}
int main()
{
HWND hwnd = FindWindowA("XXXX","XXXX");
if (CreateDeviceD3D(hwnd) < 0)
    {
        CleanupDeviceD3D();
        return 1;
    }
}

In d3d9, we can normally use DX d3d9 that creates non self process, almost compatible with all systems.
But when we use Dx11 to create DX of non self windows, some systems will be created. If someone uses the same problem, let's discuss it together.
Here is my part of the code, thanks!
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL };
RegisterClassEx(&wc);
HWND hwnd = CreateWindow(_T("ImGui Example"), _T("ImGui DirectX11 Example"),
WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
CreateDeviceD3D (hwnd );

If you use your own window, you will succeed!

[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 0
支持
分享
最新回复 (4)
雪    币: 3574
活跃值: (4719)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
QAQ  别以为装作老外我就不知道你在做吃鸡挂
2018-5-16 13:55
0
雪    币: 189
活跃值: (267)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
66++446
+  you  有遇见这种问题吗
2018-5-16 23:40
0
雪    币: 166
能力值: (RANK:10 )
在线值:
发帖
回帖
粉丝
4
syser QAQ 别以为装作老外我就不知道你在做吃鸡挂
封杀做挂的
2018-5-17 00:32
0
雪    币: 4
活跃值: (26)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
space
2019-7-13 00:48
0
游客
登录 | 注册 方可回帖
返回
//