<?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>Windows &#8211; 张三太爷</title>
	<atom:link href="https://www.somedoc.net/tag/windows/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.somedoc.net</link>
	<description>看前面，黑洞洞</description>
	<lastBuildDate>Sat, 11 Mar 2017 09:12:32 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.1</generator>

<image>
	<url>https://www.somedoc.net/wp-content/uploads/2016/12/cropped-dandycheung-1-32x32.jpg</url>
	<title>Windows &#8211; 张三太爷</title>
	<link>https://www.somedoc.net</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>全局作用域下调用属于对象的方法</title>
		<link>https://www.somedoc.net/2017/03/11/%e5%85%a8%e5%b1%80%e4%bd%9c%e7%94%a8%e5%9f%9f%e4%b8%8b%e8%b0%83%e7%94%a8%e5%b1%9e%e4%ba%8e%e5%af%b9%e8%b1%a1%e7%9a%84%e6%96%b9%e6%b3%95/</link>
					<comments>https://www.somedoc.net/2017/03/11/%e5%85%a8%e5%b1%80%e4%bd%9c%e7%94%a8%e5%9f%9f%e4%b8%8b%e8%b0%83%e7%94%a8%e5%b1%9e%e4%ba%8e%e5%af%b9%e8%b1%a1%e7%9a%84%e6%96%b9%e6%b3%95/#respond</comments>
		
		<dc:creator><![CDATA[张三太爷]]></dc:creator>
		<pubDate>Sat, 11 Mar 2017 09:12:32 +0000</pubDate>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Windows]]></category>
		<guid isPermaLink="false">http://www.somedoc.net/?p=3507</guid>

					<description><![CDATA[上周开始整理个人资料，翻腾出了一些老代码。食之无味，弃之可惜 <a href="https://www.somedoc.net/2017/03/11/%e5%85%a8%e5%b1%80%e4%bd%9c%e7%94%a8%e5%9f%9f%e4%b8%8b%e8%b0%83%e7%94%a8%e5%b1%9e%e4%ba%8e%e5%af%b9%e8%b1%a1%e7%9a%84%e6%96%b9%e6%b3%95/" class="more-link">[&#8230;]</a>]]></description>
										<content:encoded><![CDATA[<p>上周开始整理个人资料，翻腾出了一些老代码。食之无味，弃之可惜，把一两段记录到这里来也不错。</p>
<p></p><pre class="crayon-plain-tag">#include "stdafx.h"

class CTest
{
public:
	int i;

	CTest() : i(0)
	{
	}

	virtual int Wow()
	{
		_tprintf(_T("Wow, i: %d\n"), i);
		return i;
	}

	__declspec(dllexport) int Aha()
	{
		_tprintf(_T("Aha, i: %d\n"), i);
		return i;
	}
};

CTest t;

struct CTest2 : CTest
{
};

void Test(void* p)
{
	CTest2* pt = (CTest2*)p;
	pt-&gt;Wow();
	// void* p = &amp;CTest::Aha;

	typedef int (*fnAha)();
	fnAha aha = NULL;

	t.i = 7788;
	HINSTANCE hInstance = GetModuleHandle(NULL);
	(FARPROC&amp;)aha = GetProcAddress(hInstance, (LPCSTR)1);

	__asm {
		mov ecx, p
	}
	aha();
}

int _tmain(int argc, _TCHAR* argv[])
{
	Test(&amp;t);
	return 0;
}</pre><p> </p>
<p>上面的代码特意创建了一个基类的对象，而用子类的指针强制指向了它。在此情况下，首先尝试调用基类的虚方法并还修改了数据成员的值，无误；接下来采用 Windows 平台的标准方法用以找到已经作为符号被导出的基类方法的地址，通过直接向 this 寄存器赋值指定好对象，直接调用函数指针作用于该对象，执行的结果表明此方法是成功的。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.somedoc.net/2017/03/11/%e5%85%a8%e5%b1%80%e4%bd%9c%e7%94%a8%e5%9f%9f%e4%b8%8b%e8%b0%83%e7%94%a8%e5%b1%9e%e4%ba%8e%e5%af%b9%e8%b1%a1%e7%9a%84%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
