C# 制作外挂常用的API
2011-03-16 09:05
357 查看
C#做外挂的常用API.
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Text;
usingSystem.Runtime.InteropServices;//这个肯定要的
namespaceWindowsApplication1
{
classwin32API
{
publicconstintOPEN_PROCESS_ALL=2035711;
publicconstintPAGE_READWRITE=4;
publicconstintPROCESS_CREATE_THREAD=2;
publicconstintPROCESS_HEAP_ENTRY_BUSY=4;
publicconstintPROCESS_VM_OPERATION=8;
publicconstintPROCESS_VM_READ=256;
publicconstintPROCESS_VM_WRITE=32;
privateconstintPAGE_EXECUTE_READWRITE=0x4;
privateconstintMEM_COMMIT=4096;
privateconstintMEM_RELEASE=0x8000;
privateconstintMEM_DECOMMIT=0x4000;
privateconstintPROCESS_ALL_ACCESS=0x1F0FFF;
//查找窗体
[DllImport("User32.dll",EntryPoint="FindWindow")]
publicexternstaticIntPtrFindWindow(
stringlpClassName,
stringlpWindowName
);
//得到目标进程句柄的函数
[DllImport("USER32.DLL")]
publicexternstaticintGetWindowThreadProcessId(
inthwnd,
refintlpdwProcessId
);
[DllImport("USER32.DLL")]
publicexternstaticintGetWindowThreadProcessId(
IntPtrhwnd,
refintlpdwProcessId
);
//打开进程
[DllImport("kernel32.dll")]
publicexternstaticintOpenProcess(
intdwDesiredAccess,
intbInheritHandle,
intdwProcessId
);
[DllImport("kernel32.dll")]
publicexternstaticIntPtrOpenProcess(
uintdwDesiredAccess,
intbInheritHandle,
uintdwProcessId
);
//关闭句柄的函数
[DllImport("kernel32.dll",EntryPoint="CloseHandle")]
publicstaticexternintCloseHandle(
inthObject
);
//读内存
[DllImport("Kernel32.dll")]
publicstaticexternInt32ReadProcessMemory(
IntPtrhProcess,
IntPtrlpBaseAddress,
[In,Out]byte[]buffer,
intsize,
outIntPtrlpNumberOfBytesWritten
);
[DllImport("Kernel32.dll")]
publicstaticexternInt32ReadProcessMemory(
inthProcess,
intlpBaseAddress,
refintbuffer,
//byte[]buffer,
intsize,
intlpNumberOfBytesWritten
);
[DllImport("Kernel32.dll")]
publicstaticexternInt32ReadProcessMemory(
inthProcess,
intlpBaseAddress,
byte[]buffer,
intsize,
intlpNumberOfBytesWritten
);
//写内存
[DllImport("kernel32.dll")]
publicstaticexternInt32WriteProcessMemory(
IntPtrhProcess,
IntPtrlpBaseAddress,
[In,Out]byte[]buffer,
intsize,
outIntPtrlpNumberOfBytesWritten
);
[DllImport("kernel32.dll")]
publicstaticexternInt32WriteProcessMemory(
inthProcess,
intlpBaseAddress,
byte[]buffer,
intsize,
intlpNumberOfBytesWritten
);
//创建线程
[DllImport("kernel32",EntryPoint="CreateRemoteThread")]
publicstaticexternintCreateRemoteThread(
inthProcess,
intlpThreadAttributes,
intdwStackSize,
intlpStartAddress,
intlpParameter,
intdwCreationFlags,
refintlpThreadId
);
//开辟指定进程的内存空间
[DllImport("Kernel32.dll")]
publicstaticexternSystem.Int32VirtualAllocEx(
System.IntPtrhProcess,
System.Int32lpAddress,
System.Int32dwSize,
System.Int16flAllocationType,
System.Int16flProtect
);
[DllImport("Kernel32.dll")]
publicstaticexternSystem.Int32VirtualAllocEx(
inthProcess,
intlpAddress,
intdwSize,
intflAllocationType,
intflProtect
);
//释放内存空间
[DllImport("Kernel32.dll")]
publicstaticexternSystem.Int32VirtualFreeEx(
inthProcess,
intlpAddress,
intdwSize,
intflAllocationType
);
}
}
.csharpcode,.csharpcodepre
{
font-size:small;
color:black;
font-family:consolas,"CourierNew",courier,monospace;
background-color:#ffffff;
/*white-space:pre;*/
}
.csharpcodepre{margin:0em;}
.csharpcode.rem{color:#008000;}
.csharpcode.kwrd{color:#0000ff;}
.csharpcode.str{color:#006080;}
.csharpcode.op{color:#0000c0;}
.csharpcode.preproc{color:#cc6633;}
.csharpcode.asp{background-color:#ffff00;}
.csharpcode.html{color:#800000;}
.csharpcode.attr{color:#ff0000;}
.csharpcode.alt
{
background-color:#f4f4f4;
width:100%;
margin:0em;
}
.csharpcode.lnum{color:#606060;}
原文地址:
相关文章推荐
- C#制作外挂的常用API
- C#制作外挂的常用API
- C# 制作外挂常用的API
- C#制作外挂常用API。。自己存着。记录
- C# 制作外挂常用的API
- C#制作外挂的常用API
- C#做外挂常用API
- C#做外挂的常用API,本人用了很久,基本没发现问题
- C# 做外挂,常用API
- c#调用windows api C#简单游戏外挂制作(以Warcraft Ⅲ为例)
- C#简单游戏外挂制作(以Warcraft Ⅲ为例)
- C#简单游戏外挂制作(二)
- C#修改内存制作外挂
- 没事也研究一下外挂--C#简单游戏外挂制作(以Warcraft Ⅲ为例)
- 常用C#调用 Win32 API 收录
- C#.NET使用Window API 制作淡入淡出特殊效果
- C#简单游戏外挂制作(以Warcraft Ⅲ为例)
- C#简单游戏外挂制作(以Warcraft Ⅲ实践)
- C#简单游戏外挂制作(以Warcraft Ⅲ为例)
- C#与.NET Framework, ASP.NET Web API RC版本新特性:Web API的帮助文档制作