From: Owen Smith Date: Tue, 25 Jul 2017 13:09:34 +0000 (+0100) Subject: Launch monitored process without command line X-Git-Tag: 9.0.0-rc1~41 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e48fda43d60d57e3e77e9bdc7b1ae8722661183f;p=pvdrivers%2Fwin%2Fxencons.git Launch monitored process without command line Changed tty to open named pipe by name, not command line argument Signed-off-by: Owen Smith --- diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index c2ae38c..90c39b7 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -586,8 +586,6 @@ MonitorThread( ) { PMONITOR_CONTEXT Context = &MonitorContext; - DWORD CommandLineLength; - PTCHAR CommandLine; PROCESS_INFORMATION ProcessInfo; STARTUPINFO StartupInfo; BOOL Success; @@ -599,32 +597,16 @@ MonitorThread( Log("====>"); - CommandLineLength = (DWORD)(_tcslen(Context->Executable) + - 2 + - _tcslen(Context->DevicePath) + - 2) * sizeof (TCHAR); - - CommandLine = calloc(1, CommandLineLength); - - if (CommandLine == NULL) - goto fail1; - - (VOID) _sntprintf(CommandLine, - CommandLineLength - 1, - TEXT("%s \"%s\""), - Context->Executable, - Context->DevicePath); - again: ZeroMemory(&ProcessInfo, sizeof (ProcessInfo)); ZeroMemory(&StartupInfo, sizeof (StartupInfo)); StartupInfo.cb = sizeof (StartupInfo); - Log("Executing: %s", CommandLine); + Log("Executing: %s", Context->Executable); #pragma warning(suppress:6053) // CommandLine might not be NUL-terminated Success = CreateProcess(NULL, - CommandLine, + Context->Executable, NULL, NULL, FALSE, @@ -635,7 +617,7 @@ again: &StartupInfo, &ProcessInfo); if (!Success) - goto fail2; + goto fail1; Handle[0] = Context->MonitorEvent; Handle[1] = ProcessInfo.hProcess; @@ -667,17 +649,10 @@ again: //#undef WAIT_OBJECT_1 - free(CommandLine); - Log("<===="); return 0; -fail2: - Log("fail2"); - - free(CommandLine); - fail1: Error = GetLastError(); diff --git a/src/tty/tty.c b/src/tty/tty.c index c47634c..94d4f65 100644 --- a/src/tty/tty.c +++ b/src/tty/tty.c @@ -39,6 +39,7 @@ typedef struct _TTY_STREAM { HANDLE Write; } TTY_STREAM, *PTTY_STREAM; +#define PIPE_NAME TEXT("\\\\.\\pipe\\xencons") #define MAXIMUM_BUFFER_SIZE 1024 typedef struct _TTY_CONTEXT { @@ -393,18 +394,15 @@ _tmain( ) { PTTY_CONTEXT Context = &TtyContext; - PTCHAR DeviceName; SECURITY_ATTRIBUTES Attributes; HANDLE Handle[3]; DWORD Index; BOOL Success; - if (argc != 2) - ExitProcess(1); - - DeviceName = argv[1]; + UNREFERENCED_PARAMETER(argc); + UNREFERENCED_PARAMETER(argv); - Context->Device.Read = CreateFile(DeviceName, + Context->Device.Read = CreateFile(PIPE_NAME, GENERIC_READ, FILE_SHARE_WRITE, NULL, @@ -415,7 +413,7 @@ _tmain( if (Context->Device.Read == INVALID_HANDLE_VALUE) ExitProcess(1); - Context->Device.Write = CreateFile(DeviceName, + Context->Device.Write = CreateFile(PIPE_NAME, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, @@ -423,7 +421,7 @@ _tmain( FILE_ATTRIBUTE_NORMAL, NULL); - if (Context->Device.Read == INVALID_HANDLE_VALUE) + if (Context->Device.Write == INVALID_HANDLE_VALUE) ExitProcess(1); Success = GetCredentials();