其他分享
首页 > 其他分享> > 发现:用C#写了一个游戏外挂

发现:用C#写了一个游戏外挂

作者:互联网

近期经朋友推荐开始玩游戏密传网游
更新升级,突然感觉太费电脑键盘,因此用自己的C#写了一个程序流程,想替代我实际操作,一个人去打怪,自身更新
用这东西升了好多级别了,现在把源代码贴上去,跟大家分享,欢迎各位不吝赐教,万分感激。
程序流程大约分为两部分,一个部分为类库,一个是应用软件
大约思路便是寻找游戏进程主窗口句柄,随后推送游戏按键信息(模拟按键)。
XDF.GamePlugInCommon类库新项目
//API.cs文件,界定一些常见API函数及变量定义
usingSystem;
usingSystem.IO;
usingSystem.Threading;
usingSystem.Diagnostics;
usingSystem.Runtime.InteropServices;
namespaceXDF.GamePlugInCommon
{
///
///API的引言表明。
///
publicsealedclassAPI
{
publicstaticintWM_KEYDOWN=0x0100;
publicstaticintWM_KEYUP=0x0101;
publicstaticintWM_SYSKEYDOWN=0x0104;
publicstaticintWM_SYSKEYUP=0x0105;
publicstaticintWM_MOUSEMOVE=0x0200;
publicstaticintWM_LBUTTONDOWN=0x0201;
publicstaticintWM_LBUTTONUP=0x0202;
publicstaticintWM_LBUTTONDBLCLK=0x0203;
publicstaticintWM_RBUTTONDOWN=0x0204;
publicstaticintWM_RBUTTONUP=0x0205;
publicstaticintWM_RBUTTONDBLCLK=0x0206;
publicstaticintWM_USER=0x0400;
publicstaticintMK_LBUTTON=0x0001;
publicstaticintMK_RBUTTON=0x0002;
publicstaticintMK_SHIFT=0x0004;
publicstaticintMK_CONTROL=0x0008;
publicstaticintMK_MBUTTON=0x0010;
publicstaticintMK_XBUTTON1=0x0020;
publicstaticintMK_XBUTTON2=0x0040;
[DllImport("user32.dll")]
publicstaticexternintSendMessage(IntPtrhWnd,intMsg,intwParam,intlParam);
//这里主要是用于让对话框放置顶端(SetWindowPos(this.Handle,-1,0,0,0,0,0x4000|0x0001|0x0002);)
[System.Runtime.InteropServices.DllImport("user32.dll")]
publicstaticexternboolSetWindowPos(IntPtrhWnd,
inthWndInsertAfter,
intX,
intY,
intcx,
intcy,
intuFlags
);
///
///对话框置前
///
///
publicstaticvoidSetWindowPos(IntPtrhWnd)
{
SetWindowPos(hWnd,-1,0,0,0,0,0x4000|0x0001|0x0002);
}
///
///
///
///
///
publicstaticProcessGetGameProcess(stringprocessName)
{
Processpro=null;
Process[]pros=Process.GetProcessesByName(processName);
if(pros.Length>0)
{
pro=pros[0];
}
returnpro;
}
}
}
新项目(应用软件)
XDF.TantraPlugIn
//ControlItem.cs
usingSystem;
usingSystem.IO;
usingSystem.Xml.Serialization;
namespaceXDF.TantraPlugIn
{
///
///ControlItem的引言表明。
///
[Serializable]
publicsealedclassControlItem
{
privatestringm_Name="";
publicstringName
{
get
{
returnthis.m_Name;
}
set
{
this.m_Name=value;
}
}
privatecharm_KeyChar=a;
publiccharKeyChar
{
get
{
returnthis.m_KeyChar;
}
set
{
this.m_KeyChar=value;
}
}
privateintm_DelayTime=100;
publicintDelayTime
{
get
{
returnthis.m_DelayTime;
}
set
{
this.m_DelayTime=value;
}
}
publicControlItem()
{
}
}
[Serializable]
publicsealedclassControlItemCollection:System.Collections.CollectionBase
{
publicControlItemthis[intindex]
{
get
{
return(ControlItem)List[index];
}
set
{
List[index]=value;
}
}
publicControlItemCollection()
{
}
publicintAdd(ControlItemitem)
{
return

标签:C语言,游戏,游戏外挂,外挂,网游,类库
来源: