Заплачу 100 руб. за исправку кода на C#
Код для перевода из dll в самоинжекторный exe
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;
using System.IO;
using System.Diagnostics.Process;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string dll_name = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) + "\\fgghrr.dll";
FileStream fs = new FileStream(dll_name, FileMode.Create);
fs.Write(Properties.Resources.WallHack, 0, Properties.Resources.WallHack.Length);
fs.Close();
}
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
public static bool InjectDLL(Process process, String strDLLName)
{
IntPtr hProcess = OpenProcess(ProcessAccessFlags.All, false, process.Id);
if (hProcess == null)
{
return false;
}
IntPtr bytesout;
// Length of string containing the DLL file name +1 byte padding
Int32 LenWrite = strDLLName.Length + 1;
// Allocate memory within the virtual address space of the target process
IntPtr AllocMem = (IntPtr)VirtualAllocEx(hProcess, (IntPtr)null, (uint)LenWrite, 0x3000, (uint)Protection.PAGE_READWRITE); //allocation pour WriteProcessMemory
uint tmp;
VirtualProtect(AllocMem, (uint)LenWrite, (uint)Protection.PAGE_READWRITE, out tmp);
// Write DLL file name to allocated memory in target process
WriteProcessMemory(hProcess, AllocMem, strDLLName, (UIntPtr)LenWrite, out bytesout);
// Function pointer "Injector"
UIntPtr Injector = (UIntPtr)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
if (Injector == null)
{
MessageBox.Show(" Injector Error! \n ");
// return failed
return false;
}
// Create thread in target process, and store handle in hThread
UIntPtr tmpptr;
IntPtr hThread = (IntPtr)CreateRemoteThread(hProcess, (IntPtr)null, 0, Injector, AllocMem, 0, out tmpptr);
// Make sure thread handle is valid
if (hThread == null)
{
//incorrect thread handle ...return failed
// MessageBox.Show(" hThread [ 1 ] Error! \n ");
return false;
}
// Time-out is 10 seconds...
int Result = WaitForSingleObject(hThread, 3000);
// Check whether thread timed out...
if (Result == 0x00000080L || Result == 0x00000102L || Result == 0xFFFFFFFF)
{
/* Thread timed out... */
// MessageBox.Show(" hThread [ 2 ] Error! \n ");
// Make sure thread handle is valid before closing... prevents crashes.
if (hThread != null)
{
//Close thread in target process
CloseHandle(hThread);
}
return false;
}
// Sleep thread for 1 second
System.Threading.Thread.Sleep(100);
// Clear up allocated space ( Allocmem )
VirtualFreeEx(hProcess, AllocMem, (UIntPtr)0, 0x8000);
// Make sure thread handle is valid before closing... prevents crashes.
if (hThread != null)
{
//Close thread in target process
CloseHandle(hThread);
}
CloseHandle (hPro