Question

This question is related to: Which API Microsoft Word (Office 2013) is using the paint the screen, which was left unanswered.

I have an Office plug-in (native C++) which is fairly involving with Office. Using hooks I'm modifying the client area of Office application.

Things were working great for me up to Office 2010, hooking WM_NCPAINT, and using GDI method on the Office Window.

But Office 2013 uses Direct2D, DXGI, and DirectWrite. On Windows 7, if I draw something on the screen - it gets erased the next time the cursor blink. On Windows 8 - I don't even have access to the screen.

Currently, my thinking is to hook ID2D1DeviceContext::BeginDraw, ID2D1DeviceContext::EndDraw - and on last function, just before delegating to the real function, I will add my stuff. Another idea is the hook IDXGISwapChain1::Present1. Problem with both these methods that I've hard time identifying what is going on above.

I'm even thinking even a different process (or GDI based window - if possible) on top of the client area I want to decorate, with the majority of the real eastate being 100% transparent. Problem with this solution are issues like keyboard focus and mouse click.

Any tip or suggestion will be appreciated. Any tool (the Spy++ for DirectX) will be appreciated. Does DirectX (specifically Direct2D) has documented extensible or plug-able story, I'm not aware of and could use? Is there anything in Kernel Mode I'm missing?

Was it helpful?

Solution

Hm dont know exactly how that works on Direct Draw, but i hooked once the EndScene function for Direct3D and added some stuff to the scene before the real EndScene could be executed. I made a little video that shows that: http://www.youtube.com/watch?v=ZFshqIEaLBc

OTHER TIPS

Here's my advice: don't do that. Any of it. If you find yourself having to hook and hack into the host that deeply, it's a clear sign that you just shouldn't be doing that. Find another way to draw what you need, or change your UI design so that it fits in with what Office already accomodates. Even if you assume it's possible to get this working, every time Office is updated (patch, service pack, new version) you will be at high risk of all your stuff breaking, with no guarantee that you'll be able to get it working again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top