]> xenbits.xensource.com Git - pvdrivers/win/xencons.git/commitdiff
Launch monitored process without command line
authorOwen Smith <owen.smith@citrix.com>
Tue, 25 Jul 2017 13:09:34 +0000 (14:09 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 25 Jul 2017 13:09:34 +0000 (14:09 +0100)
Changed tty to open named pipe by name, not command line argument

Signed-off-by: Owen Smith <owen.smith@citrix.com>
src/monitor/monitor.c
src/tty/tty.c

index c2ae38c0d847a986400db169f6bcb2f01481b641..90c39b74ab7c0712d0950abf9b2dfc63e14ddf0e 100644 (file)
@@ -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();
 
index c47634c18a864c0865f5f1ed5d6373781ac1e6d5..94d4f653b550886d340982cd770c64a5ae0a686e 100644 (file)
@@ -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();