here is the src you can compile it yourself if there is a Virus inside
CODEnamespace WindowsFormsApplication1
{
partial class Form1
{
///
/// Required designer variable.
///
private System.ComponentModel.IContainer components = null;
///
/// Clean up any resources being used.
///
/// true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.checkedListBox1 = new System.Windows.Forms.CheckedListBox();
this.button1 = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.button2 = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.button3 = new System.Windows.Forms.Button();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// checkedListBox1
//
this.checkedListBox1.CheckOnClick = true;
this.checkedListBox1.FormattingEnabled = true;
this.checkedListBox1.Location = new System.Drawing.Point(12, 12);
this.checkedListBox1.Name = "checkedListBox1";
this.checkedListBox1.Size = new System.Drawing.Size(400, 469);
this.checkedListBox1.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(12, 513);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(209, 31);
this.button1.TabIndex = 1;
this.button1.Text = "Load";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// openFileDialog1
//
this.openFileDialog1.FileName = "gba.gba";
//
// saveFileDialog1
//
this.saveFileDialog1.FileName = "gba.gba";
//
// button2
//
this.button2.Location = new System.Drawing.Point(227, 513);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(185, 31);
this.button2.TabIndex = 2;
this.button2.Text = "Save";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(12, 490);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(107, 17);
this.checkBox1.TabIndex = 3;
this.checkBox1.Text = "Bootloader patch";
this.checkBox1.UseVisualStyleBackColor = true;
//
// button3
//
this.button3.Location = new System.Drawing.Point(227, 487);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(185, 20);
this.button3.TabIndex = 4;
this.button3.Text = "Load and auto detect";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(125, 490);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(69, 17);
this.checkBox2.TabIndex = 5;
this.checkBox2.Text = "Anti User";
this.checkBox2.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(424, 557);
this.Controls.Add(this.checkBox2);
this.Controls.Add(this.button3);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.checkedListBox1);
this.Name = "Form1";
this.Text = "patch to BKPT";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.CheckedListBox checkedListBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.CheckBox checkBox2;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
checkBox1.Checked = false;
checkBox2.Checked = false;
checkedListBox1.Items.Clear();
openFileDialog1.ShowDialog();
Stream insram = openFileDialog1.OpenFile();
Byte[] Feld = new Byte[insram.Length];
insram.Read(Feld, 0, (int)insram.Length);
//search for swi or other stuff
for (int i = 0; i < insram.Length - 1; i += 1)
{
if (Feld[i + 1] == 0xDF && Feld
< 0x2A)
{
checkedListBox1.Items.Add("swi " + Convert.ToString(Feld, 16).ToUpper() + " at " + Convert.ToString(i, 16).ToUpper() + " (thumb)");
}
if (Feld[i + 1] == 0xEF && Feld < 0x2A)
{
checkedListBox1.Items.Add("swi " + Convert.ToString(Feld, 16).ToUpper() + " at " + Convert.ToString(i, 16).ToUpper() + " (arm)");
}
}
insram.Close();
}
private void button2_Click(object sender, EventArgs e)
{
Stream insram = openFileDialog1.OpenFile();
Byte[] Feld = new Byte[insram.Length];
insram.Read(Feld, 0, (int)insram.Length);
saveFileDialog1.ShowDialog();
Stream outram = saveFileDialog1.OpenFile();
if (checkBox2.Checked)
{
/* ichfly this is not perfect but some homebrew use that in the bootloade
* mov r0, #Cpu_Mode_USRR:0x80R:0x40 ;
* msr CPSR_c, r0 ; Switch to USR mode
*
* to
*
* mov r0, 0x1F ; System (privileged 'User' mode)
* msr CPSR_c, r0 ; Switch to USR mode
*
*/
for (int i = 1; i < insram.Length - 6; i += 1)
{
if ((Feld[i - 1] == 0xD0 && Feld == 0x00 && Feld[i + 1] == 0xA0 && Feld[i + 2] == 0xE3) &&
(Feld[i + 3] == 0x00 && Feld[i + 4] == 0xF0 && Feld[i + 5] == 0x21 && Feld[i + 6] == 0xE1))
{
MessageBox.Show("User patched at " + Convert.ToString(i - 1, 16).ToUpper());
Feld[i - 1] = 0x1F; //mov r0, 0x1F ; System (privileged 'User' mode)
break;
}
}
}
if (checkBox1.Checked)
/* mov rx, pc @x zwischen 0 und 7
lsl rx, #5 @ Are we running from ROM (0x8000000 or higher) ?
jmp//bcc SkipEWRAMClear @ No, so no need to do a copy.
*/
{
for (int i = 1; i < insram.Length - 5; i += 1)
{
if ((Feld[i - 1] & 0xF8) == 0x78 && Feld == 0x46 && (Feld[i + 1] & 0xC0) == 0x40 && Feld[i + 2] == 0x01 && (Feld[i + 4] & 0xF0) == 0xD0)
{
MessageBox.Show("bootloader patched at " + Convert.ToString(i - 1, 16).ToUpper());
Feld[i + 1] = (Byte)(Feld[i + 1] | 0xC0); //lsl rx, #5 to lsl rx, #7
break;
}
}
}
for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++)
{
string strings = checkedListBox1.CheckedItems.ToString();
string[] splitted = strings.Split(" ".ToCharArray());
UInt32 addr = Convert.ToUInt32(splitted[3],16);
if (splitted[4] == "(arm)")
{
Feld[addr - 1] = Feld[addr];
Feld[addr + 1] = 0xE1;
Feld[addr] = 0x20;
Feld[addr - 2] = 0x70;
}
else if (splitted[4] == "(thumb)")
{
Feld[addr + 1] = 0xBE;
}
}
outram.Write(Feld, 0, Feld.Length);
outram.Close();
insram.Close();
}
private void button3_Click(object sender, EventArgs e)
{
checkBox1.Checked = false;
checkBox2.Checked = false;
checkedListBox1.Items.Clear();
openFileDialog1.ShowDialog();
Stream insram = openFileDialog1.OpenFile();
Byte[] Feld = new Byte[insram.Length];
insram.Read(Feld, 0, (int)insram.Length);
//search for swi or other stuff
for (int i = 1; i < insram.Length - 6; i += 1)
{
if ((Feld[i - 1] == 0xD0 && Feld == 0x00 && Feld[i + 1] == 0xA0 && Feld[i + 2] == 0xE3) &&
(Feld[i + 3] == 0x00 && Feld[i + 4] == 0xF0 && Feld[i + 5] == 0x21 && Feld[i + 6] == 0xE1))
{
if (i < 0x180) checkBox2.Checked = true;
break;
}
}
for (int i = 1; i < insram.Length - 5; i += 1)
{
if ((Feld[i - 1] & 0xF8) == 0x78 && Feld == 0x46 && (Feld[i + 1] & 0xC0) == 0x40 && Feld[i + 2] == 0x01 && (Feld[i + 4] & 0xF0) == 0xD0)
{
//MessageBox.Show("bootloader patched at " + Convert.ToString(i - 1, 16).ToUpper());
//Feld[i + 1] = (Byte)(Feld[i + 1] | 0xC0); //lsl rx, #5 to lsl rx, #7
if (i < 0x180) checkBox1.Checked = true;
break;
}
}
for (int i = 0; i < insram.Length - 1; i += 1)
{
if (Feld[i + 1] == 0xDF && Feld < 0x2A)
{
if ((Feld < 0x2A && Feld > 0x24) || (Feld < 0x20 && Feld > 0x01)) checkedListBox1.Items.Add("swi " + Convert.ToString(Feld, 16).ToUpper() + " at " + Convert.ToString(i, 16).ToUpper() + " (thumb)", true);
else {checkedListBox1.Items.Add("swi " + Convert.ToString(Feld, 16).ToUpper() + " at " + Convert.ToString(i, 16).ToUpper() + " (thumb)",false);}
}
if (Feld[i + 1] == 0xEF && Feld < 0x2A)
{
if (((Feld < 0x2A && Feld > 0x24) || (Feld < 0x20 && Feld > 0x01)) && Feld[i - 1] == 0x00 && Feld[i - 2] == 0x00) checkedListBox1.Items.Add("swi " + Convert.ToString(Feld, 16).ToUpper() + " at " + Convert.ToString(i, 16).ToUpper() + " (arm)", true);
else { checkedListBox1.Items.Add("swi " + Convert.ToString(Feld, 16).ToUpper() + " at " + Convert.ToString(i, 16).ToUpper() + " (arm)", false); }
}
}
insram.Close();
}
}
}