Public Release?

This commit is contained in:
Reece Wilson 2019-07-10 23:55:34 +01:00
parent 7459d15b9a
commit fd99822d25
15 changed files with 932 additions and 402 deletions

View File

@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\..\..\..\Game\Nevis\DevTools\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@ -26,11 +26,14 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>..\..\..\..\Game\Nevis\ModTools\Havok\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Development|AnyCPU'">
<OutputPath>bin\Development\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
@ -46,18 +49,24 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="src\Form\Form1.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Form.resx</DependentUpon>
</Compile>
<Compile Include="src\Lua\Constants.cs" />
<Compile Include="src\Form\Form.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="src\Form\Form.Designer.cs">
<DependentUpon>Form.cs</DependentUpon>
</Compile>
<Compile Include="src\Form\Form1.Designer.cs">
<DependentUpon>Form.resx</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
<Compile Include="src\Form\NodeHelper.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="src\Form\NodeHelper.designer.cs">
<DependentUpon>NodeHelper.cs</DependentUpon>
</Compile>
<Compile Include="src\Lua\Constants.cs" />
<Compile Include="src\Lua\Header.cs" />
<Compile Include="src\Lua\Instructions\AddBkInstruction.cs" />
<Compile Include="src\Lua\Instructions\AddInstruction.cs" />
@ -174,6 +183,9 @@
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Form1.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="src\Form\NodeHelper.resx">
<DependentUpon>NodeHelper.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>

View File

@ -88,6 +88,7 @@
this.SavePseudocodeItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
@ -551,7 +552,8 @@
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripButton1,
this.toolStripButton2});
this.toolStripButton2,
this.toolStripLabel1});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(1318, 25);
@ -620,6 +622,13 @@
//
this.openFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk);
//
// toolStripLabel1
//
this.toolStripLabel1.Name = "toolStripLabel1";
this.toolStripLabel1.Size = new System.Drawing.Size(116, 22);
this.toolStripLabel1.Text = "Havok Kore Backend";
this.toolStripLabel1.Click += new System.EventHandler(this.toolStripLabel1_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -713,6 +722,7 @@
private System.Windows.Forms.ColumnHeader RegColumn;
private System.Windows.Forms.ColumnHeader InstIndexColumn;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.ToolStripLabel toolStripLabel1;
}
}

View File

@ -165,5 +165,10 @@ namespace HavokHelper
{
}
private void toolStripLabel1_Click(object sender, EventArgs e)
{
new NodeHelper().Show();
}
}
}

123
src/Form/NodeHelper.cs Normal file
View File

@ -0,0 +1,123 @@
using HavokHelper.Lua;
using HavokHelper.Lua.Instructions;
using HavokHelper.src.Parser;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HavokHelper
{
public partial class NodeHelper : Form
{
private Stub SelectedStub;
public NodeHelper()
{
InitializeComponent();
}
private void NodeHelper_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
}
private void button2_Click(object sender, EventArgs e)
{
openFileDialog2.ShowDialog();
}
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
textBox1.Text = openFileDialog1.FileName;
textBox2.Text = openFileDialog1.FileName;
if (textBox1.Text.EndsWith(".lua"))
textBox2.Text = textBox1.Text.Substring(0, textBox1.Text.Length - 3) + "asm";
}
private void openFileDialog2_FileOk(object sender, CancelEventArgs e)
{
textBox2.Text = openFileDialog2.FileName;
}
private void destCompiled_CheckedChanged(object sender, EventArgs e)
{
if (textBox2.Text.Length < 4)
return;
textBox2.Text = textBox2.Text.Substring(0, textBox2.Text.Length - 3) + (destCompiled.Checked ? "lua" : "asm");
}
private void appendText(string text)
{
if (richTextBox1.InvokeRequired)
richTextBox1.Invoke(new System.Action(() => appendText(text)));
else
richTextBox1.AppendText(text);
}
private void button3_Click(object sender, EventArgs e)
{
System.IO.File.WriteAllText(@"fuck.js", string.Empty);
String buffer = "";
buffer += "var hks = require(\"" + textBox3.Text.Replace(@"\", @"\\") + "index.js\")\n";
buffer += "var test = new hks.Context();\n";
if (srcCompiled.Checked)
{
buffer += "test.fromFile(\"" + textBox1.Text.Replace(@"\", @"\\") + "\")\n";
}
else
{
buffer += "test.assembleFile(\"" + textBox1.Text.Replace(@"\", @"\\") + "\")\n";
}
if (destCompiled.Checked)
{
buffer += "test.save(\"" + textBox2.Text.Replace(@"\", @"\\") + "\")\n";
}
else
{
buffer += "test.disassembleFile(\"" + textBox2.Text.Replace(@"\", @"\\") + "\")\n";
}
System.IO.File.WriteAllText(@"fuck.js", buffer);
using (Process nodejs = new Process())
{
nodejs.StartInfo.FileName = @"C:\Program Files\nodejs\node.exe";
nodejs.StartInfo.Arguments = "fuck.js";
nodejs.StartInfo.CreateNoWindow = true;
nodejs.StartInfo.UseShellExecute = false;
nodejs.StartInfo.RedirectStandardOutput = true;
nodejs.StartInfo.RedirectStandardError = true;
nodejs.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
{
appendText(e2.Data);
appendText(Environment.NewLine);
};
nodejs.ErrorDataReceived += (object sender2, DataReceivedEventArgs e2) =>
{
appendText(e2.Data);
appendText(Environment.NewLine);
};
nodejs.Start();
nodejs.BeginOutputReadLine();
nodejs.BeginErrorReadLine();
// nodejs.WaitForExit();
}
}
}
}

235
src/Form/NodeHelper.designer.cs generated Normal file
View File

@ -0,0 +1,235 @@
namespace HavokHelper
{
partial class NodeHelper
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.srcAssembly = new System.Windows.Forms.RadioButton();
this.srcCompiled = new System.Windows.Forms.RadioButton();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.destAssembly = new System.Windows.Forms.RadioButton();
this.destCompiled = new System.Windows.Forms.RadioButton();
this.button2 = new System.Windows.Forms.Button();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button3 = new System.Windows.Forms.Button();
this.textBox3 = new System.Windows.Forms.TextBox();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.openFileDialog2 = new System.Windows.Forms.OpenFileDialog();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(1, 196);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(418, 342);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.srcAssembly);
this.groupBox1.Controls.Add(this.srcCompiled);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Location = new System.Drawing.Point(1, 13);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(418, 74);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Source";
//
// srcAssembly
//
this.srcAssembly.AutoSize = true;
this.srcAssembly.Location = new System.Drawing.Point(74, 47);
this.srcAssembly.Name = "srcAssembly";
this.srcAssembly.Size = new System.Drawing.Size(69, 17);
this.srcAssembly.TabIndex = 3;
this.srcAssembly.Text = "Assembly";
this.srcAssembly.UseVisualStyleBackColor = true;
//
// srcCompiled
//
this.srcCompiled.AutoSize = true;
this.srcCompiled.Checked = true;
this.srcCompiled.Location = new System.Drawing.Point(0, 47);
this.srcCompiled.Name = "srcCompiled";
this.srcCompiled.Size = new System.Drawing.Size(68, 17);
this.srcCompiled.TabIndex = 2;
this.srcCompiled.TabStop = true;
this.srcCompiled.Text = "Compiled";
this.srcCompiled.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Location = new System.Drawing.Point(373, 18);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(39, 23);
this.button1.TabIndex = 1;
this.button1.Text = "...";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(0, 20);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(366, 20);
this.textBox1.TabIndex = 0;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.destAssembly);
this.groupBox2.Controls.Add(this.destCompiled);
this.groupBox2.Controls.Add(this.button2);
this.groupBox2.Controls.Add(this.textBox2);
this.groupBox2.Location = new System.Drawing.Point(1, 93);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(418, 68);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Dest";
//
// destAssembly
//
this.destAssembly.AutoSize = true;
this.destAssembly.Checked = true;
this.destAssembly.Location = new System.Drawing.Point(74, 47);
this.destAssembly.Name = "destAssembly";
this.destAssembly.Size = new System.Drawing.Size(69, 17);
this.destAssembly.TabIndex = 5;
this.destAssembly.TabStop = true;
this.destAssembly.Text = "Assembly";
this.destAssembly.UseVisualStyleBackColor = true;
//
// destCompiled
//
this.destCompiled.AutoSize = true;
this.destCompiled.Location = new System.Drawing.Point(0, 47);
this.destCompiled.Name = "destCompiled";
this.destCompiled.Size = new System.Drawing.Size(68, 17);
this.destCompiled.TabIndex = 4;
this.destCompiled.Text = "Compiled";
this.destCompiled.UseVisualStyleBackColor = true;
this.destCompiled.CheckedChanged += new System.EventHandler(this.destCompiled_CheckedChanged);
//
// button2
//
this.button2.Location = new System.Drawing.Point(373, 19);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(39, 23);
this.button2.TabIndex = 3;
this.button2.Text = "...";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(0, 21);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(366, 20);
this.textBox2.TabIndex = 2;
//
// button3
//
this.button3.Location = new System.Drawing.Point(338, 167);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 3;
this.button3.Text = "Execute";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(1, 169);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(331, 20);
this.textBox3.TabIndex = 4;
this.textBox3.Text = "N:\\Project\\Master\\Havok\\DsmAsm\\";
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
this.openFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk);
//
// openFileDialog2
//
this.openFileDialog2.FileName = "openFileDialog2";
this.openFileDialog2.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog2_FileOk);
//
// NodeHelper
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(416, 535);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.button3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.richTextBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "NodeHelper";
this.Text = "Havok Kore Script Helper";
this.Load += new System.EventHandler(this.NodeHelper_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton srcAssembly;
private System.Windows.Forms.RadioButton srcCompiled;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.RadioButton destAssembly;
private System.Windows.Forms.RadioButton destCompiled;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.OpenFileDialog openFileDialog2;
}
}

126
src/Form/NodeHelper.resx Normal file
View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="openFileDialog2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>157, 17</value>
</metadata>
</root>

View File

@ -1,71 +1,71 @@
using HavokHelper.Lua.Instructions.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class CallIInstruction : BaseInstruction
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class CallIInstruction : BaseInstruction
{
public override RegisterUsage GetAUsage()
public override RegisterUsage GetAUsage()
{
return RegisterUsage.Register;
return RegisterUsage.Register;
}
public override RegisterUsage GetBUsage()
public override RegisterUsage GetBUsage()
{
return RegisterUsage.Numeric;
return RegisterUsage.Numeric;
}
public override RegisterUsage GetCUsage()
public override RegisterUsage GetCUsage()
{
return RegisterUsage.Numeric;
return RegisterUsage.Numeric;
}
public override String AStringify(Stub Stub)
{
return null;
return null;
}
public override String BStringify(Stub Stub)
{
return null;
return null;
}
public override String CStringify(Stub Stub)
{
return null;
return null;
}
public override bool HasC()
{
return true;
}
public override String GetFullName()
{
return "HKS_OPCODE_CALL_I";
public override bool HasC()
{
return true;
}
public override String GetFullName()
{
return "HKS_OPCODE_CALL_I";
}
public override bool Implemented()
{
return true;
return true;
}
public override void Decompile(StringBuilder Buf, Stub OwnerStub, ref int Index)
{
CallHelper.DecompileCall(false, this, Buf, OwnerStub, Index);
CallHelper.DecompileCall(false, this, Buf, OwnerStub, Index);
}
public override void AttainPseudoCode(StringBuilder Buf)
{
Buf.Append("TODO:");
}
}
{
Buf.Append("TODO:");
}
}
}

View File

@ -1,71 +1,71 @@
using HavokHelper.Lua.Instructions.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class CallIR1Instruction : BaseInstruction
{
public override RegisterUsage GetAUsage()
{
return RegisterUsage.Register;
}
public override RegisterUsage GetBUsage()
{
return RegisterUsage.Numeric;
}
public override RegisterUsage GetCUsage()
{
return RegisterUsage.Numeric;
}
public override String AStringify(Stub Stub)
{
return null;
}
public override String BStringify(Stub Stub)
{
return null;
}
public override String CStringify(Stub Stub)
{
return null;
}
public override bool HasC()
{
return true;
}
public override String GetFullName()
{
return "HKS_OPCODE_CALL_I_R1";
}
public override bool Implemented()
{
return true;
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class CallIR1Instruction : BaseInstruction
{
public override RegisterUsage GetAUsage()
{
return RegisterUsage.Register;
}
public override RegisterUsage GetBUsage()
{
return RegisterUsage.Numeric;
}
public override RegisterUsage GetCUsage()
{
return RegisterUsage.Numeric;
}
public override String AStringify(Stub Stub)
{
return null;
}
public override String BStringify(Stub Stub)
{
return null;
}
public override String CStringify(Stub Stub)
{
return null;
}
public override bool HasC()
{
return true;
}
public override String GetFullName()
{
return "HKS_OPCODE_CALL_I_R1";
}
public override bool Implemented()
{
return true;
}
public override void Decompile(StringBuilder Buf, Stub OwnerStub, ref int Index)
{
CallHelper.DecompileCall(true, this, Buf, OwnerStub, Index);
}
public override void AttainPseudoCode(StringBuilder Buf)
{
Buf.Append("TODO:");
}
}
CallHelper.DecompileCall(true, this, Buf, OwnerStub, Index);
}
public override void AttainPseudoCode(StringBuilder Buf)
{
Buf.Append("TODO:");
}
}
}

View File

@ -1,70 +1,70 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class ClosureInstruction : BaseInstruction
{
public override RegisterUsage GetAUsage()
{
return RegisterUsage.Register;
}
public override RegisterUsage GetBUsage()
{
return RegisterUsage.Numeric;
}
public override RegisterUsage GetCUsage()
{
return RegisterUsage.NotImplemented;
}
public override String AStringify(Stub Stub)
{
return null;
}
public override String BStringify(Stub Stub)
{
return null;
}
public override String CStringify(Stub Stub)
{
return null;
}
public override bool HasC()
{
return false;
}
public override String GetFullName()
{
return "HKS_OPCODE_CLOSURE";
}
public override bool Implemented()
{
return true;
}
public override void Decompile(StringBuilder Buf, Stub OwnerStub, ref int Index)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class ClosureInstruction : BaseInstruction
{
public override RegisterUsage GetAUsage()
{
return RegisterUsage.Register;
}
public override RegisterUsage GetBUsage()
{
return RegisterUsage.Numeric;
}
public override RegisterUsage GetCUsage()
{
return RegisterUsage.NotImplemented;
}
public override String AStringify(Stub Stub)
{
return null;
}
public override String BStringify(Stub Stub)
{
return null;
}
public override String CStringify(Stub Stub)
{
return null;
}
public override bool HasC()
{
Buf.Append(String.Format("var_{0}\t= {1}", A, OwnerStub.Closures[B].AsFnString()));
}
public override void AttainPseudoCode(StringBuilder Buf)
return false;
}
public override String GetFullName()
{
String ahh = @"
return "HKS_OPCODE_CLOSURE";
}
public override bool Implemented()
{
return true;
}
public override void Decompile(StringBuilder Buf, Stub OwnerStub, ref int Index)
{
Buf.Append(String.Format("var_{0}\t= {1}", A, OwnerStub.Closures[B].AsFnString()));
}
public override void AttainPseudoCode(StringBuilder Buf)
{
String ahh = @"
a = R[a] = dest
b = PROTO(R[b]) = closure
@ -100,9 +100,9 @@ namespace HavokHelper.Lua.Instructions
a->m_method->m_upvals[i] = target; // R[nextInstruction b] I think
ip ++;
}
";
Buf.Append(ahh);
}
}
}
";
Buf.Append(ahh);
}
}
}

View File

@ -1,70 +1,70 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class DivBkInstruction : BaseInstruction
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class DivBkInstruction : BaseInstruction
{
public override RegisterUsage GetAUsage()
public override RegisterUsage GetAUsage()
{
return RegisterUsage.Register;
return RegisterUsage.Register;
}
public override RegisterUsage GetBUsage()
public override RegisterUsage GetBUsage()
{
return RegisterUsage.Constant;
return RegisterUsage.Constant;
}
public override RegisterUsage GetCUsage()
public override RegisterUsage GetCUsage()
{
return RegisterUsage.ConstantRegister;
return RegisterUsage.ConstantRegister;
}
public override String AStringify(Stub Stub)
{
return null;
return null;
}
public override String BStringify(Stub Stub)
{
return null;
return null;
}
public override String CStringify(Stub Stub)
{
return null;
return null;
}
public override bool HasC()
{
return true;
}
public override String GetFullName()
{
return "HKS_OPCODE_DIV_BK";
public override bool HasC()
{
return true;
}
public override String GetFullName()
{
return "HKS_OPCODE_DIV_BK";
}
public override bool Implemented()
{
return true;
return true;
}
public override void Decompile(StringBuilder Buf, Stub OwnerStub, ref int Index)
{
Buf.Append(String.Format("{0}\t= {1} / {2}", OwnerStub.DecompileInstruction_A(this), OwnerStub.DecompileInstruction_B(this), OwnerStub.DecompileInstruction_C(this)));
Buf.Append(String.Format("{0}\t= {1} / {2}", OwnerStub.DecompileInstruction_A(this), OwnerStub.DecompileInstruction_B(this), OwnerStub.DecompileInstruction_C(this)));
}
public override void AttainPseudoCode(StringBuilder Buf)
{
Buf.Append("TODO:");
}
}
{
Buf.Append("TODO:");
}
}
}

View File

@ -1,70 +1,70 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class DivInstruction : BaseInstruction
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class DivInstruction : BaseInstruction
{
public override RegisterUsage GetAUsage()
public override RegisterUsage GetAUsage()
{
return RegisterUsage.Register;
return RegisterUsage.Register;
}
public override RegisterUsage GetBUsage()
public override RegisterUsage GetBUsage()
{
return RegisterUsage.ConstantRegister;
return RegisterUsage.ConstantRegister;
}
public override RegisterUsage GetCUsage()
public override RegisterUsage GetCUsage()
{
return RegisterUsage.ConstantRegister;
return RegisterUsage.ConstantRegister;
}
public override String AStringify(Stub Stub)
{
return null;
return null;
}
public override String BStringify(Stub Stub)
{
return null;
return null;
}
public override String CStringify(Stub Stub)
{
return null;
return null;
}
public override bool HasC()
{
return true;
}
public override String GetFullName()
{
return "HKS_OPCODE_DIV";
public override bool HasC()
{
return true;
}
public override String GetFullName()
{
return "HKS_OPCODE_DIV";
}
public override bool Implemented()
{
return true;
return true;
}
public override void Decompile(StringBuilder Buf, Stub OwnerStub, ref int Index)
{
Buf.Append(String.Format("{0}\t= {1} / {2}", OwnerStub.DecompileInstruction_A(this), OwnerStub.DecompileInstruction_B(this), OwnerStub.DecompileInstruction_C(this)));
Buf.Append(String.Format("{0}\t= {1} / {2}", OwnerStub.DecompileInstruction_A(this), OwnerStub.DecompileInstruction_B(this), OwnerStub.DecompileInstruction_C(this)));
}
public override void AttainPseudoCode(StringBuilder Buf)
{
Buf.Append("TODO:");
}
}
{
Buf.Append("TODO:");
}
}
}

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions.Helpers
{
@ -21,11 +22,11 @@ namespace HavokHelper.Lua.Instructions.Helpers
if (Cur.C > 1)
{
int ReturnParameters;
ReturnParameters = Cur.C - 1;
ReturnParameters = Cur.C - 1; // TODO: could be -2
if (ReturnParameters != 0)
{
for (int I = 0; I < ReturnParameters; I++)
ReturnVals.Append("val_" + I + ", ");
ReturnVals.Append("var_" + (I + Cur.A) + ", ");
ReturnVals.Remove(ReturnVals.Length - 2, 2);
ReturnVals.Append("\t= ");
}
@ -34,11 +35,11 @@ namespace HavokHelper.Lua.Instructions.Helpers
{
ReturnVals.Append("--[[top = last_result+1]]");
}
for (int Reg = Cur.A + 1; Reg < Cur.A + Cur.B; Reg++)
Parameters.Append(String.Format("val_{0}, ", Reg));
if (Parameters.Length != 0)
for (int Reg = Cur.A + 1; Reg < Cur.A + Cur.B; Reg++)
Parameters.Append(String.Format("var_{0}, ", Reg));
if (Parameters.Length != 0)
Parameters.Remove(Parameters.Length - 2, 2);
Buf.Append(String.Format("{0}{1}({2})", ReturnVals.ToString(), FuncName, Parameters.ToString()));

View File

@ -1,70 +1,70 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class PowInstruction : BaseInstruction
{
public override RegisterUsage GetAUsage()
{
return RegisterUsage.Register;
}
public override RegisterUsage GetBUsage()
{
return RegisterUsage.ConstantRegister;
}
public override RegisterUsage GetCUsage()
{
return RegisterUsage.ConstantRegister;
}
public override String AStringify(Stub Stub)
{
return null;
}
public override String BStringify(Stub Stub)
{
return null;
}
public override String CStringify(Stub Stub)
{
return null;
}
public override bool HasC()
{
return true;
}
public override String GetFullName()
{
return "HKS_OPCODE_POW";
}
public override bool Implemented()
{
return true;
}
public override void Decompile(StringBuilder Buf, Stub OwnerStub, ref int Index)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class PowInstruction : BaseInstruction
{
public override RegisterUsage GetAUsage()
{
return RegisterUsage.Register;
}
public override RegisterUsage GetBUsage()
{
return RegisterUsage.ConstantRegister;
}
public override RegisterUsage GetCUsage()
{
return RegisterUsage.ConstantRegister;
}
public override String AStringify(Stub Stub)
{
return null;
}
public override String BStringify(Stub Stub)
{
return null;
}
public override String CStringify(Stub Stub)
{
return null;
}
public override bool HasC()
{
return true;
}
public override String GetFullName()
{
return "HKS_OPCODE_POW";
}
public override bool Implemented()
{
return true;
}
public override void Decompile(StringBuilder Buf, Stub OwnerStub, ref int Index)
{
Buf.Append(String.Format("{0}\t= {1} ^ {2}", OwnerStub.DecompileInstruction_A(this), OwnerStub.DecompileInstruction_B(this), OwnerStub.DecompileInstruction_C(this)));
}
public override void AttainPseudoCode(StringBuilder Buf)
{
}
}
public override void AttainPseudoCode(StringBuilder Buf)
{
}
}
}

View File

@ -1,72 +1,72 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class SelfInstruction : BaseInstruction
{
public override RegisterUsage GetAUsage()
{
return RegisterUsage.Register;
}
public override RegisterUsage GetBUsage()
{
return RegisterUsage.Register;
}
public override RegisterUsage GetCUsage()
{
return RegisterUsage.ConstantRegister;
}
public override String AStringify(Stub Stub)
{
return null;
}
public override String BStringify(Stub Stub)
{
return null;
}
public override String CStringify(Stub Stub)
{
return null;
}
public override bool HasC()
{
return true;
}
public override String GetFullName()
{
return "HKS_OPCODE_SELF";
}
public override bool Implemented()
{
return true;
}
public override void Decompile(StringBuilder Buf, Stub OwnerStub, ref int Index)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HavokHelper.Lua.Instructions
{
public class SelfInstruction : BaseInstruction
{
public override RegisterUsage GetAUsage()
{
return RegisterUsage.Register;
}
public override RegisterUsage GetBUsage()
{
return RegisterUsage.Register;
}
public override RegisterUsage GetCUsage()
{
return RegisterUsage.ConstantRegister;
}
public override String AStringify(Stub Stub)
{
return null;
}
public override String BStringify(Stub Stub)
{
return null;
}
public override String CStringify(Stub Stub)
{
return null;
}
public override bool HasC()
{
return true;
}
public override String GetFullName()
{
return "HKS_OPCODE_SELF";
}
public override bool Implemented()
{
return true;
}
public override void Decompile(StringBuilder Buf, Stub OwnerStub, ref int Index)
{
Buf.Append( String.Format("var_{0}\t= {1}\n", A + 1, OwnerStub.DecompileInstruction_B(this)) +
String.Format("{0}\t= {1}[{2}]\n", OwnerStub.DecompileInstruction_A(this), OwnerStub.DecompileInstruction_B(this), OwnerStub.DecompileInstruction_C(this)) +
String.Format("R1\t\t= {0}", OwnerStub.DecompileInstruction_A(this)));
}
public override void AttainPseudoCode(StringBuilder Buf)
{
Buf.Append(
String.Format("{0}\t= {1}[{2}]\n", OwnerStub.DecompileInstruction_A(this), OwnerStub.DecompileInstruction_B(this), OwnerStub.DecompileInstruction_C(this)) +
String.Format("R1\t\t= {0}", OwnerStub.DecompileInstruction_A(this)));
}
public override void AttainPseudoCode(StringBuilder Buf)
{
Buf.Append(
"R1\t\t= dest_r1 \n" +
"A\t= R[A]\t= dest_a \n" +
"A_one\t= R[A + 1]= dest_a_one \n" +
@ -75,7 +75,7 @@ namespace HavokHelper.Lua.Instructions
" \n" +
"dest_a_one\t= table \n" +
"dest_a\t\t= table[key] \n" +
"dest_r1\t\t= dest_a");
}
}
"dest_r1\t\t= dest_a");
}
}
}

View File

@ -12,7 +12,7 @@ namespace HavokHelper.src.Parser
{
// port of https://bitbucket.org/codt6/luadsm/src/master/asm/assembler.js
// asm derived from https://bitbucket.org/codt6/luadsm/src/master/asm/disassembler.js
// this shit is ugly as fuck lol
// this really needs to be rewritten
public class JSParserPort
{
@ -32,8 +32,8 @@ namespace HavokHelper.src.Parser
protected static LineData[] ParseLine(String line)
{
if (line.IndexOf(';') != -1)
line = line.Substring(0, line.IndexOf(';'));
//if (line.IndexOf(';') != -1)
// line = line.Substring(0, line.IndexOf(';'));
String[] strs = line.Replace('\t', ' ') // convert tabs into spaces
.Replace(',', ' ') // convert ,'s into spaces
@ -49,11 +49,20 @@ namespace HavokHelper.src.Parser
bool Hack = false;
int I = 0;
strs.ToArray().ToList().ForEach((item) =>
StringBuilder sb = new StringBuilder();
foreach (var item in strs)
{
if (Hack) return;
LineData data = new LineData();
if (item.Length == 0) return;
if (item.Length == 0)
continue;
if (Hack)
{
sb.Append(item);
continue;
}
ret[I++] = data;
data.Raw = item;
@ -68,8 +77,17 @@ namespace HavokHelper.src.Parser
data.BoolVal = item.Equals("true");
data.BoolPresent = true;
}
else if (item.StartsWith("\""))
{
sb.Append(item.Substring(1));
Hack = true;
}
}
});
if (Hack)
{
ret[I - 1].Raw = sb.ToString().Substring(0, sb.Length - 1);
}
if (0 == I) return null;