Kullanıcağımız Sistemleri Tanımlıyalım
Kod:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
Gerekli Apileri Tanımlıyalım
Kod:
public const Int32 PROCESS_ALL_ACCESS = 0x1F0FFF;
#region DasKaos WinAPI declaration
[DllImport("USER32.DLL")]
public static extern IntPtr FindWindow(
string lpClassName,
string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
static extern uint GetWindowThreadProcessId(
IntPtr hWnd,
out uint lpdwProcessId
);
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(
UInt32 dwDesiredAccess,
Int32 bInheritHandle,
UInt32 dwProcessId
);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool ReadProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
out float buffer,
UInt32 size,
IntPtr lpNumberOfBytesRead
);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool ReadProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
out UInt32 buffer,
UInt32 size,
IntPtr lpNumberOfBytesRead
);
#endregion
// FindProcess ..
IntPtr getProcess()
{
UInt32 proc_id;
IntPtr process;
IntPtr hWnd = FindWindow(null, "Knight Online Client");
GetWindowThreadProcessId(hWnd, out proc_id);
return OpenProcess(0x1F0FFF, 1, proc_id);
}Kod:
//DasKaos ! - ReadMemory(4byte) in ProcessHandle
UInt32 readUInt32(UInt32 address)
{
UInt32 ret;
try
{
ReadProcessMemory(process, (IntPtr)address, out ret, (UInt32)4, new IntPtr());
}
catch (Exception) { ret = 0; }
return ret;
}
EX:
pencere isminden hwnd alalım hwndyide pide dönüştürelim
o pidide proccess_all_access bağdaştırıcısı ile bağdaştıralım
Kod:
IntPtr hwnd = FindWindow(null,"Knight Online Client"); // varsayılan pencere ismi
int KO_PID = GetWindowThreadProcessId(hwnd,ref 0);
IntPtr KO_HANDLE = OpenProcess(PROCESS_ALL_ACCESS, false, KO_PID);
İyi Çalışmalar