<?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"
	>

<channel>
	<title>freshbug.com</title>
	<atom:link href="http://www.freshbug.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.freshbug.com</link>
	<description>品味年轻，分享喜悦，记录过程的精彩</description>
	<pubDate>Fri, 05 Feb 2010 10:50:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Inside the C++ object Model 读书笔记（二）</title>
		<link>http://www.freshbug.com/archives/88</link>
		<comments>http://www.freshbug.com/archives/88#comments</comments>
		<pubDate>Thu, 04 Feb 2010 16:28:27 +0000</pubDate>
		<dc:creator>freshbug</dc:creator>
		
		<category><![CDATA[二十三十]]></category>

		<category><![CDATA[游戏人生]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[RTTI]]></category>

		<category><![CDATA[内存布局]]></category>

		<category><![CDATA[读书笔记]]></category>

		<guid isPermaLink="false">http://www.freshbug.com/?p=88</guid>
		<description><![CDATA[断断续续读完这本书，花了接近两年时间，做游戏之前开始读，公司的项目做的差不多了，才读完第一遍。刚进去的时候是新人，转眼成了老鸟。
初读这本书的缘由，只是逆向的时候职业习惯对于C系语言地址+偏移的敏感，不解类的构造和传统的struct在内存布局上的区别和暗中手脚。读完之后，ADT，布局，虚函数表，临时对象，模板绑定，运行期识别等实现方式了然于胸。
书的上半部分已经解了我的惑，阐述的内容集中于C++之于C的内存布局和编译器在强类型语法上的支持及实现手法，表现于vptr，virtual public之实现，重在编译和链接期。
下半部分对new/placement new，全局对象预分配，临时对象的生成时机，EH, RTTI, type_info，type_id，以及dynamic_cast之于引用和指针都做了独到的讲解，重在运行期的数据结构组织查询方式。
全书每一个测试都贯穿了执行效率和代码复杂度上代价互换的思考，到后期的一条测试主线甚至加进了各家编译器之于不同应用平台的特化性/效率取舍，受益匪浅。
以下是感悟了：
C++之尤雅 在于有效解决了函数名重用的问题 vtable的实际作用一方面在于解决了无数的if elseif，另一方面避免了系列函数名之累赘。
然而局限也在源于此，无论vtable也好，EH也好，RTTI也好，都是在编译期硬编码了某些地址或者执行期依赖的结构信息，在视野扩展到操作系统的跨进程环境下，不同进程内虚拟地址就无法共享了。
回过头来看 ，C++编译器上的很多东西，MFC也有一些蹩脚实现。书的最后几句话讲了COM相关的东西，如COM当初开发组的leader所言，微软之所以要做COM，初衷只是解决进程间通信的问题。
最后抄一段代码来结束这半年的开发和学习生活。

#include "stdafx.h"
#include &#60;iostream&#62;
#include &#60;typeinfo&#62;
using namespace std;
class B
{
};
class D :public B
{
};
int _tmain(int argc, _TCHAR* argv[])
{
B *pb = new B;
D *pd = new D;
cout &#60;&#60;&#8221;pb&#8217;s type name = &#8221; &#60;&#60; typeid(pb).name() &#60;&#60; endl;
cout &#60;&#60;&#8221;pd&#8217;s type name = &#8221; &#60;&#60; typeid(pd).name() &#60;&#60; endl;
cout &#60;&#60;&#8221;pb&#8217;s type rawname = &#8221; &#60;&#60; typeid(pb).raw_name() [...]]]></description>
			<content:encoded><![CDATA[<p>断断续续读完这本书，花了接近两年时间，做游戏之前开始读，公司的项目做的差不多了，才读完第一遍。刚进去的时候是新人，转眼成了老鸟。</p>
<p>初读这本书的缘由，只是逆向的时候职业习惯对于C系语言地址+偏移的敏感，不解类的构造和传统的struct在内存布局上的区别和暗中手脚。读完之后，ADT，布局，虚函数表，临时对象，模板绑定，运行期识别等实现方式了然于胸。</p>
<p>书的上半部分已经解了我的惑，阐述的内容集中于C++之于C的内存布局和编译器在强类型语法上的支持及实现手法，表现于vptr，virtual public之实现，重在编译和链接期。</p>
<p>下半部分对new/placement new，全局对象预分配，临时对象的生成时机，EH, RTTI, type_info，type_id，以及dynamic_cast之于引用和指针都做了独到的讲解，重在运行期的数据结构组织查询方式。</p>
<p>全书每一个测试都贯穿了执行效率和代码复杂度上代价互换的思考，到后期的一条测试主线甚至加进了各家编译器之于不同应用平台的特化性/效率取舍，受益匪浅。</p>
<p>以下是感悟了：</p>
<p>C++之尤雅 在于有效解决了函数名重用的问题 vtable的实际作用一方面在于解决了无数的if elseif，另一方面避免了系列函数名之累赘。</p>
<p>然而局限也在源于此，无论vtable也好，EH也好，RTTI也好，都是在编译期硬编码了某些地址或者执行期依赖的结构信息，在视野扩展到操作系统的跨进程环境下，不同进程内虚拟地址就无法共享了。</p>
<p>回过头来看 ，C++编译器上的很多东西，MFC也有一些蹩脚实现。书的最后几句话讲了COM相关的东西，如COM当初开发组的leader所言，微软之所以要做COM，初衷只是解决进程间通信的问题。</p>
<p>最后抄一段代码来结束这半年的开发和学习生活。<br />
<code><br />
#include "stdafx.h"<br />
#include &lt;iostream&gt;<br />
#include &lt;typeinfo&gt;<br />
using namespace std;<br />
class B<br />
{<br />
};<br />
class D :public B<br />
{<br />
};<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
B *pb = new B;<br />
D *pd = new D;<br />
cout &lt;&lt;&#8221;pb&#8217;s type name = &#8221; &lt;&lt; typeid(pb).name() &lt;&lt; endl;<br />
cout &lt;&lt;&#8221;pd&#8217;s type name = &#8221; &lt;&lt; typeid(pd).name() &lt;&lt; endl;<br />
cout &lt;&lt;&#8221;pb&#8217;s type rawname = &#8221; &lt;&lt; typeid(pb).raw_name() &lt;&lt; endl;<br />
cout &lt;&lt;&#8221;pd&#8217;s type rawname = &#8221; &lt;&lt; typeid(pd).raw_name() &lt;&lt; endl;<br />
system(&#8221;pause&#8221;);<br />
return 0;<br />
}<br />
</code></p>

	<!-- Generated by Simple Tags 1.2.2 - http://wordpress.org/extend/plugins/simple-tags -->
	关键字： <a href="http://www.freshbug.com/archives/tag/c" title="C++" rel="tag">C++</a>, <a href="http://www.freshbug.com/archives/tag/rtti" title="RTTI" rel="tag">RTTI</a>, <a href="http://www.freshbug.com/archives/tag/%e5%86%85%e5%ad%98%e5%b8%83%e5%b1%80" title="内存布局" rel="tag">内存布局</a>, <a href="http://www.freshbug.com/archives/tag/%e8%af%bb%e4%b9%a6%e7%ac%94%e8%ae%b0" title="读书笔记" rel="tag">读书笔记</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.freshbug.com/archives/88/feed</wfw:commentRss>
		</item>
		<item>
		<title>Inside the C++ object Model 读书笔记（一）</title>
		<link>http://www.freshbug.com/archives/87</link>
		<comments>http://www.freshbug.com/archives/87#comments</comments>
		<pubDate>Tue, 01 Dec 2009 03:08:50 +0000</pubDate>
		<dc:creator>freshbug</dc:creator>
		
		<category><![CDATA[二十三十]]></category>

		<category><![CDATA[游戏人生]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[call vfunc]]></category>

		<category><![CDATA[vptr]]></category>

		<category><![CDATA[vtable]]></category>

		<category><![CDATA[内存布局]]></category>

		<guid isPermaLink="false">http://www.freshbug.com/?p=87</guid>
		<description><![CDATA[这本书忙中偷闲读了半年有余才看完4章 每次总是看过几页又得往回翻 年底重拾此书 写下一些代码调试了书中知识点
发现毕业几年来第一次碰到一本书写得如此有味道
前几章的内容不外乎讲各厂家编译器里对象初始化、内存布局、内存管理、虚表的实现细节
细读来 以前理解不是很深刻的多重继承下指针转化的偏移开销 初始化表和继承member的执行顺序 派生类和基类的布局方式 虚函数表的生成和调用等问题都收益颇多
太久没有更新过这个地方了 花了点时间写的测试代码贴上来献献丑

#include "stdafx.h"
#include &#60;windows.h&#62;


class Point2d
{
public:
Point2d()
{
x= 0.1;
y=0.2;
}
~Point2d()
{
}
public:
virtual DWORD getPos(){return pos;};
public:
float x;
float y;
static DWORD pos;
};
DWORD Point2d::pos = 3;
int _tmain(int argc, _TCHAR* argv[])
{
Point2d point2d;
//取类基址 地址应该在栈上
void* p = (void*)&#38;point2d;
//取vptr地址 ms的编译器把vptr放在类开头
unsigned int pVptr = (unsigned int)*(unsigned int*)p;
//取vtable地址
unsigned int* p2 = (unsigned int*)pVptr;
//vtable里第一个DWORD就是getPos的指针
unsigned int addr = *p2;
//调用虚函数getPos
DWORD ret = 0;
__asm
{
push eax;
mov eax,addr;
call eax;
mov ret,eax;
pop [...]]]></description>
			<content:encoded><![CDATA[<p>这本书忙中偷闲读了半年有余才看完4章 每次总是看过几页又得往回翻 年底重拾此书 写下一些代码调试了书中知识点<br />
发现毕业几年来第一次碰到一本书写得如此有味道<br />
前几章的内容不外乎讲各厂家编译器里对象初始化、内存布局、内存管理、虚表的实现细节<br />
细读来 以前理解不是很深刻的多重继承下指针转化的偏移开销 初始化表和继承member的执行顺序 派生类和基类的布局方式 虚函数表的生成和调用等问题都收益颇多</p>
<p>太久没有更新过这个地方了 花了点时间写的测试代码贴上来献献丑<br />
<code><br />
#include "stdafx.h"<br />
#include &lt;windows.h&gt;<br />
</code><br />
<code><br />
class Point2d<br />
{<br />
public:<br />
Point2d()<br />
{<br />
x= 0.1;<br />
y=0.2;<br />
}<br />
~Point2d()<br />
{<br />
}<br />
public:<br />
virtual DWORD getPos(){return pos;};<br />
public:<br />
float x;<br />
float y;<br />
static DWORD pos;<br />
};<br />
DWORD Point2d::pos = 3;<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
Point2d point2d;<br />
//取类基址 地址应该在栈上<br />
void* p = (void*)&amp;point2d;<br />
//取vptr地址 ms的编译器把vptr放在类开头<br />
unsigned int pVptr = (unsigned int)*(unsigned int*)p;<br />
//取vtable地址<br />
unsigned int* p2 = (unsigned int*)pVptr;<br />
//vtable里第一个DWORD就是getPos的指针<br />
unsigned int addr = *p2;<br />
//调用虚函数getPos<br />
DWORD ret = 0;<br />
__asm<br />
{<br />
push eax;<br />
mov eax,addr;<br />
call eax;<br />
mov ret,eax;<br />
pop eax;<br />
}<br />
printf(&#8221;getPos= %u\n&#8221;,ret);<br />
printf(&#8221;&amp;point2d.x = %p\n&#8221;,&amp;point2d.x);<br />
printf(&#8221;&amp;point2d.y = %p\n&#8221;,&amp;point2d.y);<br />
printf(&#8221;&amp;Point2d::x = %p\n&#8221;,&amp;Point2d::x);<br />
printf(&#8221;&amp;Point2d::y = %p\n&#8221;,&amp;Point2d::y);<br />
printf(&#8221;&amp;point2d.pos = %p\n&#8221;,&amp;point2d.pos);<br />
printf(&#8221;&amp;Point2d::pos = %p\n&#8221;,&amp;Point2d::pos);<br />
return 0;<br />
}<br />
</code></p>

	<!-- Generated by Simple Tags 1.2.2 - http://wordpress.org/extend/plugins/simple-tags -->
	关键字： <a href="http://www.freshbug.com/archives/tag/c" title="C++" rel="tag">C++</a>, <a href="http://www.freshbug.com/archives/tag/call-vfunc" title="call&nbsp;vfunc" rel="tag">call&nbsp;vfunc</a>, <a href="http://www.freshbug.com/archives/tag/vptr" title="vptr" rel="tag">vptr</a>, <a href="http://www.freshbug.com/archives/tag/vtable" title="vtable" rel="tag">vtable</a>, <a href="http://www.freshbug.com/archives/tag/%e5%86%85%e5%ad%98%e5%b8%83%e5%b1%80" title="内存布局" rel="tag">内存布局</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.freshbug.com/archives/87/feed</wfw:commentRss>
		</item>
		<item>
		<title>VC8下多线程环境中AfxGetMainWnd()返回空指针问题及解决方法</title>
		<link>http://www.freshbug.com/archives/84</link>
		<comments>http://www.freshbug.com/archives/84#comments</comments>
		<pubDate>Fri, 03 Jul 2009 06:21:41 +0000</pubDate>
		<dc:creator>freshbug</dc:creator>
		
		<category><![CDATA[游戏人生]]></category>

		<category><![CDATA[虫子收集]]></category>

		<category><![CDATA[AfxGetMainWnd]]></category>

		<category><![CDATA[vc8]]></category>

		<category><![CDATA[多线程]]></category>

		<category><![CDATA[空指针]]></category>

		<guid isPermaLink="false">http://www.freshbug.com/?p=84</guid>
		<description><![CDATA[一个vc6的项目放到vc8下重新编译 这里死活过不去 查了些资料无果 后来翻到一句老外的回答
If AfxGetMainWnd is called from the application&#8217;s primary thread, it returns the application&#8217;s main window according to the above rules. If the function is called from a secondary thread in the application, the function returns the main window associated with the thread that made the call.
大概意思就是说在子线程里面调用AfxGetMainWnd()返回的是和当前线程相关联的窗体句柄而不是当前程序的主窗体句柄。不知道这是不是vc8的一个改变，也没时间去细查。
解决方法1：
CWnd* m_pCWnd = NULL;
在OnInitDialog里 m_pCWnd = AfxGetMainWnd();
解决方法2：
调用AfxGetMainWnd()的地方替换成AfxGetApp()->m_pMainWnd
编译后运行问题解决

	
	关键字： [...]]]></description>
			<content:encoded><![CDATA[<p>一个vc6的项目放到vc8下重新编译 这里死活过不去 查了些资料无果 后来翻到一句老外的回答</p>
<blockquote><p>If AfxGetMainWnd is called from the application&#8217;s primary thread, it returns the application&#8217;s main window according to the above rules. If the function is called from a secondary thread in the application, the function returns the main window associated with the thread that made the call.</p></blockquote>
<p>大概意思就是说在<strong>子线程里面调用AfxGetMainWnd()返回的是和当前线程相关联的窗体句柄而不是当前程序的主窗体句柄。</strong>不知道这是不是vc8的一个改变，也没时间去细查。</p>
<p>解决方法1：<br />
CWnd* m_pCWnd = NULL;<br />
在OnInitDialog里 m_pCWnd = AfxGetMainWnd();</p>
<p>解决方法2：<br />
调用AfxGetMainWnd()的地方替换成AfxGetApp()->m_pMainWnd</p>
<p>编译后运行问题解决</p>

	<!-- Generated by Simple Tags 1.2.2 - http://wordpress.org/extend/plugins/simple-tags -->
	关键字： <a href="http://www.freshbug.com/archives/tag/afxgetmainwnd" title="AfxGetMainWnd" rel="tag">AfxGetMainWnd</a>, <a href="http://www.freshbug.com/archives/tag/vc8" title="vc8" rel="tag">vc8</a>, <a href="http://www.freshbug.com/archives/tag/%e5%a4%9a%e7%ba%bf%e7%a8%8b" title="多线程" rel="tag">多线程</a>, <a href="http://www.freshbug.com/archives/tag/%e7%a9%ba%e6%8c%87%e9%92%88" title="空指针" rel="tag">空指针</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.freshbug.com/archives/84/feed</wfw:commentRss>
		</item>
		<item>
		<title>VS2005断点失效解决方法</title>
		<link>http://www.freshbug.com/archives/79</link>
		<comments>http://www.freshbug.com/archives/79#comments</comments>
		<pubDate>Sat, 23 May 2009 10:41:31 +0000</pubDate>
		<dc:creator>freshbug</dc:creator>
		
		<category><![CDATA[游戏人生]]></category>

		<category><![CDATA[虫子收集]]></category>

		<category><![CDATA[bug]]></category>

		<category><![CDATA[vs2005]]></category>

		<category><![CDATA[失效]]></category>

		<category><![CDATA[断点]]></category>

		<guid isPermaLink="false">http://www.freshbug.com/?p=79</guid>
		<description><![CDATA[最近遇到这个问题很多次了。
以前解决好了，就忘了怎么解决，然后问题过了，之后仍要重新翻帖子找资料，这确实是微软的BUG。娘的。
解决方法：
1、无效断点所在的项目和启动项目的设置：项目->属性->配置属性->C/C++->常规->调试信息格式，这里不能为『禁用』；
回：默认的Debug模式，这个就是非禁用状态。
2、项目->属性->配置属性->链接器->调试->生成调试信息，这里设为『是』；
回：Debug模式的默认值。（手抽和VS版本混乱者排除）
3、C/C++->优化->优化选择『禁用』；
回：Debug模式的默认值。（手抽和VS版本混乱者排除）
4、删除解决方案下的.ncb文件；
回：这个方法比较管用。
5、工具->选项->调试->『要求源文件与原始版本完成匹配』去掉勾；
回：这个不建议使用，不然编译出来的版本可能不是你最新的代码编译出来的。
而且你也很难找问题，强烈BS这个方法。
6、最后在上述设置的情况下，重新编译整个解决方案；
回：这个方法比较管用。
7、回过头来，检查原来的代码到底会不会被执行到
通常来说，1，2，3点出问题的可能性最大 ，实在不行 可以通过去掉和代码的完全匹配的来强制调试，但是很可能这些地方都检查之后也不能解决你的问题。
如果这些方法都不能解决问题，ctrl+A选中不能下断点的cpp或者h文件全部内容，编辑->高级->设置选定内容的格式。
一般来说清理一次符号文件和obj文件再编译就可以调试了。

	
	关键字： bug, vs2005, 失效, 断点
]]></description>
			<content:encoded><![CDATA[<p>最近遇到这个问题很多次了。<br />
以前解决好了，就忘了怎么解决，然后问题过了，之后仍要重新翻帖子找资料，这确实是微软的BUG。娘的。<br />
解决方法：<br />
1、无效断点所在的项目和启动项目的设置：项目->属性->配置属性->C/C++->常规->调试信息格式，这里不能为『禁用』；<br />
回：默认的Debug模式，这个就是非禁用状态。</p>
<p>2、项目->属性->配置属性->链接器->调试->生成调试信息，这里设为『是』；<br />
回：Debug模式的默认值。（手抽和VS版本混乱者排除）</p>
<p>3、C/C++->优化->优化选择『禁用』；<br />
回：Debug模式的默认值。（手抽和VS版本混乱者排除）</p>
<p>4、删除解决方案下的.ncb文件；<br />
回：这个方法比较管用。</p>
<p>5、工具->选项->调试->『要求源文件与原始版本完成匹配』去掉勾；<br />
回：这个不建议使用，不然编译出来的版本可能不是你最新的代码编译出来的。<br />
而且你也很难找问题，强烈BS这个方法。</p>
<p>6、最后在上述设置的情况下，重新编译整个解决方案；<br />
回：这个方法比较管用。</p>
<p>7、回过头来，检查原来的代码到底会不会被执行到</p>
<p>通常来说，1，2，3点出问题的可能性最大 ，实在不行 可以通过去掉和代码的完全匹配的来强制调试，但是很可能这些地方都检查之后也不能解决你的问题。</p>
<p>如果这些方法都不能解决问题，<strong>ctrl+A选中不能下断点的cpp或者h文件全部内容，编辑->高级->设置选定内容的格式。<br />
一般来说清理一次符号文件和obj文件再编译就可以调试了</strong>。</p>

	<!-- Generated by Simple Tags 1.2.2 - http://wordpress.org/extend/plugins/simple-tags -->
	关键字： <a href="http://www.freshbug.com/archives/tag/bug" title="bug" rel="tag">bug</a>, <a href="http://www.freshbug.com/archives/tag/vs2005" title="vs2005" rel="tag">vs2005</a>, <a href="http://www.freshbug.com/archives/tag/%e5%a4%b1%e6%95%88" title="失效" rel="tag">失效</a>, <a href="http://www.freshbug.com/archives/tag/%e6%96%ad%e7%82%b9" title="断点" rel="tag">断点</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.freshbug.com/archives/79/feed</wfw:commentRss>
		</item>
		<item>
		<title>VC8下gh0st 3.6调试环境搭建</title>
		<link>http://www.freshbug.com/archives/78</link>
		<comments>http://www.freshbug.com/archives/78#comments</comments>
		<pubDate>Sat, 21 Mar 2009 07:34:14 +0000</pubDate>
		<dc:creator>freshbug</dc:creator>
		
		<category><![CDATA[好好活着]]></category>

		<category><![CDATA[vc8 gh0st 调试]]></category>

		<guid isPermaLink="false">http://www.freshbug.com/?p=78</guid>
		<description><![CDATA[前几天大概读了下gh0st的框架 并且编译完成 着手调试 花了两天时间成功搭建好局域网利用虚拟机作为实验目标的调试环境
1.vm 6.5 绿色版 随便下一个 装上vmtool 可以顺便开个IIS测试http上线
2.找了个2000 adv server来做虚拟机 网络模式选最简单的桥接 懒得配 做好之后建立快照以便驱动崩溃后恢复
3.打开编译好的gh0st控制端生成服务端一个 选择DNS上线 ip就填控制端主机的局域网ip即可
4.将服务端文件拖到vm机上运行 ok 能够上线了
下面来配调试环境：
1.可以就用源码里的release编译 懒得新建了 改一点参数 禁用/02优化 改为/0d 调试信息格式/Zi或/ZI均可 打开调试信息输出/DEBUG 3个工程都改好后重新编译 就能断住了
2.复制重新编译生成的服务端文件和VC8远程调试工具服务端文件(remote debugger目录)到vm机 打开x86目录下的msvsmon文件 依次选择菜单栏工具-&#62;选项-&#62;无身份验证 复选允许任何用户调试 端口默认即可
3.打开vc8 gh0st解决方案 把svchost设为默认启动项目 随便下个断点（我是搜索“文件管理” ，于是断点下到了服务端处理文件管理消息的地方）
4.vc8工具栏 依次选择-&#62;调试-&#62;附加到进程-&#62;远程-&#62;输入ip地址-&#62;回车即看到目标vm机进程
5.gh0st服务端的代码是注入svchost的 由于进程列表中有多个不好确定 可以通过控制端发送一个比较大的文件 服务端打开taskmgr 被注入代码的svchost进程CPU占用率会飙升 记住pid号 回到vc8环境中 attach上去
6.断点打好 服务端随便执行点命令 ok 断住了 慢慢爽吧：）

	
	关键字： vc8&#160;gh0st&#160;调试
]]></description>
			<content:encoded><![CDATA[<p>前几天大概读了下gh0st的框架 并且编译完成 着手调试 花了两天时间成功搭建好局域网利用虚拟机作为实验目标的调试环境</p>
<p>1.vm 6.5 绿色版 随便下一个 装上vmtool 可以顺便开个IIS测试http上线</p>
<p>2.找了个2000 adv server来做虚拟机 网络模式选最简单的桥接 懒得配 做好之后建立快照以便驱动崩溃后恢复</p>
<p>3.打开编译好的gh0st控制端生成服务端一个 选择DNS上线 ip就填控制端主机的局域网ip即可</p>
<p>4.将服务端文件拖到vm机上运行 ok 能够上线了</p>
<p>下面来配调试环境：</p>
<p>1.可以就用源码里的release编译 懒得新建了 改一点参数 禁用/02优化 改为/0d 调试信息格式/Zi或/ZI均可 打开调试信息输出/DEBUG 3个工程都改好后重新编译 就能断住了</p>
<p>2.复制重新编译生成的服务端文件和VC8远程调试工具服务端文件(remote debugger目录)到vm机 打开x86目录下的msvsmon文件 依次选择菜单栏工具-&gt;选项-&gt;无身份验证 复选允许任何用户调试 端口默认即可</p>
<p>3.打开vc8 gh0st解决方案 把svchost设为默认启动项目 随便下个断点（我是搜索“文件管理” ，于是断点下到了服务端处理文件管理消息的地方）</p>
<p>4.vc8工具栏 依次选择-&gt;调试-&gt;附加到进程-&gt;远程-&gt;输入ip地址-&gt;回车即看到目标vm机进程</p>
<p>5.gh0st服务端的代码是注入svchost的 由于进程列表中有多个不好确定 可以通过控制端发送一个比较大的文件 服务端打开taskmgr 被注入代码的svchost进程CPU占用率会飙升 记住pid号 回到vc8环境中 attach上去</p>
<p>6.断点打好 服务端随便执行点命令 ok 断住了 慢慢爽吧：）</p>

	<!-- Generated by Simple Tags 1.2.2 - http://wordpress.org/extend/plugins/simple-tags -->
	关键字： <a href="http://www.freshbug.com/archives/tag/vc8-gh0st-%e8%b0%83%e8%af%95" title="vc8&nbsp;gh0st&nbsp;调试" rel="tag">vc8&nbsp;gh0st&nbsp;调试</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.freshbug.com/archives/78/feed</wfw:commentRss>
		</item>
		<item>
		<title>VC8 编译 gh0st 3.6 源代码诸多问题解决方法</title>
		<link>http://www.freshbug.com/archives/77</link>
		<comments>http://www.freshbug.com/archives/77#comments</comments>
		<pubDate>Thu, 19 Mar 2009 05:51:59 +0000</pubDate>
		<dc:creator>freshbug</dc:creator>
		
		<category><![CDATA[好好活着]]></category>

		<category><![CDATA[vc8 编译 链接 gh0st]]></category>

		<category><![CDATA[添加新标签]]></category>

		<guid isPermaLink="false">http://www.freshbug.com/?p=77</guid>
		<description><![CDATA[直接编译gh0st控制端源码会提示Cj60的一个库里面函数名找不到 估计是原来的库在VC60下编译 不匹配的问题
找到CJ60文件夹 打开 编译Cj60StaticLib库
1.报错 找不到文件&#60;..\src\afximpl.h&#62;
貌似从VC7开始这个头文件放在\src\mfc下 找到 stdafx.h 改之
#include &#60;..\src\mfc\afximpl.h&#62;
2.error C2440: “static_cast”: 无法从“UINT (__thiscall CCJControlBar::* )(CPoint)”转换为“LRESULT (__thiscall CWnd::* )(CPoint)”
类型定义的问题 把相关参数的函数返回值改成LRESULT
3.error C2440: “static_cast”: 无法从“BOOL (__thiscall CCJPagerCtrl::* )(NMPGSCROLL *,LRESULT *)”转换为“BOOL (__thiscall CCmdTarget::* )(NMHDR *,LRESULT *)”
宏展开后参数不匹配的问题 把NMPGSCROL改成NMHDR进子程序后强转
LPNMPGSCROL pnmpgs = (LPNMPGSCROL ) pnmhdr;
4.error C2664: “MultiByteToWideChar”: 不能将参数 5 从“USHORT *”转换为“LPWSTR”
这个是从某一版本以后 wchar_t开始变成编译器内置类型的问题 几个串类型之间不能默认转换 强转即可
接下来编译控制端gh0st
1.一上来提示找不到stdafx.h 我靠 打开header目录一看 有这个文件 ok 在附加包含目录里面加入“./”  解决了
2.error 2440 [...]]]></description>
			<content:encoded><![CDATA[<p>直接编译gh0st控制端源码会提示Cj60的一个库里面函数名找不到 估计是原来的库在VC60下编译 不匹配的问题</p>
<p>找到CJ60文件夹 打开 编译Cj60StaticLib库</p>
<p>1.报错 找不到文件&lt;..\src\afximpl.h&gt;</p>
<p>貌似从VC7开始这个头文件放在\src\mfc下 找到 stdafx.h 改之</p>
<p>#include &lt;..\src\mfc\afximpl.h&gt;</p>
<p>2.error C2440: “static_cast”: 无法从“UINT (__thiscall CCJControlBar::* )(CPoint)”转换为“LRESULT (__thiscall CWnd::* )(CPoint)”</p>
<p>类型定义的问题 把相关参数的函数返回值改成LRESULT</p>
<p>3.error C2440: “static_cast”: 无法从“BOOL (__thiscall CCJPagerCtrl::* )(NMPGSCROLL *,LRESULT *)”转换为“BOOL (__thiscall CCmdTarget::* )(NMHDR *,LRESULT *)”</p>
<p>宏展开后参数不匹配的问题 把NMPGSCROL改成NMHDR进子程序后强转</p>
<p>LPNMPGSCROL pnmpgs = (LPNMPGSCROL ) pnmhdr;</p>
<p>4.error C2664: “MultiByteToWideChar”: 不能将参数 5 从“USHORT *”转换为“LPWSTR”</p>
<p>这个是从某一版本以后 wchar_t开始变成编译器内置类型的问题 几个串类型之间不能默认转换 强转即可</p>
<p>接下来编译控制端gh0st</p>
<p>1.一上来提示找不到stdafx.h 我靠 打开header目录一看 有这个文件 ok 在附加包含目录里面加入“./”  解决了</p>
<p>2.error 2440 和刚才一样的问题 MFC展开宏的问题 进去强转指针即可</p>
<p>3.ok 到这里再编译 能通过了 刚才那一堆link错误 由于我们用vc8重新编译了cj60库也解决了 但是多出来几个link错误</p>
<p>nafxcw.lib(afxmem.obj) : error LNK2005: &#8220;void * __cdecl operator new(unsigned int)&#8221; (??2@YAPAXI@Z) 已经在 LIBCMT.lib(new.obj) 中定义</p>
<p>看意思大概是操作符在几个库里有重定义的问题 试了忽略nafxcw.lib和libcmt.lib 都不行 后翻到一篇帖子 这种问题需要在附加依赖项里面指定一下链接的先后顺序即可 先链接nafxcw.lib 后链接libcmt.lib 如果编译调试版在库后面加个d</p>
<p>好了 甩个服务端到虚拟机上去 咱们开始调试吧</p>
<p>参考文献：</p>
<p>http://topic.csdn.net/t/20030627/23/1966751.html</p>
<p>operator new 链接重定义的问题</p>
<p>http://blog.csdn.net/orbit/archive/2008/11/28/3405309.aspx</p>
<p>从VC6到VC9移植代码问题总结</p>

	<!-- Generated by Simple Tags 1.2.2 - http://wordpress.org/extend/plugins/simple-tags -->
	关键字： <a href="http://www.freshbug.com/archives/tag/vc8-%e7%bc%96%e8%af%91-%e9%93%be%e6%8e%a5-gh0st" title="vc8&nbsp;编译&nbsp;链接&nbsp;gh0st" rel="tag">vc8&nbsp;编译&nbsp;链接&nbsp;gh0st</a>, <a href="http://www.freshbug.com/archives/tag/%e6%b7%bb%e5%8a%a0%e6%96%b0%e6%a0%87%e7%ad%be" title="添加新标签" rel="tag">添加新标签</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.freshbug.com/archives/77/feed</wfw:commentRss>
		</item>
		<item>
		<title>我要的日子</title>
		<link>http://www.freshbug.com/archives/76</link>
		<comments>http://www.freshbug.com/archives/76#comments</comments>
		<pubDate>Thu, 11 Dec 2008 12:12:40 +0000</pubDate>
		<dc:creator>freshbug</dc:creator>
		
		<category><![CDATA[二十三十]]></category>

		<category><![CDATA[幸福]]></category>

		<category><![CDATA[日子]]></category>

		<guid isPermaLink="false">http://www.freshbug.com/?p=76</guid>
		<description><![CDATA[从上海辞职回来已经大半年了，成都的感觉真好。
因缘际会做到了喜欢的游戏行业，想做的，做到了，这就是最大的幸福。
下班，骑着小车回家，路边都是臭豆腐摊子，老地方停下来吃了几个蛋烘糕，土豆丝的，豇豆的，芽菜的。
骑了一段，发现卖锅盔的婆婆今天尽然没收摊，冲上去要了两个，排在后面的哥们搞定了最后两个，话说平时这个小摊的顾客都是20个20个的买，那个汗啊。
回家，做做逆向，吃饭，洗澡上床，敲两行代码，直到深夜，要是不爽，还可以鼓捣老爸陪着出去喝啤酒吃烧烤。
周末，朋友，烫火锅，烫羊肉，陪老妈逛家具市场。
没有压抑，没有孤独，再没有看不到奔头的日子，今天下午的太阳真暖和。

	
	关键字： 幸福, 日子
]]></description>
			<content:encoded><![CDATA[<p>从上海辞职回来已经大半年了，成都的感觉真好。</p>
<p>因缘际会做到了喜欢的游戏行业，想做的，做到了，这就是最大的幸福。</p>
<p>下班，骑着小车回家，路边都是臭豆腐摊子，老地方停下来吃了几个蛋烘糕，土豆丝的，豇豆的，芽菜的。</p>
<p>骑了一段，发现卖锅盔的婆婆今天尽然没收摊，冲上去要了两个，排在后面的哥们搞定了最后两个，话说平时这个小摊的顾客都是20个20个的买，那个汗啊。</p>
<p>回家，做做逆向，吃饭，洗澡上床，敲两行代码，直到深夜，要是不爽，还可以鼓捣老爸陪着出去喝啤酒吃烧烤。</p>
<p>周末，朋友，烫火锅，烫羊肉，陪老妈逛家具市场。</p>
<p>没有压抑，没有孤独，再没有看不到奔头的日子，今天下午的太阳真暖和。</p>

	<!-- Generated by Simple Tags 1.2.2 - http://wordpress.org/extend/plugins/simple-tags -->
	关键字： <a href="http://www.freshbug.com/archives/tag/%e5%b9%b8%e7%a6%8f" title="幸福" rel="tag">幸福</a>, <a href="http://www.freshbug.com/archives/tag/%e6%97%a5%e5%ad%90" title="日子" rel="tag">日子</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.freshbug.com/archives/76/feed</wfw:commentRss>
		</item>
		<item>
		<title>VA自定义注释格式</title>
		<link>http://www.freshbug.com/archives/75</link>
		<comments>http://www.freshbug.com/archives/75#comments</comments>
		<pubDate>Sat, 22 Nov 2008 02:40:47 +0000</pubDate>
		<dc:creator>freshbug</dc:creator>
		
		<category><![CDATA[游戏人生]]></category>

		<category><![CDATA[snippets]]></category>

		<category><![CDATA[VA]]></category>

		<category><![CDATA[注释]]></category>

		<category><![CDATA[自定义]]></category>

		<guid isPermaLink="false">http://www.freshbug.com/?p=75</guid>
		<description><![CDATA[VA的快捷键注释很好用，但默认的几种注释风格有一些单调，在开发中经常需要针对建立文件，修改，合并等不同动作进行不同注释。
笔者在编辑注释模板时遇到一些展开宏的名字不甚清楚，查阅了下列官方文档后解决问题。
文档中的宏定义：
Code




Reserved String
Meaning


Date
$DATE$
Year/month/day formatted as %04d/%02d/%02d



$DAY$
Day of month formatted as %d



$DAY_02$
Day of month formatted as %02d



$DAYNAME$
Three-character abbreviation of day



$DAYLONGNAME$
Full name of day



$MONTH$
Month formatted as %d



$MONTH_02$
Month formatted as %02d



$MONTHNAME$
Three-character abbreviation of month



$MONTHLONGNAME$
Full name of month



$YEAR$
Year formatted as %d



$YEAR_02$
Year formatted as %02d


File
$FILE$
Full filename with path*



$FILE_UPPER$
Full filename with path in uppercase*



$FILE_BASE$
Filename without path or extension*



$FILE_BASE_UPPER$
Filename without path or extension [...]]]></description>
			<content:encoded><![CDATA[<p>VA的快捷键注释很好用，但默认的几种注释风格有一些单调，在开发中经常需要针对建立文件，修改，合并等不同动作进行不同注释。</p>
<p>笔者在编辑注释模板时遇到一些展开宏的名字不甚清楚，查阅了下列官方文档后解决问题。</p>
<p>文档中的宏定义：</p>
<h4>Code</h4>
<table class="text" border="0" cellpadding="4" summary="Special Strings">
<tbody>
<tr align="center">
<td></td>
<td bgcolor="#c9e5bf"><strong>Reserved String</strong></td>
<td bgcolor="#c9e5bf"><strong>Meaning</strong></td>
</tr>
<tr align="center">
<td bgcolor="#dddddd"><strong>Date</strong></td>
<td bgcolor="#eeeeee">$DATE$</td>
<td bgcolor="#eeeeee">Year/month/day formatted as %04d/%02d/%02d</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$DAY$</td>
<td bgcolor="#eeeeee">Day of month formatted as %d</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$DAY_02$</td>
<td bgcolor="#eeeeee">Day of month formatted as %02d</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$DAYNAME$</td>
<td bgcolor="#eeeeee">Three-character abbreviation of day</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$DAYLONGNAME$</td>
<td bgcolor="#eeeeee">Full name of day</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$MONTH$</td>
<td bgcolor="#eeeeee">Month formatted as %d</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$MONTH_02$</td>
<td bgcolor="#eeeeee">Month formatted as %02d</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$MONTHNAME$</td>
<td bgcolor="#eeeeee">Three-character abbreviation of month</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$MONTHLONGNAME$</td>
<td bgcolor="#eeeeee">Full name of month</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$YEAR$</td>
<td bgcolor="#eeeeee">Year formatted as %d</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$YEAR_02$</td>
<td bgcolor="#eeeeee">Year formatted as %02d</td>
</tr>
<tr align="center">
<td bgcolor="#dddddd"><strong>File</strong></td>
<td bgcolor="#eeeeee">$FILE$</td>
<td bgcolor="#eeeeee">Full filename with path*</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$FILE_UPPER$</td>
<td bgcolor="#eeeeee">Full filename with path in uppercase*</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$FILE_BASE$</td>
<td bgcolor="#eeeeee">Filename without path or extension*</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$FILE_BASE_UPPER$</td>
<td bgcolor="#eeeeee">Filename without path or extension in upper case*</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$FILE_EXT$</td>
<td bgcolor="#eeeeee">Filename extension*</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$FILE_EXT_UPPER$</td>
<td bgcolor="#eeeeee">Filename extension in upper case*</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$FILE_PATH$</td>
<td bgcolor="#eeeeee">Path of file*</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$FILE_PATH_UPPER$</td>
<td bgcolor="#eeeeee">Path of file in upper case*</td>
</tr>
<tr align="center">
<td bgcolor="#dddddd"><strong>General</strong></td>
<td bgcolor="#eeeeee">$clipboard$</td>
<td bgcolor="#eeeeee">Current clipboard</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$end$</td>
<td bgcolor="#eeeeee">Position of caret after expansion</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$selected$</td>
<td bgcolor="#eeeeee">Current selection**</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$$</td>
<td bgcolor="#eeeeee">$</td>
</tr>
<tr align="center">
<td bgcolor="#dddddd"><strong>GUID</strong></td>
<td bgcolor="#eeeeee">$GUID_DEFINITION$</td>
<td bgcolor="#eeeeee">Generated GUID formatted for use in a definition</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$GUID_STRING$</td>
<td bgcolor="#eeeeee">Generated GUID formatted for use in a string</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$GUID_STRUCT$</td>
<td bgcolor="#eeeeee">Generated GUID formatted for use in a struct</td>
</tr>
<tr align="center">
<td></td>
<td colspan="2" bgcolor="#ffffff">(Note that all instances of GUID reserved words will use a singe generated GUID.)</td>
</tr>
<tr align="center">
<td bgcolor="#dddddd"><strong>Refactor</strong></td>
<td bgcolor="#eeeeee">$GeneratedPropertyName$</td>
<td bgcolor="#eeeeee">Property name generated during Encapsulate Field</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$MethodArg$</td>
<td bgcolor="#eeeeee">One parameter of the method and its type</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$MethodArgName$</td>
<td bgcolor="#eeeeee">One parameter of the method</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$MethodArgType$</td>
<td bgcolor="#eeeeee">Type of one parameter of the method</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$MethodBody$</td>
<td bgcolor="#eeeeee">Body of implementation</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$MethodQualifier$</td>
<td bgcolor="#eeeeee">Optional qualifiers of method</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$ParameterList$</td>
<td bgcolor="#eeeeee">Parameters separated by commas</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$SymbolContext$</td>
<td bgcolor="#eeeeee">Context and name of method</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$SymbolName$</td>
<td bgcolor="#eeeeee">Name of method</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$SymbolPrivileges$</td>
<td bgcolor="#eeeeee">Access of method</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$SymbolStatic$</td>
<td bgcolor="#eeeeee">Keyword static or blank</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$SymbolType$</td>
<td bgcolor="#eeeeee">Return type of method</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$SymbolVirtual$</td>
<td bgcolor="#eeeeee">Keyword virtual or blank</td>
</tr>
<tr align="center">
<td bgcolor="#dddddd"><strong>Time</strong></td>
<td bgcolor="#eeeeee">$HOUR$</td>
<td bgcolor="#eeeeee">Hour formatted as %d</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$HOUR_02$</td>
<td bgcolor="#eeeeee">Hour formatted as %02d</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$MINUTE$</td>
<td bgcolor="#eeeeee">Minute formatted as %02d</td>
</tr>
<tr align="center">
<td bgcolor="#ffffff"></td>
<td bgcolor="#eeeeee">$SECOND$</td>
<td bgcolor="#eeeeee">Second formatted as %02d</td>
</tr>
</tbody>
</table>
<p>例子：</p>
<p><code>/****************************************************************<br />
//  FileName:	$FILE_BASE$.$FILE_EXT$<br />
//  Author:	freshbug<br />
//  Create:	$MONTH$-$DAY$-$YEAR$<br />
//  Company:	fresh-lab<br />
//  Checked:	freshbug $MONTH$-$DAY$-$YEAR$<br />
****************************************************************/</code></p>
<p>效果：</p>
<p><code>/****************************************************************<br />
//  FileName:	BufferServerMsg.h<br />
//  Author:	freshbug<br />
//  Create:	11-22-2008<br />
//  Company:	fresh-lab<br />
//  Checked:	freshbug 11-22-2008<br />
****************************************************************/</code></p>
<p><strong>原文连接请看这里：</strong><a href="http://www.wholetomato.com/products/features/vasnippets.asp">http://www.wholetomato.com/products/features/vasnippets.asp</a></p>

	<!-- Generated by Simple Tags 1.2.2 - http://wordpress.org/extend/plugins/simple-tags -->
	关键字： <a href="http://www.freshbug.com/archives/tag/snippets" title="snippets" rel="tag">snippets</a>, <a href="http://www.freshbug.com/archives/tag/va" title="VA" rel="tag">VA</a>, <a href="http://www.freshbug.com/archives/tag/%e6%b3%a8%e9%87%8a" title="注释" rel="tag">注释</a>, <a href="http://www.freshbug.com/archives/tag/%e8%87%aa%e5%ae%9a%e4%b9%89" title="自定义" rel="tag">自定义</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.freshbug.com/archives/75/feed</wfw:commentRss>
		</item>
		<item>
		<title>buffer服务器开发</title>
		<link>http://www.freshbug.com/archives/74</link>
		<comments>http://www.freshbug.com/archives/74#comments</comments>
		<pubDate>Fri, 21 Nov 2008 07:15:53 +0000</pubDate>
		<dc:creator>freshbug</dc:creator>
		
		<category><![CDATA[游戏人生]]></category>

		<category><![CDATA[buffer server dev database 缓冲]]></category>

		<guid isPermaLink="false">http://www.freshbug.com/?p=74</guid>
		<description><![CDATA[公司需要一台缓冲服务器缓解数据库频繁存取的压力，请教几位大牛后，建议fb详细看看memcached源码，采用filemap开两个进程，一进一出。这样即使逻辑服务器当机，也可从buffer服务器中恢复数据，理想状态下在出现突发性事故时可以避免回档。
关于memcached的介绍请看官方主页说明：http://www.danga.com/memcached/
最新版本是1.2.6。下载页面是这个：http://www.danga.com/memcached/download.bml
也可点击这里(memcached-1.2.6.tar.gz)直接下载压缩包。
转一篇PeakGao大牛关于数据库缓冲服务器的文章：
http://www.cppblog.com/PeakGao/archive/2006/06/10/8379.html
PeakGao
别读成痞子高
游戏数据库的思考
上个周末看了下MySQL，安装了一个试了下，重点看了c测试程序已经mysql.h中的API，发现好简单，目前公司的游戏计划也是用mysql，但是要设计好一个给游戏使用的数据库模块，也不是简单的处理一下api就能了事的，游戏数据库由于存取特别频繁，在我看来，他的设计主要解决下面几个问题：
1、数据缓存的功能
想想那么平凡的数据存取，完全依赖数据库的直接操作，这个性能是可想而知的，所以应该建立起游戏服务器和数据库之间的一个桥梁（暂且命名为数据库前端），游戏服务器只跟数据库前端交互，数据库前端自己具有数据持久化的策略，不依赖于游戏服务器的操作。数据库前端在第一次取出原始数据后（如一个角色登录时的数据），将进行本地缓存，下次存取数据都是在本地进行，并不需要更新到数据库中，至于何时更新到数据库可以有数据库前端自行决定（当然也不排除游戏服务器发出持久化的通知）。
2、增量更新的功能
其实好多数据的提交中，有很大一部分的数据是没有改变的，如果在从前端提交数据到数据库的时候采取相应的增量更新的办法，应该对性能会有所提升，尤其是在几个游戏服务器操作同一个数据库的时候，因为异步的原因，增量更新能够保证数据的正确性。
3、抛包策略
游戏服务器有很多数据实在太过频繁，但是有些类型的数据的重要性一般，所以中途丢失一些也问题不大，在服务器数据交换比较频繁的时候完全可以抛弃一些，加快存取速度（不过有了前端后是不是可以忽略这点）。
4、数据分流功能
主要体现在游戏服务器的一些不同类型的数据存取可以通过不同的几个异步队列进行处理，这样即使由于数据库的某些操作延时，也只影响到操作所在队列，不会影响其他队列。
5、灵活的多前端，多数据库等支持
实现游戏服务器，数据库前端，游戏数据库之间的多对多关系，便于灵活的运用。
写完后个人感觉达到第1，2点后，这个数据库前端功能就已经比较强劲了。

	
	关键字： buffer&#160;server&#160;dev&#160;database&#160;缓冲
]]></description>
			<content:encoded><![CDATA[<p>公司需要一台缓冲服务器缓解数据库频繁存取的压力，请教几位大牛后，建议fb详细看看memcached源码，采用filemap开两个进程，一进一出。这样即使逻辑服务器当机，也可从buffer服务器中恢复数据，理想状态下在出现突发性事故时可以避免回档。</p>
<p>关于memcached的介绍请看官方主页说明：<a href="http://www.danga.com/memcached/">http://www.danga.com/memcached/</a></p>
<p>最新版本是1.2.6。下载页面是这个：<a href="http://www.danga.com/memcached/download.bml">http://www.danga.com/memcached/download.bml</a></p>
<p>也可点击<a href="http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz">这里(memcached-1.2.6.tar.gz)</a>直接下载压缩包。</p>
<p>转一篇PeakGao大牛关于数据库缓冲服务器的文章：</p>
<p><a href="http://www.cppblog.com/PeakGao/archive/2006/06/10/8379.html">http://www.cppblog.com/PeakGao/archive/2006/06/10/8379.html</a></p>
<blockquote><p>PeakGao<br />
别读成痞子高<br />
游戏数据库的思考<br />
上个周末看了下MySQL，安装了一个试了下，重点看了c测试程序已经mysql.h中的API，发现好简单，目前公司的游戏计划也是用mysql，但是要设计好一个给游戏使用的数据库模块，也不是简单的处理一下api就能了事的，游戏数据库由于存取特别频繁，在我看来，他的设计主要解决下面几个问题：</p>
<p>1、数据缓存的功能</p>
<p>想想那么平凡的数据存取，完全依赖数据库的直接操作，这个性能是可想而知的，所以应该建立起游戏服务器和数据库之间的一个桥梁（暂且命名为数据库前端），游戏服务器只跟数据库前端交互，数据库前端自己具有数据持久化的策略，不依赖于游戏服务器的操作。数据库前端在第一次取出原始数据后（如一个角色登录时的数据），将进行本地缓存，下次存取数据都是在本地进行，并不需要更新到数据库中，至于何时更新到数据库可以有数据库前端自行决定（当然也不排除游戏服务器发出持久化的通知）。</p>
<p>2、增量更新的功能</p>
<p>其实好多数据的提交中，有很大一部分的数据是没有改变的，如果在从前端提交数据到数据库的时候采取相应的增量更新的办法，应该对性能会有所提升，尤其是在几个游戏服务器操作同一个数据库的时候，因为异步的原因，增量更新能够保证数据的正确性。</p>
<p>3、抛包策略</p>
<p>游戏服务器有很多数据实在太过频繁，但是有些类型的数据的重要性一般，所以中途丢失一些也问题不大，在服务器数据交换比较频繁的时候完全可以抛弃一些，加快存取速度（不过有了前端后是不是可以忽略这点）。</p>
<p>4、数据分流功能</p>
<p>主要体现在游戏服务器的一些不同类型的数据存取可以通过不同的几个异步队列进行处理，这样即使由于数据库的某些操作延时，也只影响到操作所在队列，不会影响其他队列。</p>
<p>5、灵活的多前端，多数据库等支持</p>
<p>实现游戏服务器，数据库前端，游戏数据库之间的多对多关系，便于灵活的运用。</p>
<p>写完后个人感觉达到第1，2点后，这个数据库前端功能就已经比较强劲了。</p></blockquote>

	<!-- Generated by Simple Tags 1.2.2 - http://wordpress.org/extend/plugins/simple-tags -->
	关键字： <a href="http://www.freshbug.com/archives/tag/buffer-server-dev-database-%e7%bc%93%e5%86%b2" title="buffer&nbsp;server&nbsp;dev&nbsp;database&nbsp;缓冲" rel="tag">buffer&nbsp;server&nbsp;dev&nbsp;database&nbsp;缓冲</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.freshbug.com/archives/74/feed</wfw:commentRss>
		</item>
		<item>
		<title>经济大萧条时代来了，你准备好了吗？</title>
		<link>http://www.freshbug.com/archives/73</link>
		<comments>http://www.freshbug.com/archives/73#comments</comments>
		<pubDate>Wed, 15 Oct 2008 03:38:20 +0000</pubDate>
		<dc:creator>freshbug</dc:creator>
		
		<category><![CDATA[二十三十]]></category>

		<category><![CDATA[每日观察]]></category>

		<category><![CDATA[萧条]]></category>

		<category><![CDATA[金融危机]]></category>

		<guid isPermaLink="false">http://www.freshbug.com/?p=73</guid>
		<description><![CDATA[1. 不要辞职。不要换工作。不要转行。不要创业。
2. 多备份几个，自己可以去的公司职位。冬天里的裁员往往会一窝蜂。上次9.11之后，我周围的人走马灯式地换工作，不是自己想换，迫不得已啊。
3. 不要主动要求老板涨工资。裁员往往会从工资高的裁起。
4. 多帮朋友留意工作机会，多介绍，轮到自己找工作的时，才会有朋友帮你。
5. 存钱。买国债。或者双币存款。别买股票。
6. 每月给父母寄钱，经济不好，越穷的人越难过。
7. 别买车。
8. 危机的后期，才最难受。现在还没开始，别觉得自己很强、没事。
9. 别离婚。别生孩子。
10. 别找小三。

	
	关键字： 萧条, 金融危机
]]></description>
			<content:encoded><![CDATA[<p>1. 不要辞职。不要换工作。不要转行。不要创业。<br />
2. 多备份几个，自己可以去的公司职位。冬天里的裁员往往会一窝蜂。上次9.11之后，我周围的人走马灯式地换工作，不是自己想换，迫不得已啊。<br />
3. 不要主动要求老板涨工资。裁员往往会从工资高的裁起。<br />
4. 多帮朋友留意工作机会，多介绍，轮到自己找工作的时，才会有朋友帮你。<br />
5. 存钱。买国债。或者双币存款。别买股票。<br />
6. 每月给父母寄钱，经济不好，越穷的人越难过。<br />
7. 别买车。<br />
8. 危机的后期，才最难受。现在还没开始，别觉得自己很强、没事。<br />
9. 别离婚。别生孩子。<br />
10. 别找小三。</p>

	<!-- Generated by Simple Tags 1.2.2 - http://wordpress.org/extend/plugins/simple-tags -->
	关键字： <a href="http://www.freshbug.com/archives/tag/%e8%90%a7%e6%9d%a1" title="萧条" rel="tag">萧条</a>, <a href="http://www.freshbug.com/archives/tag/%e9%87%91%e8%9e%8d%e5%8d%b1%e6%9c%ba" title="金融危机" rel="tag">金融危机</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.freshbug.com/archives/73/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
