KN4CK3R / OSHGui

77 stars 33 forks source link

No such interface supported error from D3DX11CreateEffectFromMemory #28

Open n0wonmai opened 4 months ago

n0wonmai commented 4 months ago

So, i have added some debug messages to understand what goes wrong when injecting the DLL

Direct3D11Renderer.cpp:

HRESULT hr = D3DX11CompileFromMemory(shaderSource, sizeof(shaderSource), nullptr, nullptr, nullptr, nullptr, "fx_5_0", 0, 0, nullptr, &blob, &errors, nullptr);
    if (FAILED(hr))
    {
        std::string msg = "D3DX11CompileFromMemory failed: ";
        if (errors)
        {
            msg += static_cast<const char*>(errors->GetBufferPointer());
            errors->Release();
        }
        else
        {
            msg += "Unknown error";
        }
        throw Misc::Exception(msg);
    }

    hr = D3DX11CreateEffectFromMemory(blob->GetBufferPointer(), blob->GetBufferSize(), 0, device.Device, &effect);
    if (FAILED(hr))
    {
        std::string msg = "D3DX11CreateEffectFromMemory failed: ";
        LPVOID lpMsgBuf;
        FormatMessage(
            FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
            NULL,
            hr,
            MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
            (LPTSTR)&lpMsgBuf,
            0, NULL );

        msg += (char*)lpMsgBuf;
        LocalFree(lpMsgBuf);

        throw Misc::Exception(msg);
    }

Getting message with "No such interface supported" error. What can be the issue?

IDE: VS2019 DXSDK: Microsoft DirectX SDK (June 2010) Platform: Win11x64

KN4CK3R commented 4 months ago

Does the sample work for you?

n0wonmai commented 4 months ago

@KN4CK3R is there any dx11 sample? If you mean dx9, no i didn't try

Btw seems like D3DX11CompileFromMemory and D3DX11CreateEffectFromMemory functions are deprecated for now, you should compile shaders instead, e.g:

static const char* vertexShader =
            "cbuffer vertexBuffer : register(b0) \
            {\
            float4x4 ProjectionMatrix; \
            };\
            struct VS_INPUT\
            {\
            float2 pos : POSITION;\
            float4 col : COLOR0;\
            float2 uv  : TEXCOORD0;\
            };\
            \
            struct PS_INPUT\
            {\
            float4 pos : SV_POSITION;\
            float4 col : COLOR0;\
            float2 uv  : TEXCOORD0;\
            };\
            \
            PS_INPUT main(VS_INPUT input)\
            {\
            PS_INPUT output;\
            output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
            output.col = input.col;\
            output.uv  = input.uv;\
            return output;\
            }";

        D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &g_pVertexShaderBlob, NULL);

Didn't try this with OSHGui but with other custom-gui app it works fine