Risking Perfect
I'm not dead, Just deployed
Super Moderators
To start, I am not a coder, I focus on the physical aspect of Xbox 360's. I am looking into making an xMessage ui plugin that pops up when the system boots.
I was looking into this forum and it seems to have the code to use but I might as well be trying to read a foreign language here.
Thanks to anyone who can explain or help me out here.
I was looking into this forum and it seems to have the code to use but I might as well be trying to read a foreign language here.
Code:
DATA HOSTED WITH ♥ BY PASTEBIN.COM - DOWNLOAD RAW - SEE ORIGINAL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using XDevkit;
using JRPC_Client;
namespace XUtilities
{
public enum XMessageBoxIcons
{
XBM_NOICON,
XMB_ERRORICON,
XMB_WARNINGICON,
XMB_ALERTICON
}
public class XMessageBoxUIProgress : EventArgs
{
public uint Result { get; private set; }
public uint Code { get; private set; }
private XMessageBoxUIProgress() { }
public XMessageBoxUIProgress(uint result, uint code)
{
Result = result;
Code = code;
}
}
public class ActiveXMessageBoxes
{
public uint Size;
public byte[] XOverlappedBytes;
public ActiveXMessageBoxes(uint size, byte[] xOverlappedBytes)
{
Size = size;
XOverlappedBytes = xOverlappedBytes;
}
}
public static class XMessageBoxTracking
{
public static List<ActiveXMessageBoxes> ActiveMessageBoxes = new List<ActiveXMessageBoxes>();
}
public class XMessageBoxUI
{
public IXboxConsole Console;
public ActiveXMessageBoxes CurMessageBox;
public volatile uint XOverlappedAddr;
public volatile uint ResultAddr;
public volatile bool IsMessageBoxOpen = false;
public event EventHandler<XMessageBoxUIProgress> MessageBoxUIResult;
public string MessageBoxTitle;
public string MessageBoxMessage;
public string[] XMessageBoxButtons;
public XMessageBoxIcons XMessageBoxIcon;
public int SelectedButton = 0;
public XMessageBoxUI(IXboxConsole console, string MsgBoxTitle, string MsgBoxMsg, string[] MsgBoxButtons, XMessageBoxIcons Icon, int SelectedButtonIndex)
{
Console = console;
MessageBoxTitle = MsgBoxTitle;
MessageBoxMessage = MsgBoxMsg;
XMessageBoxButtons = MsgBoxButtons;
XMessageBoxIcon = Icon;
SelectedButton = SelectedButtonIndex;
}
public void RemoveMessageBox(ActiveXMessageBoxes mBox)
{
XMessageBoxTracking.ActiveMessageBoxes.Remove(CurMessageBox);
if (XMessageBoxTracking.ActiveMessageBoxes.Count() > 0)
Console.SetMemory(XOverlappedAddr, XMessageBoxTracking.ActiveMessageBoxes.Last().XOverlappedBytes);
}
public void CheckMessageBoxResult()
{
while (IsMessageBoxOpen)
{
try
{
if (CurMessageBox == XMessageBoxTracking.ActiveMessageBoxes.Last())
{
uint code = Console.ReadUInt32(XOverlappedAddr);
uint result = 0;
switch (code)
{
case 0: //the user clicked one of the buttons
result = Console.ReadUInt32(ResultAddr);
IsMessageBoxOpen = false;
break;
case 0x65b: //the user pressed b or back to close the message box ui
case 0x4c7: //user pressed the guide button to close the message box
result = 420;
IsMessageBoxOpen = false;
break;
case 0x3e5: //the messagebox is still open
break;
default: //unhandled case
result = 710;
IsMessageBoxOpen = false;
break;
}
if (!IsMessageBoxOpen)
{
RemoveMessageBox(CurMessageBox);
MessageBoxUIResult(this, new XMessageBoxUIProgress(result, code));
}
}
Thread.Sleep(200);
}
catch (Exception)
{
return;
}
}
}
public bool Show()
{
if (IsMessageBoxOpen)
{
MessageBox.Show("This XMessageBox is already open. Close it before opening it again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
if (XMessageBoxButtons.Count() > 3)
{
MessageBox.Show("Number of buttons may not exceed 3.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
else if (XMessageBoxButtons.Count() == 0)
{
MessageBox.Show("Must have at least one button.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
uint FreeMemory = Console.ResolveFunction("xam.xex", 2601) + 0x3000;
//XOverlapped and Result share the same address for every message box... no clue how to ger around this.
uint XOverlapped = FreeMemory;
uint Result = FreeMemory + 0x20; // xoverlapped is about 0x18 in size... we'll just do 0x20 to be safe
//If we already have message boxes open, increment the new messageboxes location in memory
foreach(ActiveXMessageBoxes mb in XMessageBoxTracking.ActiveMessageBoxes)
FreeMemory += mb.Size;
//setup our title text and copy it into memory on the console
byte[] title = JRPC.WCHAR(MessageBoxTitle);
uint Title = Result + 0x10;
Console.SetMemory(Title, title);
//setup our message text and copy it into memory on the console
byte[] msg = JRPC.WCHAR(MessageBoxMessage);
uint Msg = Title + (uint)title.Length;
Console.SetMemory(Msg, msg);
//setup our button text and copy it into memory on the console
List<byte[]> ButtonList = new List<byte[]>();
foreach (string s in XMessageBoxButtons)
ButtonList.Add(JRPC.ToWCHAR(s));
uint ButtonAddr = Msg + (uint)msg.Length;
uint OrigButtonAddr = ButtonAddr;
foreach (byte[] b in ButtonList)
{
Console.SetMemory(ButtonAddr, b);
ButtonAddr += (uint)b.Length;
}
//copy pointers to button wstrs into an array
uint EndAddr = FreeMemory;
for (int i = 0; i < ButtonList.Count(); i++)
{
EndAddr = ButtonAddr + ((uint)i * 4);
Console.WriteUInt32(EndAddr, OrigButtonAddr);
OrigButtonAddr += (uint)ButtonList.ElementAt(i).Length;
}
//finally, call XamShowMessageBoxUI
uint LocalClientIndex = 0;
uint addr = Console.ResolveFunction("xam.xex", 0x2ca);
int ret = Console.Call<int>(addr, LocalClientIndex, Title, Msg, ButtonList.Count(), ButtonAddr, SelectedButton, (uint)XMessageBoxIcon, Result, XOverlapped);
if (ret == 0x3e5) //messagebox was opened on the console successfully
{
IsMessageBoxOpen = true;
//set our xoverlapped and result addresses for later use
XOverlappedAddr = XOverlapped;
ResultAddr = XOverlappedAddr + 0x20;
//grab the current xoverlapped bytes from the console and store them in an array incase we popup a messagebox on top of this one
byte[] XOverlappedBytes = Console.GetMemory(XOverlappedAddr, 0x20);
//grab the size of all the stuff we just set into memory on the console
uint Size = (EndAddr + 0x4) - FreeMemory;
while ((Size & 0x3) != 0) //make sure address is 4 byte aligned (don't know if this even matters)
Size += 0x1;
//add this messagebox to the list of active messageboxes
CurMessageBox = new ActiveXMessageBoxes(Size, XOverlappedBytes);
XMessageBoxTracking.ActiveMessageBoxes.Add(CurMessageBox);
//create a new thread to monitor the messagebox
Thread MessageBoxThread = new Thread(CheckMessageBoxResult);
MessageBoxThread.Start();
}
else
IsMessageBoxOpen = false;
return IsMessageBoxOpen;
}
}
}
0
Thanks to anyone who can explain or help me out here.