public static ProcessEnvironmentHelper Parse(byte[] payload) { ProcessEnvironmentHelper helper = new ProcessEnvironmentHelper(); helper.ExpectedSizeInBytes = BitConverter.ToUInt32(payload, 0); helper.Future = BitConverter.ToUInt16(payload, 4); return(helper); }
/// <summary> /// Gets all environement variables and their values from the target process. /// </summary> /// <returns>A dictionary containing all of the environment variables defined in the target process.</returns> public Dictionary <string, string> GetProcessEnvironment() { IpcMessage message = CreateProcessEnvironmentMessage(); using IpcResponse response = IpcClient.SendMessageGetContinuation(_endpoint, message); ValidateResponseMessage(response.Message, nameof(GetProcessEnvironmentAsync)); ProcessEnvironmentHelper helper = ProcessEnvironmentHelper.Parse(response.Message.Payload); return(helper.ReadEnvironment(response.Continuation)); }
internal async Task <Dictionary <string, string> > GetProcessEnvironmentAsync(CancellationToken token) { IpcMessage message = CreateProcessEnvironmentMessage(); using IpcResponse response = await IpcClient.SendMessageGetContinuationAsync(_endpoint, message, token).ConfigureAwait(false); ValidateResponseMessage(response.Message, nameof(GetProcessEnvironmentAsync)); ProcessEnvironmentHelper helper = ProcessEnvironmentHelper.Parse(response.Message.Payload); return(await helper.ReadEnvironmentAsync(response.Continuation, token).ConfigureAwait(false)); }
public Dictionary <string, string> GetProcessEnvironment() { var message = new IpcMessage(DiagnosticsServerCommandSet.Process, (byte)ProcessCommandId.GetProcessEnvironment); Stream continuation = IpcClient.SendMessage(_endpoint, message, out IpcMessage response); switch ((DiagnosticsServerResponseId)response.Header.CommandId) { case DiagnosticsServerResponseId.Error: int hr = BitConverter.ToInt32(response.Payload, 0); throw new ServerErrorException($"Get process environment failed (HRESULT: 0x{hr:X8})"); case DiagnosticsServerResponseId.OK: ProcessEnvironmentHelper helper = ProcessEnvironmentHelper.Parse(response.Payload); Task <Dictionary <string, string> > envTask = helper.ReadEnvironmentAsync(continuation); envTask.Wait(); return(envTask.Result); default: throw new ServerErrorException($"Get process environment failed - server responded with unknown command"); } }