public static void Main(string[] args) { using (var input = File.OpenRead(@"C:\src\w2\compiledscripts.w2scripts")) { var test = new CompiledScriptsFile(); test.Deserialize(input); for (int i = 0; i < test.TypeDefs.Length; i++) { Console.WriteLine(i + ". " + test.TypeDefs[i]); if (test.TypeDefs[i] is FileFormats.Script.ClassDefinition) { var classDef = test.TypeDefs[i] as FileFormats.Script.ClassDefinition; foreach (var propDef in classDef.Properties) { Console.WriteLine(" " + propDef.Value); } Console.WriteLine(); foreach (var funcDef in classDef.Functions) { Console.WriteLine(" " + funcDef.Value); } } } Console.WriteLine("\n\nFUNCTIONS:"); for (int index = 0; index < test.FuncDefs.Length; index++) { var funcDef = test.FuncDefs[index]; Console.WriteLine(index + ". " + funcDef); funcDef.DisassembleToConsole(); } } }
static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("Usage: Gibbed.RED.ScriptDecompiler <path to compiledscripts.w2scripts>"); return; } var input = File.OpenRead(args[0]); var scriptFile = new CompiledScriptsFile(); scriptFile.Deserialize(input); input.Close(); foreach (var typedef in scriptFile.TypeDefs) { if (typedef is ClassDefinition) { DecompileClass((ClassDefinition)typedef, Console.Out); } else if (typedef is EnumDefinition) { DecompileEnum((EnumDefinition)typedef, Console.Out); } } foreach (var func in scriptFile.FuncDefs) { if (func.ContainingClass == null) { DecompileFunction(func, Console.Out, ""); } } }
static void Main(string[] args) { if (args.Length != 2) { Console.WriteLine("Usage: Gibbed.RED.Diff <old.w2scripts> <new.w2scripts>"); return; } var oldScripts = new CompiledScriptsFile(); var newScripts = new CompiledScriptsFile(); using (var oldInput = File.OpenRead(args[0])) { oldScripts.Deserialize(oldInput); } using (var newInput = File.OpenRead(args[1])) { newScripts.Deserialize(newInput); } var oldFunctions = new Dictionary <string, FunctionDefinition>(); foreach (var def in oldScripts.FuncDefs) { oldFunctions[def.ToString()] = def; } foreach (var def in newScripts.FuncDefs) { if (!oldFunctions.ContainsKey(def.ToString())) { Console.WriteLine("\n\n\nNew function: " + def); def.DisassembleToConsole(); } else { var oldDef = oldFunctions[def.ToString()]; if (!oldDef.Equals(def)) { Console.WriteLine("\n\n\nChanged function: " + def); Console.WriteLine("Old bytecode: "); oldDef.DisassembleToConsole(); Console.WriteLine("New bytecode: "); def.DisassembleToConsole(); } } } }
public StringConst(CompiledScriptsFile scripts) { _scripts = scripts; }
public FinalFunc(CompiledScriptsFile scripts) { _scripts = scripts; }
public TypeRef(Opcode opcode, CompiledScriptsFile scripts) { _opcode = opcode; _scripts = scripts; }
public FinalFunc(CompiledScriptsFile scripts) { _scripts = scripts; }
public U16S32(Opcode opcode, CompiledScriptsFile scripts) { _opcode = opcode; _scripts = scripts; }
public VirtualFunc(CompiledScriptsFile scripts) { _scripts = scripts; }
public TypeMember(Opcode opcode, CompiledScriptsFile scripts) { _opcode = opcode; _scripts = scripts; }
public Constructor(CompiledScriptsFile scripts) { _scripts = scripts; }
public Constructor(CompiledScriptsFile scripts) { _scripts = scripts; }
public U16S32(Opcode opcode, CompiledScriptsFile scripts) { _opcode = opcode; _scripts = scripts; }
public StringConst(CompiledScriptsFile scripts) { _scripts = scripts; }
public VirtualFunc(CompiledScriptsFile scripts) { _scripts = scripts; }