See the question and my original answer on StackOverflow

There are two problems:

1.dcomp implementation seems strange to be the least because it answers this successfully but dcompDevice3 is in fact broken somehow, hence the crash:

ComPtr<IDCompositionDevice3> dcompDevice3;
HR(dcompDevice->QueryInterface(__uuidof(IDCompositionDevice), (LPVOID*)&dcompDevice3))

2.and your code is also bad as it should be this:

HR(DCompositionCreateDevice3( // only this factory can give you an IDCompositionDevice3 implementation

ComPtr<IDCompositionDevice3> dcompDevice3;
HR(dcompDevice->QueryInterface(__uuidof(IDCompositionDevice3), (LPVOID*)&dcompDevice3)); // use IDCompositionDevice3 here

And now it should work, at least, continue.