private void ImmediateSwap(object sender, EventArgs e) { try { gecko.Pause(); gecko.poke(sourceFile.dataAddress, targetFile.offset); gecko.poke(sourceFile.dataAddress + 1, targetFile.entries); gecko.Resume(); MessageBox.Show("Files swapped"); } catch (EUSBGeckoException exc) { exceptionHandling.HandleException(exc); } }
public void Assemble(UInt32 address, String command) { if (!File.Exists(GAs)) { MessageBox.Show(GAs + " not found! Cannot assemble!"); return; } if (!File.Exists(GLd)) { MessageBox.Show(GLd + " not found! Cannot assemble!"); return; } if (!File.Exists(GOc)) { MessageBox.Show(GOc + " not found! Cannot assemble!"); return; } command = command.Trim(); if (isBranch(command)) { if (!extractTargetAddress(address, ref command)) { MessageBox.Show("Command parsing error!"); return; } } StreamWriter sw = new StreamWriter("ass.txt"); sw.WriteLine(command); sw.Close(); Process proc = new Process(); proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; proc.StartInfo.UseShellExecute = false; proc.StartInfo.FileName = GAs; proc.StartInfo.Arguments = "-mgekko -mregnames -o ass.o ass.txt"; proc.StartInfo.CreateNoWindow = true; proc.StartInfo.RedirectStandardError = true; proc.Start(); String output = String.Empty; while (!proc.StandardError.EndOfStream) { output += proc.StandardError.ReadLine() + "\n"; } proc.WaitForExit(/*2000*/); int exitCode = proc.ExitCode; proc.Close(); File.Delete("ass.txt"); if (exitCode != 0 || !File.Exists("ass.o")) { if (File.Exists("ass.o")) { File.Delete("ass.o"); } MessageBox.Show(output); return; } proc = new Process(); proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; proc.StartInfo.UseShellExecute = false; proc.StartInfo.FileName = GLd; proc.StartInfo.Arguments = " -Ttext 0x80000000 -o ass2.o ass.o"; proc.StartInfo.CreateNoWindow = true; proc.StartInfo.RedirectStandardError = true; proc.Start(); output = String.Empty; while (!proc.StandardError.EndOfStream) { output += proc.StandardError.ReadLine() + "\n"; } proc.WaitForExit(); exitCode = proc.ExitCode; proc.Close(); File.Delete("ass.o"); if (exitCode != 0 || !File.Exists("ass2.o")) { if (File.Exists("ass2.o")) { File.Delete("ass2.o"); } MessageBox.Show(output); return; } proc = new Process(); proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; proc.StartInfo.UseShellExecute = false; proc.StartInfo.FileName = GOc; proc.StartInfo.Arguments = " -O binary ass2.o ass.bin"; proc.StartInfo.CreateNoWindow = true; proc.StartInfo.RedirectStandardError = true; proc.Start(); output = String.Empty; while (!proc.StandardError.EndOfStream) { output += proc.StandardError.ReadLine() + "\n"; } proc.WaitForExit(); exitCode = proc.ExitCode; proc.Close(); File.Delete("ass2.o"); if (exitCode != 0) { if (File.Exists("ass.bin")) { File.Delete("ass.bin"); } MessageBox.Show(output); return; } UInt32 machineCode; FileStream sr = new FileStream("ass.bin", FileMode.Open); machineCode = GlobalFunctions.ReadStream(sr); sr.Close(); File.Delete("ass.bin"); try { gecko.poke(address, machineCode); System.Threading.Thread.Sleep(100); DissToBox(address); } catch (EUSBGeckoException e) { exceptionHandling.HandleException(e); } }