This does a very basic job of bundling a PowerShell runtime into the SDK. Previously, scripts had been run by spawning a separate PowerShell process and feeding the script into it. This was nothing better than a hack and meant that PowerShell had to be separately installed on the machine it's executing on. This should open up the opportunity for scripts to run on other platforms. There's still some things that need to be figured out. Some sort of console output as well as a debugging mode would be highly beneficial for those that wish to actively develop scripts for their games.
30 lines
806 B
C#
30 lines
806 B
C#
using System;
|
|
using System.IO;
|
|
using System.Management.Automation;
|
|
|
|
namespace LANCommander.SDK.PowerShell.Cmdlets
|
|
{
|
|
[Cmdlet(VerbsData.Edit, "PatchBinary")]
|
|
[OutputType(typeof(string))]
|
|
public class EditPatchBinaryCmdlet : Cmdlet
|
|
{
|
|
[Parameter(Mandatory = true, Position = 0)]
|
|
public long Offset { get; set; }
|
|
|
|
[Parameter(Mandatory = true, Position = 1)]
|
|
public byte[] Data { get; set; }
|
|
|
|
[Parameter(Mandatory = true, Position = 2)]
|
|
public string FilePath { get; set; }
|
|
|
|
protected override void ProcessRecord()
|
|
{
|
|
using (var writer = File.OpenWrite(FilePath))
|
|
{
|
|
writer.Seek(Offset, SeekOrigin.Begin);
|
|
|
|
writer.Write(Data, 0, Data.Length);
|
|
}
|
|
}
|
|
}
|
|
}
|