protected void ReceiveData(string data) { m_bufferReceive += data; for (; ;) { int posEndLine = m_bufferReceive.IndexOf('\n'); if (posEndLine == -1) { break; } else { string line = m_bufferReceive.Substring(0, posEndLine); m_bufferReceive = m_bufferReceive.Substring(posEndLine + 1); if (line.StartsWith("ee:", StringComparison.InvariantCulture) == false) { Engine.Instance.Logs.LogVerbose("Elevated unexpected log: " + line); } else { int posEndKind = line.IndexOf(':', 3); if (posEndKind == -1) { return; } string packetKind = line.Substring(3, posEndKind - 3); if (packetKind == "log") { string logB = line.Substring(posEndKind + 1); string log = Conversions.Base64ToString(logB); Engine.Instance.Logs.LogVerbose(log); // For example, DNS flush messages } else if (packetKind == "fatal") { string logB = line.Substring(posEndKind + 1); string log = Conversions.Base64ToString(logB); FatalError(log); } else if (packetKind == "pid") { // For example under MacOS, it's not possible to obtain PID with AuthorizationExecuteWithPrivileges. // So, it's the elevated that inform the launcher of his PID. string pidB = line.Substring(posEndKind + 1); string pidS = Conversions.Base64ToString(pidB); int pid = Conversions.ToInt32(pidS); m_process = System.Diagnostics.Process.GetProcessById(pid); } else { int posEndId = line.IndexOf(":", posEndKind + 1, StringComparison.InvariantCulture); string packetIdS = ""; string packetData = ""; if (posEndId == -1) { packetIdS = line.Substring(posEndKind + 1); packetData = ""; } else { packetIdS = line.Substring(posEndKind + 1, posEndId - posEndKind - 1); packetData = line.Substring(posEndId + 1); packetData = Conversions.Base64ToString(packetData); } UInt32 packetId = Convert.ToUInt32(packetIdS); if (PendingCommands.ContainsKey(packetId) == false) { return; } Command c = PendingCommands[packetId]; if (packetKind == "data") { c.Data(packetData); } else if (packetKind == "exception") { c.Exception(packetData); PendingCommands.Remove(packetId); } else if (packetKind == "end") { c.End(); PendingCommands.Remove(packetId); } } } } } }