[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH 5/6] Launch monitored process without command line
From: Owen Smith <owen.smith@xxxxxxxxxx> Changed tty to open named pipe by name, not command line argument Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx> --- src/monitor/monitor.c | 31 +++---------------------------- src/tty/tty.c | 14 ++++++-------- 2 files changed, 9 insertions(+), 36 deletions(-) diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index 9ddce52..6e1e85f 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(); -- 2.8.3 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |