Sign in to follow this  
wyck

DirectX10 via service in Vista

Recommended Posts

I realize the odds are stacked against me, but I'm trying to launch a DirectX 10 application from a service in Windows Vista, and have encountered a problem. I have read the obvious relevant information and restrictions about session 0 isolation with respect to services in Windows Vista and I believe I am doing *mostly* the right thing so far, in terms of using CreateProcessAsUser to launch the DX10 app as its own process, using the winsta0\Default desktop and running it in session 1 by adjusting the session of the user token. However, my D3D swap chain is reporting the error code DXGI_STATUS_OCCLUDED from the Present function. I am able to create my application window (in the DX10 app), and can do regular GDI drawing in that window -- those graphics appear normally, and it all looks fine, but when I try to present a D3D10 swap chain, it returns the DXGI_STATUS_OCCLUDED error code -- ALWAYS. I seem to be so close: the window is visible, and GDI drawing is possible, but the swap chain just won't present. I know the dx10 app code is working, because if I launch the DX10 app interactively, it works just fine. So what's the secret? How can I do this? What am I missing? I've tried to learn as much as I can about winlogon, session 0 isolation, services in Vista, security, privileges, authentication, window stations, desktops, etc. But I'm not finding the clues I need yet. Any suggestions?

Share this post


Link to post
Share on other sites
As far as I know this simply won't work - D3D isn't designed for service based rendering. I say this as much because I've heard some discussion on it being a use-case for future work (e.g. getting a web server to render D3D content for webpages), suggesting that it is known not to work at the moment...

That said, hopefully someone else can help you prove me wrong [grin]

hth
Jack

Share this post


Link to post
Share on other sites
I appreciate the heads-up, Jack. I would fully expect trying to use DirectX directly in a service process to fail due to the fact that services are not allowed to interact with the desktop in Vista (session 0 isolation). But all the MSDN documentation says that it's possible to get the service to launch an interactive process and run it in the context of the interactive user.

So, I just want to clarify that the service process is not doing the DirectX rendering in my situation. The service launches a new process as the interactive user and runs it in the user's session. I've tried this, and the newly launched app runs, is able to create windows, and is able to do GDI based rendering, but within that application DirectX somehow is prevented from operating normally by virtue of the fact that this process was launched from a service process.

I tried running my process-starting code interactively (by adding a way to start the service code interactively from WinMain instead of as a service) and having it launch the directx application exe and it works fine. So it's not a problem with chaining the exe's together. It's something about the fact that it was started by the service. I'm not taking enough steps to allow the newly started exe to render. (Or maybe there's a bug in DirectX10, I don't know)

I'm just looking for a way to get the service exe to launch a directX application exe in the context of the interactive user in such a way that rendering will work.

Share this post


Link to post
Share on other sites
I can reproduce this behaviour with the EmptyProject10 sample in the DirectX SDK. Launch it interactively and it shows a light blue background. But, launch the EmptyProject10 application from a service (jumping through all the hoops I can think of) and you get a black window background (present, presumably returning DXGI_STATUS_OCCLUDED). An example of launching an application from a service can be found here:

http://www.codeproject.com/KB/vista-security/VistaSessions.aspx

I'm still trying to find whether I'm just doing something wrong, or if there is a bug in either Direct3D 10 or in Windows Vista. Can anyone else reproduce this?

Share this post


Link to post
Share on other sites
Does this issue occur with D3D9Ex and D3D9 apps also?

Are you using code pretty much like that in the codeproject link? If this is a bug in the DXGI or D3D stack, I'd like to get a simple repro going to see if it's a simple fix.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this