﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>学习日记 &#187; 外挂</title>
	<atom:link href="https://www.softwareace.cn/?cat=23&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>https://www.softwareace.cn</link>
	<description>时刻想着为自己的产品多做一些对他好的事情</description>
	<lastBuildDate>Fri, 20 Mar 2026 06:58:28 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>游戏外挂开发系列&#8211;游戏喊话器</title>
		<link>https://www.softwareace.cn/?p=179</link>
		<comments>https://www.softwareace.cn/?p=179#comments</comments>
		<pubDate>Wed, 20 Feb 2013 09:10:00 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[外挂]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=179</guid>
		<description><![CDATA[from&#160;http://blog.csdn.net/sandyandy/article/detail [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>from&nbsp;http://blog.csdn.net/sandyandy/article/details/1917074</p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	<strong>前言</strong></p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	无疑，伴随着现在的游戏市场日益膨胀的同时，带来了很多与游戏相关的商业活动，游戏中的交易带来了无限的商机和巨额的利润，而如何在游戏中进行产品和业务的推广，是十分重要的。前段时间，鉴于朋友的摆脱，帮忙开发了一个游戏中喊话器，其中涉及一些技术要点，现在总结如下</p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	<strong>1. 一些在动手开发前要说的</strong></p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	游戏喊话，初级的实现是借助键盘模拟，高级的实现是借助键盘驱动的模拟，但是这些模拟都会有个缺点：不能同是在多个游戏中喊话，也不能在后台喊话，因此这种模拟技术不是完美的（这是由windows原理决定的）。游戏的外挂开发大多是跨进程，普通的方法是注入（我的喊话程序的第一个版本就是基于注入的），更高级点实现是想办法将要跨进程的操作转化为不要跨进程（我的喊话程序的第二个版本就是基于这种思想的），下面逐个讲解下其中的技术要点。</p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	<strong>2. 如何获取游戏的窗口？</strong></p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	HWND WindowFromPoint(<br />
	&nbsp; POINT<em>&nbsp;<a class="synParam" href="http://writeblog.csdn.net/Editor/FCKeditor/editor/" style="color: rgb(51, 102, 153); text-decoration: initial;">Point</a></em>&nbsp; // point<br />
	);</p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	利用这个函数能够拾取游戏的窗口</p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	<strong>3.如何获取窗口的线程？</strong></p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	DWORD GetWindowThreadProcessId(<br />
	&nbsp; HWND<em>&nbsp;<a class="synParam" href="http://writeblog.csdn.net/Editor/FCKeditor/editor/" style="color: rgb(51, 102, 153); text-decoration: initial;">hWnd</a></em>,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // handle to window<br />
	&nbsp; LPDWORD<em>&nbsp;<a class="synParam" href="http://writeblog.csdn.net/Editor/FCKeditor/editor/" style="color: rgb(51, 102, 153); text-decoration: initial;">lpdwProcessId</a>&nbsp;</em>// process identifier<br />
	);</p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	利用这个函数能够获取游戏窗口的线程ID</p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	<strong>4.如何获取游戏窗口线程的局部状态？</strong></p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	BOOL AttachThreadInput(<br />
	&nbsp; DWORD<em>&nbsp;<a class="synParam" href="http://writeblog.csdn.net/Editor/FCKeditor/editor/" style="color: rgb(51, 102, 153); text-decoration: initial;">idAttach</a></em>,&nbsp;&nbsp;&nbsp; // thread to attach<br />
	&nbsp; DWORD<em>&nbsp;<a class="synParam" href="http://writeblog.csdn.net/Editor/FCKeditor/editor/" style="color: rgb(51, 102, 153); text-decoration: initial;">idAttachTo</a></em>,&nbsp; // thread to attach to<br />
	&nbsp; BOOL<em>&nbsp;<a class="synParam" href="http://writeblog.csdn.net/Editor/FCKeditor/editor/" style="color: rgb(51, 102, 153); text-decoration: initial;">fAttach</a></em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // attach or detach<br />
	);</p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	利用这个函数能够绑定游戏窗口线程的局部状态，到此，你就不用跨进程去操作游戏窗口了</p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	<strong>4.接下来应该怎么办？</strong></p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	HWND SetFocus(<br />
	&nbsp; HWND<em>&nbsp;<a class="synParam" href="http://writeblog.csdn.net/Editor/FCKeditor/editor/" style="color: rgb(51, 102, 153); text-decoration: initial;">hWnd</a></em>&nbsp;&nbsp; // handle to window<br />
	);</p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	为什么要进行这个调用?因为wm_keydown,wm_keyup是发送给线程中具有焦点的窗口，因此需要对游戏的窗口进行焦点的设置</p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	<strong>5.如何在游戏窗口上喊话？</strong></p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	BOOL PostMessage(<br />
	&nbsp; HWND<em>&nbsp;<a class="synParam" href="http://writeblog.csdn.net/Editor/FCKeditor/editor/" style="color: rgb(51, 102, 153); text-decoration: initial;">hWnd</a></em>,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // handle to destination window<br />
	&nbsp; UINT<em>&nbsp;<a class="synParam" href="http://writeblog.csdn.net/Editor/FCKeditor/editor/" style="color: rgb(51, 102, 153); text-decoration: initial;">Msg</a></em>,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // message<br />
	&nbsp; WPARAM<em>&nbsp;<a class="synParam" href="http://writeblog.csdn.net/Editor/FCKeditor/editor/" style="color: rgb(51, 102, 153); text-decoration: initial;">wParam</a></em>,&nbsp; // first message parameter<br />
	&nbsp; LPARAM<em>&nbsp;<a class="synParam" href="http://writeblog.csdn.net/Editor/FCKeditor/editor/" style="color: rgb(51, 102, 153); text-decoration: initial;">lParam</a></em>&nbsp;&nbsp; // second message parameter<br />
	);</p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	这里就将要喊话的内容以wm_keydown,wm_keyup发送到游戏窗口上了</p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	<strong>6. 补充的东西</strong></p>
<p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">
	以这种方法能够在后台同时在多个游戏中喊话，与键盘模拟的实现来相比起来，出色多了，但是在某些游戏中会出现喊话的内容重叠的时候，如果哪位大虾能指点一二，感激不尽。</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=179</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
