コード例 #1
0
ファイル: Program.cs プロジェクト: imthe666st/NTRClient
        private static void Main()
        {
            try
            {
                PyEngine = Python.CreateEngine();
                NtrClient = new NtrClient();
                ScriptHelper = new ScriptHelper();

                GlobalScope = PyEngine.CreateScope();
                GlobalScope.SetVariable("nc", ScriptHelper);

                LoadConfig();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                GCmdWindow = new CmdWindow();
                Dc = new DebugConsole();
                Application.Run(GCmdWindow);
            }
            catch (Exception e)
            {
                BugReporter br = new BugReporter(e, "Program exception");
                MessageBox.Show(
                    @"WARNING - NTRDebugger has encountered an error" + Environment.NewLine +
                    @"This error is about to crash the program, please send the generated" + Environment.NewLine +
                    @"Error log to imthe666st!" + Environment.NewLine + Environment.NewLine +
                    @"Sorry for the inconvinience -imthe666st"
                    );
            }
        }
コード例 #2
0
ファイル: CmdWindow.cs プロジェクト: imthe666st/NTRClient
        private void updateTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                Program.NtrClient.SendHeartbeatPacket();

                if (_hbc != null)
                {
                    label_heart_status.Text = _hbc.Status()
                        ? @"Heartbeat status: Running"
                        : @"Heartbeat status: OFFLINE";
                }
                else
                    label_heart_status.Text = @"Heartbeat status: OFFLINE";

                // Update check
                if (_lookedForUpdate == false)
                {
                    LookForUpdate();
                }
            }
            catch (Exception ex)
            {
                BugReporter br = new BugReporter(ex, "Timer exception");
            }
        }
コード例 #3
0
ファイル: Octo.cs プロジェクト: imthe666st/NTRClient
 public static async Task<Release> GetLastUpdate()
 {
     try
     {
         IReadOnlyList<Release> lastReleases = await Rep.Release.GetAll("imthe666st", "NTRClient");
         LastRelease = lastReleases[0];
         return LastRelease;
     }
     catch (Exception e)
     {
         MessageBox.Show(@"An error occured trying to look for updates!");
         BugReporter br = new BugReporter(e, "Updater exception", false);
         return null;
     }
 }
コード例 #4
0
 public static void SaveToXml(string filePath, SettingsManager sourceObj)
 {
     try
     {
         using (StreamWriter writer = new StreamWriter(filePath))
         {
             System.Xml.Serialization.XmlSerializer xmlSerializer =
                 new System.Xml.Serialization.XmlSerializer(sourceObj.GetType());
             xmlSerializer.Serialize(writer, sourceObj);
         }
     }
     catch (Exception ex)
     {
         BugReporter br = new BugReporter(ex, "XML save exception");
     }
 }
コード例 #5
0
 public static SettingsManager LoadFromXml(string filePath)
 {
     try
     {
         using (StreamReader reader = new StreamReader(filePath))
         {
             System.Xml.Serialization.XmlSerializer xmlSerializer =
                 new System.Xml.Serialization.XmlSerializer(typeof (SettingsManager));
             return (SettingsManager) xmlSerializer.Deserialize(reader);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(@"Ignore this message if you just downloaded or updated this tool..." +
                         Environment.NewLine + Environment.NewLine + ex.Message);
         BugReporter br = new BugReporter(ex, "XML Load exception", false);
     }
     return new SettingsManager();
 }
コード例 #6
0
ファイル: Utility.cs プロジェクト: imthe666st/NTRClient
 public static int RunCommandAndGetOutput(string exeFile, string args, ref string output)
 {
     try
     {
         Process proc = new Process
         {
             StartInfo = new ProcessStartInfo
             {
                 FileName = exeFile,
                 Arguments = args,
                 RedirectStandardOutput = true,
                 CreateNoWindow = true,
                 UseShellExecute = false,
                 RedirectStandardError = true
             }
         };
         proc.Start();
         proc.WaitForExit();
         var processOutput = proc.StandardError.ReadToEnd();
         processOutput += proc.StandardOutput.ReadToEnd();
         var ret = proc.ExitCode;
         output = processOutput;
         proc.Close();
         return ret;
     }
     catch (System.ComponentModel.Win32Exception e) {
         output = String.Format ("Could not open '{0}'. Make sure it is on your executable path.", exeFile);
         Console.Error.WriteLine (e);
         return -1;
     }
     catch (Exception e)
     {
         output = e.Message;
         BugReporter br = new BugReporter(e, "Run CMD exception", false);
         return -1;
     }
 }
コード例 #7
0
ファイル: DebugConsole.cs プロジェクト: imthe666st/NTRClient
        public void ExecuteCommand(string n)
        {
            Addlog(n);
            textBox_cmd.Clear();
            string[] args = n.Split(' ');
            string cmd = args[0];

            if (cmd == "close")
            {
                Hide();
            }
            else if (cmd == "gs_use")
            {
                if (args.Length == 1)
                {
                    Addlog(string.Format("GS_USE: {0}", Program.Sm.GsUsed));
                }
                else if (args.Length >= 3)
                {
                    try
                    {
                        int a = Convert.ToInt32(args[2]);

                        if (args[1] == "set")
                        {
                            Program.Sm.GsUsed = a;
                            Addlog(string.Format("GS_USE: {0}", Program.Sm.GsUsed));
                        }
                        else if (args[1] == "add")
                        {
                            Program.Sm.GsUsed += a;
                            if (Program.Sm.GsUsed < 0)
                            {
                                Program.Sm.GsUsed = 0;
                            }
                            Addlog(string.Format("GS_USE: {0}", Program.Sm.GsUsed));
                        }
                        else
                        {
                            Addlog("USAGE: gs_use <cmd> <amount>");
                        }
                    }
                    catch (Exception)
                    {
                        Addlog("USAGE: gs_use " + args[1] + " <amount>");
                    }
                }
                else
                {
                    Addlog("USAGE: gs_use <cmd> <amount>");
                }
            }
            else if (cmd == "update")
            {
                string nVersion = Octo.GetLastVersionName();
                string nBody = Octo.GetLastVersionBody();
                MessageBox.Show(
                    @"A new Update has been released!" + Environment.NewLine +
                    nVersion + Environment.NewLine + Environment.NewLine +
                    nBody
                    );
            }
            else if (cmd == "error")
            {
                Addlog("Generating error file");
                BugReporter br = new BugReporter(new Exception("User generated exception"), "User generated exception");
            }
        }
コード例 #8
0
ファイル: CmdWindow.cs プロジェクト: imthe666st/NTRClient
 private void button_dummy_write_dec_Click(object sender, EventArgs e)
 {
     try
     {
         int addr = Convert.ToInt32(textBox_dummy_addr.Text, 16);
         uint v = Convert.ToUInt32(textBox_dummy_value_dec.Text, 10);
         RunCmd(GenerateWriteString(addr, v, (uint)numericUpDown_dummy_length.Value));
     }
     catch (Exception ex)
     {
         BugReporter br = new BugReporter(ex,
             @"Dummy HEX write Exception [" + textBox_dummy_addr.Text + @" -> " + textBox_dummy_value_hex + @"]");
     }
 }
コード例 #9
0
ファイル: CmdWindow.cs プロジェクト: imthe666st/NTRClient
 public string RunCmd(string cmd)
 {
     try
     {
         Addlog("> " + cmd);
         object ret = Program.PyEngine.CreateScriptSourceFromString(cmd).Execute(Program.GlobalScope);
         if (ret != null)
         {
             Addlog(ret.ToString());
             return ret.ToString();
         }
             Addlog("null");
             return "";
         }
     catch (Exception ex)
     {
         Addlog(ex.Message);
         BugReporter br = new BugReporter(ex, "Command execution exception", false);
         return "";
     }
 }
コード例 #10
0
ファイル: CmdWindow.cs プロジェクト: imthe666st/NTRClient
        private void button_debug_conv_dec_Click(object sender, EventArgs e)
        {
            try
            {
                int v = Convert.ToInt32(textBox_debug_conv_dec.Text, 10);

                textBox_debug_conv_hex.Text = string.Format("{0:X}", v);
                textBox_debug_conv_hex_le.Text = string.Format("{0:X}",
                    FromLe(v, (int)numericUpDown_debug_hextest.Value));
            }
            catch (Exception ex)
            {
                BugReporter br = new BugReporter(ex, "Debug Convert DEC Exception");
            }
        }
コード例 #11
0
ファイル: NtrClient.cs プロジェクト: imthe666st/NTRClient
        private void PacketRecvThreadStart()
        {
            byte[] buf = new byte[84];
            uint[] args = new uint[16];
            NetworkStream stream = NetStream;

            while (true)
            {
                try
                {
                    int ret = ReadNetworkStream(stream, buf, buf.Length);
                    if (ret == 0)
                    {
                        break;
                    }
                    int t = 0;
                    uint magic = BitConverter.ToUInt32(buf, t);
                    t += 4;
                    uint seq = BitConverter.ToUInt32(buf, t);
                    t += 4;
                    uint type = BitConverter.ToUInt32(buf, t);
                    t += 4;
                    uint cmd = BitConverter.ToUInt32(buf, t);
                    for (int i = 0; i < args.Length; i++)
                    {
                        t += 4;
                        args[i] = BitConverter.ToUInt32(buf, t);
                    }
                    t += 4;
                    uint dataLen = BitConverter.ToUInt32(buf, t);
                    
                    if (cmd != 0)
                    {
                        Log(string.Format("packet: cmd = {0}, dataLen = {1}", cmd, dataLen));
                    }

                    if (magic != 0x12345678)
                    {
                        Log(string.Format("broken protocol: magic = {0}, seq = {1}", magic, seq));
                        break;
                    }

                    if (cmd == 0)
                    {
                        if (dataLen != 0)
                        {
                            byte[] dataBuf = new byte[dataLen];
                            ReadNetworkStream(stream, dataBuf, dataBuf.Length);
                            string logMsg = Encoding.UTF8.GetString(dataBuf);
                            // Tinkering even more with the Debugger

                            if (logMsg.StartsWith("valid memregions:"))
                            {
                                // Setting memregions 
                                Program.GCmdWindow.textBox_memlayout.Invoke(
                                    new CmdWindow.SetMemregionsCallback(Program.GCmdWindow.SetMemregions), logMsg);
                            }
                            else if (logMsg.StartsWith("patching smdh") || logMsg.StartsWith("rtRecvSocket failed: "))
                            {
                                Program.GCmdWindow.RunProcessesCmd();
                            }
                            else if(logMsg.StartsWith("pid: "))
                            {
                                Program.GCmdWindow.textBox_processes.Invoke(
                                    new CmdWindow.SetProcessesCallback(Program.GCmdWindow.SetProcesses), logMsg);
                            }
                            // END

                            Log(logMsg);
                        }
                        lock (_syncLock)
                        {
                            _heartbeatSendable = 1;
                        }
                        continue;
                    }
                    if (dataLen != 0)
                    {
                        byte[] dataBuf = new byte[dataLen];
                        ReadNetworkStream(stream, dataBuf, dataBuf.Length);
                        HandlePacket(cmd, seq, dataBuf);
                    }
                }
                catch (Exception e)
                {
                    Log(e.Message);
                    Log(e.StackTrace);
                    BugReporter br = new BugReporter(e, "Packet receiver exception");
                    break;
                }
            }

            Log("Server disconnected.");
            Disconnect(false);
        }
コード例 #12
0
ファイル: NtrClient.cs プロジェクト: imthe666st/NTRClient
 public void Log(string msg)
 {
     OnLogArrival?.Invoke(msg);
     try
     {
         Program.GCmdWindow.BeginInvoke(Program.GCmdWindow.DelAddLog, msg);
     }
     catch (Exception ex)
     {
         BugReporter br = new BugReporter(ex, "Logging exception");
     }
 }