)
{
PMONITOR_CONTEXT Context = &MonitorContext;
- DWORD CommandLineLength;
- PTCHAR CommandLine;
PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo;
BOOL Success;
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,
&StartupInfo,
&ProcessInfo);
if (!Success)
- goto fail2;
+ goto fail1;
Handle[0] = Context->MonitorEvent;
Handle[1] = ProcessInfo.hProcess;
//#undef WAIT_OBJECT_1
- free(CommandLine);
-
Log("<====");
return 0;
-fail2:
- Log("fail2");
-
- free(CommandLine);
-
fail1:
Error = GetLastError();
HANDLE Write;
} TTY_STREAM, *PTTY_STREAM;
+#define PIPE_NAME TEXT("\\\\.\\pipe\\xencons")
#define MAXIMUM_BUFFER_SIZE 1024
typedef struct _TTY_CONTEXT {
)
{
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,
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,
FILE_ATTRIBUTE_NORMAL,
NULL);
- if (Context->Device.Read == INVALID_HANDLE_VALUE)
+ if (Context->Device.Write == INVALID_HANDLE_VALUE)
ExitProcess(1);
Success = GetCredentials();