J'ai un petit problème qui n'a rien a voir avec le code du bot.
J'ai une classe console qui ajoute des lignes dans ma console et je l'appelle depuis plusieurs autres classes mais voilà seule la classe main arrive à écrire quelque chose dans la console... Et je n'arrive pas à trouver ce qui cloche :s
Code classe console :
Cliquez pour révéler
Cliquez pour masquer
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MyBot.Interface
{
public partial class ConsoleForm : Form
{
public ConsoleForm()
{
InitializeComponent();
}
public void Add(string log, Color color)
{
rtLog.SelectionColor = color;
rtLog.AppendText("[" + DateTime.Now.ToString("h:mm:ss tt")+ "] : " + log + "\r\n");
}
public void Add(string log)
{
rtLog.AppendText("[" + DateTime.Now.ToString("h:mm:ss tt") + "] : " + log + "\r\n");
}
public void Add(byte[] buffer, string log, Color color)
{
rtLog.SelectionColor = color;
rtLog.AppendText("[" + DateTime.Now.ToString("h:mm:ss tt") + "] : " + log);
rtLog.SelectionColor = Color.Black;
for (int i = 0; i < buffer.Length; i++)
{
rtLog.AppendText(buffer.ToString() + "");
}
rtLog.AppendText("\r\n");
}
private void button1_Click(object sender, EventArgs e)
{
rtLog.Text = null;
}
private void rtLog_TextChanged(object sender, EventArgs e)
{
rtLog.SelectionStart = rtLog.Text.Length;
rtLog.ScrollToCaret();
}
private void btClose_Click(object sender, EventArgs e)
{
Hide();
}
}
}
Code de la classe qui l'appelle :
Cliquez pour révéler
Cliquez pour masquer
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using MyBot.Interface;
using MyBot.Divers;
using MyBot.Network;
namespace MyBot.Client
{
public class Injection
{
ConsoleForm console;
public Injection()
{
console = new ConsoleForm();
}
public string ApplicationPath
{
get { return Environment.CurrentDirectory; }
}
public void Inject(int dofusModId)
{
try
{
if (!(File.Exists(ApplicationPath + "\\No.Ankama.dll")))
{
console.Add("Le fichier No.Ankama.dll ne se trouve pas dans le dossier ! Veuillez vérifier cela avec votre Antivirus.");
return;
}
DllInjector dllInjector = new DllInjector();
dllInjector.Inject(Convert.ToUInt32(dofusModId), ApplicationPath + "\\No.Ankama.dll");
console.Add("Processus Dofus à l'id = " + dofusModId + " a bien été patché !");
}
catch (Exception e)
{
console.Add(e.ToString(), Color.Red);
}
}
public void ProcessDofus()
{
Process[] proc;
try
{
proc = Process.GetProcessesByName("Dofus");
if (proc.Length == 0)
{
console.Add("Aucun processus Dofus trouvé.", Color.Red);
return;
}
for (int i = 0; i < proc.Length; i++)
{
console.Add("Processus Dofus trouvé avec l'id = " + proc.Id);
Inject(proc.Id);
}
}
catch (Exception e)
{
console.Add(e.ToString(), Color.Red);
}
}
}
}