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

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

2018-5-16 13:16
3852
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!

[培训]内核驱动高级班,冲击BAT一流互联网大厂工 作,每周日13:00-18:00直播授课

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