Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.Threading;
- using System.Windows.Forms;
- namespace WindowsFormsApp1
- {
- public class Form1 : Form
- {
- private IContainer components = null;
- private Button button1;
- private TextBox textBox1;
- private TextBox textBox2;
- private Label label1;
- private TextBox textBox3;
- private Label label2;
- private Label label3;
- private Label label4;
- public Form1()
- {
- InitializeComponent();
- }
- [DllImport("kernel32.dll")]
- public static extern int OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
- [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(uint dwDesiredAccess, int bInheritHandle, int dwProcessId);
- [DllImport("kernel32.dll")]
- public static extern int CloseHandle(IntPtr hObject);
- [DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true)]
- private 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", ExactSpelling = true, SetLastError = true)]
- private static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);
- [DllImport("kernel32.dll")]
- private 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", ExactSpelling = true, SetLastError = true)]
- internal static extern int WaitForSingleObject(IntPtr handle, int milliseconds);
- [DllImport("kernel32.dll")]
- public static extern bool ReadProcessMemory(int hProcess, long lpBaseAddress, byte[] buffer, int size, int lpNumberOfBytesRead);
- [DllImport("kernel32.dll")]
- public static extern bool WriteProcessMemory(int hProcess, long lpBaseAddress, byte[] buffer, int size, int lpNumberOfBytesWritten);
- public int GetProcessId(string proc)
- {
- Process[] processesByName = Process.GetProcessesByName(proc);
- return processesByName[0].Id;
- }
- public static byte[] ReadProcessMemory(long adress, int processSize, int processHandle)
- {
- byte[] array = new byte[processSize];
- ReadProcessMemory(processHandle, adress, array, processSize, 0);
- return array;
- }
- public static void WriteProcessMemory(long adress, byte[] processBytes, int processHandle)
- {
- WriteProcessMemory(processHandle, adress, processBytes, processBytes.Length, 0);
- }
- public static int GetObjectSize(object TestObject)
- {
- BinaryFormatter binaryFormatter = new BinaryFormatter();
- MemoryStream memoryStream = new MemoryStream();
- binaryFormatter.Serialize(memoryStream, TestObject);
- byte[] array = memoryStream.ToArray();
- return array.Length;
- }
- public static string ConvertStringToHex(string asciiString)
- {
- string text = "";
- foreach (char c in asciiString)
- {
- int num = c;
- text += $"{Convert.ToUInt32(num.ToString()):x2}";
- }
- return text;
- }
- public static byte[] StringToByteArray(string hex)
- {
- return (from x in Enumerable.Range(0, hex.Length)
- where x % 2 == 0
- select Convert.ToByte(hex.Substring(x, 2), 16)).ToArray();
- }
- public void InjectDLL(IntPtr hProcess, string strDLLName)
- {
- int num = strDLLName.Length + 1;
- IntPtr intPtr = VirtualAllocEx(hProcess, (IntPtr)null, (uint)num, 12288u, 4u);
- WriteProcessMemory(hProcess, intPtr, strDLLName, (UIntPtr)(ulong)num, out IntPtr intPtr2);
- UIntPtr procAddress = GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
- bool flag = false;
- IntPtr intPtr3 = CreateRemoteThread(hProcess, (IntPtr)null, 0u, procAddress, intPtr, 0u, out intPtr2);
- bool flag2 = false;
- int num2 = WaitForSingleObject(intPtr3, 10000);
- if ((long)num2 == 128 || (long)num2 == 258 || num2 == uint.MaxValue)
- {
- MessageBox.Show(" hThread [ 2 ] Error! \n ");
- bool flag3 = true;
- CloseHandle(intPtr3);
- }
- else
- {
- Thread.Sleep(1000);
- VirtualFreeEx(hProcess, intPtr, (UIntPtr)0uL, 32768u);
- bool flag4 = true;
- CloseHandle(intPtr3);
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string text = textBox1.Text;
- string text2 = textBox2.Text;
- try
- {
- Process.Start("BlackDesert64.exe", (textBox1.Text + "," + textBox2.Text) ?? "");
- }
- catch
- {
- MessageBox.Show("Cannot find BlackDesert64.exe, make sure the launcher is in the bin64 folder.", "Error!");
- return;
- }
- Thread.Sleep(1500);
- string strDLLName = "steam_api64.dll";
- string proc = "BlackDesert64";
- int processId = GetProcessId(proc);
- if (processId >= 0)
- {
- IntPtr hProcess = OpenProcess(2035711u, 1, processId);
- bool flag = false;
- InjectDLL(hProcess, strDLLName);
- Thread.Sleep(500);
- Process[] processesByName = Process.GetProcessesByName("BlackDesert64");
- uint num = 65536u;
- uint num2 = 131072u;
- uint num3 = 262144u;
- uint num4 = 524288u;
- uint num5 = 1048576u;
- uint num6 = 4095u;
- uint dwDesiredAccess = num | num2 | num3 | num4 | num5 | num6;
- int processHandle = OpenProcess(dwDesiredAccess, false, processesByName[0].Id);
- IntPtr baseAddress = processesByName[0].MainModule.BaseAddress;
- ReadProcessMemory(baseAddress.ToInt64() + 43055736, 11, processHandle);
- if (textBox3.Text == null)
- {
- string hex = ConvertStringToHex("127.0.0.1");
- baseAddress = processesByName[0].MainModule.BaseAddress;
- WriteProcessMemory(baseAddress.ToInt64() + 43055736, StringToByteArray(hex), processHandle);
- }
- else
- {
- string hex2 = ConvertStringToHex(textBox3.Text);
- baseAddress = processesByName[0].MainModule.BaseAddress;
- WriteProcessMemory(baseAddress.ToInt64() + 43055736, StringToByteArray(hex2), processHandle);
- }
- }
- Application.Exit();
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing && components != null)
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
- private void InitializeComponent()
- {
- this.button1 = new System.Windows.Forms.Button();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.textBox3 = new System.Windows.Forms.TextBox();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.SuspendLayout();
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(19, 122);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 0;
- this.button1.Text = "Start Game";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click_1);
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(76, 29);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(100, 20);
- this.textBox1.TabIndex = 1;
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(76, 55);
- this.textBox2.Name = "textBox2";
- this.textBox2.Size = new System.Drawing.Size(100, 20);
- this.textBox2.TabIndex = 2;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(18, 32);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(58, 13);
- this.label1.TabIndex = 3;
- this.label1.Text = "Username:";
- this.label1.Click += new System.EventHandler(this.label1_Click);
- //
- // textBox3
- //
- this.textBox3.Location = new System.Drawing.Point(76, 96);
- this.textBox3.Name = "textBox3";
- this.textBox3.Size = new System.Drawing.Size(100, 20);
- this.textBox3.TabIndex = 4;
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(18, 99);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(54, 13);
- this.label2.TabIndex = 5;
- this.label2.Text = "Server IP:";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(18, 58);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(56, 13);
- this.label3.TabIndex = 6;
- this.label3.Text = "Password:";
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(43, 9);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(124, 13);
- this.label4.TabIndex = 7;
- this.label4.Text = "bdoEmu - Test Launcher";
- //
- // Form1
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(496, 218);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.textBox3);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.textBox2);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.button1);
- this.Name = "Form1";
- this.Text = "bdoEmu";
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- private void label1_Click(object sender, EventArgs e)
- {
- }
- private void button1_Click_1(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement