public static async Task RefreshStatus() { InteropRequest request = new InteropRequest(); request.header.RequestType = InteropRequestType.GetGameInformation; var response = await TASInterop.MakeRequestAsync(request); Status = new TASStatus(); if (response?.header.ResponseType == InteropResponseType.Success) { Status.Connected = true; GetGameInformationResponse responseData = new GetGameInformationResponse(); TASInterop.MarshalArrayToObject(ref responseData, response?.responseData); Status.H1DLLLoaded = responseData.Halo1Loaded; Status.H2DLLLoaded = responseData.Halo2Loaded; Status.H3DLLLoaded = responseData.Halo3Loaded; Status.ODSTDLLLoaded = responseData.ODSTLoaded; Status.ReachDLLLoaded = responseData.ReachLoaded; Status.H4DLLLoaded = responseData.Halo4Loaded; if (Status.H1DLLLoaded) { Status.Halo1.CheatsEnabled = responseData.Halo1.CheatsEnabled; } } else { Status.Connected = false; } }
public static async Task SetSkullEnabled(Halo2Skull skull, bool enabled) { InteropRequest request = new InteropRequest(); request.header.RequestType = InteropRequestType.Halo2SetCheatEnabled; request.header.RequestPayloadSize = Marshal.SizeOf(typeof(Halo2SetSkullEnabledRequest)); var payload = new Halo2SetSkullEnabledRequest(); payload.Skull = (int)skull; payload.Enabled = enabled; request.requestData = TASInterop.MarshalObjectToArray(payload); var response = await TASInterop.MakeRequestAsync(request); if (response?.header.ResponseType != InteropResponseType.Success) { // Something went wrong } }
public static async Task <InteropResponse?> MakeRequestAsync(InteropRequest request) { using (NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", "MCCTAS", PipeDirection.InOut)) { try { await pipeClient.ConnectAsync(500); } catch (TimeoutException) { return(null); } if (pipeClient.IsConnected) { try { InteropDataStream ids = new InteropDataStream(pipeClient); var headerData = MarshalObjectToArray(request.header); ids.WriteData(headerData); if (request.requestData != null) { ids.WriteData(request.requestData); } await ids.FlushRequest(); return(await ids.GetResponse()); } catch (Exception) { return(null); } } } return(null); }
public static async Task ExecuteCommand(string command) { if (string.IsNullOrWhiteSpace(command)) { return; } InteropRequest request = new InteropRequest(); request.header.RequestType = InteropRequestType.ExecuteCommand; request.header.RequestPayloadSize = Marshal.SizeOf(typeof(ExecuteCommandRequest)); var payload = new ExecuteCommandRequest(); payload.Command = command; request.requestData = TASInterop.MarshalObjectToArray(payload); var response = await TASInterop.MakeRequestAsync(request); if (response?.header.ResponseType != InteropResponseType.Success) { // Something went wrong } }