Post: CEX DEX C# Codes
03-29-2014, 11:39 AM #1
(adsbygoogle = window.adsbygoogle || []).push({}); Hey NGU im gunna post some basic C# CEX/DEX Codes That i found in some txt files on my computer hope this helps. Gobble
    under "InitializeComponent();" add this code:
public static PS3API PS3 = new PS3API();


    Connect:
try
{
PS3.ConnectTarget(0);
MessageBox.Show("Successfully Connected to Target!", "Connected", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch
{
MessageBox.Show("Failed to Connect", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
}



    Attach:

try
{
PS3.AttachProcess();
MessageBox.Show("Successfully Attached to Proccess!", "Attached", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch
{
MessageBox.Show("Failed to Attached", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
}


    PS3.ChangeAPI(SelectAPI.TargetManager);


    PS3.ChangeAPI(SelectAPI.ControlConsole);


    if (checkBox1.Checked == true)
{
byte[] Redboxes = new byte[] { 0x01 };
PS3.SetMemory(0x01CC4B78, Redboxes);

}
else
{
byte[] Redboxes = new byte[] { 0x00 };
PS3.SetMemory(0x01CC4B78, Redboxes);
}


    Name Changer add this to a button;
PS3.Extension.WriteString(0x26BDFD8, textBox1.Text);


    Flashing Name;//add a timer if you want a flashing name add this code to a checkbox next code will make the name flash
if (checkBox11.Checked == true)

if (checkBox11.Checked == true)
{
timer1.Start();
}
else
{
timer1.Stop();
}


    Random random = new Random();//add this to your timer
int Colors = random.Next(0, 7);
PS3.SetMemory(0x26BDFD8, this.StringToByteArray("^" + Colors + this.textBox1.Text + "\0"));
}
public byte[] StringToByteArray(string str)
{
ASCIIEncoding encoding = new ASCIIEncoding();
return encoding.GetBytes(str);


Add my skype: ogxkillem if you have any problems i will be glad to help with you C# Smile
(adsbygoogle = window.adsbygoogle || []).push({});

The following 2 users say thank you to WhyMoDz for this useful post:

coreconfusion, ImHazx
03-30-2014, 08:50 PM #11
seb5594
Proud Former Admin
Originally posted by Bad
instead of :
    
byte[] NAME = Encoding.ASCII.GetBytes(textBox1.Text);
Array.Resize(ref NAME, NAME.Length + 1);
PS3.SetMemory(0x26BDFD8, NAME);


Put this:
    
byte[] NAME = Encoding.ASCII.GetBytes(textBox1.Text + "\0");
PS3.SetMemory(0x26BDFD8, NAME);


it can save you some lines Smile


instead of :
    
byte[] NAME = Encoding.ASCII.GetBytes(textBox1.Text + "\0");
PS3.SetMemory(0x26BDFD8, NAME);


Put this:
    
PS3.SetMemory(0x26BDFD8, Encoding.ASCII.GetBytes(textBox1.Text + "\0"));


it can save you more lines :whistle:
03-31-2014, 10:25 AM #12
spudeeelad
I defeated!
Originally posted by ImHazx View Post
The lines are free... why would you save some? Happy

It's called optimization. Basically, as a general rule (only if you follow proper coding practice and use lines appropriately), the less lines you use, the better your code is.

You're way of doing it took 3 lines, but that's 3 separate tasks. If each of those tasks takes 0.1ms, your code would take 0.3ms to run. Whereas even though doing the same thing, the one liner is one task, thus in most cases, will take 0.1ms to run. Whilst it only saves 0.2 ms in this example, over the course of a more complicated app like mentioned above, every 0.2ms seconds saved eventually adds up to seconds and minutes.

Thus it's not really the number of lines, it's the amount of tasks - it's always easier to do things in one go than 3. It also helps catch exactly where errors occur and saves duplication of code.

Technically speaking, to achieve that one task and catch a good, meaningful error that points you straight to the source of the problem when an error occurs, you should have;

    
try
{
byte[] NAME = Encoding.ASCII.GetBytes(textBox1.Text);
}

catch(Exception ex)
{
MessageBox.Show("Error retrieving Bytes for value inputted to TextBox1. The following may be useful: " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}

try
{
Array.Resize(ref NAME, NAME.Length + 1);
}

catch (Exception ex)
{
MessageBox.Show("Error re-sizing byte array. The following may be useful: " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}

try
{
PS3.SetMemory(0x26BDFD8, NAME);
}

catch (Exception ex)
{
MessageBox.Show("Error setting memory on PS3. The following may be useful: " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}


Whereas because the other person's code is optimized, he can simply have the below to achieve the exact same result. Thus eliminating duplication and saving time
    
try
{
PS3.Extention.WriteString(offset, textBox1.Text);
}

catch (Exception ex)
{
MessageBox.Show("Error occured writing inputted text string to PS3 Memory. The following may be useful: " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}

The following user thanked spudeeelad for this useful post:

ImAzazel
05-27-2016, 11:02 AM #13
OMG I LOVE YOU THANK YOU <333333333Gandalf the Grey

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo