forked from az64/mm-rando
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VC_Inject.cs
48 lines (41 loc) · 1.47 KB
/
VC_Inject.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace MMRando
{
public partial class ROMFuncs
{
private static void GetApp5(byte[] ROM, string VCDir)
{
BinaryReader a50 = new BinaryReader(File.Open(VCDir + "5-0", FileMode.Open));
BinaryReader a51 = new BinaryReader(File.Open(VCDir + "5-1", FileMode.Open));
BinaryWriter app5 = new BinaryWriter(File.Open(VCDir + "00000005.app", FileMode.Create));
byte[] buffer = new byte[a50.BaseStream.Length];
a50.Read(buffer, 0, buffer.Length);
app5.Write(buffer);
app5.Write(ROM);
buffer = new byte[a51.BaseStream.Length];
a51.Read(buffer, 0, buffer.Length);
app5.Write(buffer);
a50.Close();
a51.Close();
app5.Close();
}
private static byte[] AddVCHeader(byte[] ROM)
{
byte[] Header = new byte[] { 0x08, 0x00, 0x00, 0x00 };
return Header.Concat(ROM).ToArray();
}
public static void BuildVC(byte[] ROM, string VCDir, string FileName)
{
ROM = AddVCHeader(ROM);
GetApp5(ROM, VCDir);
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = "wadpacker.exe";
p.Arguments = "mm.tik mm.tmd mm.cert \"" + FileName + "\" -i NMRE";
p.WorkingDirectory = VCDir;
Process.Start(p);
}
}
}