日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > C# >内容正文

C#

C# 制作外挂常用的API

發布時間:2025/4/16 C# 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C# 制作外挂常用的API 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
  • C#做外掛的常用API,本人用了很久,基本沒發現問題??
  • ??
  • using?System;??
  • using?System.Collections.Generic;??
  • using?System.Text;??
  • using?System.Runtime.InteropServices;??//這個肯定要的???
  • ??
  • namespace?WindowsApplication1??
  • {??
  • ????class?win32API??
  • ????{??
  • ????????public?const?int?OPEN_PROCESS_ALL?=?2035711;??
  • ????????public?const?int?PAGE_READWRITE?=?4;??
  • ????????public?const?int?PROCESS_CREATE_THREAD?=?2;??
  • ????????public?const?int?PROCESS_HEAP_ENTRY_BUSY?=?4;??
  • ????????public?const?int?PROCESS_VM_OPERATION?=?8;??
  • ????????public?const?int?PROCESS_VM_READ?=?256;??
  • ????????public?const?int?PROCESS_VM_WRITE?=?32;??
  • ??
  • ????????private?const?int?PAGE_EXECUTE_READWRITE?=?0x4;??
  • ????????private?const?int?MEM_COMMIT?=?4096;??
  • ????????private?const?int?MEM_RELEASE?=?0x8000;??
  • ????????private?const?int?MEM_DECOMMIT?=?0x4000;??
  • ????????private?const?int?PROCESS_ALL_ACCESS?=?0x1F0FFF;??
  • ??
  • ?????????
  • ??
  • ??
  • ????????//查找窗體??
  • ????????[DllImport("User32.dll",?EntryPoint?=?"FindWindow")]??
  • ????????public?extern?static?IntPtr?FindWindow(??
  • ????????????string?lpClassName,??
  • ????????????string?lpWindowName??
  • ????????????);??
  • ??
  • ????????//得到目標進程句柄的函數??
  • ????????[DllImport("USER32.DLL")]??
  • ????????public?extern?static?int?GetWindowThreadProcessId(??
  • ????????????int?hwnd,??
  • ????????????ref?int?lpdwProcessId??
  • ????????????);??
  • ????????[DllImport("USER32.DLL")]??
  • ????????public?extern?static?int?GetWindowThreadProcessId(??
  • ????????????IntPtr?hwnd,??
  • ????????????ref?int?lpdwProcessId??
  • ????????????);??
  • ??
  • ????????//打開進程??
  • ????????[DllImport("kernel32.dll")]??
  • ????????public?extern?static?int?OpenProcess(??
  • ????????????int?dwDesiredAccess,??
  • ????????????int?bInheritHandle,??
  • ????????????int?dwProcessId??
  • ????????????);??
  • ????????[DllImport("kernel32.dll")]??
  • ????????public?extern?static?IntPtr?OpenProcess(??
  • ????????????uint?dwDesiredAccess,??
  • ????????????int?bInheritHandle,??
  • ????????????uint?dwProcessId??
  • ????????????);??
  • ?????????
  • ????????//關閉句柄的函數??
  • ????????[DllImport("kernel32.dll",?EntryPoint?=?"CloseHandle")]??
  • ????????public?static?extern?int?CloseHandle(??
  • ????????????int?hObject??
  • ????????????);??
  • ??
  • ????????//讀內存??
  • ????????[DllImport("Kernel32.dll?")]??
  • ????????public?static?extern?Int32?ReadProcessMemory(??
  • ????????????IntPtr?hProcess,??
  • ????????????IntPtr?lpBaseAddress,??
  • ????????????[In,?Out]?byte[]?buffer,??
  • ????????????int?size,??
  • ????????????out?IntPtr?lpNumberOfBytesWritten??
  • ????????????);??
  • ????????[DllImport("Kernel32.dll?")]??
  • ????????public?static?extern?Int32?ReadProcessMemory(??
  • ????????????int?hProcess,??
  • ????????????int?lpBaseAddress,??
  • ????????????ref?int?buffer,??
  • ????????????//byte[]?buffer,??
  • ????????????int?size,??
  • ????????????int?lpNumberOfBytesWritten??
  • ????????????);??
  • ????????[DllImport("Kernel32.dll?")]??
  • ????????public?static?extern?Int32?ReadProcessMemory(??
  • ????????????int?hProcess,??
  • ????????????int?lpBaseAddress,??
  • ????????????byte[]?buffer,??
  • ????????????int?size,??
  • ????????????int?lpNumberOfBytesWritten??
  • ????????????);??
  • ??
  • ????????//寫內存??
  • ????????[DllImport("kernel32.dll")]??
  • ????????public?static?extern?Int32?WriteProcessMemory(??
  • ????????????IntPtr?hProcess,??
  • ????????????IntPtr?lpBaseAddress,??
  • ????????????[In,?Out]?byte[]?buffer,??
  • ????????????int?size,??
  • ????????????out?IntPtr?lpNumberOfBytesWritten??
  • ????????????);??
  • ??
  • ????????[DllImport("kernel32.dll")]??
  • ????????public?static?extern?Int32?WriteProcessMemory(??
  • ????????????int?hProcess,??
  • ????????????int?lpBaseAddress,??
  • ????????????byte[]?buffer,??
  • ????????????int?size,??
  • ????????????int?lpNumberOfBytesWritten??
  • ????????????);??
  • ??
  • ????????//創建線程??
  • ????????[DllImport("kernel32",?EntryPoint?=?"CreateRemoteThread")]??
  • ????????public?static?extern?int?CreateRemoteThread(??
  • ????????????int?hProcess,??
  • ????????????int?lpThreadAttributes,??
  • ????????????int?dwStackSize,??
  • ????????????int?lpStartAddress,??
  • ????????????int?lpParameter,??
  • ????????????int?dwCreationFlags,??
  • ????????????ref?int?lpThreadId??
  • ????????????);??
  • ??
  • ????????//開辟指定進程的內存空間??
  • ????????[DllImport("Kernel32.dll")]??
  • ????????public?static?extern?System.Int32?VirtualAllocEx(??
  • ?????????System.IntPtr?hProcess,??
  • ?????????System.Int32?lpAddress,??
  • ?????????System.Int32?dwSize,??
  • ?????????System.Int16?flAllocationType,??
  • ?????????System.Int16?flProtect??
  • ?????????);??
  • ??
  • ????????[DllImport("Kernel32.dll")]??
  • ????????public?static?extern?System.Int32?VirtualAllocEx(??
  • ????????int?hProcess,??
  • ????????int?lpAddress,??
  • ????????int?dwSize,??
  • ????????int?flAllocationType,??
  • ????????int?flProtect??
  • ????????);??
  • ??
  • ????????//釋放內存空間??
  • ????????[DllImport("Kernel32.dll")]??
  • ????????public?static?extern?System.Int32?VirtualFreeEx(??
  • ????????int?hProcess,??
  • ????????int?lpAddress,??
  • ????????int?dwSize,??
  • ????????int?flAllocationType??
  • ????????);??
  • ????}??
  • }??
  • 總結

    以上是生活随笔為你收集整理的C# 制作外挂常用的API的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。