diff --git a/v2rayN/v2rayN/Handler/CoreHandler.cs b/v2rayN/v2rayN/Handler/CoreHandler.cs index f07b39fc..b284a189 100644 --- a/v2rayN/v2rayN/Handler/CoreHandler.cs +++ b/v2rayN/v2rayN/Handler/CoreHandler.cs @@ -228,15 +228,21 @@ namespace v2rayN.Handler string fileName = CoreFindexe(coreInfo); if (fileName == "") return -1; + var pathTemp = Utils.GetConfigPath($"temp_{Utils.GetGUID(false)}.json"); + File.WriteAllText(pathTemp, configStr); + if (!File.Exists(pathTemp)) + { + return -1; + } + Process p = new Process { StartInfo = new ProcessStartInfo { FileName = fileName, - Arguments = "-config stdin:", + Arguments = $"-config \"{pathTemp}\"", WorkingDirectory = Utils.GetConfigPath(), UseShellExecute = false, - RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true, @@ -255,15 +261,16 @@ namespace v2rayN.Handler p.Start(); p.BeginOutputReadLine(); - p.StandardInput.Write(configStr); - p.StandardInput.Close(); - if (p.WaitForExit(1000)) { throw new Exception(p.StandardError.ReadToEnd()); } Global.processJob.AddProcess(p.Handle); + + Thread.Sleep(1000); + File.Delete(pathTemp); + return p.Id; } catch (Exception ex)