Telnet Server Creates Process NOT redirected (how to do that?)

Telnet Server Creates Process NOT redirected (how to do that?)

Post by Neste » Thu, 26 Dec 2002 03:19:38



I'm writing an application that allows to launch a HLDS.exe server, it works
fine with telnet server, but the process if launched from telnet has not his
console in desktop.
If my program is launched manually, then it spawn correctly hlds console
windows.
Should i use createProcessAsUser?
Tell me how please
Best Regards
Marco Montesissa.
 
 
 

Telnet Server Creates Process NOT redirected (how to do that?)

Post by Ivan Brugiolo [MSFT » Thu, 26 Dec 2002 03:27:46


You need to specify the right WindowStation \ Desktop for your process,
and then you need to change the Security Descriptor of the target
WindowStation \ Desktop in order to allow
your window to "appear" and have a sensible interaction with the user.
All of this is of course discouraged.
Why are you thinking of opening an interactive program in the logged on user
WindowsStation Desktop ?
(assuming of course that there is an interactive user (there are even
headless severs with no video card at all),
 and that there aren't many interactive user logged on via TS)
If an Administrator opens an interactive program (maybe just notepad) in the
interactive WindowStation \ Desktop,
then the user can exploit notepad to change the logon scripts for the domain
on behaf of the Administrator,
and this is just an example of why what you are trying to do is bad.

--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


Quote:> I'm writing an application that allows to launch a HLDS.exe server, it
works
> fine with telnet server, but the process if launched from telnet has not
his
> console in desktop.
> If my program is launched manually, then it spawn correctly hlds console
> windows.
> Should i use createProcessAsUser?
> Tell me how please
> Best Regards
> Marco Montesissa.


 
 
 

Telnet Server Creates Process NOT redirected (how to do that?)

Post by Neste » Fri, 27 Dec 2002 21:42:24


Thx, I used cmd runas.exe and i solved my problem...Thx and merry xmas...



> You need to specify the right WindowStation \ Desktop for your process,
> and then you need to change the Security Descriptor of the target
> WindowStation \ Desktop in order to allow
> your window to "appear" and have a sensible interaction with the user.
> All of this is of course discouraged.
> Why are you thinking of opening an interactive program in the logged on
user
> WindowsStation Desktop ?
> (assuming of course that there is an interactive user (there are even
> headless severs with no video card at all),
>  and that there aren't many interactive user logged on via TS)
> If an Administrator opens an interactive program (maybe just notepad) in
the
> interactive WindowStation \ Desktop,
> then the user can exploit notepad to change the logon scripts for the
domain
> on behaf of the Administrator,
> and this is just an example of why what you are trying to do is bad.

> --
> This posting is provided "As Is" with no warranties, and confers no
rights.
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm



> > I'm writing an application that allows to launch a HLDS.exe server, it
> works
> > fine with telnet server, but the process if launched from telnet has not
> his
> > console in desktop.
> > If my program is launched manually, then it spawn correctly hlds console
> > windows.
> > Should i use createProcessAsUser?
> > Tell me how please
> > Best Regards
> > Marco Montesissa.

 
 
 

1. Redirecting stderr: in single process, *not* in a child process.

Hello all.

I spent a long day yesterday battling trying to achieve something that
sounds very simple until you actually try and do it.  Let me explain
the situation:

I've taken a third party bit of server software that comes with a BSD
license and I have written a thin wrapper for it using our standard C+
+ classes for logging, configuration, service management etc.  The
source code for the original software is basically unchanged, and I
want to keep it this way so that is simple to upgrade it when need be.

The problem is that the software uses simple c-style logging to
stderr, using fprintf mostly.  What I want to do is capture this
output and send it somewhere else within my own application.

On unix I have solved this problem in the following manner:

? Create a pair of interconnected sockets using the "socketpair" call.
? Use dup2 to make stderr send its output to one of these sockets.
? Start a thread to monitor the other end of the socket and process
the output as it arrives.

This would all work fine on windows except on win32, sockets are not
the same as file descriptors.  In short the method I am using on Unix
will not work on windows, or not that I can see.

I've spent hours trying to find an alternative solution to this simple
problem, playing with SetStdHandler, pipes, named pipes, sockets and
all sorts.  I have yet to find a way to redirect everything sent to
"stderr" to a place of my choosing.

An example of how hard this is can be seen in the following code:

<code>
///
/// Function: main()
///
int main ( int argc, char * const argv[] )
{
        HANDLE hRead, hWrite;

        if ( !CreatePipe( &hRead, &hWrite ,NULL, 10 ) )
                return FALSE;

        SetStdHandle( STD_ERROR_HANDLE, hWrite );

        fprintf( stderr, "This will NOT go to the pipe, but instead to the
console\n" );

        return 0;
</code>

Even though I redirect the stderr to my pipe, that output will go to
the screen.  Apparantly stderr has already been setup within the
printf code, and calling SetStdHandle has no effect.

In short I'm completely stumped.  If someone can show me a way to do
this I would be most grateful.  All examples on the web seem to be
oriented towards how to redirect the output of a child process, which
is really not what I'm trying to do here.

Thanks in advance.

Jamie

2. difficult modem problem?

3. Problem redirecting stdout from child DOS process

4. RRAS stops local ip traffic

5. Creating a Child Process with Redirected Input and Output

6. Console Process w redirected stdout - Buffer does not flush

7. How to redirect STDIO of console process created with CreateProcess() ??

8. Redirecting output of DOS app run in DOS box

9. Registering Active Object in In-Process Server for Out of Process Server, HOW?

10. Redirecting telnet output to serial port

11. Win32 Create Process and DOS Apps