Проблема с переходом на вторую форму - Вопросы и ответы, обсуждения - Ваши вопросы по C# только в данном разделе
22.09.2014, 20:38
#1
Разведчик
Регистрация: 21.08.2014
Сообщений: 0
Популярность: -79
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Проблема с переходом на вторую форму
Вот собственно код:
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Threading;
using System.Security.Cryptography;
namespace Привязка
{
public partial class Form1 : Form
{
static int a = 0;
string Key_File = "http://razdachawf.bl.ee/keys.txt";
MD5 md5 = new MD5CryptoServiceProvider();
string s;
string ke;
string kes;
string Infa = String.Empty;
string temp = String.Empty;
string temp1 = String.Empty;
public Form1()
{
InitializeComponent();
Thread load = new Thread(ГенерацияКлюча);
load.IsBackground = true;
load.Start();
}
void ГенерацияКлюча()
{
ke = HWIDGrabber.GetUHI;
kes = RemoveChars(ke);
byte[] checkSum = md5.ComputeHash(Encoding.UTF8.GetBytes(kes));
ke = BitConverter.ToString(checkSum).Replace("-", String.Empty);
kes = RemoveChars(ke);
int n = int.Parse("8");
List<string> lst = new List<string>();
for (int i = 0; i + n <= kes.Length; i += n)
{
lst.Add(kes.Substring(i, n));
}
s = string.Join("/", lst.Select((x) => new string(x.Reverse().ToArray())));
key.Invoke((MethodInvoker)(() => key.Text = s));
Запрос();
Проверка();
}
private void Запрос()
{
HttpWebRequest rew = (HttpWebRequest)WebRequest.Create(Key_File);
HttpWebResponse resp = (HttpWebResponse)rew.GetResponse();
Stream str = resp.GetResponseStream();
StreamReader readStream = new StreamReader(str, Encoding.UTF8);
string message = readStream.ReadToEnd();
richTextBox1.Invoke((MethodInvoker)(() => richTextBox1.AppendText(message)));
}
void Проверка()
{
while (a != -1)
{
richTextBox1.Invoke((MethodInvoker)(() => a = this.richTextBox1.Find(s, a, RichTextBoxFinds.None)));
if (a != -1)
{
this.Invoke((MethodInvoker)(() => this.Hide()));
Form2 f2 = new Form2();
f2.ShowDialog();
//this.Invoke((MethodInvoker)(() => this.Text = "Ключ Активирован"));
}
else
{
this.Invoke((MethodInvoker)(() => this.Text = "Программа не активирована!"));
copy.Invoke((MethodInvoker)(() => copy.Enabled = true));
chck.Invoke((MethodInvoker)(() => chck.Enabled = true));
key.Invoke((MethodInvoker)(() => key.Enabled = true));
pic.Invoke((MethodInvoker)(() => pic.Enabled = false));
}
break;
}
a++;
}
public static string RemoveChars(string inpStr)
{
StringBuilder sb = new StringBuilder();
foreach (char c in inpStr)
{
if (Char.IsDigit(c))
{
sb.Append(c);
}
}
return sb.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
Clipboard.SetText(key.Text);
}
private void pic_Click(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
MessageBox.Show("Для полной версии программы нужно купить лицензию");
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("");
}
private void button2_Click_1(object sender, EventArgs e)
{
webBrowser1.Refresh();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void chck_TextChanged(object sender, EventArgs e)
{
}
private void key_TextChanged(object sender, EventArgs e)
{
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
}
}
}
Вот ошибка:
[
Ссылки могут видеть только зарегистрированные пользователи. ]
Буду благодарен любой помощи.
22.09.2014, 20:40
#2
Старший сержант
Регистрация: 29.07.2011
Сообщений: 197
Популярность: 8989
Сказал(а) спасибо: 45
Поблагодарили 175 раз(а) в 139 сообщениях
Re: Проблема с переходом на вторую форму
Думаю у формы другой namespace
23.09.2014, 12:17
#3
Разведчик
Регистрация: 21.08.2014
Сообщений: 0
Популярность: -79
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Re: Проблема с переходом на вторую форму
Это помогло, спасибо.
Но теперь другая проблема:
Кнопка не становится активной, хотя процесс csgo.exe запущен.
Вот код второй формы:
Код:
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.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using System.IO;
namespace Привязка
{
public partial class Form2 : Form
{
# region Импорт
[DllImport("kernel32")]
public static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr lpThreadAttributes, uint dwStackSize, UIntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, out IntPtr lpThreadId);
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Int32 bInheritHandle, Int32 dwProcessId);
[DllImport("kernel32.dll")]
public static extern Int32 CloseHandle(IntPtr hObject);
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize, uint dwFreeType);
[DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
public static extern UIntPtr GetProcAddress(IntPtr hModule, string procName);
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);
[DllImport("kernel32.dll")]
static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, string lpBuffer, UIntPtr nSize, out IntPtr lpNumberOfBytesWritten);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetModuleHandle(string lpModuleName);
[DllImport("kernel32", SetLastError = true, ExactSpelling = true)]
internal static extern Int32 WaitForSingleObject(IntPtr handle, Int32 milliseconds);
public Int32 GetProcessId(String proc)
{
Process[] ProcList;
ProcList = Process.GetProcessesByName(proc);
return ProcList[0].Id;
}
#endregion
# region Inject
public void InjectDLL(IntPtr hProcess, String strDLLName)
{
IntPtr bytesout;
Int32 LenWrite = strDLLName.Length + 1;
IntPtr AllocMem = (IntPtr)VirtualAllocEx(hProcess, (IntPtr)null, (uint)LenWrite, 0x1000, 0x40);
WriteProcessMemory(hProcess, AllocMem, strDLLName, (UIntPtr)LenWrite, out bytesout);
UIntPtr Привязка = (UIntPtr)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
if (Привязка == null)
{
MessageBox.Show(" Injecto Error! \n ");
return;
}
IntPtr hThread = (IntPtr)CreateRemoteThread(hProcess, (IntPtr)null, 0, Привязка, AllocMem, 0, out bytesout);
if (hThread == null)
{
MessageBox.Show("Thread injection Failed");
return;
}
int Result = WaitForSingleObject(hThread, 10 * 1000);
if (Result == 0x00000080L || Result == 0x00000102L || Result == 0xFFFFFFFF)
{
MessageBox.Show("Thread 2 inject failed");
if (hThread != null)
{
CloseHandle(hThread);
}
return;
}
Thread.Sleep(1000);
VirtualFreeEx(hProcess, AllocMem, (UIntPtr)0, 0x8000);
if (hThread != null)
{
CloseHandle(hThread);
}
return;
}
#endregion
public Form2()
{
InitializeComponent();
timer1.Start();
}
private void Form2_Load(object sender, EventArgs e)
{
}
string NameDLL = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) + "\\Info.dll";
String ProcName = "csgo";
private void timer1_Tick(object sender, EventArgs e)
{
if (Process.GetProcessesByName(ProcName).Length == 1)
{
timer1.Stop();
button1.Enabled = true;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (File.Exists(NameDLL))
{
Int32 ProcID = GetProcessId(ProcName);
if (ProcID >= 0)
{
IntPtr hProcess = (IntPtr)OpenProcess(0x1F0FFF, 1, ProcID);
if (hProcess == null)
{
MessageBox.Show("Не удалось(");
return;
}
else
{
InjectDLL(hProcess, NameDLL);
Application.Exit();
}
}
}
else
{
MessageBox.Show("Чит не загружен!", "Ошибка");
Application.Exit();
}
}
private void Form2_Load_1(object sender, EventArgs e)
{
}
private void button1_Click_1(object sender, EventArgs e)
{
if (File.Exists(NameDLL))
{
Int32 ProcID = GetProcessId(ProcName);
if (ProcID >= 0)
{
IntPtr hProcess = (IntPtr)OpenProcess(0x1F0FFF, 1, ProcID);
if (hProcess == null)
{
MessageBox.Show("Не удалось(");
return;
}
else
{
InjectDLL(hProcess, NameDLL);
Application.Exit();
}
}
}
else
{
MessageBox.Show("Чит не найден!", "Ошибка");
Application.Exit();
}
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}
30.09.2014, 21:44
#4
Рыцарь-капитан
Регистрация: 14.06.2012
Сообщений: 511
Популярность: 7566
Сказал(а) спасибо: 4
Поблагодарили 181 раз(а) в 88 сообщениях
Re: Проблема с переходом на вторую форму
а вы поставьте бряк и посмотрите, доходит ли вообще до этого места программа и почему вы сравниваете длину с единицей
if (Process.GetProcessesByName(ProcName).Length == 1)
________________
Хотите как то отблагодарить за помощь?
Не стесняйтесь нажимайте "Спасибо"Для просмотра ссылок или изображений в подписях, у Вас должно быть не менее 10 сообщение(ий). Сейчас у Вас 0 сообщение(ий).
Делаю программы на заказ, по всем вопросам в скайп: Ginrey2
Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения
HTML код Выкл.
Заявление об ответственности / Список мошенников
Часовой пояс GMT +4, время: 18:06 .