Guest User

Untitled

a guest
May 4th, 2014
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.34 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3. using XDevkit;
  4. using System.Diagnostics;
  5.  
  6. namespace WindowsFormsApplication1
  7. {
  8.     static class Program
  9.     {
  10.         public class Form1 : Form
  11.         {
  12.             public TextBox textBox1;
  13.             static uint sprintfAddress = 0x82012F48;
  14.             static IXboxManager xbm;
  15.             static XboxConsole xboxConsole;
  16.  
  17.             public Form1()
  18.             {
  19.                 InitializeComponent();
  20.             }
  21.  
  22.             private void InitializeComponent()
  23.             {
  24.                 this.textBox1 = new System.Windows.Forms.TextBox();
  25.                 this.SuspendLayout();
  26.                 //  
  27.                 // textBox1
  28.                 //  
  29.                 this.textBox1.AcceptsReturn = true;
  30.                 this.textBox1.AcceptsTab = true;
  31.                 this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
  32.                 this.textBox1.Multiline = true;
  33.                 this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
  34.                 //  
  35.                 // Form1
  36.                 //  
  37.                 this.ClientSize = new System.Drawing.Size(284, 264);
  38.                 this.Controls.Add(this.textBox1);
  39.                 this.Text = "TextBox Example";
  40.                 this.ResumeLayout(false);
  41.                 this.PerformLayout();
  42.  
  43.                 xbm = new XboxManager();
  44.                 xboxConsole = xbm.OpenConsole(xbm.DefaultConsole);
  45.                 xboxConsole.DebugTarget.SetBreakpoint(sprintfAddress);
  46.                 xboxConsole.OnStdNotify += new XboxEvents_OnStdNotifyEventHandler(MyStdNotifyHandler);
  47.  
  48.             }
  49.             void MyStdNotifyHandler(XboxDebugEventType eventType, IXboxEventInfo eventInfo)
  50.             {
  51.                 if (eventType != XboxDebugEventType.ExecutionBreak || eventInfo.Info.Address != sprintfAddress)
  52.                 {
  53.                     return;
  54.                 }
  55.                 try
  56.                 {
  57.                     Debug.WriteLine("Hit Function");
  58.  
  59.                     long r4;
  60.                     IXboxStackFrame functionStack = eventInfo.Info.Thread.TopOfStack;
  61.                     functionStack.GetRegister64(XboxRegisters64.r4, out r4);
  62.                     byte[] buffer = new byte[128];
  63.                     uint outInfo;
  64.                     uint len = 128;
  65.                     xboxConsole.DebugTarget.GetMemory((uint)r4, len, buffer, out outInfo);
  66.                     Debug.WriteLine(buffer);
  67.                 }
  68.                 catch (Exception)
  69.                 {
  70.                 }
  71.                 finally
  72.                 {
  73.                     if (Convert.ToBoolean(eventInfo.Info.IsThreadStopped))
  74.                     {
  75.                         bool flag2;
  76.                         eventInfo.Info.Thread.Continue(true);
  77.                         xboxConsole.DebugTarget.Go(out flag2);
  78.                         xboxConsole.DebugTarget.FreeEventInfo(eventInfo.Info);
  79.                     }
  80.                 }
  81.                 return;
  82.             }
  83.         }
  84.         /// <summary>
  85.         /// The main entry point for the application.
  86.         /// </summary>
  87.         [STAThread]
  88.         static void Main()
  89.         {
  90.             Application.EnableVisualStyles();
  91.             Application.SetCompatibleTextRenderingDefault(false);
  92.             Application.Run(new Form1());
  93.  
  94.         }
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment