<?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>零度x&#039;s blog &#187; 线程</title>
	<atom:link href="http://www.lingdux.com/tag/%e7%ba%bf%e7%a8%8b/feed" rel="self" type="application/rss+xml" />
	<link>http://www.lingdux.com</link>
	<description>Take it slowly,it&#039;s OK,it&#039;s OK.</description>
	<lastBuildDate>Wed, 04 Aug 2010 01:09:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>驱动学习笔记&#8211;创建线程</title>
		<link>http://www.lingdux.com/2009/72.html</link>
		<comments>http://www.lingdux.com/2009/72.html#comments</comments>
		<pubDate>Sun, 21 Jun 2009 05:03:24 +0000</pubDate>
		<dc:creator>零度x</dc:creator>
				<category><![CDATA[驱动学习]]></category>
		<category><![CDATA[创建]]></category>
		<category><![CDATA[学习]]></category>
		<category><![CDATA[笔记]]></category>
		<category><![CDATA[线程]]></category>
		<category><![CDATA[驱动]]></category>

		<guid isPermaLink="false">http://www.lingdux.com/?p=72</guid>
		<description><![CDATA[在内核模式下创建线程和用户模式下创建线程有所不同，在用户模式下创建线程线程函数执行完自动返回，在内核模式下需要调用API来结束一个线程。

下面编写一个新建一个线程来输出&#8221;welcome to www.lingdux.com&#8221;

首先确认流程如下:

<span class="readmore"><a href="http://www.lingdux.com/2009/72.html" title="驱动学习笔记&#8211;创建线程">阅读全文——共730字</a></span>]]></description>
			<content:encoded><![CDATA[<p>在内核模式下创建线程和用户模式下创建线程有所不同，在用户模式下创建线程线程函数执行完自动返回，在内核模式下需要调用API来结束一个线程。</p>
<p>下面编写一个新建一个线程来输出&#8221;welcome to <a href="http://www.lingdux.com">www.lingdux.com</a>&#8221;</p>
<p>首先确认流程如下:</p>
<p>1.定义线程函数MyThread()用来实现输出&#8221;welcome to <a href="http://www.lingdux.com/">www.lingdux.com</a>\n&#8221;。</p>
<p>2.线程函数中使用PsTerminateSystemThread()函数来终止线程。</p>
<p>3.使用PsCreateSystemThread()函数来创建线程并运行线程函数。</p>
<p>实现代码如下：</p>
<p> </p>
<p>#include &#8220;ntddk.h&#8221;</p>
<p><span id="more-72"></span><br />
VOID Unload(IN PDRIVER_OBJECT DriverObject)<br />
{<br />
}<br />
VOID MyThread(IN PVOID pContext)//线程函数<br />
{<br />
 DbgPrint(&#8220;Welcome to <a href="http://www.lingdux.com">www.lingdux.com</a>\n&#8221;);<br />
 PsTerminateSystemThread(0);//终止线程<br />
}<br />
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPath)<br />
{<br />
 HANDLE myhandle;//定义句柄<br />
 PsCreateSystemThread(&amp;myhandle,//得到句柄<br />
  0,<br />
  NULL,<br />
  NULL,<br />
  NULL,<br />
  MyThread,//线程函数<br />
  NULL);//不传递参数，为空<br />
 DriverObject-&gt;DriverUnload=Unload;<br />
 return STATUS_SUCCESS;<br />
}</p>
<p>加载驱动DbgView成功截获到Welcome to <a href="http://www.lingdux.com">www.lingdux.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lingdux.com/2009/72.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
