Skip to content

Commit b481987

Browse files
committed
fixes
1 parent ea4fb84 commit b481987

File tree

11 files changed

+581
-7
lines changed

11 files changed

+581
-7
lines changed

VM/Program.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ unsafe class Program
1313
{
1414
static void Main(string[] args)
1515
{
16-
VirtualMachine vm = new VirtualMachine(File.ReadAllBytes("vmtest"));
17-
//Console.WriteLine(String.Join("-", BitConverter.GetBytes((int)120).Select(x => x.ToString("x2"))));
16+
VirtualMachine vm;
17+
if (args.Length > 0)
18+
vm = new VirtualMachine(File.ReadAllBytes(args[0]));
19+
else
20+
vm = new VirtualMachine(File.ReadAllBytes("vmtest"));
1821
vm.Run(0);
1922

2023
Console.WriteLine("");
@@ -123,13 +126,14 @@ public void Run(int Offset)
123126
int argcount = Marshal.ReadInt32(MemoryPointer, CodeSectionOffset + Offset + 16);
124127
Type[] types = new Type[argcount];
125128
object[] arguments = new object[argcount];
126-
for (int i = 0; i < argcount; i++)
129+
for (int i = argcount - 1; i > -1; i--)
127130
{
128-
temp = new byte[Marshal.ReadInt32(MemoryPointer, CodeSectionOffset + Offset + 20 + i * 4)];
131+
temp = new byte[Marshal.ReadInt32(MemoryPointer, CodeSectionOffset + Offset + 20 + i * 8)];
132+
129133
Marshal.Copy(
130134
IntPtr.Add(MemoryPointer,
131135
CSharpTypesSectionOffset + Marshal.ReadInt32(MemoryPointer,
132-
CodeSectionOffset + Offset + 24 + i * 4)), temp, 0, temp.Length);
136+
CodeSectionOffset + Offset + 24 + i * 8)), temp, 0, temp.Length);
133137
types[i] = Type.GetType(Encoding.UTF8.GetString(temp));
134138
arguments[i] = pop();
135139
}

VMCompiler/Form1.Designer.cs

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VMCompiler/Form1.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.IO;
55
using System.Text;
66
using System.Linq;
7+
using System.Reflection;
78
using System.Text.RegularExpressions;
89
using System.Windows.Forms;
910

@@ -458,10 +459,10 @@ private void Compile()
458459
for (int a = 0; a < vd.Arguments.Length; a++)
459460
{
460461
Array.Copy(BitConverter.GetBytes(vd.Arguments[a].Length), 0, CodeSection,
461-
CodeSection.Length - vd.Length + 21 + a * 4, 4);
462+
CodeSection.Length - vd.Length + 21 + a * 8, 4);
462463

463464
Array.Copy(BitConverter.GetBytes(vd.Arguments[a].Start), 0, CodeSection,
464-
CodeSection.Length - vd.Length + 25 + a * 4, 4);
465+
CodeSection.Length - vd.Length + 25 + a * 8, 4);
465466
}
466467
}
467468
break;
@@ -661,5 +662,15 @@ private void Highlight(string text, int offset)
661662
richTextBox1.SelectionColor = ColorTranslator.FromHtml("#27ae60");
662663
}
663664
}
665+
666+
private void getTypeToolStripMenuItem_Click(object sender, EventArgs e)
667+
{
668+
new GetTypeName().Show();
669+
}
670+
671+
private void getMethodsInTypeToolStripMenuItem_Click(object sender, EventArgs e)
672+
{
673+
new GetTypeMethods().Show();
674+
}
664675
}
665676
}

VMCompiler/Form1.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,7 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120+
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121+
<value>17, 17</value>
122+
</metadata>
120123
</root>

VMCompiler/GetTypeMethods.Designer.cs

Lines changed: 103 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VMCompiler/GetTypeMethods.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Windows.Forms;
9+
10+
namespace VMCompiler
11+
{
12+
public partial class GetTypeMethods : Form
13+
{
14+
public GetTypeMethods()
15+
{
16+
InitializeComponent();
17+
}
18+
19+
private void button1_Click(object sender, EventArgs e)
20+
{
21+
Type type = Type.GetType(textBox1.Text);
22+
foreach (var method in type.GetMethods())
23+
{
24+
if (method.Name.Contains(textBox3.Text))
25+
{
26+
textBox2.Text += type.Name + ":" + method.Name + "(" + String.Join(",", method.GetParameters().Select(x => x.ParameterType.Name)) + ")" + "\r\n";
27+
}
28+
}
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)