I'm trying to launch an exe based on ServerApplication - let's call it AppA - from a windows 7 service (the service is yet another ServerApplication, let's call it AppB). The reason I'm doing it this way is AppA makes use of OpenGL resources that Windows has cut off access to from service to hardware - it's called Session 0 isolation. That's why I need a launcher AppB that logs in an interactive user and launches AppA as that user.
The code sample I dug up to try and do this is found here: http://msdn.microsoft.com/en-us/library/aa379608(VS.85).aspx
That code defines StartInteractiveClientProcess() function which is run from AppB shown below:
- Code: Select all
class WinInteractiveService : public Poco::Util::ServerApplication
{
public:
protected:
void initialize(Poco::Util::Application& self)
{
loadConfiguration(); //load default configuration files, if present
ServerApplication::initialize(self);
std::string tempString = config().getString("username");
m_userName = std::wstring(tempString.begin(), tempString.end()); //ascii to wide is fine
tempString = config().getString("password");
m_password = std::wstring(tempString.begin(), tempString.end());
tempString = config().getString("domain");
m_domain = std::wstring(tempString.begin(), tempString.end());
tempString = config().getString("process");
m_process = std::wstring(tempString.begin(), tempString.end());
tempString = config().getString("workingDirectory", "");
m_workingDirectory = std::wstring(tempString.begin(), tempString.end());
}
int main(const std::vector<std::string> & args)
{
//convert command from const char * to char * that can be modified, this is for CreateProcessAsUser() call
wchar_t * commandCopy = new wchar_t[m_process.size()+1];
memcpy(commandCopy, m_process.c_str(), sizeof(wchar_t) * m_process.size());
commandCopy[m_process.size()] = L'\0';
//login user interactively
StartInteractiveClientProcess(m_userName.c_str(), m_domain.c_str(), m_password.c_str(), commandCopy, m_workingDirectory.empty() ? NULL : m_workingDirectory.c_str());
waitForTerminationRequest();
delete [] commandCopy;
return 0; //success
}
private:
std::wstring m_userName;
std::wstring m_password;
std::wstring m_domain;
std::wstring m_process;
std::wstring m_workingDirectory;
};
Now here's the problem. I can run almost any executable command using AppB code given above, running AppB from command line. For example I run AppB which runs dir.exe, SampleApp from Poco or GLUT sample program with rotating triangles etc. However any application based on Poco::ServerApplication fails with "R6010 abort() has been called" - I tried my own AppA or SampleServer from POCO source code. So somewhere there's an assert() that fails in Poco code. I cannot track it down. The debugger can't attach to the application that failed when it was run this way, and I can't reproduce this error when running application normally directly by me.
Anyone have any clue what's going on? What can be failing?
Thanks.





